gjs
Posts: 148
Joined: Fri Dec 02, 2011 8:04 pm

Re: Lowest cost com port

Fri Jan 27, 2012 4:32 pm

What's the cheapest way to add an RS232 serial port to the Raspberry Pi WITHOUT using a USB to RS232 adaptor.

Thanks!

User avatar
RaTTuS
Posts: 10462
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Lowest cost com port

Fri Jan 27, 2012 4:33 pm

do it yourself using the pins......
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

spurious
Posts: 343
Joined: Mon Nov 21, 2011 9:29 pm

Re: Lowest cost com port

Fri Jan 27, 2012 4:40 pm

solder up the gpio pins

gjs
Posts: 148
Joined: Fri Dec 02, 2011 8:04 pm

Re: Lowest cost com port

Fri Jan 27, 2012 4:55 pm

Sorry, solder the GPIO pins to what?

Thanks.

User avatar
RaTTuS
Posts: 10462
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK

Re: Lowest cost com port

Fri Jan 27, 2012 5:09 pm

gjs said:


Sorry, solder the GPIO pins to what?

Thanks.


to a rs232 socket ... you asked about the cheepest way ....
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

gjs
Posts: 148
Joined: Fri Dec 02, 2011 8:04 pm

Re: Lowest cost com port

Fri Jan 27, 2012 5:39 pm

So there is an RS232 port already on the board and which can be connected to directly through the pins that are called GPIO?

richardp
Posts: 117
Joined: Thu Jan 12, 2012 11:46 am

Re: Lowest cost com port

Fri Jan 27, 2012 5:41 pm

The DB9 Connector on Maplin is ONLY £1.89, the full USB->232 adapter on ebay is the same price! (and less!) 

Now to define what is cheaper
RaspberryPi's galore
Solid run CuBox
ODroid U2

User avatar
Gert van Loo
Posts: 2485
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Lowest cost com port

Fri Jan 27, 2012 5:51 pm

gjs said:


So there is an RS232 port already on the board and which can be connected to directly through the pins that are called GPIO?



Not that way. There is an UART port but it does not have the correct voltage levels. You need a 3V3 to RS323 level converter. Only then can you connect it to a DB9 connector.

hippy
Posts: 5980
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Lowest cost com port

Fri Jan 27, 2012 5:54 pm

gjs said:


So there is an RS232 port already on the board and which can be connected to directly through the pins that are called GPIO?



There are UART pins but these are unlikely to be either electrically or polarity compatible with RS232C so you probably cannot simply connect those pins to a 9-way D socket. You would have to use a MAX232 or similar interface between the two. If you don't you could potentially destroy your R-Pi.

It should be possible to software bit-bang serial with the correct polarity and even reduce the interface to a couple of resistors. Bit-banged serial from the R-Pi would be easier than bit-banged serial in, and probably easier if bare metal programming than with an OS on top but I'd have thought it possible either way. Possible doesn't however necessarily mean easy.

User avatar
johnbeetem
Posts: 945
Joined: Mon Oct 17, 2011 11:18 pm
Location: The Mountains
Contact: Website

Re: Lowest cost com port

Fri Jan 27, 2012 7:38 pm

You need something like this: http://www.raspberrypi.org/for.....kout-board

The board has a MAX3232 3.3V to RS-232 converter, plus some breadboarding space for other fun things like I2C RTC.

gjs
Posts: 148
Joined: Fri Dec 02, 2011 8:04 pm

Re: Lowest cost com port

Sat Jan 28, 2012 5:19 pm

Thanks for all your replies.

So, there is a UART that can be connected to via the GPIO pins, at 3.3V level, which can be connected to a MAX232 chip, that all makes sense to me.

A couple more questions on this:

1.  How are the RTS , CTS etc. lines activated on the RS232 side if the UART only has Tx, Rx and GND?  Do some of the GPIO pins have to be connected to the MAX232 chip as well?

2.  How does the UART look to the OS?  Does it just appear as COM1 (or tty0 I think is the linux equivalent)?

Thanks!

hippy
Posts: 5980
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Lowest cost com port

Sat Jan 28, 2012 5:48 pm

gjs said:

1.  How are the RTS , CTS etc. lines activated on the RS232 side if the UART only has Tx, Rx and GND?  Do some of the GPIO pins have to be connected to the MAX232 chip as well?
There usually isn't CTS and RTS etc hardware lines for such UART. Any flow control would usually be implemented in software or no flow control used at all, risking data being sent into the ether or excess data lost when received.

It is possible to use GPIO for hardware flow control signals but that's not usually done and would usually have to be implemented in the software or drivers.

User avatar
johnbeetem
Posts: 945
Joined: Mon Oct 17, 2011 11:18 pm
Location: The Mountains
Contact: Website

Re: Lowest cost com port

Sat Jan 28, 2012 8:13 pm

gjs said:

1.  How are the RTS , CTS etc. lines activated on the RS232 side if the UART only has Tx, Rx and GND?  Do some of the GPIO pins have to be connected to the MAX232 chip as well?

2.  How does the UART look to the OS?  Does it just appear as COM1 (or tty0 I think is the linux equivalent)?


1.  I don't know the specifics of RasPi's Broadcom SoC, but it's often the case that if a SoC provides UART it also provides RTS and CTS optionally on certain GPIO pins so you can have precision flow control.  You have to select the correct function for the GPIO pins using a configuration register.  I expect we'll find out if RasPi's SoC has this capability and how to configure it when RasPi is able to release the relevant parts of the Broadcom documentation.

If the SoC doesn't provide hardware RTS and CTS then you have to do it in software, which is a real pain if you want to do it precisely.

DTR, DSR, and CD are generally handled as GPIO pins.

2.  No idea.  It should look like /dev/tty* where * is a number, but who knows what it will do with the data set signals (CTS, etc.)  At some point someone who knows will be kind enough to update the Wiki.  You may decide that you're much better off getting a USB serial port just because it's easier to deal with the software :-/

Dean
Posts: 4
Joined: Mon Jan 30, 2012 8:18 pm

Re: Lowest cost com port

Mon Jan 30, 2012 8:24 pm

If you want to use the GPIO pins for serial communications rather than a usb to serial adapter you need to convert from the low voltage UART signal levels on the GPIO pins to RS232 voltage levels.  You can use one of these devices to do it:

http://www.sparkfun.com/products/8745

http://www.sparkfun.com/products/449

spotthemaniac
Posts: 7
Joined: Wed Feb 01, 2012 4:04 pm

Re: Lowest cost com port

Wed Feb 01, 2012 4:34 pm

Dont know if anyone is interested but due to lack of serial ports on most laptops these days i looked into getting a USB to TTL serial convertor. As I have a similar problem debugging a startup issue on a synology box.

I have purchased two of these to play around with:

http://www.amazon.co.uk/TRIXES.....038;sr=8-1

In the vague hope that it will do the job.

drgeoff
Posts: 9825
Joined: Wed Jan 25, 2012 6:39 pm

Re: Lowest cost com port

Wed Feb 01, 2012 4:47 pm

spotthemaniac said:


Dont know if anyone is interested but due to lack of serial ports on most laptops these days i looked into getting a USB to TTL serial convertor. As I have a similar problem debugging a startup issue on a synology box.

I have purchased two of these to play around with:

http://www.amazon.co.uk/TRIXES.....038;sr=8-1

In the vague hope that it will do the job.



Be careful with those.  They are sold as TTL compatible so the I/Os may not be compatible with the (3.3 volt?) GPIOs on the RP.  Might even damage the RP

spotthemaniac
Posts: 7
Joined: Wed Feb 01, 2012 4:04 pm

Re: Lowest cost com port

Wed Feb 01, 2012 4:54 pm

The spec for the chip is here and quotes outputs of 3.0 to 3.6 typ 3.3

http://www.silabs.com/Support%.....cp2102.pdf

fingers crossed and i will try it on the synology box first via a hub

thanks for the warning.

drgeoff
Posts: 9825
Joined: Wed Jan 25, 2012 6:39 pm

Re: Lowest cost com port

Wed Feb 01, 2012 5:20 pm

