LUA / Can Bus help
Posted: Sun Aug 02, 2015 5:13 pm
Hi everyone!
Over the last couple of months, I've been working on an interface to obtain data from my ECU to send via CAN to the Race Capture Pro.
Here are the parameters I am currently obtaining:
* RPM
* Vehicle Speed
* Coolant Temp
* Throttle Position
* Clutch Switch
* Brake Switch
* Calculated Gear
My data is structured like this
{ 'RPM 1' , 'RPM 2' , 'Speed' , 'Coolant temp','Throttle Position', 'Clutch Switch', 'Brake Switch', 'Calculated Gear'}
| high byte low byte | byte | byte | byte | byte | byte | byte |
| (RPM1 | RPM2 << 8 )/4.0 | 0 - 255 | 0 - 255 | 0 - 100 | 0/1 | 0/1 | 0-6 |
All of the parameters will be packed into a 8 byte CAN message sent on to the race capture pro:
{'canID'',EXT','RPM1','RPM2','Speed','Coolant temp','Throttle Position','Clutch Switch','Brake Switch','Calculated Gear'}
This leads me to my question. I'm absolutely terrible with Lua, and I have no idea how to interpret my RPM data in the RCP.
What I do know:
* I'm fairly confident the ECU data is little endian
* The RPM value can be calculated in C/Arduino like this: (RPM1 | RPM2 << 8 )/4.0
Below is my best guess on how to map the CAN data out in the RCP. Any help you may have is appreciated.
--format is: [CAN Id] = function(data) map_chan(<channel id>, data, <CAN offset>, <CAN length>, <multiplier>, <adder>)
CAN_map = {``
[1365] = function(data) map_chan_le(rpmID, data, 0, 2 , .25, 0)
map_chan_le(mphID, data, 2, 1 , 0, 0),
map_chan_le(tmpID, data, 3, 1 , 0, 0),
map_chan_le(tpsID, data, 4, 1 , 0, 0),
map_chan_le(cltID, data, 5, 1 , 0, 0),
map_chan_le(brkID, data, 6, 1 , 0, 0),
map_chan_le(gerID, data, 7, 1 , 0, 0) end,
}
Thanks!
Ryan
Over the last couple of months, I've been working on an interface to obtain data from my ECU to send via CAN to the Race Capture Pro.
Here are the parameters I am currently obtaining:
* RPM
* Vehicle Speed
* Coolant Temp
* Throttle Position
* Clutch Switch
* Brake Switch
* Calculated Gear
My data is structured like this
{ 'RPM 1' , 'RPM 2' , 'Speed' , 'Coolant temp','Throttle Position', 'Clutch Switch', 'Brake Switch', 'Calculated Gear'}
| high byte low byte | byte | byte | byte | byte | byte | byte |
| (RPM1 | RPM2 << 8 )/4.0 | 0 - 255 | 0 - 255 | 0 - 100 | 0/1 | 0/1 | 0-6 |
All of the parameters will be packed into a 8 byte CAN message sent on to the race capture pro:
{'canID'',EXT','RPM1','RPM2','Speed','Coolant temp','Throttle Position','Clutch Switch','Brake Switch','Calculated Gear'}
This leads me to my question. I'm absolutely terrible with Lua, and I have no idea how to interpret my RPM data in the RCP.
What I do know:
* I'm fairly confident the ECU data is little endian
* The RPM value can be calculated in C/Arduino like this: (RPM1 | RPM2 << 8 )/4.0
Below is my best guess on how to map the CAN data out in the RCP. Any help you may have is appreciated.
--format is: [CAN Id] = function(data) map_chan(<channel id>, data, <CAN offset>, <CAN length>, <multiplier>, <adder>)
CAN_map = {``
[1365] = function(data) map_chan_le(rpmID, data, 0, 2 , .25, 0)
map_chan_le(mphID, data, 2, 1 , 0, 0),
map_chan_le(tmpID, data, 3, 1 , 0, 0),
map_chan_le(tpsID, data, 4, 1 , 0, 0),
map_chan_le(cltID, data, 5, 1 , 0, 0),
map_chan_le(brkID, data, 6, 1 , 0, 0),
map_chan_le(gerID, data, 7, 1 , 0, 0) end,
}
Thanks!
Ryan