go away spammer

Author Topic: Putty settings for serial data from atmega  (Read 12164 times)

0 Members and 1 Guest are viewing this topic.

Offline silo_xtremeTopic starter

  • Robot Overlord
  • ****
  • Posts: 173
  • Helpful? 0
  • I really love robots, they keep me awake at night.
Putty settings for serial data from atmega
« on: November 30, 2009, 07:50:28 PM »
Hey all,

I have my usart sending at 9600 bps, my windows hardware com1 set to 9600, and putty at 9600.  All are 8n1 with no hardware control.  I'm sending a 1 and in putty I'm getting a what looks like an 'a' with a symbol on it.  Pretty much a dos symbol.  I also have a 10ms delay between transmits.

Any idea why I'm not getting the 1 I am expecting?

Offline hopslink

  • Robot Overlord
  • ****
  • Posts: 202
  • Helpful? 14
Re: Putty settings for serial data from atmega
« Reply #1 on: December 01, 2009, 02:40:11 AM »
The default for the terminal is ASCII characters and that is what you are seeing. If you can, try to switch to binary data in your terminal settings, or stream to a binary file and open with a hex editor.



Offline silo_xtremeTopic starter

  • Robot Overlord
  • ****
  • Posts: 173
  • Helpful? 0
  • I really love robots, they keep me awake at night.
Re: Putty settings for serial data from atmega
« Reply #2 on: December 01, 2009, 07:33:33 AM »
Hey hopslink,

I did think about that.... But the data doesn't appear to match.

For example,  I'm sending all 1's and my hex file says "E0 00 E0 00 ..."

unless I'm missing something silly here...?

Offline hopslink

  • Robot Overlord
  • ****
  • Posts: 202
  • Helpful? 14
Re: Putty settings for serial data from atmega
« Reply #3 on: December 01, 2009, 09:31:35 AM »
Weird, but I will bet it is still a mangling according to one of the various character sets. Try to grab yourself a serial monitor program like RealTerm. This should allow viewing of incoming data as uint8 data, which should be what the micro is sending.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: Putty settings for serial data from atmega
« Reply #4 on: December 01, 2009, 09:39:50 AM »
Do you have a level translator between your USART and your PC?
The USART sends a low for a Start bit and the RS232 com port input expects a high for a Start bit.

Also, send ASCII characters as suggested above for debugging, hex is a pain when troubleshooting.
« Last Edit: December 01, 2009, 09:41:02 AM by waltr »

Offline silo_xtremeTopic starter

  • Robot Overlord
  • ****
  • Posts: 173
  • Helpful? 0
  • I really love robots, they keep me awake at night.
Re: Putty settings for serial data from atmega
« Reply #5 on: December 02, 2009, 03:10:22 PM »
hey hopslink,

 I started using RealTerm to help debug this problem. Here is what I am finding:

When I try to send 1 char, I get a first transmit of 0 when the USART initializes, but then it was not sending the next char.

When I try to send many chars from 255 down to 0, I get uint's that are out of order in the beginning but seem to become ordered and count by 2 from 100 to 255; what is weird is that the 255 comes at the end of TX send and I'm expecting the beginning.

Here's some corresponding binary data if interested (see attached).  It's just supposed to be data from 255 down to 0.

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: Putty settings for serial data from atmega
« Reply #6 on: December 02, 2009, 03:13:04 PM »
Try reading my above post again. Really sound like the serial logic is inverted.

Offline silo_xtremeTopic starter

  • Robot Overlord
  • ****
  • Posts: 173
  • Helpful? 0
  • I really love robots, they keep me awake at night.
Re: Putty settings for serial data from atmega
« Reply #7 on: December 02, 2009, 03:23:36 PM »
I don't currently have a level shifter connected.  Should I?  How would this be fixed with out?

Offline silo_xtremeTopic starter

  • Robot Overlord
  • ****
  • Posts: 173
  • Helpful? 0
  • I really love robots, they keep me awake at night.
Re: Putty settings for serial data from atmega
« Reply #8 on: December 02, 2009, 04:41:53 PM »
Ok, I'm using Realterm to invert the data ... but is not solving the problem entirely.

The data now starts at 255, but the next number is 127, or as in binary:

11111111
01111111
00111111
10111111
10011111
01011111
00011111

etc....

again, not what I am expecting.  Any thoughts?

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: Putty settings for serial data from atmega
« Reply #9 on: December 02, 2009, 07:34:09 PM »
I don't currently have a level shifter connected.  Should I?  How would this be fixed with out?
Yes you should.
This is Asynchronous data. There is a START bit and a STOP bit that frames the 8 data bits. The UART uses the START bit to know when to start sampling the incoming data bits. Here are a Wiki articles on RS232 which is what your PC's comm port is expecting:
http://en.wikipedia.org/wiki/RS-232
http://en.wikipedia.org/wiki/Universal_asynchronous_receiver/transmitter

Compare the RS232 wave forms to this:
http://www.societyofrobots.com/microcontroller_uart.shtml
Note that out of the UART the START bit in logic Low, this is TTL level asynchronous. Whereas RS232 the START bit is HIGH and the levels are approximately -10V to +10 volts (although modern PC com ports will work with 0V to 5V signals but the the START bit must be high).

Note the START and STOP bits and try doing a timing diagram of the bits you are sending (plus Start & stop) inverted and see where the START bit would be. I'll bet this would explain every thing you are experiencing.

 


Get Your Ad Here

data_list