RegisterSearchFAQMemberlistUsergroupsLog in
Reply to topic Page 1 of 1
Shift X shift light
Author Message
Reply with quote
Post Shift X shift light 
Hello,

I am scripting first timer so please bare with me. We are trying to hook up the shift x light which uses three GPIO pins but we have had no success using the script provided in the example:

------
setTickRate(15)

function onTick()
local r = getTimerRpm(0)
if r > 5000 then setGpio(2,1) else setGpio(2,0) end
if r > 6000 then setGpio(1,1) else setGpio(1,0) end
if r > 7000 then setGpio(0,1) else setGpio(0,0) end
end
-------
We are using CAN bus off the megasquirt for all values, including RPM. Would this change the script?
FYI: the lights flash x1 when the ignition is turned on so we can confirm there is power going to the lights.

Thank you for the help.

PK

View user's profile Send private message Send e-mail AIM Address
Reply with quote
Post  
Anyone? Maybe I have posted in the wrong sub-forum.

Cheers,
PK

View user's profile Send private message Send e-mail AIM Address
Reply with quote
Post  
The function getTimerRpm(0) is your problem. This function would provide an RPM signal from a hardwired sensor connected to FrequencyIn 1.

You would need to get the value from your CAN mapped RPM channel into the lua scripting section.
For the following to work you may need FW 2.13.x to be able to use the command getChannel("xxxChannelNamexxx") and get the value from the matching channel name into the lua scritping section.

Try the following and please give some feedback how it works for you:

------
setTickRate(25)

function onTick()
local r = getChannel("RPM") --assuming RPM is the name you have choosen
if r ~= nil then
if r > 5000 then setGpio(2,1) else setGpio(2,0) end
if r > 6000 then setGpio(1,1) else setGpio(1,0) end
if r > 7000 then setGpio(0,1) else setGpio(0,0) end
end
end
-------

Regards,
Mike

View user's profile Send private message Visit poster's website
Reply with quote
Post  
I wrote a test script to make sure I had hooked my leds up right...

greenLed = 0
yellowLed = 1
redLed = 2

tick = 0
function onTick()
--println(tick)
if tick == 0 then
setGpio(greenLed,1)
elseif tick == 1 then
setGpio(yellowLed, 1)
elseif tick == 2 then
setGpio(redLed, 1)
else
tick = -1
setGpio(greenLed, 0)
setGpio(yellowLed, 0)
setGpio(redLed, 0)
end

tick = tick + 1
end

You can just plug a laptop into the usb port and run that script.

View user's profile Send private message
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum