launch controll for autocross on micro rusefi #4341

This commit is contained in:
rusefillc 2022-07-14 16:20:03 -04:00
parent 3079ab9bae
commit 604a3f4ba2
2 changed files with 41 additions and 0 deletions

View File

@ -4,6 +4,7 @@ startPwm(1, 80, 1.0)
-- disable
startPwm(2, 80, 0.0)
-- p, i, d, min, max
pid = Pid.new(2, 0, 0, -100, 100)
biasCurveIndex = findCurveIndex("bias")

View File

@ -0,0 +1,40 @@
desiredRpmCurve = findCurveIndex("desired_rpm")
desiredBoostCurve = findCurveIndex("desired_boost")
initialTorqueReductionTable = findTableIndex("torque_red")
sparkCutByTorqueCurve = findCurveIndex("spark_cut")
sparkRetardByTorqueCurve = findCurveIndex("spark_retard")
previousLaunchButtonState = 0
-- 50Hz
setTickRate(50)
-- p, i, d, min, max
pid = Pid.new(2, 0, 0, -100, 100)
function onTick()
launchButtonState = getAuxAnalog(0) > 1.5
launchStrength = getAuxAnalog(1)
if previousLaunchButtonState == 1 and launchButtonState == 0 then
print "Exiting LC"
elseif previousLaunchButtonState == 0 and launchButtonState == 1 then
desiredRPM = curve(desiredRpmCurve, launchStrength)
desiredBoost = curve(desiredBoostCurve, launchStrength)
initialTorqueReduction = table3d(initialTorqueReductionTable, desiredRPM, desiredBoost)
print ("Running LC " ..desiredRPM .." boost=" + desiredBoost ..' t=' ..initialTorqueReduction)
elseif launchButtonState == 1 then
print ("Running LC " ..desiredRPM .." boost=" + desiredBoost)
else
print "Not running LC"
end
end