Page 1 of 1

Lua script command to get battery voltage on RC Track?

Posted: Sat Apr 11, 2020 1:30 pm
by GTIspirit
What's the Lua script API command to get battery voltage on the RC Track? It's not mentioned here:
Analog Sensor Functions

Reason I'm asking is because it's off a bit compared to what my ECU and multimeter measure. So I want to output the battery voltage on CAN to measure and record together with my ECU internal variable for battery voltage. Then I can figure out the proper linearization for battery voltage in the RC Track.

P.S. no, it's not different because of different measurement points in the voltage bus. I've put the multimeter at exactly the point where the RC Track is connected, and the multimeter reads very close to what the ECU reads, and not same as what the RC Track measures.

Posted: Sat Apr 11, 2020 1:37 pm
by GTIspirit
Answered my own question by thinking, what channel might brentp use if the RC Track has no analog inputs. If the last analog is connected to battery, and the RC Track has no analog, maybe it's 0.

Confirmed with this Lua script code:

Code: Select all

println('Battery: ' ..getAnalog(0))
Hint, maybe the Wiki page could be updated. :idea:

Posted: Tue May 12, 2020 8:32 pm
by brentp
Thanks, we updated the wiki!