User avatar
psergiu
Posts: 223
Joined: Mon Nov 07, 2011 8:36 am
Location: TX, U.S.A. (was: RO, E.U.)
Contact: Website

Re: GPIO -> Multiple Serial Ports (UART)

Sun Jan 01, 2012 10:40 pm

Hello,

Since i'm a beginner at embeeded electronics, i have to ask:

Is there a way to connect multiple UART chips to RPi's GPIO pins so you can have multiple serial ports (once you write the Linux drivers) ? Can any GPIO pin become a UART TX or RX or there is something special about the UART pins ?

I know RPi has one 3v3 UART, but i was curious if more can be added without resorting to USB-Serial adapters.

I have a storage room half-filled with older Unix servers & workstations - all of them have serial consoles. I am envisioning a RPi Rev.B + UART chips + MAX232s acting as a terminal server - you telnet/ssh to port 2000+n and you are connected to serial port n.

User avatar
liz
Raspberry Pi Foundation Employee & Forum Moderator
Raspberry Pi Foundation Employee & Forum Moderator
Posts: 5202
Joined: Thu Jul 28, 2011 7:22 pm
Contact: Website

Re: GPIO -> Multiple Serial Ports (UART)

Sun Jan 01, 2012 10:46 pm

The UART pins are the only ones with a hardware-accelerated UART attached. You can bitbang a UART if you want, but it'll use up a lot of processing resources which the UART pins wouldn't use.
Director of Communications, Raspberry Pi

bsmulders
Posts: 18
Joined: Wed Nov 23, 2011 6:13 pm

Re: GPIO -> Multiple Serial Ports (UART)

Sun Jan 01, 2012 11:01 pm

If you don't need to communicate with several servers at once, you can always try multiplexing?

I do must say that I wouldn't try multiplexing on-the-fly / hot-swapping, but switching when there is no active connection should be fine.

Edit: Just googled it, you can use the MAX389/MAX399:

http://www.maxim-ic.com/app-no.....mvp/id/588

I have no affiliation with Maxim.

mjtessmer
Posts: 27
Joined: Sun Nov 20, 2011 12:50 am

Re: GPIO -> Multiple Serial Ports (UART)

Sun Jan 01, 2012 11:14 pm

Maxim has a SPI to UART/RS232 converter chip; MAX3111.

You can hook up several of these chips to the R-Pi's

SPI port on the GPIO connector and then use the GPIO bits

to select the chips.

User avatar
psergiu
Posts: 223
Joined: Mon Nov 07, 2011 8:36 am
Location: TX, U.S.A. (was: RO, E.U.)
Contact: Website

Re: GPIO -> Multiple Serial Ports (UART)

Sun Jan 01, 2012 11:18 pm

liz - thanks a lot for the info ! So the sollution seems to be SPI-UART or I2C-UART (like MAX3107 or SC16IS750)

bsmulders - it's extremely useful to log all the messages received on the console - otherwise multiplexing would have been a great idea.

User avatar
psergiu
Posts: 223
Joined: Mon Nov 07, 2011 8:36 am
Location: TX, U.S.A. (was: RO, E.U.)
Contact: Website

Re: GPIO -> Multiple Serial Ports (UART)

Sun Jan 01, 2012 11:48 pm

mjtessmer - thanks - looks like someone wrote a linux kernel driver for MAX3100: http://lwn.net/Articles/301914/  

Going with USB, the sollution is:

4 * 2.89 USD http://www.dealextreme.com/p/usb-to-rs2 ... ngth-24799

1 * 3.20 USD http://www.dealextreme.com/p/compact-usb-4-ports-hub-48

~15 USD (lower if you get them from eBay)

Blars
Posts: 88
Joined: Sun Aug 28, 2011 3:22 am
Contact: Website

Re: GPIO -> Multiple Serial Ports (UART)

Mon Jan 02, 2012 4:41 am

The gert board has a pic chip that almost certainly has a hardware uart or two.  That would be cheaper than the overpriced maxim chips.  usb-serial boards are cheap too.

error404
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm

Re: GPIO -> Multiple Serial Ports (UART)

Tue Jan 03, 2012 7:22 pm

The NXP SPI->UART chips are fairly inexpensive, a dual UART (SC16IS752) is about $2.50. Even the DIP version of SC26C92, another dual UART, is about $5.00.

USB is probably the way to go though, unless you need low latency. It's certainly going to be easier to get going, but you'll end up with a bit of a mess of dongles and hubs. But without support or documentation at launch for the SPI port it's really the only way that's going to work for now.

I've had this same idea in the past, connecting a bunch of serial ports to an OpenWRT router as a console server. They rarely expose SPI or even enough GPIO though, so never got anywhere with that. I like your idea, but I'd want to see a clean implementation using SPI, so I'll be patient for now.

Wooloomooloo
Posts: 92
Joined: Fri Nov 25, 2011 10:52 am

Re: GPIO -> Multiple Serial Ports (UART)

Tue Jan 03, 2012 7:39 pm

