Help with Calculated channel
Posted: Fri Mar 25, 2016 2:02 am
I'm trying to set up a virtual channel based on a calculation of existing CAN channels but I've not been able to get it to work. I started with the channel averaging example that is posted in the scripting examples. I'd like to calculate wheel slip which is one of the rear wheel speeds divided by the average of the two front wheel speeds.
I have an E46 M3 and the individual wheel speeds are working, it's just the calculated channel that isn't.
Can anyone see any issues with the script below?
lfWheelId = addChannel("LFWheelSpd", 10, 0, 0, 200, "MPH")
rfWheelId = addChannel("RFWheelSpd", 10, 0, 0, 200, "MPH")
lrWheelId = addChannel("LRWheelSpd", 10, 0, 0, 200, "MPH")
rrWheelId = addChannel("RRWheelSpd", 10, 0, 0, 200, "MPH")
rrslipId = addChannel("RRWheelSlip", 10, 0, 0, 100, "%")
function onTick()
local a1 = getrrWheelId
local a2 = getlfWheelId
local a3 = getlrWheelId
if lfWheelId > 10 then
setChannel(rrslipId, 100 * ( 1 - ( a1 / ((a2 + a3) / 2))))
end
end
I have an E46 M3 and the individual wheel speeds are working, it's just the calculated channel that isn't.
Can anyone see any issues with the script below?
lfWheelId = addChannel("LFWheelSpd", 10, 0, 0, 200, "MPH")
rfWheelId = addChannel("RFWheelSpd", 10, 0, 0, 200, "MPH")
lrWheelId = addChannel("LRWheelSpd", 10, 0, 0, 200, "MPH")
rrWheelId = addChannel("RRWheelSpd", 10, 0, 0, 200, "MPH")
rrslipId = addChannel("RRWheelSlip", 10, 0, 0, 100, "%")
function onTick()
local a1 = getrrWheelId
local a2 = getlfWheelId
local a3 = getlrWheelId
if lfWheelId > 10 then
setChannel(rrslipId, 100 * ( 1 - ( a1 / ((a2 + a3) / 2))))
end
end