MaxRPM reset button
MaxRPM reset button
Could someone help me with some code to add to the MaxRPM code. i'd like to use a GPIO channel connected to ground or 5v (whichever's easiest) thru a momentary button that will reset the MaxRPM channel back to zero. like the memory button on a tach. heres my best guess below. thanks, Dave.
setTickRate(10)
maxRpmId = addChannel("MaxRPM", 10)
maxRpm = 0
-- Gpio(0) set to input mode
-- momemtary button connected to 5v
function onTick()
local rpm = getTimerRpm(0)
if rpm > maxRpm then
maxRpm = rpm
setChannel(maxRpmId, maxRpm)
if getGpio(0) = 1 then
setChannel(maxRpmId, 0)
end
end
setTickRate(10)
maxRpmId = addChannel("MaxRPM", 10)
maxRpm = 0
-- Gpio(0) set to input mode
-- momemtary button connected to 5v
function onTick()
local rpm = getTimerRpm(0)
if rpm > maxRpm then
maxRpm = rpm
setChannel(maxRpmId, maxRpm)
if getGpio(0) = 1 then
setChannel(maxRpmId, 0)
end
end
Well, that code failed, so i'm gonna try this next. my scripting abilities suck.
maxRpmId = addChannel("MaxRPM", 10)
maxRpm = 0
function rpmReset()
local rpm = getTimerRpm(0)
local clear = getGpio(0)
if rpm > maxRpm then
maxRpm = rpm
setChannel(maxRpmId, maxRpm)
end
if clear == 0 then
maxRpm = 0
setChannel(maxRpmId, maxRpm)
end
end
maxRpmId = addChannel("MaxRPM", 10)
maxRpm = 0
function rpmReset()
local rpm = getTimerRpm(0)
local clear = getGpio(0)
if rpm > maxRpm then
maxRpm = rpm
setChannel(maxRpmId, maxRpm)
end
if clear == 0 then
maxRpm = 0
setChannel(maxRpmId, maxRpm)
end
end
that fixed it. now the next problem. when its reset to zero, it wont display a maxrpm until it exceeds that last "maxrpm" value. like it has a memory that needs to be reset. heres the code im using. i have a potentiometer im using to simulate rpm during bench testing.
maxRpmId = addChannel("MaxRPM", 10, 2)
MaxRpm = 0
function rpmReset()
local rpm = getAnalog(6)
if rpm > MaxRpm then
MaxRpm = rpm
setChannel(maxRpmId, MaxRpm)
end
local clear = getGpio(0)
if getGpio(0) == 0 then
setChannel(maxRpmId, 0)
end
end
function onTick()
rpmReset()
end
maxRpmId = addChannel("MaxRPM", 10, 2)
MaxRpm = 0
function rpmReset()
local rpm = getAnalog(6)
if rpm > MaxRpm then
MaxRpm = rpm
setChannel(maxRpmId, MaxRpm)
end
local clear = getGpio(0)
if getGpio(0) == 0 then
setChannel(maxRpmId, 0)
end
end
function onTick()
rpmReset()
end
Great, sounds like you're on your way.
This is a cool use of Lua scripting we didn't originally consider, nice job.
Fyi, we just expanded the troubleshooting section here, might be helpful as you go forward:
https://wiki.autosportlabs.com/RaceCapt ... leshooting
This is a cool use of Lua scripting we didn't originally consider, nice job.
Fyi, we just expanded the troubleshooting section here, might be helpful as you go forward:
https://wiki.autosportlabs.com/RaceCapt ... leshooting
you got me thinking, so i went back to the original script you asked about. slapped it in and it works exactly as planned. when you push reset button, it zeros and instantly reads current value. i don't know how i did it but it works! small miracles. thanks for the support, you and your team rock. happy holidays. Dave in NY.
ill post a video in a few minutes, as well as the code referencing the timer channel for anyone else whom might like to reset maxrpm during a caution lap.
maxRpmId = addChannel("MaxRPM", 10, 2)
maxRpm = 0
function rpmReset()
local rpm = getAnalog(6)
local clear = getGpio(0)
if rpm > maxRpm then
maxRpm = rpm
setChannel(maxRpmId, maxRpm)
end
if clear == 0 then
maxRpm = 0
setChannel(maxRpmId, maxRpm)
end
end
function onTick()
rpmReset()
end
ill post a video in a few minutes, as well as the code referencing the timer channel for anyone else whom might like to reset maxrpm during a caution lap.
maxRpmId = addChannel("MaxRPM", 10, 2)
maxRpm = 0
function rpmReset()
local rpm = getAnalog(6)
local clear = getGpio(0)
if rpm > maxRpm then
maxRpm = rpm
setChannel(maxRpmId, maxRpm)
end
if clear == 0 then
maxRpm = 0
setChannel(maxRpmId, maxRpm)
end
end
function onTick()
rpmReset()
end
Heres a link to my youtube page with a short video of the Rpm Reset button code in action.
https://youtu.be/ernEa37stWs
Heres the code:
maxRpmId = addChannel("MaxRPM", 10)
maxRpm = 0
function rpmReset()
local rpm = getTimerRpm(0)
local clear = getGpio(0)
if rpm > maxRpm then
maxRpm = rpm
setChannel(maxRpmId, maxRpm)
end
if clear == 0 then
maxRpm = 0
setChannel(maxRpmId, maxRpm)
end
end
function onTick()
rpmReset()
end
notes: i had to add a 100K pulldown resistor across the GPIO(0) and 5v inputs.
https://youtu.be/ernEa37stWs
Heres the code:
maxRpmId = addChannel("MaxRPM", 10)
maxRpm = 0
function rpmReset()
local rpm = getTimerRpm(0)
local clear = getGpio(0)
if rpm > maxRpm then
maxRpm = rpm
setChannel(maxRpmId, maxRpm)
end
if clear == 0 then
maxRpm = 0
setChannel(maxRpmId, maxRpm)
end
end
function onTick()
rpmReset()
end
notes: i had to add a 100K pulldown resistor across the GPIO(0) and 5v inputs.