× You're looking at the old version of the wiki! As of January 2020, all pages have been migrated to the new site at: http://wiki.speeduino.com
Secondary Serial IO interface
Overview
The Arduino Mega2560 version of Speeduino supports the use of Serial3 for supplemetry IO.The proposed STM32 and Teensy3.5 versions use Serial2 . On a Mega 2560 Serial3 can be found on the board at pins 14 and 15.The connection speed is 115200baud.
Settings
- Enable Secondary IO interface - To enable use of the Secondary io interface it must be enabled in TunerStudio.
Dependant on if CAN_COMMANDS have been enabled will vary the type of dropdown menu you will see
- Secondary IO options - Again dependant on if CAN_COMMANDS have been enabled will vary what options you have to enable Secondary serial.
- Enable options
- 1. Disabled
- 2. Enabled Secondary IO via Serial port
- 3. Enabled Secondary IO via canbus (this option will only be available when CAN_COMMANDS are enabled
How to use it
Depending on if the secondary port is a simple serial port or is a canbus port there are several things that the Secondary io interface is capable of.
- 1. Retreive the current realtime data just as is sent to TunerStudio.
- 2. Read in the Analog data values from 8 remote sensors.
- 3. Acivate External Outputs(coming soon!)
Retrieve realtime data
To get Speeduino to send out the realtime data to your device connected on a Secondary Serial IO port you must send either an "A" or an "r" to it.
- Send an "A"
If you send an "A" to the port it will reply with ,
"A" confirming the received instruction (sent as 0x41 in hex),
The port will now transmit a single byte in hex ,this is the number of bytes it is about to send .This is currently 0x39 (57 in decimal).
The port will then transmit ALL the realtime data.
- Send an "r"
if you send an "r" to the port you must also send 4 further bytes immediately after the "r". These are a 2 byte offset and a 2 byte length. the offset is the position in he realtime list you want the data returned to start from and the 2 byte length is the number of bytes you want returned. the bytes are sent LSB first . The port will reply with ,
"r" confirming the received instruction (send as 0x72 in hex) ,
The port will now transmit a single byte in hex ,this is the number of bytes it is about to send confirming what was requested.
The port will then transmit the realtime data requested starting at the byte position sent for the number of bytes length.
- The Realtime Data List
As of 02/05/2017 the data list is as follows
0 - currentStatus.secl
secl is simply a counter that increments each second
1 - currentStatus.squirt
Squirt Bitfield
2 - currentStatus.engine
Engine Status Bitfield
3 - (byte)(divu100(currentStatus.dwell))
Dwell in ms * 10
4 - (byte)(currentStatus.MAP >> 1)
map value is divided by 2
5 - (byte)(currentStatus.IAT + CALIBRATION_TEMPERATURE_OFFSET)
mat
6 - (byte)(currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET)
Coolant ADC
7 - currentStatus.tpsADC
TPS (Raw 0-255)
8 - currentStatus.battery10
battery voltage
9 - currentStatus.O2;
primary O2
10 - currentStatus.egoCorrection
Exhaust gas correction (%)
11 - currentStatus.iatCorrection
Air temperature Correction (%)
12 - currentStatus.wueCorrection
Warmup enrichment (%)
13 - lowByte(currentStatus.RPM)
rpm LB
14 - highByte(currentStatus.RPM)
rpm HB
15 - currentStatus.TAEamount
acceleration enrichment (%)
16 - currentStatus.baro
Barometer value
17 - currentStatus.corrections
Total GammaE (%)
18 - currentStatus.VE
Current VE 1 (%)
19 - currentStatus.afrTarget
chosen afr target
20 - (byte)(currentStatus.PW1 / 100)
Pulsewidth 1 multiplied by 10 in ms. Have to convert from uS to mS
21 - currentStatus.tpsDOT
TPS DOT
22 - currentStatus.advance
Current spark advance
23 - currentStatus.TPS
TPS (0% to 100%)
24 - lowByte(currentStatus.loopsPerSecond)
loops per second LB
25 - highByte(currentStatus.loopsPerSecond)
loops per second HB
26 - lowByte(currentStatus.freeRAM)
freeRam LB
27 - highByte(currentStatus.freeRAM)
freeRam HB
28 = currentStatus.batCorrection
Battery voltage correction (%)
29 = currentStatus.spark
Spark related bitfield
30 = currentStatus.O2_2
Second O2
31 = lowByte(currentStatus.rpmDOT)
rpmDOT must be sent as a signed integer
32 = highByte(currentStatus.rpmDOT)
rpmDOT HB
33 = currentStatus.ethanolPct
Flex sensor value (or 0 if not used)
34 = currentStatus.flexCorrection
Flex fuel correction (% above or below 100)
35 = currentStatus.flexIgnCorrection
Ignition correction (Increased degrees of advance) for flex fuel
36 = getNextError()
Error codes
37 = currentStatus.boostTarget
Target boost pressure
38 = currentStatus.boostDuty
current pwm boost dutycycle
39 = currentStatus.idleLoad
idleload
40 = currentStatus.testOutputs
testoutputs bitfield
41 = lowByte(currentStatus.canin[0])
Can input 0 LB
42 = highByte(currentStatus.canin[0])
Can input 0 HB
43 = lowByte(currentStatus.canin[1])
Can input 1 LB
44 = highByte(currentStatus.canin[1])
Can input 1 HB
45 = lowByte(currentStatus.canin[2])
Can input 2 LB
46 = highByte(currentStatus.canin[2])
Can input 2 HB
47 = lowByte(currentStatus.canin[3])
Can input 3 LB
48 = highByte(currentStatus.canin[3])
Can input 3 HB
49 = lowByte(currentStatus.canin[4])
Can input 4 LB
50 = highByte(currentStatus.canin[4])
Can input 4 HB
51 = lowByte(currentStatus.canin[5])
Can input 5 LB
52 = highByte(currentStatus.canin[5])
Can input 5 HB
53 = lowByte(currentStatus.canin[6])
Can input 6 LB
54 = highByte(currentStatus.canin[6])
Can input 6 HB
55 = lowByte(currentStatus.canin[7])
Can input 7 LB
56 = highByte(currentStatus.canin[7])
Can input 7 HB
Read external analog data
To get Speeduino to read analog data over Serial3 you must enable it. this is done in TS on an per channel basis.
You then set the input parameter group,input start byte number and input parameter number of bytes according to the sensor being accessed. Once enabled and configured Speeduino will periodically poll for that device on Serial3
The IO on Serial3 follows a similar protocol format to that of J1939 , this makes looking up a sensors configuration details quite straight forward.
Example 1:
Sensor type : Engine oil Temperature parameter group = 65262 start byte = 1 number of bytes = 1
Example 2:
sensor type : Engine oil pressure parameter group = 65263 start byte = 4 number of bytes = 1
Example 3:
sensor type : Exhaust temperture port 1 parameter group = 65187 start byte = 1 number of bytes = 2
Example 4:
sensor type : Exhaust temperature port 3 parameter group = 65263 start byte = 5 number of bytes = 2
Using Example 1 this is how to get your remote device to reply to the request from Speeduino for data.
Speeduino will send an "R"
Followed by the device parameter group number(this is sent in two bytes LSB first)
Speeduino will now await the response.
You must first send an "G" ,
Then send 8 bytes of data. The Data you wish to send is placed in bytes 0 and 1 (LSB and MSB respectively)if it is two bytes long or in byte 0 if it is only a single byte long .
The value sent is readable in Tunerstudio using the CanIN gauges