RegisterSearchFAQMemberlistUsergroupsLog in
Reply to topic Page 1 of 1
Extracting thermocouple data from CAN bus compound messaging
Author Message
Reply with quote
Post Extracting thermocouple data from CAN bus compound messaging 
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!

View user's profile Send private message
Reply with quote
Post  
Part 2.
Been through the CAN bus wiki quite a bit, but I am still stumped.

View user's profile Send private message
Reply with quote
Post  
Ok, so as I do not have the actual Racegrade TC8 module yet, I created the following script:

Code:
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.

View user's profile Send private message
Reply with quote
Post  
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.

View user's profile Send private message Visit poster's website
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum