Last active
May 8, 2016 07:10
-
-
Save kosenko-max/6f8c314b0c4181c2602e75e59cb9fe75 to your computer and use it in GitHub Desktop.
Fuel controllers management (Easy Performance + Fuellab Prodigy)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
initCAN(0, 500000) | |
setTickRate(1000) | |
setPwmClockFreq(1250) -- Fuelab recommends 500-1500 | |
local surgePumpVoltage = 2.5 | |
local mainPumpDuty = (90-20)/2 -- Fuelab uses 20%-90% range | |
local pumpSurgeVoltChannel = addChannel( "pumpSurgeV", 1000, 2, 0, 5, "V" ) | |
local pumpMainDutyChannel = addChannel( "pumpMainD", 1000, 1, 0, 100, "%" ) | |
function onTick() | |
avg0=getAnalog(0) | |
avg1=getAnalog(1) | |
avg3=getAnalog(3) | |
surgePumpVoltage = surgePumpVoltage - (avg1 - 12.0) * 0.0001 | |
if surgePumpVoltage > 5 then surgePumpVoltage = 5 | |
elseif surgePumpVoltage < 0.2 then surgePumpVoltage = 0.2 end | |
setAnalogOut(0,surgePumpVoltage) | |
setChannel(pumpSurgeVoltChannel,surgePumpVoltage) | |
mainPumpDuty = mainPumpDuty - (avg0 - avg3 - 43.5113)*0.01 | |
if mainPumpDuty > 90 then mainPumpDuty = 90 | |
elseif mainPumpDuty < 35 then mainPumpDuty = 35 end | |
setPwmDutyCycle(1,mainPumpDuty) | |
setChannel(pumpMainDutyChannel,mainPumpDuty) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment