Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Arduino and cRIO serial connection (http://www.chiefdelphi.com/forums/showthread.php?t=106971)

apples000 17-06-2012 14:06

Arduino and cRIO serial connection
 
I've been working on using an arduino to control lights and maybe read sensors on our robot. I have decided to try to use serial instead of SPI or I2C because there isn't much documentation about the Arduino being the slave for either of them. I believe that the cRIO's serial port uses full voltage RS-232 serial and the arduino uses 5v TTL. I have found an old MAX232 based level converter board that I have laying around and I think that the cRIO will work with it. I know how to connect the Tx and Rx of the cRIO and Arduino, but I don't know if or what I have to do with the other pins. Do I only need ground, tx, and rx, or do I need to connect the others?

Meshbeard 17-06-2012 17:12

Re: Arduino and cRIO serial connection
 
I wouldn't abandon the I2C interface yet.
http://wiring.org.co/learning/libraries/ has some examples of how to use the arduino as a slave in an I2C system. Look under "slave sender."

apples000 18-06-2012 16:03

Re: Arduino and cRIO serial connection
 
Wow, I had no idea that the arduino could be a slave. I was using an older version of the wire library that did not have good documentation. I would like to use i2c, but I have no idea how to send more than one byte between the two devices. Do you know where I could find an example for sending an integer or a string? I can only seem to find information about sending one byte.

Gdeaver 18-06-2012 18:59

Re: Arduino and cRIO serial connection
 
On this page look at the master slave examples for the wire lib.
http://arduino.cc/en/Tutorial/HomePage

apples000 18-06-2012 21:04

Re: Arduino and cRIO serial connection
 
Thanks for the quick reply! I understand how it works, but I am unsure how I would go about storing the transmitting information to a variable. From what I understand, it sends one character at a time. Then, for the last one, it will send the end of the line. I think that if I wanted to store the string, I would have to add all of the letters together, then stop when I got the new line. For what I am trying to do, I would like to send several integers. If I sent three integers separated by commas (12,45,65), could I read it using

Code:

void receiveEvent(int howMany)
{
  while(Wire.available())
  {
 int a = Wire.parseint();
 int b = Wire.parseint();
 int c = Wire.parseint();

       
  }
 
}



All times are GMT -5. The time now is 00:53.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi