Help Please - Numerous ShiftX2 Faults

Q&A For ShiftX2, RGB sequential shift light <a href="https://wiki.autosportlabs.com/ShiftX2">Installation and Operation Guide</a>
VPD
Posts: 36
Joined: Sat Aug 11, 2018 1:40 pm
Location: NC

Help Please - Numerous ShiftX2 Faults

Post by VPD »

Hello, can't seem to get ShiftX2 to behave correctly after numerous hours fiddling with it. I suspect it comes down to Lua script problems, but I'm not sure since what I'm trying is essentially a copy and paste sample script...nothing fancy.

Background:
-RC/Track Mk2
-1.14.6 Android app
-Use 2 different android devices, same result (side note Samsung S7, Android 8.0 RC app never closes properly, unrelated)
-2.13.5 firmware
-direct CAN mapped on channels 1 & 2 from car, works fine
-ShiftX2 on CAN 2 using RJ45 splitter
-Disco Light Demo script works fine, starts immediately on RC hardware power up (no app) as intended
-Install allows RC & ShiftX2 to power up before CAN buses are alive
-Struggled with this "bug" - still no feedback viewtopic.php?t=6082
-Portion of script works fine, see below

Faults:
-Won't start on RC hardware power up, only starts after opening app and hitting Run, or flashing a new write
-Once started, RPM linear graph, and RHS Alert 0 (Oil Temp) works fine. LHS Alert 1 will not start or update.
--------This is true no matter what channel I pull into Alert 1, and Water temp updates no problem in the Dashboard
--------If I go to CAN mapping and open the CAN channel edit dialog box for Water and then hit the check mark to close out the window (no edits made), then and only then will Alert 1 turn on and receive a single value. Alert 1 value will never update again until I pretend to edit the CAN mapping again.
-ShiftX2 button press only randomly will report in the log, sometimes 0.0 or 1.0, far from consistent

Other Info:
-on Write reports 16Kb memory used, seems high for small script. What is included in that memory value?
-Flashing a new write will often cause the Wifi connection to be killed and reports back "Port Closed," typically takes multiple tries to achieve successful write
-Using the Poll feature often creates hangs and generates various error messages, kills connection, etc.

Code: Select all

--&#91;&#91;RPM Shift, Water & Oil Alerts&#93;&#93;

sxCan=1
sxId=0
tickRate=30
sxBright, sxScale=0,51 --&#91;&#91;0 auto 1-100, 51 default 0-255&#93;&#93;

function sxOnUpdate&#40;&#41; --&#91;&#91;updates on tick&#93;&#93;
  sxUpdateLinearGraph&#40;getChannel&#40;"RPM"&#41;&#41;
  sxUpdateAlert&#40;0,getChannel&#40;"OilTemp"&#41;&#41; --&#91;&#91;rhs LED&#93;&#93;
  sxUpdateAlert&#40;1,getChannel&#40;"Water"&#41;&#41; --&#91;&#91;lhs LED&#93;&#93;
end

function sxOnInit&#40;&#41;
  --&#91;&#91;L->R, smooth linear, min, max range&#93;&#93;
  sxCfgLinearGraph&#40;0,0,0,7300&#41; 

  sxSetLinearThresh&#40;0,0,2000,0  ,255,0  ,0&#41; --&#91;&#91;green&#93;&#93;
  sxSetLinearThresh&#40;1,0,3500,255,255,0  ,0&#41; --&#91;&#91;yellow&#93;&#93;
  sxSetLinearThresh&#40;2,0,6000,255,0  ,0  ,0&#41; --&#91;&#91;red&#93;&#93;
  sxSetLinearThresh&#40;3,0,6500,255,255,255,10&#41; --&#91;&#91;white flash&#93;&#93;

  --&#91;&#91;config rhs LED, oil temp&#93;&#93;
  sxSetAlertThresh&#40;0,0,0  ,0  ,0  ,255,1&#41; --&#91;&#91;blue flash&#93;&#93;
  sxSetAlertThresh&#40;0,1,180,0  ,255,0  ,0&#41; --&#91;&#91;green&#93;&#93;
  sxSetAlertThresh&#40;0,2,210,255,255,0  ,0&#41; --&#91;&#91;yellow&#93;&#93;
  sxSetAlertThresh&#40;0,3,225,255,0  ,0  ,0&#41; --&#91;&#91;red&#93;&#93;
  sxSetAlertThresh&#40;0,4,240,255,0  ,0  ,10&#41; --&#91;&#91;red flash&#93;&#93;

  --&#91;&#91;config lhs LED, water temp&#93;&#93;
  sxSetAlertThresh&#40;1,0,0  ,0  ,0  ,255,1&#41; --&#91;&#91;blue flash&#93;&#93;
  sxSetAlertThresh&#40;1,1,160,0  ,255,0  ,0&#41; --&#91;&#91;green&#93;&#93;
  sxSetAlertThresh&#40;1,2,200,255,255,0  ,0&#41; --&#91;&#91;yellow&#93;&#93;
  sxSetAlertThresh&#40;1,3,210,255,0  ,0  ,0&#41; --&#91;&#91;red&#93;&#93;
  sxSetAlertThresh&#40;1,4,220,255,0  ,0  ,10&#41; --&#91;&#91;red flash&#93;&#93;
end

function sxOnBut&#40;b&#41; --&#91;&#91;button state change&#93;&#93;
  println&#40;'button&#58; ' ..b&#41;
end

--&#91;&#91;ShiftX2 functions&#93;&#93;

function sxSetLed&#40;i,l,r,g,b,f&#41;
  sxTx&#40;10,&#123;i,l,r,g,b,f&#125;&#41;
end

function sxSetLinearThresh&#40;id,s,th,r,g,b,f&#41;
  sxTx&#40;41,&#123;id,s,spl&#40;th&#41;,sph&#40;th&#41;,r,g,b,f&#125;&#41;
end

function sxSetAlertThresh&#40;id,tid,th,r,g,b,f&#41;
  sxTx&#40;21,&#123;id,tid,spl&#40;th&#41;,sph&#40;th&#41;,r,g,b,f&#125;&#41;
end

function setBaseConfig&#40;bright,scale&#41;
  sxTx&#40;3,&#123;bright,scale&#125;&#41;
end

function sxSetAlert&#40;id,r,g,b,f&#41;
  sxTx&#40;20,&#123;id,r,g,b,f&#125;&#41;
end

function sxUpdateAlert&#40;id,v&#41;
  if v~=nil then sxTx&#40;22,&#123;id,spl&#40;v&#41;,sph&#40;v&#41;&#125;&#41; end
end

function sxCfgLinearGraph&#40;rs,ls,lr,hr&#41; 
  sxTx&#40;40,&#123;rs,ls,spl&#40;lr&#41;,sph&#40;lr&#41;,spl&#40;hr&#41;,sph&#40;hr&#41;&#125;&#41;
end

function sxUpdateLinearGraph&#40;v&#41;
  if v ~= nil then sxTx&#40;42,&#123;spl&#40;v&#41;,sph&#40;v&#41;&#125;&#41; end
end

function sxInit&#40;&#41;
  println&#40;'config shiftX2'&#41;
  setBaseConfig&#40;sxBright,sxScale&#41;
  if sxOnInit~=nil then sxOnInit&#40;&#41; end
end

function sxChkCan&#40;&#41;
  id,ext,data=rxCAN&#40;sxCan,0&#41;
  if id==sxCanId then sxInit&#40;&#41; end
  if id==sxCanId+60 and sxOnBut~=nil then sxOnBut&#40;data&#91;1&#93;&#41; end
end

function sxProcess&#40;&#41;
  sxChkCan&#40;&#41;
  if sxOnUpdate~=nil then sxOnUpdate&#40;&#41; end
end

function sxTx&#40;offset, data&#41;
  txCAN&#40;sxCan, sxCanId + offset, 1, data&#41;
  sleep&#40;10&#41;
end

function spl&#40;v&#41; return bit.band&#40;v,0xFF&#41; end
function sph&#40;v&#41; return bit.rshift&#40;bit.band&#40;v,0xFF00&#41;,8&#41; end

function onTick&#40;&#41;
  sxProcess&#40;&#41;
  collectgarbage&#40;&#41;
end

sxCanId = 0xE3600 + &#40;256 * sxId&#41;
println&#40;'shiftX2 base id '..sxCanId&#41;

setTickRate&#40;tickRate&#41;
sxInit&#40;&#41;

VPD
Posts: 36
Joined: Sat Aug 11, 2018 1:40 pm
Location: NC

Post by VPD »

This morning I tried another test, I commented out the sxUpdateAlert for ID 0 (oil temp) and made no other changes.

--sxUpdateAlert(0,getChannel("OilTemp")) --[[rhs LED]]

Now ID 1 will run and update continuously whereas before it would do neither. It now seems something about the setup will not allow both Alert ID's to work simultaneously, but the issue is not specific to ID 1 as I previously thought. Either way, it still won't work until I Run the script from within the RC app.

Is anyone else running ShiftX2 from RC/Track Mk2 with both Alert ID's working?

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

Post by brentp »

Hi,

Thanks for the note. It looks like you might be running into some memory issues with your current script.

We have some good news; with the new 2.15.0 firmware we built for ShiftX3 support, we have now bundled built-in functions to support ShiftX3 -- which will also work with ShiftX2. This built-in support will reduce the memory footprint of your system.

You can see the current sample scripts for ShiftX3 here - note how small they are compared to the original scripts for ShiftX2.
https://wiki.autosportlabs.com/ShiftX3

We will be updating the sample scripts for ShiftX2 as well to reflect the improvements made in the firmware.

We are working on making these changes to the wiki and documentation and will follow up here when complete.

Also, the latest app improves the lua scripting window to make it easier to navigate and edit in a mobile environment; be sure download and update when you can.

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

VPD
Posts: 36
Joined: Sat Aug 11, 2018 1:40 pm
Location: NC

Post by VPD »

Hi Brent. As posted above I am using the 1.14.6 android app which is the latest version I see in Google Play Store. What app version are you referring to?

As for firmware, I see you just updated the downloads page to show 2.15.0 Track Mk2 now, I was wondering if this might be a firmware problem. I don't see a firmware update process for TC Track, do I follow the RC Pro firmware update process?

What features really eat into the memory Lua needs? Number of CAN channels directly mapped, etc.? Maybe I can reduce usage other ways.

VPD
Posts: 36
Joined: Sat Aug 11, 2018 1:40 pm
Location: NC

Post by VPD »

I updated to 2.15.0 firmware and I'm cautiously optimistic... that it mostly works. It still won't start the script on power up. It requires launching the app and hitting Run.

It took multiple flashes and multiple power cycles to get the new ShiftX3 based script (I removed all the gear related code) loaded and working. Strangely it would behave erratically in between each attempt, seemingly mixing portions of old and new script like the flash can't seem to purge the old. Polling the log kept reporting "event overrun" and despite the smaller script still reports 16K memory usage.

It's disconcerting the sample scripts advertised / lack of adequate memory supplied leads to so many problems.

2 Questions
1) What other features really consume the memory Lua needs? Number of CAN channels mapped, etc.? What else can I do to reduce memory?
2) With the new 2.15.0 firmware, is there missing code in the sample X3 script leading to failure to start on power up? How do I initialize it to fix this?

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

Post by brentp »

Hi, Can you post your current script that doesn't work? We can show you how to change it given the changes in the 2.15.0 firmware.

For 1) CAN channes do not affect Lua memory availability. 2) There's no missing code in the example, we've bundled many of the ShiftX2/3 support functions natively into the firmware.

While we look at your script, can you try the Demo script here with your ShiftX2? Be sure to first erase any script you might have before copy/pasting the script in.

https://wiki.autosportlabs.com/ShiftX3# ... ights_Demo

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

VPD
Posts: 36
Joined: Sat Aug 11, 2018 1:40 pm
Location: NC

Post by VPD »

Below is my script. Its a direct copy paste from the X3 product page. Only mods are delete gear code and change channel names/values to match mine. I use TPS_Pedal to test RPM shift light behavior. Through all this the linear graph has worked pretty well the whole time, just the alert lights and script start on power up remain goofy.

I always delete the full script before pasting a new one, I've even tried flashing a blank script window in between new scripts - doesn't make a difference.

I downloaded and flashed the X3 disco demo script and it worked just fine, even starts immediately on power up. This is the same result I had with the X2 disco demo too, it worked 100% as intended on the old firmware.

When a non disco demo script is flashed, the X2 light behavior reverts back to its initial behavior as if only power and ground are connected (the linear graph sweeps back and forth and the alerts flash in unison as it steps through the colors), this is true whether the CAN bus is alive or not. Hit Run and that stops and the script starts. Makes me think it doesn't even know the script is there.

Last, I noticed in the poll log tonight during start up it says something like "[OBD] Init Current Values." Is it defaulting to expecting OBD data instead of knowing I am using direct CAN mapping instead on power up? Might that explain some of it? Disco demo is not dependent on data so incorrect source wouldn't matter.

Code: Select all

setTickRate&#40;30&#41;

-- Set ShiftX3 configuration parameters with default parameters
-- orientation&#58; 0=normal, 1=inverted &#40;display above LED bar&#41;
-- brightness&#58; 0-100%, 0 = auto brightness
-- can bus&#58; 0=CAN1, 1=CAN2
sxSetConfig&#40;0,0,1&#41;

--config shift light
sxCfgLinearGraph&#40;0,0,0,100&#41; --left to right graph, smooth style, 0 - 7000 RPM range

sxSetLinearThresh&#40;0,0,30,0,255,0,0&#41; --green
sxSetLinearThresh&#40;1,0,50,255,255,0,0&#41; --yellow
sxSetLinearThresh&#40;2,0,60,255,0,0,0&#41; --red
sxSetLinearThresh&#40;3,0,65,255,255,255,10&#41; --whiteflash


--configure first alert &#40;right LED&#41; as engine temperature &#40;F&#41;
sxSetAlertThresh&#40;1,0,40,255,255,0,0&#41; --yellow warning at 205F
sxSetAlertThresh&#40;1,1,60,255,0,0,10&#41; -- red flash at 225F

--configure second alert &#40;left LED&#41; as oil pressure &#40;PSI&#41;
sxSetAlertThresh&#40;0,0,40,255,0,0,10&#41; --red flash below 15 psi
sxSetAlertThresh&#40;0,1,60,255,255,0,5&#41; --yellow flash 15-20 PSI

function onTick&#40;&#41;
  --update RPM
  sxUpdateLinearGraph&#40;getChannel&#40;"TPS_Pedal"&#41;&#41;
  --update engine temp alert
  sxUpdateAlert&#40;1, getChannel&#40;"Water"&#41;&#41;
  --update oil pressure alert
  sxUpdateAlert&#40;0, getChannel&#40;"OilTemp"&#41;&#41;
end

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

Post by brentp »

Hi, Thanks for the reply.

When you say "just the alert lights and script start on power up remain goofy" what do you mean exactly by "goofy"?

Are you able to vary the value on the channel associated with the alert to test it's behavior? e.g. you can associate it with the TPS signal just to see what it's doing.

Also, can you describe your wiring? Is this testing on a bench or already installed in the car? how long is the cable and what kind of cable/wiring do you have connecting the two? We should rule out any electrical issues which might interfere with communications.

Also, the OBDII notes in the log do not affect ShiftX2's operation.
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

VPD
Posts: 36
Joined: Sat Aug 11, 2018 1:40 pm
Location: NC

Post by VPD »

I think I've answered the goofy questions above. Yes, once the script is working the linear graph and alert lights are correctly associated and values update. I've played around with it enough to be confident in that now. The new 2.15 firmware fixed this aspect as far as I can tell. This wasn't true on the old firmware, above you can read how the alert lights were temperamental using the old firmware. The multiple flashes and power cycles to get a new script working is still true though. Other users have documented this too on the forum.

I'm using RJ45 Cat cables and splitters per your wiring guide, and it's installed in the car. Cable length is 5' max. I've done all the basic electrical checks and combined with proper functioning lights once you Run the script, t's clear the wiring job is solid.

At this point I believe the focus should be only getting the script to run on power up so I don't have to launch it from the app each time. Fix that and I think we're good assuming your initial low memory diagnosis isn't lurking, I have plans to leverage Lua for more than this.

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

Post by brentp »

Thanks for the clarification.

When things are power cycled, are ShiftX2 and RCP powered on simultaneously, or are you powering them on separately, where one has power and the other does not?

Also, try this:

Set the app to poll the log (under the scripting window).

Then, power everything off, and then power everything back on simultaneously. Let the app poll the log upon startup. Do you see a script error?

If you see no script error, does the ShiftX2 ever fire up and start responding to the script, or does it always and forever just show the startup 'scanning'?

Also, so we can keep track of things, can you llink the forum URLs for the other cases ("Other users have documented this too on the forum. ")

Also, also, does the disco light demo exhibit the same problem - it won't startup correctly from a power on, (and you need to hit the 'run' button)?
Thanks,

VPD
Posts: 36
Joined: Sat Aug 11, 2018 1:40 pm
Location: NC

Post by VPD »

Everything is powered up simultaneously, the power for RC is shared with X2 by way of the RJ45 splitter.

I'll do the start poll log and power cycle test tomorrow and report back any errors.

With a "real" script loaded the X2 never fires up the script, the startup "scanning" continues for a while and eventually ends. Even after the scanning lights end there is no script response, it's just dead until I hit "Run"

I answered the disco light question above. It starts immediately on power up as intended. "I downloaded and flashed the X3 disco demo script and it worked just fine, even starts immediately on power up. This is the same result I had with the X2 disco demo too, it worked 100% as intended on the old firmware. " Because it does not depend on data but real scripts do, this feels like a clue.

Can you fully replicate my hardware, direct CAN mapping, and script setup and see what you get?

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

Post by brentp »

Got it.

Try this - add the following command right before sxSetConfig

sleep(500)

and see if that makes a difference.
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

VPD
Posts: 36
Joined: Sat Aug 11, 2018 1:40 pm
Location: NC

Post by VPD »

As requested I turned polling on and power cycled RC. While monitoring using the windows app over USB the only message returned at power up is:

[ShiftX] Received configuration message for base address: 931328

Then I tried adding the sleep(500) and power cycled again. Same message in the poll and no change in behavior except the "scanning" lights delayed starting, BUT only the first time. I power cycled again and the "scanning" lights never started, but neither did the script. I then changed the sleep timer to 2000 then 5000 and each time I also changed an LED color. The "scanning" lights never started and the script never did either, no matter the timer. After the script didn't run automatically, each I time I would then hit "run" manually and everything in the script worked. By changing an LED color each time, I could confirm the write flash worked each time.

When I hit "Run" manually this is the poll:

[lua] Gracefully stopping Lua Task
[lua] Destroying Lua State
[lua] Initializing Lua state
[lua] memory usage: 16KB
[lua] Starting Lua Task
[lua] Loading script. Length: 1126
[lua] Successfully loaded script.

So now what?

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

Post by brentp »

Thanks for the update.

Hm, I think to normalize the test conditions for your environment and ours, I will provide a test script that creates simulated channels within the script, instead of relying on sensor channels. This will provide a baseline for comparison and we can work from there. I should have something available tomorrow morning.

Thanks for working through this!
Brent Picasso
CEO and Founder, Autosport Labs
Facebook | Twitter

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

Post by brentp »

Hi, Here's a configuration that will exactly replicate what we have testing here.

This script creates 3 simulated channels that cycle up and down automatically.

See if this works reliably when you power cycle everything together.

Worth noting, when you are doing your power cycling test, make sure you're disconnected from USB, since your laptop will otherwise keep RCP powered up.
Attachments
shiftX2_3_test_script.rcp.zip
(3.68 KiB) Downloaded 211 times

Post Reply