Cannot get shift x to work

Discussion on the Lua Scripting capabilities for RaceCapture/Pro. Also see the <a href="http://autosportlabs.net/RaceCapturePro_Lua_Scripting">Lua Scripting Guide</a>

Moderators: JeffC, stieg

Post Reply
Ash-b-84
Posts: 14
Joined: Fri Aug 28, 2015 12:58 pm

Cannot get shift x to work

Post by Ash-b-84 »

Hi I have the mk1 I have set the gpio jumpers to out position
Set the digital in/out to outputs 10hz in race capture
Copied an pasted the pula script off the website but changed rpm values
But nothing happens to the lights on the shift x
My rpm is displayed on the rpm2 channel not rpm is there anything else I need to change as getting quite frustrated

Many thanks in advance

Ash-b-84
Posts: 14
Joined: Fri Aug 28, 2015 12:58 pm

Post by Ash-b-84 »

Also when 12v car power Is first turned on an the rcp gets power all the leds on the shift x light up at the same time for a second then go off but will not come on at any rpm

gizmodo
Posts: 138
Joined: Mon Aug 05, 2013 10:22 pm

Post by gizmodo »

Did you change the script so it is using your RPM input and not the test value?
function ctON(ul,ll)
--RPM=getTimerRpm(0) <-- Remove '--'
RPM=testRPM <-- Remove this line
factor = 0.5 * FREQ_HZ * (1 - (ul - RPM) / (ul - ll))
if factor >= 0.5 * FREQ_HZ then --can't blink faster than tickRate/2--
on_time = MAX_ON_TIME
elseif factor < 1 then --can't blink slower than max period--
on_time = 0
else
on_time = MAX_ON_TIME / factor
end
return on_time / loop_time
end

brentp
Site Admin
Posts: 6282
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

Hi Ash,

Can you post your lua script so we can review further?

Also, are you getting RPM from the RPM connection on RaceCapture/Pro?
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Ash-b-84
Posts: 14
Joined: Fri Aug 28, 2015 12:58 pm

Post by Ash-b-84 »

function onTick() end

setTickRate(15) --15Hz

--Shift Now!!!!
function onTick()
rpm=getTimerRpm(0) --read RPM

--activate LEDs
if rpm > 6600 then setGpio(2,1) else setGpio(2,0) end
if rpm > 6900 then setGpio(1,1) else setGpio(1,0) end
if rpm > 7200 then setGpio(0,1) else setGpio(0,0) end
end

that's what I have my rpm comes from rpm2 when I check the dashboard in racecapture

brentp
Site Admin
Posts: 6282
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

Hi,

The line:

rpm=getTimerRpm(0) --read RPM

means 'get RPM from the first timer input port'

0 = first port
1 = second port
2 = third port

When facing the terminal block, the right most port is 0, then 1 and two towards the middle.

If you have it hooked up to the 3rd port, then you'll have to make this line:

rpm=getTimerRpm(2) --read RPM


Also,

you have onTick() listed twice in the script. It should only be defined once.

Here's an updated script. Let us know if this works:



Code: Select all

setTickRate&#40;15&#41; --15Hz 

--Shift Now!!!! 
function onTick&#40;&#41; 
rpm=getTimerRpm&#40;2&#41; --read RPM 

--activate LEDs 
if rpm > 6600 then setGpio&#40;2,1&#41; else setGpio&#40;2,0&#41; end 
if rpm > 6900 then setGpio&#40;1,1&#41; else setGpio&#40;1,0&#41; end 
if rpm > 7200 then setGpio&#40;0,1&#41; else setGpio&#40;0,0&#41; end 
end 

Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Ash-b-84
Posts: 14
Joined: Fri Aug 28, 2015 12:58 pm

Post by Ash-b-84 »

Managed to get it workin now changed it to output (1) however at set rpm both the amber an green come on at the same time an also I'm still gettin spikes when revved where it will read over 40000rpm for a split second throwing the lights on etc seems more stable when rpm is raised slowly so maybe better under load

brentp
Site Admin
Posts: 6282
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

Hi,

Great - glad you got it working!
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Ash-b-84
Posts: 14
Joined: Fri Aug 28, 2015 12:58 pm

Post by Ash-b-84 »

Beet is there a way I can input a line to say for no more than 7200 rpm turn all LEDs off that way if it does spike higher it won't throw the lights on ?

brentp
Site Admin
Posts: 6282
Joined: Wed Jan 24, 2007 6:36 am

Post by brentp »

The best way is to actually filter the RPM signal at the source, but if that is not practical or possible then you can possibly apply a band-aid solution, like this:

Code: Select all

setTickRate&#40;15&#41; --15Hz 

--Shift Now!!!! 
function onTick&#40;&#41; 
rpm=getTimerRpm&#40;2&#41; --read RPM 

--activate LEDs 
if rpm > 15000 then return end --this filters out RPM spikes
if rpm > 6600 then setGpio&#40;2,1&#41; else setGpio&#40;2,0&#41; end 
if rpm > 6900 then setGpio&#40;1,1&#41; else setGpio&#40;1,0&#41; end 
if rpm > 7200 then setGpio&#40;0,1&#41; else setGpio&#40;0,0&#41; end 
end 
See if this makes a difference.

Post Reply