Yes, in the meantime I'd already been off for a look at the data sheet for the CP2102.  It has an onboard 3.3 volt regulator which can be optionally used to power the chip.  If an external supply is used instead the max is 3.6 volt.  So looks like it is electrically compatible with the RP.  It also looks like the polarity is inverted which I expect is also the way the RP's UART has its I/O.

spotthemaniac
Posts: 7
Joined: Wed Feb 01, 2012 4:04 pm

Re: Lowest cost com port

Tue Feb 07, 2012 2:22 pm

Have got two of these beasties running on my laptop right now will be playing with a synology box tonight to see if they work okay. Will let you know. Hopefully if they work okay on the synology serial port they should be good to go for the pie just need to get my hands on one now!!! tick tock tick tock.

IDE
Posts: 52
Joined: Fri Jan 13, 2012 12:28 am
Contact: Website

Re: Lowest cost com port

Wed Feb 08, 2012 6:17 pm

Hey guys,

I buy these from eBay from time to time. They do free shipping, and it's very fair price.

http://www.ebay.com/itm/New-MA.....2a11dd57c5

This is one of many out there. 

And I just hook the RTS and CTS together.. works for me!

I use it on my WRT54-GL router

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Lowest cost com port

Wed Feb 08, 2012 7:26 pm

drgeoff said:


It also looks like the polarity is inverted which I expect is also the way the RP's UART has its I/O.


That's usual with RS232 drivers.

laszlo
Posts: 25
Joined: Thu Jan 26, 2012 6:03 pm

Re: Lowest cost com port

Wed Feb 08, 2012 7:31 pm

I have used this cable for other similar devices which provide a serial port this way (3.3V only, I hear there are 5V ones too).  This cable includes the necessary 3232 type circuit for converting between the 3.3V on the device side to 12V on the RS232 side.  This is where I got the idea: http://www.nslu2-linux.org/wiki/HowTo/AddASerialPort

NOKIA DKU-5 USB Cable

http://www.ebay.com/itm/190409304749

It's < $5 USD.  After cutting off the cell phone plug on the end the wires worked out like this:1
2
3 - orange, not needed
4 - green, 3.3v from device
5
6 - white, serial RX, data to device
7 - blue, serial TX, data from device
8 - black, GND This particular one requires power from the device. There are other similar cables which draw their power from the USB host instead. I also have some other DKU5 cables which are RS232 on the host end, not USB, and you can find tons of those on Ebay as well. It is good enough for a console but probably too flaky for much else without connecting the flow control pins. I plan to use one of those for Raspberry Pi.  

ecw
Posts: 10
Joined: Tue Jan 10, 2012 1:56 pm

Re: Lowest cost com port

Wed Feb 08, 2012 8:32 pm

All the dku5 and other similar Nokia cables I"ve played with use pl2303 USB to serial convertors, and seem to have the same PCB layout hidden under the USB shroud - from my notes,

Pad. Signal
1. Not connected
2. +5v
3. Ring indicate
4. CTS
5. Not connected
6. GND
7. DCD
8. DSR
9. RX
10. RTS
11. DTR
12. TX

A cheap an cheerful way to play serial, but I"d recommend checking the pin outs yourself using a simple programme to toggle computer settable bits, a multi-meter, and a couple of wires to loop back from the (computer) output pins to the input pins to work out which is which.

User avatar
teh_orph
Posts: 346
Joined: Mon Jan 30, 2012 2:09 pm
Location: London
Contact: Website

Re: Lowest cost com port

Mon Feb 20, 2012 12:20 pm

Hi guys,

slight thread grave-dig here: what's the conclusion on kit to get?

I'd like to connect to the main UART with a USB->serial adaptor but of course don't want to fry it! Was that Amazon link sufficient?

Cheers

cheapskate
Posts: 9
Joined: Tue Feb 07, 2012 11:18 am

Re: Lowest cost com port

Mon Feb 20, 2012 12:54 pm

Ebay sell those CP2102 adaptors:

http://www.ebay.co.uk/itm/ws/e.....tegory=162

£2.48 instead of £6.50!

Return to “General discussion”