Go Down

Topic: Receiving Serial ASCII Problem [solved] (Read 452 times) previous topic - next topic

dwarrenku

Nov 27, 2012, 02:22 am Last Edit: Nov 27, 2012, 05:38 am by Nick Gammon Reason: 1
I have a problem. I'm reading the ASCII output from a radar unit that spits out a car's speed in ASCII from RS232 serial. I have it wired to the arduino via the RS232 digicute shield, and the arduino is using SoftwareSerial. The SoftwareSerial is so I can program the arduino while having the shield mounted.

When the radar is powered up, it spits out the following in ascii, with a 0x0A new line in before the first 000:
Code: [Select]

000
001
002
003
004
005
006
007
008
009
010
000


I can't get the arduino to print out anything like this. I've tried using print and write, and nothing seems to work.

When I use "Serial.write" (which prints hex, right?):
Code: [Select]
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup()  
{
 Serial.begin(9600);
 mySerial.begin(115200);
}
void loop()
{
 if (mySerial.available()) {
     Serial.write(mySerial.read());
 }
}


I get:
0..!.0.LH.0..!.0..H.0..!.0.SH.0..!.0.SH.0..!.0.N!.0&.H.0..!.

When I use this Serial.println:
Code: [Select]
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
void setup()  
{
 Serial.begin(9600);
 mySerial.begin(115200);
}
void loop()
{
 if (mySerial.available()) {
     Serial.println(mySerial.read());
 }
}


I get:
48
152
152
33
225
48
152
76
33
225
48
152... (it goes on for a while)

Does anyone have any idea what I'm doing wrong here?

Krupski


I have a problem. I'm reading the ASCII output from a radar unit that spits out a car's speed in ASCII from RS232 serial. I have it wired to the arduino via the RS232 digicute shield, and the arduino is using SoftwareSerial. The

Does anyone have any idea what I'm doing wrong here?


Your ASCII dump looks like a combination of mis-matched baud rate (or noise) and ASCII data being represented as decimal.

For example, "48" is the number 0. The 33 is an exclamation point and 76 is the letter "L" (all of which appear in your example of bad data).

If you connect the radar detector to a regular computer & serial port, do you get clean data?
Gentlemen may prefer Blondes, but Real Men prefer Redheads!

dwarrenku

When I connect the radar to the computer and start it up it gives me this over serial:
Code: [Select]

000
001
002
003
004
005
006
007
008
009
010
000

dwarrenku

Nevermind. I got around the problem by setting the output of the radar unit to bytes instead of ascii, now all is well.
Thanks for your help.

Go Up