Extracting thermocouple data from CAN bus compound messaging

Discussions on CAN mapping for ECUs, sensors, PDMs, and more.
Post Reply
dvsu12
Posts: 18
Joined: Sun May 17, 2015 11:02 pm

Extracting thermocouple data from CAN bus compound messaging

Post by dvsu12 »

Hi all,

Goimg to be implementing a Racegrade TC8 on CAN bus 1 with my RCP mk2.
Due to a current issue with Racegrade's firmware, I have to use the default MoTec E888 mode, which uses compound messaging to distribute each of the 8 TC channels.

How do I extract this in Lua? Help!
Attachments
2017-11-03 08.54.44.png
2017-11-03 08.54.44.png (235.45 KiB) Viewed 2018 times

dvsu12
Posts: 18
Joined: Sun May 17, 2015 11:02 pm

Post by dvsu12 »

Part 2.
Been through the CAN bus wiki quite a bit, but I am still stumped.
Attachments
2017-11-03 10.31.07.png
2017-11-03 10.31.07.png (213.68 KiB) Viewed 2017 times

dvsu12
Posts: 18
Joined: Sun May 17, 2015 11:02 pm

Post by dvsu12 »

Ok, so as I do not have the actual Racegrade TC8 module yet, I created the following script:

Code: Select all

function onTick() 
EGT1 = addChannel("EGT1", 10)
EGT2 = addChannel("EGT2", 10)
idcan=0x0F0
datacanEGT1={0x00,0x00,0x00,0x05,0x0F,0x00,0x00,0x00}
datacanEGT2={0x20,0x00,0x00,0x06,0x0F,0x00,0x00,0x00}
while idcan==0x0F0 do
 if datacanEGT1[1]==0x00 then
 datacansumEGT1=datacanEGT1[4]+datacanEGT1[5]
 if datacanEGT2[1]==0x20 then
 datacansumEGT2=datacanEGT2[4]+datacanEGT2[5] 
end
end

setChannel(EGT1, datacansumEGT1)
setChannel(EGT2, datacansumEGT2)
end
end
datacanEGT1 and 2 are some dummy values I created in the same format I'd expect to receive over CAN bus from the RG TC8, idcan is also a dummy variable to simulate CAN address of the RG TC8.

Bassically, if this were a real CAN stream, datacanEGT1 and 2 would be one variable only, of which the while / if loop would extract data from the correct bytes depending on the TC channel required.

With this dummy script, I have managed to get decimal values of EGT1 = 20 and EGT2 = 21, which is what i've put in bytes 4 and 5 for the dummy values.

Comments? Criticisms?

Brent, I know you have suggested having MoTec USA preconfigure the unit for me, but I think it would be a good addition to the wiki to show others how to decode compounded / multiplexed messages, such as in use with the MoTec E888 expander.

MikeD
Posts: 39
Joined: Sun May 29, 2016 11:55 am
Location: Austria
Contact:

Post by MikeD »

Hi Adam,
we've been in contact already via FB pm...
Your script above is not that bad, anyway from a quick look at least you have the byte numbering wrong when you want to receive data from the TC8:
Generally speaking about CAN the bytes are numbered from 0-7... i.e. the first byte is called byte 0, the second byte is called byte 1 and so on...
However sadly within the RaceCapture script the bytes are named 1-8.
With this in mind when you watch out for byte 4+5 to get TC1 as an example within your script it will be bytes 5+6 that you want specify.

Post Reply