RegisterSearchFAQMemberlistUsergroupsLog in
Reply to topic Page 1 of 1
Lua script for shift-x crashing my RCP
Author Message
Reply with quote
Post Lua script for shift-x crashing my RCP 
I've been crashing Analyzer and bricking the hardware trying to script the shift light. I was trying to run something like this (off the top of my head, not at my RCP now):

Code:

setTickRate(15)

r=0
function onTick()
   r=r+500
        if(r>7000) then
          r = 0
        end
   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


Is there something I can do to debug what's going wrong? I was able to have the lights blink by incrementing variable r in onTick and setting each GPIO port with modulus %2,%3,%4 to make each segment blink at different rates.

I am using latest analyzer 1.1.5 and firmware 1.2.7.

View user's profile Send private message
Reply with quote
Post  
According to this blog post there is a println function that should allow you to debug.
http://www.autosportlabs.com/racecapturepro-updates-firmware-software-lua-scripting-examples/

I haven't had a chance to give it a try yet though.

View user's profile Send private message
Reply with quote
Post Re: Lua script for shift-x crashing my RCP 
SaabPower wrote:
I've been crashing Analyzer and bricking the hardware trying to script the shift light. I was trying to run something like this (off the top of my head, not at my RCP now):

Code:

setTickRate(15)

r=0
function onTick()
   r=r+500
        if(r>7000) then
          r = 0
        end
   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


Is there something I can do to debug what's going wrong? I was able to have the lights blink by incrementing variable r in onTick and setting each GPIO port with modulus %2,%3,%4 to make each segment blink at different rates.

I am using latest analyzer 1.1.5 and firmware 1.2.7.


Idea This sounds similar to what I had in mind for my ShiftX. As the limit is approaching the light should blink faster and faster, then when the limit is reached the light should stay on solid and the next one should start blinking, etc. So in your example above, the first light would start blinking slowly at say 4000rpm, and start blinking faster as engine speed gets nearer 5000rpm. Then when engine speed is greater than 5000rpm that first light would be solid, and the second light would start blinking slowly, and the blink rate would increase as engine speed approaches 6000, above which it would stay on solid, and so on.

I'm not a SW engineer so coding myself isn't so comfortable, but I'm familiar with the concepts. I guess the implementation would be such that the difference between current engine speed and threshold to next light would be the off time multiplied by a scalar. So for a big difference the off time would be larger, and then as the difference approaches zero the light is essentially on constantly (no off time).

View user's profile Send private message
Reply with quote
Post  
We just released a firmware version 1.2.8 that should help with lua scripting stability. Please download / install and try it out, and make sure you're using the latest version of RaceAnalyzer (1.1.15 as of this writing)

Also, we've worked in the ability to have the firmware recover in case a bad script causes RCP to hang - it's in the new v2.0 firmware that's in progress. V2.0 is a major update and won't work with the current version of Race Analyzer, note.

Let us know how the v1.2.8 firmware works!


_________________
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter
View user's profile Send private message Send e-mail
Reply with quote
Post  
It seems like anytime I touch the RUN button in the scripting section of race analyzer, it crashes my RCP and it no longer show in device manager under Ports (COM..) .

I have to redo using flashRCP.bat

I am on v1.1.15 and FW 1.2.8

View user's profile Send private message
Reply with quote
Post  
The V2 firmware makes improvements in this area, especially around recovering from lua script crashes. I believe we're targeting alpha release this weekend. Stand by...


_________________
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter
View user's profile Send private message Send e-mail
Reply with quote
Post  
quick post to bump this thread. got bored and played around with blinking lights.

video:
http://youtu.be/Y7ZwME-Fy5E


here is the Lua script used:

Code:
setTickRate(15)  --15hz

t = 0  --"ticker"

function onTick()
    t = t+1  --increment ticker
   local v = getAnalog(7)  --get voltage

   if v > 0 and t % 2 == 0 then setGpio(2,1) else setGpio(2,0) end   
     --flash every even Hz (7.5x per second)
   if v > 11 and t % 5 == 0 then setGpio(1,1) else setGpio(1,0) end
     --flash every 5th tick (3x per second)
   if v > 13 and t % 10 == 0 then setGpio(0,1) else setGpio(0,0) end
     --flash every 10th tick (1.5x per second)
 end


View user's profile Send private message
Reply with quote
Post  
Please try the script with the V2 firmware and let us know if you still have problems!


_________________
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter
View user's profile Send private message Send e-mail
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