Hi, I want to control my exhaust cut-out valve.
I want it to open over 110kpa and close again 1 second after MAP goes under 100kpa.
Is there a way to do that? Do I need to use a LUA script?
General output
- AndreyB
- Site Admin
- Posts: 14347
- Joined: Wed Aug 28, 2013 1:28 am
- Location: Jersey City
- Github Username: rusefillc
- Slack: Andrey B
Re: General output
You have two options. general purpose PWM option would not have the one second delay.
To get the one second logic yes you would need a Lua script.
To get the one second logic yes you would need a Lua script.
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
Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute
Re: General output
So I've done my first LUA script and it works but not as I want.
Can someone please take a look and give me some feedback/pointer to make it simpler/better.
It's the curve thing that don't work as intended. I want to be able to set the on/off kpa and the delay time in Tunerstudio.
Can someone please take a look and give me some feedback/pointer to make it simpler/better.
It's the curve thing that don't work as intended. I want to be able to set the on/off kpa and the delay time in Tunerstudio.
Code: Select all
t = Timer.new()
startPwm(1, 100, 0)
res = 0 -- init res flag
val = 0 -- init val
on = 115 -- Turn on kpa
off = 110 -- Turn off kpa
curve1 = findCurveIndex("time") -- ????
function onTick()
kpa = getSensor("Map") -- get kpa
time = curve(curve1, kpa) -- get time from curve
if kpa > on then
res = 1 -- set res flag to 1
output = 1
setPwmDuty(1, 1) -- set PWM to 100%
end
if res > 0 and kpa < off then -- check flag and kpa
res = 0 -- set flag to 0
t : reset() -- reset timer
end
val = t : getElapsedSeconds()
if res < 1 and val < time then -- check flag and time
output = 1
setPwmDuty(1, 1) -- keep PWM at 100%
elseif
kpa < off then -- check kpa
output = 0
setPwmDuty(1, 0) -- set PWM to 0%
end
print(output .." " ..res .." " ..val)
end
- AndreyB
- Site Admin
- Posts: 14347
- Joined: Wed Aug 28, 2013 1:28 am
- Location: Jersey City
- Github Username: rusefillc
- Slack: Andrey B
Re: General output
you need a bunch of print statements that's really the primary way to debug Lua
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
Always looking for C/C++/Java/PHP developers! Please help us see https://rusefi.com/s/howtocontribute