Digital inputs LUA

Post Reply
SubaruLT
Posts: 35
Joined: Tue May 16, 2023 2:38 pm
Slack: SubaruLT

Digital inputs LUA

Post 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
 
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Digital inputs LUA

Post 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?
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
SubaruLT
Posts: 35
Joined: Tue May 16, 2023 2:38 pm
Slack: SubaruLT

Re: Digital inputs LUA

Post 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
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Digital inputs LUA

Post 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?
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
SubaruLT
Posts: 35
Joined: Tue May 16, 2023 2:38 pm
Slack: SubaruLT

Re: Digital inputs LUA

Post 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.
User avatar
AndreyB
Site Admin
Posts: 14292
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Github Username: rusefillc
Slack: Andrey B

Re: Digital inputs LUA

Post 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.
Very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions

Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
SubaruLT
Posts: 35
Joined: Tue May 16, 2023 2:38 pm
Slack: SubaruLT

Re: Digital inputs LUA

Post by SubaruLT »

4,7v all the time. When it's not working, and after AC burns when it starts to work.
SubaruLT
Posts: 35
Joined: Tue May 16, 2023 2:38 pm
Slack: SubaruLT

Re: Digital inputs LUA

Post 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.
Post Reply