Mike Lua Questions

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
MikeStang
Posts: 10
Joined: Thu Jan 24, 2019 8:31 pm
Location: Firestone, CO

Mike Lua Questions

Post by MikeStang »

Figured I would start a thread about programming the Lua commands in my Race Capture Pro MK3. Bare with me I am learning... I have just started reading a book on Lua.

Info: RC Pro MK3 with X2 Shift light. Not an OBD2 car so all my inputs are wired into Analog. ShiftX2 is wired to the RJ45 connector using CAN1. I did update my App in my Windows computer to the newest release and updated the Firmware in the RC MK3 to the 2.15

All I want to verify at this time is the the X2 comes on. I copy and pasted the script for "Disco Demo Light". In the Scripting text there was only 1 line that says,

function onTick () end

Do I leave this or delete it?
1981 Mustang track car

ferg
Posts: 36
Joined: Mon Dec 03, 2018 7:56 pm
Location: Paso Robles, California
Contact:

Post by ferg »

That is a placeholder for code you want to execute. For example, you might be creating a channel with data from another channel. So you would read the channels, do the math, and write the new channel each Tick event.

Generally to make something happen more than once, there will need to be code within that function.
David Ferguson
Veracity Racing Data
Autosport Labs Preferred Dealer
https://veracitydata.com

MikeStang
Posts: 10
Joined: Thu Jan 24, 2019 8:31 pm
Location: Firestone, CO

Post by MikeStang »

I'm so new I don't even understand the previous comment.

Regardless.... The X2 does not do anything... not even sure where to go from here. I can double check my wiring just to be sure (already checked several times before install)

Update: So I missed that the RJ45 port does not actually supply a power, even though in pic of the port it says 12v. I was able to get the lights to turn on a run the test pattern with help from Kyle at Sector Purple racing (Race Capture Dealer)

So Ill get back to this in the morn, got to re-route B+
1981 Mustang track car

MikeStang
Posts: 10
Joined: Thu Jan 24, 2019 8:31 pm
Location: Firestone, CO

Post by MikeStang »

OK, Shift X2 now has power. It goes through a light sequence on power up, Red Green Blue run back and fourth, it does this with nothing in the "Scripting" section. If I copy and paste the "disco light" test as is says in the set up instruction, it does not do anything different. I changed it to CAN2 because it says that what all the default script is set to...



Is there a tests I can run to see iof the RC "sees" the X2 on the CAN2 line?
1981 Mustang track car

MikeStang
Posts: 10
Joined: Thu Jan 24, 2019 8:31 pm
Location: Firestone, CO

Post by MikeStang »

CAN Bus Channel 2 Baud rate set to 500k from 250k, now X2 shift lights work.

So much info, such scattered placement...

Finally can start learning Scripting now that it is connected. Its odd that sometimes I write a script change and it does not take? I guess I will stumble through it.
1981 Mustang track car

BigLobsterDude
Posts: 17
Joined: Sun Dec 27, 2015 12:55 am
Location: Freehold, NJ

Post by BigLobsterDude »

A few hints

1. Make sure you always write the configuration to your RCP after making any script changes.

2. Turn on the "poll log" checkbox. Note in the log window whether your script loaded properly. It you have a syntax error your script, you'll see it report a problem that generally identifies the approximate line number in your script with the problem.

3. There are buttons in the scripting page that force a restart of the script (and clear the log window). These can make the startup issues more obvious is your missed the log feedback when the script first starts.

