6

I want to use a Rpi to interface with 3 atmega ics in an embedded system but the pi seems to only have one uart port. I know arduino can emulate a serial connection over two io pins, will this be possible on a pi? I plan on using a headless raspbian setup with a mono c# terminal application.

7

What you are referring to is called Software Serial, where bytes are bit banged and create the same effect as a serial port.

Using a normal Linux distribution the answer is, No. The reason is because bit banging required real time processing of data, otherwise the data will just be junk.

This answer at Electronics Stack shows a USB board with 4 hardware serial ports on it. Its not cheap but it will great.

You can use a multiplexer which is a cheap way to get 4 serial ports but you cannot use all 4 at the same time. You can switch between ports on demand.

You can buy a SC16IS752 that uses I2C - Which means you can add a few of these with real time data flow. It is more complicated since you have to build everything around it your self.

enter image description here

You also buy cheap USB to UART - a USB Hub and add as many as you like

enter image description here

  • Ok, is there any way to enable the second serial port on the RPi so that I can at least interface with two atmegas? Otherwise I will probably have to use i2c. – Gerharddc Nov 7 '13 at 11:57
  • There is a second one but its not connected to anything... go figure. So i'm afraid the answer is No. – Piotr Kula Nov 7 '13 at 13:11
2

You need to use RS485 for connecting instead of RS232. Then you can have single master (RPi) polling multiple slaves (AVRs) one after another in a loop. For this you can use MODBUS or some other similar communication protocol.

  • I will look into it but I am not sure how far this functionality has been implement for the pi yet, especially in terms of c# – Gerharddc Nov 7 '13 at 14:32
  • 1
    There are RS232<>RS485 convertors, both as ready made devices and as microchips you might want to embed. After that, from developer side you do everything the same as you did with RS232. RPi polls AVRs one by one and sends data requests. Each data request message includes slave address. Once AVR gets the message, it looks into address and decides wether it should answer it or pass it. – avra Nov 7 '13 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.