Page 1 of 1

Digital inputs LUA

Posted: Tue May 16, 2023 2:59 pm
by SubaruLT
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
 

Re: Digital inputs LUA

Posted: Tue May 16, 2023 3:07 pm
by AndreyB
What board is this about?

Either way please find a much smaller script to reproduce the issue maybe just one input one test LED for output to begin with?

Re: Digital inputs LUA

Posted: Tue May 16, 2023 4:06 pm
by SubaruLT
Core8 board. The code is to control Subaru 4EAT auto transmission gear shifting. That's why I notice the problem. There is a simple code to test pins. Its script pin status on the rusEFI console. PS I am a beginner at scripting so I can't make fancy codes :roll:

Code: Select all

function onTick()
	print(' Pin status: ')
	print('status PF0: ' ..readPin("PF0"))
	print('status PF1 ' ..readPin("PF1"))
	print('status PC13 ' ..readPin("PC13"))
	print('status PE6 ' ..readPin("PE6"))
	print('status PF5 ' ..readPin("PF5"))
	print('status PF4 ' ..readPin("PF4"))
	print('status PF3 ' ..readPin("PF3"))
	print('status PF2 ' ..readPin("PF2"))

end

Re: Digital inputs LUA

Posted: Tue May 16, 2023 4:21 pm
by AndreyB
It's less important how fancy the script it's way more important to break up complex task into much smaller subtasks with clear objectives and clear results.

The script which just prints status of pins is a great step forward. Does that script behaves as expected on bench?

Re: Digital inputs LUA

Posted: Tue May 16, 2023 4:32 pm
by SubaruLT
Same problem as with full code. Only works when I select them in the A\C setting field and burn. But only until ECU gets a power cycle.

Re: Digital inputs LUA

Posted: Tue May 16, 2023 4:35 pm
by AndreyB
Poke into wires with a digital multimeter and figure out what does selecting as A/C means. I guess this initializes the pins with pull-up or something like that. Which means that you are in charge of having a pull-up of your own.

Re: Digital inputs LUA

Posted: Tue May 16, 2023 6:12 pm
by SubaruLT
4,7v all the time. When it's not working, and after AC burns when it starts to work.

Re: Digital inputs LUA

Posted: Tue May 16, 2023 7:26 pm
by SubaruLT
Update FW with no tune. All pins don't work. Only after burn in TS starts working and not only by AC. Launch settings help too. Only when I upload my old tune, those 3 of the inputs start working all the time. The rest of it is only after TS burn.