(Sorry I don't have the RCP handy to verify the exact button names in the RCP app. I think the buttons are "run" and "clear" but I may be incorrect.)

Hope that helps

John
Schumacher Taxi # 189

MikeStang
Posts: 10
Joined: Thu Jan 24, 2019 8:31 pm
Location: Firestone, CO

Post by MikeStang »

Yup, I see the Write Tab and know to do that. I have saved files and send to my RC dealer for some assistance. I used Poll Log, but when the Baud Rate was wrong i was not able to see the issue in the Poll Log. Yes, there is a Clear and RUN tab. This is all new to me. I loaded the test Script that is on the website and it kind of works, not as I suspect it should from reading the script. Dealer was sending me different Script to try and they were not acting as he thought they would either, he was suspect of a firmware issue??? Ill just keep poking away as I always do. fourms seem pretty dead. Ill post what I learn, maybe it will help someone out one day.
BigLobsterDude wrote:A few hints

1. Make sure you always write the configuration to your RCP after making any script changes.

2. Turn on the "poll log" checkbox. Note in the log window whether your script loaded properly. It you have a syntax error your script, you'll see it report a problem that generally identifies the approximate line number in your script with the problem.

3. There are buttons in the scripting page that force a restart of the script (and clear the log window). These can make the startup issues more obvious is your missed the log feedback when the script first starts.

(Sorry I don't have the RCP handy to verify the exact button names in the RCP app. I think the buttons are "run" and "clear" but I may be incorrect.)

Hope that helps

John
Schumacher Taxi # 189
1981 Mustang track car

BigLobsterDude
Posts: 17
Joined: Sun Dec 27, 2015 12:55 am
Location: Freehold, NJ

Post by BigLobsterDude »

MikeStang wrote:. I loaded the test Script that is on the website and it kind of works, not as I suspect it should from reading the script.

... Ill just keep poking away as I always do. fourms seem pretty dead. Ill post what I learn, maybe it will help someone out one day. ...
Sounds like you probably have it working. The "disco light" demo test script just randomly sets colors and turns the 9 the shift leds rapidly on and off -- nothing more. If they're flashing, it's working.

With the new 15.1 firmware you can also automatically load a script (without cut/paste) that gives a better demo of the shift light in action. In the scripting menu, click on the "Preset Button", click browse to download (from the internet) various predefined scripts, and scroll down see the various preset scripts, load it and write the configuration to the RCP. The "shift light in action" demo is about 1/2 down the list.

These scripts work for the X2 and X3 (but of course there's no 7 segment gear display.)

You can use these scripts as is or modify them (like setting shift points) as needed. Make small changes, verify each change is written and starts up correctly (watching the log) and keep backup versions of the scripts in a Notepad editor so you can keep track of things.

FYI - there is also a facebook "Autosport Labs Community" where support is being provided.

John
Schumacher Taxi #189

MikeStang
Posts: 10
Joined: Thu Jan 24, 2019 8:31 pm
Location: Firestone, CO

Post by MikeStang »

Thanks, good to know the X2 and X3 script will work together.

I was initially confused because on power up the lights run back and fourth and change color. I now know this is where there is no CAN communication

BigLobsterDude wrote:
MikeStang wrote:. I loaded the test Script that is on the website and it kind of works, not as I suspect it should from reading the script.

... Ill just keep poking away as I always do. fourms seem pretty dead. Ill post what I learn, maybe it will help someone out one day. ...
Sounds like you probably have it working. The "disco light" demo test script just randomly sets colors and turns the 9 the shift leds rapidly on and off -- nothing more. If they're flashing, it's working.

With the new 15.1 firmware you can also automatically load a script (without cut/paste) that gives a better demo of the shift light in action. In the scripting menu, click on the "Preset Button", click browse to download (from the internet) various predefined scripts, and scroll down see the various preset scripts, load it and write the configuration to the RCP. The "shift light in action" demo is about 1/2 down the list.

These scripts work for the X2 and X3 (but of course there's no 7 segment gear display.)

You can use these scripts as is or modify them (like setting shift points) as needed. Make small changes, verify each change is written and starts up correctly (watching the log) and keep backup versions of the scripts in a Notepad editor so you can keep track of things.

FYI - there is also a facebook "Autosport Labs Community" where support is being provided.

John
Schumacher Taxi #189
1981 Mustang track car

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

Post by brentp »

We have a very basic example of the standard ShiftX3 script also controlling a 2nd ShiftX on a different CAN address. Here's how you could do it:

https://gist.github.com/brentpicasso/eb ... 841cf24760
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Post Reply