2
\$\begingroup\$

I understand you can create a serial transmission between the Raspberry Pi and an Atmega328 using the GPIO: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=22736&p=293668

I'm interested in having more serial options, like the USB ports. I managed to do so, but with an Arduino board: http://www.doctormonk.com/2012/04/raspberry-pi-and-arduino.html

I've searched a lot on this topic and got pretty confused. Is there a safe way to use the RPi's USB port for serial communications with an Atmega328? What would be the easiest safety intermediate circuit? Thanks!

(Note: Easiest as in minimal number of components, like transistors and resistors. Preferrably NOT ICs. This is to reduce size and ensure availability of components in my country)

\$\endgroup\$
1
\$\begingroup\$

The standard Raspberry Pi distributions have FTDI driver support so you can use a USB to serial adapter based on FTDI chipsets. In fact FTDI have released a few products specifically marketed for use with the Raspberry Pi:

http://www.ftdichip.com/Products/Cables/RPi.htm

http://www.ftdichip.com/Products/Modules/RPi.htm

You could also purchase their chip level devices to roll your own custom solution if you prefer. There is also some information on supported USB to serial adapters here, Prolific PL2303 based devices are also listed as supported:

http://elinux.org/RPi_VerifiedPeripherals#USB_UART_and_USB_to_Serial_.28RS-232.29_adapters

I noticed you have already mentioned a GPIO based solution and a similar FTDI based system. Those are really about the only two options, converting USB to serial is quite complex and certainly the most practical path is a dedicated chipset.

To gain some additional serial lines over the GPIO port you could also use a technique called 'bit banging' to toggle an I/O line to transmit data and write something to decode the incoming serial data on another GPIO line. However that would normally require the use of a hardware timer for reliable operation so I believe you would need to write your own kernel drivers. From user code you may be able to use standard timers but given that Linux is not a real-time operating system in the true sense I doubt that would work 100% reliably, especially at higher baud rates.

\$\endgroup\$
  • \$\begingroup\$ Actually, a dedicated USB-serial chipset is not a clear win over a usb-capable micro-controller. Each has tradeoffs, that depend as much on the individual device as on its broad category. \$\endgroup\$ – Chris Stratton Mar 21 '13 at 12:55
  • \$\begingroup\$ @ChrisStratton, agreed and it's not the way I'd go about the overall project personally, but question does mention the ATmega328 specifically. \$\endgroup\$ – PeterJ Mar 21 '13 at 13:03
  • \$\begingroup\$ There are two widely popular designs with the '328, taking opposite approaches - one with a dedicated converter, another with a helper USB-enabled micro. That's in addition to those which use its 32u cousins instead of the '328, or approximate USB with software on the '328 and diodes. \$\endgroup\$ – Chris Stratton Mar 21 '13 at 13:24
  • \$\begingroup\$ Thanks for your answer! Luckily, these components are available. However, I believe there's the need for MAX232? \$\endgroup\$ – Ahmed Farid Mar 21 '13 at 15:21
  • 1
    \$\begingroup\$ You would only need a MAX232 if you were interfacing to a traditional RS232-level serial device. You do not need it if interfacing two bare processors at low voltage levels, or a processor and a USB-serial chip. However, if you interface two processors at differing low voltage signaling levels (distinct combinations of 5v, 3.3v or 1.8v for example) you may need other level translation circuitry. \$\endgroup\$ – Chris Stratton Mar 21 '13 at 15:23

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.