Yeah, unless UART via USB is absolutely out of the question, I'd go with that solution too. The standard way is to slap one or more FTDI chips on, they'll get you all the UARTs you need and will already be supported in Linux. One can even buy pre-made cables with USB on one end and bare UART wires on the other, for various voltage levels (5V/3V/etc), various DIP IC-shaped modules with USB connector on board, and even "15-pin D-sub" standard RS232-port shaped components that have a USB connector instead of the 15 pins, and will fit existing legacy cases / cutouts. Or you can just solder SMD ICs if you wish, of course.

Tomo2k
Posts: 127
Joined: Mon Dec 19, 2011 10:00 pm

Re: GPIO -> Multiple Serial Ports (UART)

Tue Jan 03, 2012 9:50 pm

FTDI even have USB to quad-serial chips (FT4232), which gives you quite a lot of serial without needing a hub or anything.

- Interestingly it can do JTAG, SPI and I2C as well, which sounds rather cute.

User avatar
rew
Posts: 425
Joined: Fri Aug 26, 2011 3:25 pm

Re: GPIO -> Multiple Serial Ports (UART)

Wed Jan 04, 2012 12:58 am

Yeah. A bunch of usb-serial converters on a hub hanging off the raspberry pi would be much more convenient than bitbanging an uart on the gpio pins....
Check out our raspberry pi addons: https://www.bitwizard.nl/shop/

plugwash
Forum Moderator
Forum Moderator
Posts: 3462
Joined: Wed Dec 28, 2011 11:45 pm

Re: GPIO -> Multiple Serial Ports (UART)

Tue Feb 07, 2012 2:39 pm

rew said:


Yeah. A bunch of usb-serial converters on a hub hanging off the raspberry pi would be much more convenient than bitbanging an uart on the gpio pins….


Umm is the request here for one extra uart or four extra uarts?

bitbanging a UART should be possible in theory but will require very fequent polling especially if you want high baudrates.

SPI could be a good route but i'd expect it to be quite tricky to get going.

If going the USB route i've heard good things about FTDI stuff and not so good things (hangups affter hours of usage and similar) about cheap converters from china (the suspiscion is they are using counterfiet prolific chips). Personally if you can handle the soldering I would just put a FTDI chip on your own board and not bother with USB-serial cables cables (FTDI USB-serial cables are pricy)

Edit: sorry I got two threads confused.

error404
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm

Re: GPIO -> Multiple Serial Ports (UART)

Tue Feb 07, 2012 5:57 pm

MCP2200 is cheap, readily available in an easy SOIC package, has been reliable for me, and uses the USB CDC so should be supported everywhere. If you want to build something yourself, anyway. Add a cheap USB hub chip (e.g. TUSB2046) and you could put a few on one board...

User avatar
psergiu
Posts: 223
Joined: Mon Nov 07, 2011 8:36 am
Location: TX, U.S.A. (was: RO, E.U.)
Contact: Website

Re: GPIO -> Multiple Serial Ports (UART)

Tue Feb 07, 2012 7:16 pm

As i unfortunatelly am SMD-challenged, the only DIP-spaced thing i could find is a FT4232H evualuation module which together with 4 MAX232 chips could nicely fit on a RPi-sized proto-board. But it will cost more than a USB hub+4 Chinese USB-Serial dongles.

Thanks everyone for the sugestions !

error404
Posts: 351
Joined: Wed Dec 21, 2011 11:49 pm

Re: GPIO -> Multiple Serial Ports (UART)

Tue Feb 07, 2012 8:17 pm

Anyone (and I mean that literally) can do SOIC with basically zero practice. You just need to get over the irrational fear people have of SMD assembly. It's actually much faster and easier once you get the hang of it (no snipping of wires and no turning the board over = parts falling out), especially if you're making the boards yourself (less/no holes to drill). But it will definitely cost more than the Chinese dongles anyway, unless you're doing it in quantity.

If you get a tiny hub and tear all the cases off of things and permanently solder them all together inside a suitable case you might be able to get a pretty clean solution that way.

User avatar
psergiu
Posts: 223
Joined: Mon Nov 07, 2011 8:36 am
Location: TX, U.S.A. (was: RO, E.U.)
Contact: Website

Re: GPIO -> Multiple Serial Ports (UART)

Tue Feb 07, 2012 8:35 pm

I'm a lost cause. For almost 30 years i have used my trusty soldering gun and i'm unconfortable holding a standard soldering iron. Yes, i have done SMD with that beast. I'd rather not do it again And i'm only using proto-boards as i'm a failure at making my own boards. I'm a wanna-be tinkerer

Once i get my RPi i'll build one or both of the versions and i'll post the result here.

ajith
Posts: 3
Joined: Mon Apr 23, 2012 5:57 am
Contact: Website

Re: GPIO -> Multiple Serial Ports (UART)

Sat Apr 28, 2012 12:27 am

Interfacing to the serial port is not difficult. I connected the Tx pin to the Rx pin of a PIC micro running at 5V, taken from Rpi. The Tx pin of PIC is connected using a voltage divider, 3.3k  and  1.5k, to the Rx pin on Rpi.

