Pages: [1]   Go Down
Author Topic: Serial communication between 2 different boards.  (Read 790 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 92
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
« Last Edit: August 23, 2010, 07:24:17 pm by BKnight760 » Logged

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8922
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you connect the rasor to a normal pc serial port, can you see the proper output a terminal program like hyperterminal?
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for replies .

It is ascii values. Should have checked that smiley-sad

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

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8922
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Sussex UK / CT USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1028
Forums forever
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: