Problems accessing Data from Mega Squirt in LUA. Any advice

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
davef_dci
Posts: 39
Joined: Wed Mar 22, 2017 4:57 am

Problems accessing Data from Mega Squirt in LUA. Any advice

Post by davef_dci »

Three days to race and I’m battling some RaceCapture issues and could use some help.
Running Racecapture MK3 in a Neon that’s controlled with a Megasquirt. I am transferring data from the Megaquirt to Racecapture via canbus.

I have an android tablet in the car that is displaying gages including RPM, Engine temp, etc. and these are working perfectly - meaning I am successfully transferring data from the Megasquirt to race capture. The RPM Tachometer on the android seems to scroll smoothly and in synch with the engine.

However, when I try to access the date inside my LUA script I am getting glitches and sporatic results.

For example, the following very simple code will occasionally print correct RPMs but mostly just print 999's to the screen. Because it is occasionally correct I know that I'm accessing the data - but it's not reliable. I will go several minutes getting 999's - and then have every other value the correct RPM, followed by brief stints where the RPMs will be accurate.

Code: Select all

setTickRate&#40;10&#41;
function onTick&#40;&#41;
rpm = getChannel&#40;"RPM_ms"&#41;
if rpm == nil then rpm = 999 end
println &#40;" RPM=  " ..rpm&#41;
end
Again - to reiterate, the Racecapture dashboard gages are working flawlessly - so i know the data is getting from Megasquirt to Racecapture. But I'm really struggling to reliably access it using the Getchannel command.

Any ideas?

Thanks!!!!

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

Post by brentp »

I see you have also posted this to the facebook group, so we can continue helping there.

Thanks!
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

Canyonfive
Posts: 69
Joined: Mon Jan 29, 2018 11:20 pm

Re: Problems accessing Data from Mega Squirt in LUA. Any advice

Post by Canyonfive »

If anyone is in a similar issue, I like to use the Can Realtime Broadcasting instead, since you can better control the rate information is sent and have access to more channels.

The info from Megasquirt is here http://www.msextra.com/doc/pdf/Megasqui ... adcast.pdf
The base ID is 1520 and the list has group numbers, so 1520+group number = the ID. So if it says Group 10 then its 1520+10 = and ID of 1530.

for RPM's you would go in your Megasquirt to Can Realtime Broadcasting and turn on group 0 to whatever HZ you want, then map that channel over on your racecapture under can mapping.

ID = 1520
Offset = 6
Size = 2
Unsigned
Big-endian (All these are big endian)
Multiply Divide Add
1 1 0

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

Re: Problems accessing Data from Mega Squirt in LUA. Any advice

Post by brentp »

The new beta firmware resolves the issue with getChannel() returning nil. You can try it here:

https://discord.gg/JbKUyFw

See the rc-v2-beta-testing channel for how to get started.

Post Reply