View previous topic :: View next topic |
Author |
Message |
weg22
Joined: 08 Jul 2005 Posts: 91
|
Is MAX232 chip required?? |
Posted: Tue Jan 23, 2007 2:31 pm |
|
|
Hi all,
I am using the MaxSonar EZ-1 ultrasonic sensor. It outputs data in RS232 format. According to the 2nd page of the datasheet (see below), the RS232 voltages range from 0-5V and not -12V to 12V. Therefore, shouldn't I be able to grab data from it without using a MAX232 chip?
http://www.superdroidrobots.com/product_info/MaxSonar-EZ1-Datasheet.pdf
I was able to get data from it without any problems when integrating my PIC with a MAX232 chip, but when I hook it up directly to the PIC I get a bunch of weird ASCII characters.
Thanks in advance,
-weg |
|
|
frequentguest Guest
|
|
Posted: Tue Jan 23, 2007 2:53 pm |
|
|
Just a quick off-the-top-of-my-head answer without looking at the datasheet. Could the signals be inverted? |
|
|
weg22
Joined: 08 Jul 2005 Posts: 91
|
|
Posted: Tue Jan 23, 2007 3:10 pm |
|
|
What signals are you referring to? Are you suggesting that my Tx and Rx lines are reversed? If so, this is not correct or I wouldn't be seeing any data coming in. |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Tue Jan 23, 2007 3:19 pm |
|
|
The usual MAX232 chip inverts the 0's and 1's. If you are using a software UART you can specify INVERT in the users232 setup line. Otherwise you can use any normal logic inverter. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jan 23, 2007 3:37 pm |
|
|
Look at their FAQ page. Scroll about 40% of the way down the page
to the section on "TX output", where they show a photo of a DB-9
connector.
http://www.maxbotix.com/MaxSonar-EZ1__FAQ.html
They say that the unit connects directly to the PC with a serial cable.
This means that the sonar unit has the equivalent of a MAX232 circuit
inside it (even though it uses 0 to 5v levels instead of -12v to +12v).
To amplify Sherpa Doug's comments, this means that if you use
the hardware UART in the PIC, then you must add an external inverter
chip to the Tx and Rx signals (a chip such as a 74HC04 or 74HCT04).
If you use a software UART, then you must use the INVERT option in
the #use rs232() statement. The hardware UART can't use the INVERT
option. It only works with a soft UART. |
|
|
weg22
Joined: 08 Jul 2005 Posts: 91
|
|
Posted: Tue Jan 23, 2007 3:41 pm |
|
|
Yep, that was it! Used the INVERT option and it worked perfectly! Thanks Sherpadog and PCM.
-weg |
|
|
|