Sharing Math Channels for E46 M3
Posted: Wed Mar 22, 2017 2:18 am
I've recently discovered how to add math channels to the E46 standard script that I have been using and wanted to share them here. The calculations have mostly come from the book "analysis techniques for racecar data acquisition" by Jorge Segers. I've condensed some of the calculations and scaling factors to reduce the length of the equations and so it may not be completely clear from the script.I have not tested these out on a track yet, just driving around the block. I make no claims to their accuracy or usefulness.
I will copy the whole script in the next post but wanted to explain each of the math channels individually. The channel Id should be added to you list of channels at the top of the script.
The calculation should be added after the "processCAN(CAN_chan)" line which can be found immediatly after the can map section.
i.e.
function onTick()
processCAN(CAN_chan)
ADD MATH CHANNELS HERE
end
Gear Calculator. This is for the E46 M3 with standard diff ratio (3.62)
gearId=addChannel("Gear",10,0,0,6)
local a1=getChannel(rpmId)
local a2=getChannel(clutchId)
local a3=getChannel(gearId)
local w3=getChannel(lrWheelId)
if a2<0.5 then
setChannel(gearId,(w3/a1)*240)
else
setChannel(gearId,a3)
end
This channel works by dividing the wheel speed by the rpm and multiplying that value by 240. Using no decimal places it matches the gear position. The gear calculator runs when the clutch is engaged. When the clutch is disengaged, the gear calculator remembers the last position. This will prevent erroneous numbers when blipping the throttle on a down shift.
Wheel Longitudinal slip.
This channel will calculate the forward/aft slip of the individual wheels. This will measure wheelspin during acceleration and wheel lockup under braking.
Channels:
lfslipId=addChannel("LFWheelSlip",10,1,0,100,"%")
rfslipId=addChannel("RFWheelSlip",10,1,0,100,"%")
lrslipId=addChannel("LRWheelSlip",10,1,0,100,"%")
rrslipId=addChannel("RRWheelSlip",10,1,0,100,"%")
Calculation:
local w1=getChannel(lfWheelId)
local w2=getChannel(rfWheelId)
local w3=getChannel(lrWheelId) -- not needed here is using with gear calculator above.
local w4=getChannel(rrWheelId)
if w4 > 10 then
setChannel(lfslipId,100-(50*(w3+w4))/w1)
setChannel(rfslipId,100-(50*(w3+w4))/w2)
setChannel(lrslipId,100-(50*(w1+w2))/w3)
setChannel(rrslipId,100-(50*(w1+w2))/w4)
end
This one works by tacking the average speed of the wheels on one axel and comparing that to the speed of a wheel on the other axel. The calculation is only performed at greater than 10 mph otherwise it provide lager slip angles when speeds are low. I also increased the wheel speed channel to 1 decimal place to get better accuracy with these calculations.
I will copy the whole script in the next post but wanted to explain each of the math channels individually. The channel Id should be added to you list of channels at the top of the script.
The calculation should be added after the "processCAN(CAN_chan)" line which can be found immediatly after the can map section.
i.e.
function onTick()
processCAN(CAN_chan)
ADD MATH CHANNELS HERE
end
Gear Calculator. This is for the E46 M3 with standard diff ratio (3.62)
gearId=addChannel("Gear",10,0,0,6)
local a1=getChannel(rpmId)
local a2=getChannel(clutchId)
local a3=getChannel(gearId)
local w3=getChannel(lrWheelId)
if a2<0.5 then
setChannel(gearId,(w3/a1)*240)
else
setChannel(gearId,a3)
end
This channel works by dividing the wheel speed by the rpm and multiplying that value by 240. Using no decimal places it matches the gear position. The gear calculator runs when the clutch is engaged. When the clutch is disengaged, the gear calculator remembers the last position. This will prevent erroneous numbers when blipping the throttle on a down shift.
Wheel Longitudinal slip.
This channel will calculate the forward/aft slip of the individual wheels. This will measure wheelspin during acceleration and wheel lockup under braking.
Channels:
lfslipId=addChannel("LFWheelSlip",10,1,0,100,"%")
rfslipId=addChannel("RFWheelSlip",10,1,0,100,"%")
lrslipId=addChannel("LRWheelSlip",10,1,0,100,"%")
rrslipId=addChannel("RRWheelSlip",10,1,0,100,"%")
Calculation:
local w1=getChannel(lfWheelId)
local w2=getChannel(rfWheelId)
local w3=getChannel(lrWheelId) -- not needed here is using with gear calculator above.
local w4=getChannel(rrWheelId)
if w4 > 10 then
setChannel(lfslipId,100-(50*(w3+w4))/w1)
setChannel(rfslipId,100-(50*(w3+w4))/w2)
setChannel(lrslipId,100-(50*(w1+w2))/w3)
setChannel(rrslipId,100-(50*(w1+w2))/w4)
end
This one works by tacking the average speed of the wheels on one axel and comparing that to the speed of a wheel on the other axel. The calculation is only performed at greater than 10 mph otherwise it provide lager slip angles when speeds are low. I also increased the wheel speed channel to 1 decimal place to get better accuracy with these calculations.