Re-scale/ID CAN data to drive gauge cluster
Posted: Mon May 06, 2019 5:19 pm
I have an RX-8 with a 13b-REW engine swap (FD engine) and Megasquirt ECU. I'm trying to use my RaceCapture/Track MK2 to drive the OEM RX-8 gauge cluster which uses CAN data for RPM, speed, coolant temp, and oil pressure.
I need the Lua script to:
1. Receive CAN data from the Megasquirt and store as local variables (RPM, Speed, coolant temp, oil pressure)
2. Re-scale the data to what the OEM cluster is expecting and perform bit-shift operations
3. Transmit the data via CAN to the proper CAN IDs that the cluster expects
I have #2 and #3 working perfectly. I can fake an engine RPM (define "RPM=3000" in the script) and my script is able to re-scale the data properly and transmit it to the cluster, and the tach works. Same with the other variables/gauges. However, I'm still struggling with the best way to execute #1. I originally assumed that I could use "getChannel" to import a CAN variable that has already been defined in the "CAN mapping" tab - but that is not working at all (now I'm thinking it only works for channels defined in the Lua script using "addChannel"). My next attempt will be to use the "CAN bus integration" example script for the E46 to import these CAN variables. My concern is that I will be defining some CAN channels twice (once in "CAN mapping", and once in Lua) and that may cause some issues.
To summarize my questions, I'm stuck on how to receive CAN data and store as a local variable in Lua:
- Is there an easy way to grab channels that are already mapped in the CAN mapping tab for use in Lua?
- Is the CAN bus integration script the right way for me to receive CAN data and store it as a local variable in Lua?
I appreciate any help. I'll post an update if I make progress.
I need the Lua script to:
1. Receive CAN data from the Megasquirt and store as local variables (RPM, Speed, coolant temp, oil pressure)
2. Re-scale the data to what the OEM cluster is expecting and perform bit-shift operations
3. Transmit the data via CAN to the proper CAN IDs that the cluster expects
I have #2 and #3 working perfectly. I can fake an engine RPM (define "RPM=3000" in the script) and my script is able to re-scale the data properly and transmit it to the cluster, and the tach works. Same with the other variables/gauges. However, I'm still struggling with the best way to execute #1. I originally assumed that I could use "getChannel" to import a CAN variable that has already been defined in the "CAN mapping" tab - but that is not working at all (now I'm thinking it only works for channels defined in the Lua script using "addChannel"). My next attempt will be to use the "CAN bus integration" example script for the E46 to import these CAN variables. My concern is that I will be defining some CAN channels twice (once in "CAN mapping", and once in Lua) and that may cause some issues.
To summarize my questions, I'm stuck on how to receive CAN data and store as a local variable in Lua:
- Is there an easy way to grab channels that are already mapped in the CAN mapping tab for use in Lua?
- Is the CAN bus integration script the right way for me to receive CAN data and store it as a local variable in Lua?
I appreciate any help. I'll post an update if I make progress.