Used minicom and then pyserial for communication. Everything worked fine and I could transfer data at around 10kbytes/sec .

There is one problem with the AMA driver, it sends a 0xF8 when you open the port.

Ajith

User avatar
rew
Posts: 425
Joined: Fri Aug 26, 2011 3:25 pm

Re: GPIO -> Multiple Serial Ports (UART)

Sat Apr 28, 2012 8:30 am

error404 said:


(no snipping of wires and no turning the board over = parts falling out),


No... instead of the components falling OUT they fall OFF. Big difference!
Check out our raspberry pi addons: https://www.bitwizard.nl/shop/

User avatar
Dave_G_2
Posts: 196
Joined: Sat Apr 14, 2012 7:04 pm

Re: GPIO -> Multiple Serial Ports (UART)

Sat Apr 28, 2012 12:51 pm

Maybe he has his Pi in a case, then components would fall OFF the board and OUT of the case.

technix
Posts: 120
Joined: Sat Jul 13, 2013 4:55 pm

Re: GPIO -> Multiple Serial Ports (UART)

Tue Nov 11, 2014 4:40 pm

Actually I tried the SC16IS752 but found out that ATtiny85 worked better. A quick sketch in Arduino software can turn those tiny micros into really good I2C/SPI to UART adapters, bit banging the UART lines, with an impressive 256 bytes of FIFO and settings memorized in EEPROM. Microcontrollers can bit bang rather effortlessly because they are dedicated to this function, unlike bit banging on your Pi which is multitasking. Also they have fewer external parts than SC16IS752 as it runs on internal oscillator. If the protocol is very specific it can even do some protocol decapsulating, offloading the main processor. Most importantly, for me, is that they are available in DIP packages and is breadboard friendly. However with higher baudrates you may want an ATtiny2313/4313 that have hardware UART module.

Also when you need A LOT of UARTs all at slower speeds you can try wire a maximum of 107 of those microcontrollers to one I2C bus, all using a different address. However if you really have THAT much UART your data routing algorithm will have to be some Cisco-grade stuff.

User avatar
rpdom
Posts: 15362
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: GPIO -> Multiple Serial Ports (UART)

Tue Nov 11, 2014 5:23 pm

technix wrote:Actually
Replying to a post that is over 30 months old must be a new record.

technix
Posts: 120
Joined: Sat Jul 13, 2013 4:55 pm

Re: GPIO -> Multiple Serial Ports (UART)

Tue Nov 11, 2014 8:20 pm

rpdom wrote:
technix wrote:Actually
Replying to a post that is over 30 months old must be a new record.
Oops... Jus that I recently ran into this issue as well and found out the hard way that an ATtiny serves better here than any other chips you are suggesting.

User avatar
Douglas6
Posts: 4778
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: GPIO -> Multiple Serial Ports (UART)

Tue Nov 11, 2014 8:49 pm

technix wrote:Actually I tried the SC16IS752 but found out that ATtiny85 worked better. A quick sketch in Arduino software can turn those tiny micros into really good I2C/SPI to UART adapters
(I always like to encourage a good necro-thread...) I've actually been searching for SPI code that will run on an ATTiny85, any pointers? TinyWire works for I2C, but I've googled SPI and all I can find is 'just bit-bang it!'. Without an analyzer or the skills to use one, I dread the thought of writing and debugging bit-banged SPI, myself.

technix
Posts: 120
Joined: Sat Jul 13, 2013 4:55 pm

Re: GPIO -> Multiple Serial Ports (UART)

Sat Nov 22, 2014 3:08 pm

Douglas6 wrote:
technix wrote:Actually I tried the SC16IS752 but found out that ATtiny85 worked better. A quick sketch in Arduino software can turn those tiny micros into really good I2C/SPI to UART adapters
(I always like to encourage a good necro-thread...) I've actually been searching for SPI code that will run on an ATTiny85, any pointers? TinyWire works for I2C, but I've googled SPI and all I can find is 'just bit-bang it!'. Without an analyzer or the skills to use one, I dread the thought of writing and debugging bit-banged SPI, myself.
You can coax the onboard USI into SPI mode and bit bang UART (SoftSerial) The USI-as-SPI code can be taken from Atmel Studio documentation.

z80pi
Posts: 1
Joined: Wed Sep 14, 2016 11:27 pm

Re: GPIO -> Multiple Serial Ports (UART)

Wed Sep 14, 2016 11:51 pm

Don't mean to be a troll, but I have an old z80 network system from the mid 80s I'd like to virtualise across it's x16 I/O ports, to allow emulated (or real) hardware to connect via TCP.

It uses a parallel interface hardwired to a Z80 and some simple buffers to dish out x16 'parallel' ports which in turn connect to the CP/M terminals IO. The terminal boots CPM via this IO port, which likewise is hard wired to it's Z80.

My thinking to achieve this was to interface these to the pi's GPIO, and this thread is encouraging, but I fear the Pi won't be up to it.

As I understand it the ATtiny85 magic could be used per port to get my old server to connect to the Pi efficiently?

Thanks.

Return to “Other projects”