Go Down

Topic: Serial communication between 2 different boards. (Read 1 time) previous topic - next topic

edjmo

I have pretty well exhausted everything I can to solve this problem.

I have a 9dof Razor and have tried to send data to every other make of Arduino Board there is and never get the proper info coming across.

I use  this line to send the data

Code: [Select]
Serial.print((int(ToDeg(MAG_Heading))));

Using an Ftdi serial cable i can read that data fine on my computer.

I send that same data to any other Arduino capture it and then ask it to print and it is not correct.

Here is the capture and print code.

Code: [Select]

byte headingData[2];
int i, headingValue;
void loop()
{
//-------------------------------------------- this is all gps stuff. This is just the example code given from tiny gps library.
//----------------------------------------------I deleted the part of the code for the time and date. I did not want it.

i=0;
headingValue =0;
compassheading();
if (headingValue != 0)
{
 Serial.println(headingValue);
}
}

void compassheading(){
   i = 0;
 while(Serial.available() && i < 2)
 {
   headingData[i] = Serial.read();

   i++;
 }


headingValue = (headingData[0]*256 + headingData[1]);  
headinggps = headingValue / 10;      // this is the heading of the compass

}


Anyhow am I missing something here?
Probably and i think i know what it is.

I have been using the Arduinos Uarts and am thinking i need to throw a Max232 into the mix.
I certainly hope not.
If so am just going to breakout the SPI on the Razor  and communicate that way.

All I am trying to do at this stage is to read the compass from the razor  and send that heading to another board.

BKnight760

#1
Aug 24, 2010, 02:22 am Last Edit: Aug 24, 2010, 02:24 am by BKnight760 Reason: 1
The data coming across may be converted to ASCII.  So a digit "0" appears as decimal 48.  check out http://www.klcconsulting.net/images/ascii-full.gif

If you're just sending integers, you can just subtract 48 from all the serial.read() results.  

If you're sending more than just integers, you'll need to parse out the data.

To help debug the issue, could you paste the sent data and the actual received values?

zoomkat

If you connect the rasor to a normal pc serial port, can you see the proper output a terminal program like hyperterminal?
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

edjmo

Thanks for replies .

It is ascii values. Should have checked that :(

As far as the razor working direct to the PC yes it does.

And so does the Arduino boards work properly connected direct to the PC. It only happens when I send data from one device to the other using the serial port that this happens.

zoomkat

Quote
As far as the razor working direct to the PC yes it does.


This sounds like the rasor is using standard rs232 communications which would need to be converted to TTL for the arduino to use.
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

tkbyd

Are you trying to use the Serial Monitor to "see" things, at the same time as you are trying to use the Ardunio's serial port to talk with Razor?

I prefer to use a separate port, via NewSoftSerial, to avoid clashes. Even if you aren't using Serial Monitor, the Arduino's main port is "busy" with programming from time to time.

More at...

http://sheepdogguides.com/dt4t.htm

Don't let the "Delphi" bits put you off... there are general principles implicit in the discussion.

edjmo

Solved the problem.

Baud Rate at  57,600 between the 2 boards just does not work.

Each board direct  to pc  57,600 works fine

Join the boards together and try using 57600 and it fails.

Dropping baud of both boards to 38,400 solved this problem.

Go Up