Author Topic: rs232 shifter vs max232  (Read 8591 times)

0 Members and 1 Guest are viewing this topic.

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
rs232 shifter vs max232
« on: August 18, 2007, 01:46:00 PM »
So I got this rs232 shifter from sparkfun:
http://www.sparkfun.com/commerce/product_info.php?products_id=133#

Its all hooked up, Im outputting stuff from my TX line on my ATmega8 UART, and my multimeter Hz reading is getting about 1.3kHz (which doesnt mean much, but verifies Im transmitting). The RX LED is flashing, too.

Now I dont have a serial port on my laptop so Im using a serial to USB adaptor . . . Now using hyperterminal Ive tried all of the baud rates and still not recieving any text.

So I have two theories why this is not working:
1) The adaptor cant handle the shifter board. What is shifting anyway? (seriously, I dont know)
2) Im not transmitting at any of the normal baud rates, and that I should change my F_CPU in code to fix this.

Im using avrlib, with an rprintf.c

I have F_CPU = 3686400 set in both my makefile and global.h (mentioned both making sure I didnt overwrite it). Im using the internal oscillator for the ATmega8.

I still dont quite understand this UART stuff, how do I relate my F_CPU to the baud rate? And what baud should I be expecting?

paulstreats

  • Guest
Re: rs232 shifter vs max232
« Reply #1 on: August 18, 2007, 04:42:28 PM »
The shifter board is actually doing nothing with the serial data, except amplifying 0or reducing the voltage where necesarry.

 The problem may lie more with the usb serial adapter. If this needs a serial signal of +/- 12v(Like the old serial standard) then it wont work as the shifter that you bought only converts this to a signal voltage of 0/5v for the newer serial port standard. So if the usb adapter needs a 12v signal to register high, the shifter that you have is only regulating the 12v down to 5v and not being picked up.

 Find out if the usb adapter works with the old or new serial standard (the old is rs-232 needing +/- 12v for high/ low signals and the new is eia-232 which uses 5v/0v for high/low - your rs232 shifter changes the old standard to the new.)

 It may be something else but there is a chance that this is where youre problem lies.

paulstreats

  • Guest
Re: rs232 shifter vs max232
« Reply #2 on: August 18, 2007, 04:45:12 PM »
Also serial communications are very fiddly with baud rates and synching etc... this is why im converting accross to i2c comms for ucontrollers and sensors/outputs

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
    • dunk's robot
Re: rs232 shifter vs max232
« Reply #3 on: August 18, 2007, 05:37:25 PM »
Quote
The shifter board is actually doing nothing with the serial data, except amplifying 0or reducing the voltage where necesarry.
yup. a level shifter also inverts the signal.

Quote
The problem may lie more with the usb serial adapter. If this needs a serial signal of +/- 12v(Like the old serial standard) then it wont work as the shifter that you bought only converts this to a signal voltage of 0/5v for the newer serial port standard. So if the usb adapter needs a 12v signal to register high, the shifter that you have is only regulating the 12v down to 5v and not being picked up.
this is rarely a problem.
as you say, it is common to find serial devices that don't transmit at as high a voltage as they used to back in the day.
the reasons for this is that it is rare these days that people use serial comms for long distance communication the way they were first envisaged.
all these serial port devices are still compatible for short ranges though. the RX side will still accept a wide range of voltages.
what does all this mean?
as long as your serial cable is less than 5 meters or so you don't have to worry about any of what i've just been talking about. it should Just Work (tm).

Quote
Find out if the usb adapter works with the old or new serial standard (the old is rs-232 needing +/- 12v for high/ low signals and the new is eia-232 which uses 5v/0v for high/low - your rs232 shifter changes the old standard to the new.)
sorry Paul, this is just plain wrong.
there is relatively little difference between rs232 and eia-232 for what Admin is trying to do.
http://www.camiresearch.com/Data_Com_Basics/RS232_standard.html#anchor1181130

both rs232 and eia-232 will need to go through a level shifter (and inverter) to reach the TTL UART levels that a microcontroller can deal with.
the level shifter Admin has bought should work fine for rs232 or eia-232.
the fact a USB dongle is being used should have no impact on the situation.

so, to trouble shoot this i would do some loop back tests.
plug in your USB serial thing, open hyperterminal (or whatever comms program you are using) and connect to your serial port.
disable all flow controll. it doesn't matter which baud rate you choose for this test.
now, connect pins 2 and 3 on your serial port.
everything you type in hyperterminal should be sent down the TX line and come back in the RX line and appear on your screen.

if that works, plug in your sparkfun level shifter, power it and join the TX and RX lines on it (the TX and RX wires that will go to your microcontroller).
you should again see the same results, this time transmitting from your serial port, through the level shifter, through the loop, back into the level shifter, back into the serial port and appear on your screen.

dunk.

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: rs232 shifter vs max232
« Reply #4 on: August 18, 2007, 09:15:46 PM »
Ill be in New Hampshire for the next four days for this UUST conference (for underwater robots) so I wont be able to test the hardware till I get back.

Dunk, lets assume your test shows everything works (I feel dumb for not thinking of it sooner), then what about the F_CPU?

Know any good links that explain baud vs uC frequency for UART?

Offline dunk

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 1,086
  • Helpful? 21
    • dunk's robot
Re: rs232 shifter vs max232
« Reply #5 on: August 19, 2007, 03:55:07 AM »
Quote
Dunk, lets assume your test shows everything works (I feel dumb for not thinking of it sooner), then what about the F_CPU?
all i really found was the datasheet.
there are a few places you can go wrong though.
make sure the F_CPU matches your clock speed (obviously).
also make sure your clock divider fuse bit is not set.

so when i first started working with the UART on AVRs i used some of the example code from Procyon AVRlib to get things working.
http://www.mil.ufl.edu/~chrisarnold/components/microcontrollerBoard/AVR/avrlib/

if you can't get it working let me know and i'll send you some test code and fuse bit settings that i have confirmed working on the ATmega8.

another thing you can try,
you should be able to see serial data on an oscilloscope.
set your scope to trigger on logic change and set the freqency to around 10x the baud rate you think you are using.
now when you hold down a key on your keyboard you should be able to see the serial data.

good luck,

dunk.

 


Get Your Ad Here