Auto-generated default tune

This commit is contained in:
GitHub gen-default-tune Action 2024-06-29 21:51:54 +00:00
parent 2bccf97653
commit e2d3876cd9
1 changed files with 72 additions and 50 deletions

View File

@ -2333,40 +2333,86 @@ IN_285 = 0x285 -- 645
IN_285 = 0x285
IN_35D = 0x35d
OUT_1F9 = 0x1F9 -- 505
OUT_233 = 0x233 -- 563
OUT_23D = 0x23D -- 573
ENGINE_1_1F9_505 = 505
ENGINE_7_233_563 = 563
ENGINE_3_23D_573 = 573
setTickRate(100)
t = Timer.new()
t : reset()
HEATER_OUTOUT_INDEX = 1
startPwm(HEATER_OUTOUT_INDEX, 1, 0)
startUpTimer = Timer.new()
startUpTimer : reset()
rpm = 0
pps = 0
globalAcOut = 0
cltGauge = 0
function getTwoBytesMSB(data, offset, factor)
return (data[offset + 1] * 256 + data[offset + 2]) * factor
end
function onTick()
local MAF = getSensor("MAF")
MAF = (MAF == nil and 0 or MAF)
local TPS = getSensor("Tps1")
TPS = (TPS == nil and 0 or TPS)
local PPS = getSensor("AcceleratorPedal")
PPS = (PPS == nil and 0 or PPS)
-- print ("MAF " .. MAF .. " TPS " .. TPS .. " PPS " .. PPS)
local rpmValue = math.floor(getSensor("RPM") + 0.5)
local RPMread = rpmValue / 3.125
-- Little-endian System, "Intel"
function setTwoBytesLsb(data, offset, value)
value = math.floor(value)
data[offset + 2] = value >> 8
data[offset + 1] = value & 0xff
end
payloadENGINE_3_573 = { 0x00, 0, 0x0C, 0x01, 0x0A, 0x87, 0xFF, 0xFF }
function sendENGINE_3_573()
rpmWithSweep = startUpTimer : getElapsedSeconds() < 2 and 8000 or rpm
setTwoBytesLsb(payloadENGINE_3_573, 3, rpmWithSweep / 3.125)
payloadENGINE_3_573[2] = pps / 0.392
payloadENGINE_3_573[3] = pps / 0.392 -- Throttle_position_capped
txCan(1, ENGINE_3_23D_573, 0, payloadENGINE_3_573)
end
payloadENGINE_7_563 = {0x79, 0xa2, 0x00, 0x18, 0x0e, 0x00, 0x00, 0x01}
function sendENGINE_7_233_563()
local RPMread = rpm / 3.125
local RPMhi = RPMread / 256
local RPMlo = RPMread
payloadENGINE_7_563[1] = cltGauge
payloadENGINE_7_563[4] = state_233
payloadENGINE_7_563[5] = RPMlo
payloadENGINE_7_563[8] = RPMhi
state_233 = rpm > 250 and 0x10 or 0x18
txCan(1, ENGINE_7_233_563, 0, payloadENGINE_7_563) -- transmit CLT and RPM for who knows whom
end
function sendENGINE_1_505()
if rpm > 250 then
if cltValue <= 80 then
txCan(1, ENGINE_1_1F9_505, 0, fanPayloadOff)
elseif cltValue < 85 then
-- send nothing
elseif cltValue < 90 then
txCan(1, ENGINE_1_1F9_505, 0, fanPayloadLo)
else
txCan(1, ENGINE_1_1F9_505, 0, fanPayloadHi)
end
else
txCan(1, ENGINE_1_1F9_505, 0, fanPayloadOff)
end
-- print('CLT temp' ..cltValue)
end
_10msPeriodTimer = Timer.new()
function onTick()
pps = getSensor("AcceleratorPedal") or 0
pps = (pps == nil and 0 or pps)
rpm = math.floor(getSensor("RPM") + 0.5)
cltValue = getSensor("CLT")
cltValue = (cltValue == nil and 0 or cltValue)
--print('ac out = ' ..globalAcOut)
if globalAcOut == 1 and rpmValue > 250 then
if globalAcOut == 1 and rpm > 250 then
fanPayloadOff = { 0x88, 0x00 }
fanPayloadLo = { 0x88, 0x00 }
fanPayloadHi = { 0x88, 0x00 }
@ -2377,47 +2423,23 @@ function onTick()
fanPayloadHi = { 0x80, 0x00 }
end
cltGauge = 0x00
-- clt gauge stuff
if cltValue < 115 then
cltGauge = math.floor(cltValue * 1.5 + 0.5)
else
cltGauge = 0xF0
end
-- print('clt gauge = '..cltGauge)
-- rpm fun stuff
PPS256 = PPS * 256 / 100
if t : getElapsedSeconds() < 2 then
CLTandRPM_D = { 0x00, PPS256, 0x0C, 0x01, 0x0A, 0x87, 0xFF, 0xFF }
else
CLTandRPM_D = { 0x00, PPS256, 0x0c, RPMlo, RPMhi, 0x87, 0xFF, cltGauge }
if _10msPeriodTimer : getElapsedSeconds() > 0.01 then
_10msPeriodTimer : reset()
sendENGINE_1_505()
sendENGINE_7_233_563()
sendENGINE_3_573()
end
state_233 = rpmValue > 250 and 0x10 or 0x18
CLTandRPM_3 = { cltGauge, 0x8C, 0x20, state_233, RPMlo, 0x00, 0x00, RPMhi }
txCan(1, OUT_233, 0, CLTandRPM_3) -- transmit CLT and RPM for who knows whom
txCan(1, OUT_23D, 0, CLTandRPM_D) -- transmit CLT and RPM for gauge cluster
if rpmValue > 250 then
setPwmDuty(HEATER_OUTOUT_INDEX, 1)
if cltValue <= 80 then
txCan(1, OUT_1F9, 0, fanPayloadOff)
elseif cltValue < 85 then
-- send nothing
elseif cltValue < 90 then
txCan(1, OUT_1F9, 0, fanPayloadLo)
else
txCan(1, OUT_1F9, 0, fanPayloadHi)
end
else
setPwmDuty(HEATER_OUTOUT_INDEX, 0)
txCan(1, OUT_1F9, 0, fanPayloadOff)
end
-- print('CLT temp' ..cltValue)
end
function onCanRxAbs1(bus, id, dlc, data)