Pages: [1]   Go Down
Author Topic: Receiving Serial ASCII Problem [solved]  (Read 370 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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:
#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:
#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?
« Last Edit: November 26, 2012, 11:38:29 pm by Nick Gammon » Logged

Worst state in America
Offline Offline
God Member
*****
Karma: 32
Posts: 792
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

Gentlemen may prefer Blondes, but Real Men prefer Redheads!

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When I connect the radar to the computer and start it up it gives me this over serial:
Code:
000
001
002
003
004
005
006
007
008
009
010
000
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: