Digital inputs LUA
Posted: Tue May 16, 2023 2:59 pm
Hello. Have a problem with the digital pin input on LUA. PC13, PF2-PF5 don't work. PF0, PF1, and PE6 work only with a few sec delay. But when I test all those pins on Tuner Studio in the AC setting field, they all work normally. And what's most strange, after testing they all start working in LUA with no delay like it should. But when I disconnect ECU and connected it again, it's all like in the beginning. Checking all on AC and all works in LUA again
Code: Select all
startPwm(0, 100, 0)
startPwm(1, 100, 0)
startPwm(2, 100, 0)
setTickRate(5) -- set tick rate to 1hz
function onTick()
TPS = getSensor("Tps1")
ger1 = readPin("PF0")
ger2 = readPin("PF1")
ger3 = readPin("PC13")
ger4 = readPin("PE6")
print('TPS: ' ..TPS)
print('gear1: ' ..ger1)
print('gear2 ' ..ger2)
print('gear3 ' ..ger3)
print('gear4 ' ..ger4)
print('status PF5 ' ..readPin("PF5"))
print('status PF4 ' ..readPin("PF4"))
print('status PF3 ' ..readPin("PF3"))
print('status PF2 ' ..readPin("PF2"))
if ger1 == 0 or ger4 == 0 then
setPwmDuty(1, 1.0)
else
setPwmDuty(1, 0.0)
end
if ger2 == 0 or ger4 == 0 then
setPwmDuty(2, 1.0)
else
setPwmDuty(2, 0.0)
end
if ger3 == 0 and TPS < 5 then
setPwmDuty(0, 1)
else
setPwmDuty(0, 0)
end
end