Help with RS232 GPIO connection


36 posts   Page 1 of 2   1, 2
by kghunt » Mon Jul 02, 2012 2:38 pm
Am I right in assuming the serial interface on the pi is TTL and not RS232?

I have a mifare reader below that is stated to work at 5v and 3.3v but it has an RS232 interface.

Image

I have writted some python to read, format and return the UID of some cards. It is currently connected to a usb to serial converter and works fine.

Image

Next step is I want to get this working directly from the pi. How do I interface this?

I measured the voltage across Ground and TX on the reader and it is -7.25v and goes to -6.88v when I present a badge.

Anyone got suggestions I don't want to damage my pi by prematurely connecting a device to it when I don't fully understand the circuitry.

Cheers in advance

Oh also here is the datasheet of the reader. Not sure what the "out 1" and "out 2" pins do or the "RST".
http://www.ehuoyan.com/download/module/ ... G++_EN.pdf
Posts: 358
Joined: Sun Mar 04, 2012 9:28 am
by rurwin » Mon Jul 02, 2012 2:45 pm
You are correct -- the voltages you need for the Pi are no more than 3.3V and no lower than 0V.

The voltages you measured are within spec for RS232. I'm not sure what sort of device you are showing in the pictures. There is a USB to serial adapter going to a PCB, and it looks like the same connections then feeding a coaxial cable. Where is the RaspPi, where is the reader, and what is the PCB?

Edit: Having read the datasheet, there is no configuration to select 3.3V output and the output is described as RS232. I surmise that it is RS232 only. You will need either the USB interfcase in your pictures or a RS232/3.3V convertor.
User avatar
Forum Moderator
Forum Moderator
Posts: 2913
Joined: Mon Jan 09, 2012 3:16 pm
by kghunt » Mon Jul 02, 2012 2:59 pm
Yes it is currently connected to a usb to rs232 adapter.

The PCB in the picture is the reader.

The white cable going off to the right is a 5v supply. I wasn't Sure if the Rs232 adapter would supply any voltage to power the reader so I powered it separately.

How to I shift the voltages can I do it or do I just need to buy an rs232 to TTL converter of some sort?

Cheers
Posts: 358
Joined: Sun Mar 04, 2012 9:28 am
by LandyManLuke » Mon Jul 02, 2012 3:52 pm
Google 'MAX232'.

Logic to RS232 converters are very common.

Luke
Posts: 14
Joined: Tue Jun 05, 2012 9:45 pm
by selsinork » Mon Jul 02, 2012 5:14 pm
Can't tell from the photos, but U3 is probably a max232 or similar.
From the photos here http://www.ehuoyan.com/english/ow_large ... flagname=2 and here http://www.ehuoyan.com/english/ow_large ... flagname=3 it seems likely that it would be possible to run the mifare from 3.3v, remove u3 and fit the two zero ohm links visible to the right of J1 pins 6 & 7 in the second photo.

There's a YHY502CTG (without the two plusses suffixed) that provides the ttl output. See the photo here http://www.ehuoyan.com/english/ow_large ... flagname=1 for the fairly obvious difference.
Posts: 151
Joined: Mon Apr 16, 2012 8:31 am
by Grumpy Mike » Mon Jul 02, 2012 8:35 pm
LandyManLuke wrote:Google 'MAX232'.

Logic to RS232 converters are very common.

Luke


Yes but that is a 5V part, you need the low voltage part so you don't fry your Pi.
It is the MAX3232 that you want to use.
User avatar
Posts: 784
Joined: Sat Sep 10, 2011 7:49 pm
Location: Manchester (England England)
by LandyManLuke » Tue Jul 03, 2012 10:43 am
My apologies, I have used MAX232 chips with 5v chips, I had overlooked the 3v3 aspect of the Pi.

Luke
Posts: 14
Joined: Tue Jun 05, 2012 9:45 pm
by TonyD » Tue Jul 03, 2012 12:15 pm
If you want to connect directly to the GPIO on the RPi Expansion Header I've made a small MAX3232 board which plugs directly onto it.

