Sending data to arduino via aux serial port

Race Capture Pro hardware installation- power, wiring, physical installation, etc. See the dedicated forum for Sensor related topics

Moderators: JeffC, rdoherty, stieg, brentp

Post Reply
rwdsubi
Posts: 3
Joined: Sun Jul 02, 2017 5:16 am

Sending data to arduino via aux serial port

Post by rwdsubi »

I'm trying to use the Aux serial port on my Racecapture Pro Mk2 to send data to an arduino uno. I know thw racecapture is sending the data but it's showing up as gibberish on the arduino.

Baud rate is set at 9600 across the board. I have the aux TX pin going into the TX pin on the arduino (pin 1) and the RX into RX (pin 0)

Is there anything I'm missing on this? I tried switching the TX and RX but with that, nothing showed up.

Racecapture Pro Mk2 script

Code: Select all

tickRate = 25

ser_baud = 9600
ser_port = 4
ser_bits = 8
ser_par = 0
ser_sbit = 1

ser_start_char = '<'
ser_end_char = '>'

function sendDataToDis&#40;&#41;	
	local oilTemp = 123
	local coolTemp = 789
	
	local mes = ser_start_char .. oilTemp .. "|" .. coolTemp .. ser_end_char
	
	writeSer&#40;ser_port, mes&#41;	
end

function onTick&#40;&#41;
 sendDataToDis&#40;&#41;
end

setTickRate&#40;tickRate&#41;
initSer&#40;ser_port, ser_baud, ser_bits, ser_par, ser_sbit&#41;
Arduino Code

Code: Select all

void setup&#40;&#41; &#123;
    Serial.begin&#40;19200&#41;;
    Serial.println&#40;"<Arduino is ready>"&#41;;
&#125;

void loop&#40;&#41; &#123;
    recvWithStartEndMarkers&#40;&#41;;
&#125;

void recvWithStartEndMarkers&#40;&#41; &#123;
    char startMarker = '<';
    char endMarker = '>';
    char rc;
 
    while &#40;Serial.available&#40;&#41; > 0&#41; &#123;
        rc = Serial.read&#40;&#41;;
        Serial.println&#40;rc&#41;;
    &#125;
&#125;
Attachments
Arduino serial output
Arduino serial output
Capture.PNG (8.19 KiB) Viewed 13473 times

brentp
Site Admin
Posts: 6282
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

Looks like a baud rate issue. Have you tried different baud rates on the Arduino side?

Also, you can get a USB to serial adapter for your computer as an alternate way to test, and use a terminal program to test your data output.
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

BigLobsterDude
Posts: 17
Joined: Sun Dec 27, 2015 12:55 am
Location: Freehold, NJ

Post by BigLobsterDude »

This is waking up an old thread but hopefully this may help others having trouble connecting devices with a serial interface (e.g. Arduino, maybe some gauges, etc.) to the RaceCapturePro Aux serial interface.

The problem is that the serial ports on the RCP and Arduino use different physical level (electrical) interfaces. The asynchronous serial protocol (baud rates, stop bits, etc.) riding on top of the physical layer is the same.

The RCP aux port uses an RS232 electrical interface with signals of -12V (logical 1) and +12V (logical 0).

Arduino COM ports use a TTL electrical interface with signal levels of +3.3 volt (or 5 volt) for a logical 1, and 0 volts (e.g., ground) for the logical 0.

It is necessary to use a signal converter to communicate between the two systems. Sparkfun Electronics (and many other places) sell these (https://www.sparkfun.com/products/449).

For you electronics gurus, I found inverting the signal with a simple NPN transistor circuit (with resulting voltage levels of 0 and 12 volts) also works for transmitting data from the Arduino to the RCP. A second circuit for transmitting data to the Auduino should also work, but I've not tested that. In any case, your mileage may vary.

Without a converter for the electrical signals the devices will never communicate and the mismatch may cause damage.

A good description of the issue is found at https://www.sparkfun.com/tutorials/215

John
Schumacher Taxi #189 racing team

brentp
Site Admin
Posts: 6282
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

Thanks for the useful note. This isn't a problem, but actually a feature of the system; RS232 is the proper signaling when exposing serial data to the outside world; it would be bad if the raw 3.3v TTL signals were present on the external connector.

The RS232 transceiver step up the voltage so it can be broadcast over a longer distance, but also provide protection against surge / transient voltage spikes, as well.
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

BigLobsterDude
Posts: 17
Joined: Sun Dec 27, 2015 12:55 am
Location: Freehold, NJ

Post by BigLobsterDude »

Brent,

I agree 100% with you - RS232 is the proper interface for an external communications connector.

I was not trying to suggest any issue with the RCP - just explain a common misconception about serial communications protocols.

brentp
Site Admin
Posts: 6282
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

Understood. No problem, and thanks for contributing!
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Post Reply