Log in

View Full Version : Vex/Arduino Serial Port Help


weinbergmath
28-12-2007, 22:51
Hi everyone,

I've been working on an idea I've had for a while now of using an Arduino board as a navigation coprocessor for our team's FRC robot. The board works quite well for its current purpose, which is to read encoder counts, calculate distance, orientation, and potentially other important quantities related to navigation. My plan is to have the board output this data to the serial port using the same format as the CMU camera, allowing me to use and tweak Kevin Watson's code for grabbing camera data for this application.

Right now I am prototyping this on a Vex RC using the TTL serial port and the camera software written for the edubot that HAS previously worked with the camera. (We used it last year for prototyping.) I have connected the grounds between the Arduino and Vex and the Vex rx pin to the Arduino TX output. As a test, I sent the letter 'k' continuously through serial port 2, and wrote another program on the arduino to turn on an led when it receives a 'k'.

The problem is (as you might have guessed) that the two are not talking to each other in this simple test. I have configured the arduino at 9600 bps, 8-N-1 as is default in the serial port software for serial port two. I have tested the serial port with another arduino board at both 9600 and 115200 bps to show that the serial port functions. I have also tried 115200 bps out of the vex from both serial ports one and two.

By connecting a dumb terminal to the output, I've been able to read directly the output of the vex serial port. On serial port one, the characters come out correctly when I call "Write_Serial_Port_One('k'), but the serial data is clearly not read by the arduino since the LED does not go on. With serial port two, things become a bit more strange - the only way to send the 'k' is by sending the character code in Write_Serial_Port_Two(), and not with 'k' in the parentheses. When I call Write_Serial_Port_Two('k') it sends a blank character, and this is independent of the speed I tell it to send at.

I guess the deal breaker is that I can't verify that the serial ports are communicating, and without this, there's no chance the arduino can send the data back to the RC.

My question for the experts: If the pins are correctly connected (RX to TX, grounds connected together) and the port speeds are the same, is there anything ELSE that would also have to be configured to make two serial ports talk to each other? Is there a reason why the Write_Serial_Port functions would not be able to send a character ('k') out of serial port 2, but would be able to out of serial port 1?

Please let me know if you can think of things to try....

Thanks!

Evan

billbo911
30-05-2008, 17:54
I have connected the grounds between the Arduino and Vex and the Vex rx pin to the Arduino TX output. As a test, I sent the letter 'k' continuously through serial port 2, and wrote another program on the Arduino to turn on an led when it receives a 'k'.



Wow Evan, sounds like you are doing what I plan on doing this summer. (I know this is somewhat obsolete considering the new controller we will have in 2009, but I still like the challenge and the learning it provides.)

I think your communication problem stems from your wiring. If you are sending the "k" from the Vex to the Arduino, then you output on the Vex should be Tx, and your input on the Arduino should be Rx. It looks like you have the two backward.

I would love to see your Sketches for the Arduino. It would save me a ton of time. Either way, I'll figure it out. I also plan on adding a gyro input to the Arduino and sending the encoders and rotation orientation to the Vex via serial stream.

Foster
30-05-2008, 20:43
I've had good luck connecting things to the serial ports. As noted above you need to take the VEX TX and put it to the other device RX.

I have a breakout box that puts an LED on the line and at low baud rates I can see the LED flicker as the characters go by.

When looking for characters from the Arduino (TX) port to the VEX input (RX) port check the USART status buffer. It will tell you if you got frame errors (bitrates wrong).

Good luck,
Foster