Image
Tony
User avatar
Posts: 341
Joined: Thu Sep 08, 2011 10:58 am
Location: Newcastle, UK
by kghunt » Thu Jul 05, 2012 9:31 pm
I have ordered the ttl version anyway. $13 dollars plus $20 shipping. When I get to prototyping I'll order a fair few anyway.
Posts: 358
Joined: Sun Mar 04, 2012 9:28 am
by arewetheredad » Thu Jul 05, 2012 9:46 pm
You need a slightly different chip to the MAX232 as this will not drive the 3.3v circuit correctly. Try the MAX3232CPE which you can get from Maplin in the UK for £4.99 (part no DT26D). You will also need 4 0.1uF capacitors for the charge pump, it is a really easy circuit to make and I have done this loads of times for various microprocessors. If you don't fancy building it yourself, this http://www.byvac.com/bv3/index.php?rout ... uct_id=113 device would seem to do the job at £7.00
Posts: 8
Joined: Thu Jun 28, 2012 10:00 pm
by arewetheredad » Thu Jul 05, 2012 9:56 pm
Actually looking at what you are trying to do, you need the chip option as the part that I linked to would convert the UART pins on the GPIO to a USB interface (for example to connect to a PC). From what I can see, I think you are trying to connect an RFID tag reader to the PI. You therefore have probably 2 options
1) build an interface using the MAX3232 chip - the advantage is this protects your PI
2) see if you can find the UART signals on the RFID reader as this almost certainly has a MAX232 or similar levels converter to give the RS232 compliant voltages - this will most likely be fed from 3.3v circuitry especially if you can supply the RFID board with 3.3v (if its 5V, you could use a zener to limit the volts if you are only looking for data from the card reader)
Posts: 8
Joined: Thu Jun 28, 2012 10:00 pm
by huaraz » Thu Jul 05, 2012 11:24 pm
Hi

I read this viewtopic.php?f=44&t=8301 and got a USB to RS232 converter http://www.amazon.co.uk/gp/product/B004ROOPK6/ but it does not work. I can see the
getty running on ttyAMA0 but my terminal emulator (SecurCRT on XP) with the following settings:

• Speed: 115200
• Bits: 8
• Parity: None
• Stop Bits: 1
• Flow Control: None

does not show anything. Does anybody have an idea what to check / test ? I connect GND / TX / RX from the converter Image to pin 3, 4 and 5 respectively.

Thank you
Markus
Posts: 13
Joined: Thu Jul 05, 2012 11:04 pm
by arewetheredad » Fri Jul 06, 2012 7:45 am
The configuration you probably need is:
GND -> GND
TX -> RX
RX -> TX

So try swapping your TX and RX at one end and see if this works (assuming you are just trying to connect to a PC)

I am assuming that the pin numbers you mentioned are not from a DB9 connector on the converter, usually RS232 uses pins 2, 3 and 5 (5 being GND) on a 9 way D type (DB9).

Also check that you have the right driver installed for the converter and are using the correct COM port.
Posts: 8
Joined: Thu Jun 28, 2012 10:00 pm
by arewetheredad » Fri Jul 06, 2012 7:55 am
Further to my last post (really should read things properly before I click post), the amazon link appears to be for a TTL device which would probably not be suitable for connection to the PI due to 5V levels although I have not looked at a data sheet for the device. 5V on the GPIO pins could damage the PI so I would be extremely careful, also the 3.3V on the PI's TX pin probably won't consistently produce a logic 1 on the converter so that could be problematic too.

Of course if you have a datasheet that says this converter will operate at 3.3v, fine but that would either need a reference 3.3v from the PI board or a reg on the converter I would think.
Posts: 8
Joined: Thu Jun 28, 2012 10:00 pm
by huaraz » Fri Jul 06, 2012 2:47 pm
arewetheredad wrote:The configuration you probably need is:
GND -> GND
TX -> RX
RX -> TX

So try swapping your TX and RX at one end and see if this works (assuming you are just trying to connect to a PC)

I am assuming that the pin numbers you mentioned are not from a DB9 connector on the converter, usually RS232 uses pins 2, 3 and 5 (5 being GND) on a 9 way D type (DB9).

Also check that you have the right driver installed for the converter and are using the correct COM port.


Sorry the Pins I mean are the ones shown here Image

I have the correct driver for the converter as a driver CD was sent with it.

Markus
Posts: 13
Joined: Thu Jul 05, 2012 11:04 pm
by huaraz » Sat Jul 07, 2012 4:19 pm
arewetheredad wrote:Further to my last post (really should read things properly before I click post), the amazon link appears to be for a TTL device which would probably not be suitable for connection to the PI due to 5V levels although I have not looked at a data sheet for the device. 5V on the GPIO pins could damage the PI so I would be extremely careful, also the 3.3V on the PI's TX pin probably won't consistently produce a logic 1 on the converter so that could be problematic too.

Of course if you have a datasheet that says this converter will operate at 3.3v, fine but that would either need a reference 3.3v from the PI board or a reg on the converter I would think.


Following http://www.silabs.com/Support%20Documents/TechnicalDocs/cp2102.pdf it seems to be capable of working with 3.3.V

Markus
Posts: 13
Joined: Thu Jul 05, 2012 11:04 pm
by jamodio » Sun Jul 08, 2012 7:16 am
If you want to get the serial interface via a USB virtual serial port you can get one of the FTDI232 breakout boards from SparkFun Electronics.

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

I currently have the R-pi serial console wired through it and works like a charm.

Here is a picture of my current setup, the board below the R-Pi is a switching DC-DC power supply that takes 7-28V on one side and feeds the 5V up to 2A to the R-Pi.

https://picasaweb.google.com/lh/photo/N ... directlink

-J
Posts: 49
Joined: Sun Feb 19, 2012 4:30 pm
by kghunt » Sun Jul 08, 2012 7:56 am
That is cool but a tab expensive when you can get a USB serial adapter for a couple of quid off eBay.
Posts: 358
Joined: Sun Mar 04, 2012 9:28 am
by jamodio » Sun Jul 08, 2012 5:07 pm
USB<->serial adapters are useless since you still need the level conversion from the R-Pi digital pins to RS232 levels. Regular serial adapters work from RS232 levels and some of the cheap ones you can get from eBay don't work very well.
Posts: 49
Joined: Sun Feb 19, 2012 4:30 pm
by kghunt » Sun Jul 08, 2012 8:29 pm
I didn't say USB rs232 I said USB serial. There are also plenty of ttl uart USB adapters for less than a fiver.
Posts: 358
Joined: Sun Mar 04, 2012 9:28 am
by jokkebk » Tue Jul 10, 2012 7:46 am
If you're looking for a DIY solution instead of a ready-made 3.3V TTL cable, I wrote a RaspPi serial tutorial for MAX3232CPE just a week ago, with Clear Pictures of Everything(tm) :)

http://codeandlife.com/2012/07/01/raspberry-pi-serial-console-with-max3232cpe/

In the example I'm connecting from PC to Pi, but the same circuit would work to connect any true RS-232 level circuit to the Pi.
Posts: 7
Joined: Sun Jul 01, 2012 5:30 pm
by kghunt » Thu Jul 12, 2012 5:50 pm
My ttl reader has arrived. I assume I can use py serial to communicate with it?
Posts: 358
Joined: Sun Mar 04, 2012 9:28 am
by kghunt » Thu Jul 12, 2012 9:28 pm
Here is the ttl reader.

Image

Cant tell any major differences until I get them together tomorrow. Re-reading the data sheet I noticed there are 2 usable output pins which is goos as i am getting low.

Using 9 for keypad
Want to use 6 for LCD
Using 1 for buzzer
Need 2 for ttl reader

That has already got me oversubscribed by 1 but if I move the buzzer to the reader then I should have enough and still have a couple left on the reader for a green and red LED.
Posts: 358
Joined: Sun Mar 04, 2012 9:28 am
by el_toro » Fri Jul 13, 2012 6:08 pm
kghunt wrote:Am I right in assuming the serial interface on the pi is TTL and not RS232?


I am trying one of these but with no joy.

http://www.ebay.co.uk/itm/RS232-Serial- ... %26ps%3D63

I am using the Pi 3v3 pin to vcc, and GND to GND. I have tried with TX-TX and TX-RX. As the Pi boots I get a lot of activity on the LEDs, but nothing on a puTTY serial session on my laptop.

I have tried changing the BAUD to 9600 in inittab for ttyAMA0 as I got some gibberish briefly (usually indicates a speed or parity mismatch), but still nothing.

I was hoping to switch off the getty and use the port for capturing sentences on an NMEA bus

Have I totally missed the point here?
User avatar
Posts: 12
Joined: Sat Jun 30, 2012 10:26 pm
by dbodnar » Mon Jul 16, 2012 10:14 am
Good day - I would like to offer another suggestion for an inexpensive way to connect the Pi's UART to a standard serial port.

I found a single board with the MAX3232 chip and the 5 capacitors already mounted - all are surface mount components and the price is quite attractive.

Have a look at the description of what I used on my web page here:

http://www.trainelectronics.com/RaspberryPi/

Please let me know if you have any questions.

thanks!

dave
Posts: 6
Joined: Mon Jul 16, 2012 10:10 am
Location: Pittsburgh, PA