Dear all. Maybe someone with more LUA expertise can helpe me.
Getting Main Battery voltage telemetry via Spirit ESC integration is great, however if I have mixed heli settings with different cell counts from 3S to 6S, 8S and 12S, therefore absolute Battery value don't tell me to much during flight but I would rather get average cell voltage reported, like 3.6V. Having said, I started to look into LUA to get this solved. However I could not get any meaningful output. Using mixed Scripts, I took RBV1 which reports 22.91V as input, asked for numbers of cells (6) to calculate output, but get value like 0.2 not even close to expected 3.82V. Beside, if I use like a Stick as Input it works 100/6 = 16.7. What am I doing wrong here. Plan is to use this calculated average value as alarm trigger for announcement. Any help is appreciated, many thanks.
SCRIPTS/MIXES/avcell.lua
-- Calculating average cell voltage from Main battery -- -- by Adrian May 2020 -- This script will ask user for number of Main Battery cells -- based on reported Telemetry it calculates av. cell voltage -- Selection of Telemetrie Source and number of cells used local inputs = { {"Tele Source", SOURCE }, {"Number Cells", VALUE , 1, 14, 6 }} -- returning the average cell voltage local outputs = { "vcel" }
-- Calculating the average cell voltage local function run(voltage, cell) local avCel = voltage / cell return avCel end -- Return statement return { run=run, output=outputs, input=inputs }
_________________ Oxy4max SpiritPro + HW // SOXOS 550, SpiritPro, HW120A V4, 920KV // SOXOS 600, SpiritPro, HW160A, Pyro650 // SOXOS Strike7, SpiritPro, HW160A, Pyro750 // Skywing Spirit Aero // FrSky Horus X10S + Taranis X7 /
|