It is currently Sun 24. Nov 2024 16:00:36

All times are UTC + 1 hour





Post new topic Reply to topic  [ 5 posts ] 
  Print view Previous topic | Next topic 
Author Message
PostPosted: Mon 04. May 2020 21:47:56 
Offline

Joined: Thu 08. Oct 2015 14:43:12
Posts: 204
Location: Switzerland
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 /


Top
 Profile  
 
PostPosted: Tue 05. May 2020 15:09:59 
Offline

Joined: Thu 08. Oct 2015 14:43:12
Posts: 204
Location: Switzerland
Well, dived a bit more into it, I figured out that mixes are using 16-Bit signed integer doing division of 10.24 at the end to match 1024 to 100%.
return avCel * 10.24
Multiplying return by 10.24 gives correct value, however with mixes, I can't solve it, as there is also no decimal used. 3.4V eq. 3V

I'll investigate more, currently I'm thinking of using telemetry background function.
If someone has an idea or working script, let me know.

Thanks, Adrian

_________________
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 /


Top
 Profile  
 
PostPosted: Tue 05. May 2020 20:58:32 
Offline

Joined: Thu 08. Oct 2015 14:43:12
Posts: 204
Location: Switzerland
Finally I did manage it, by using a mixed Script with direct voice prompts to alert pilot.
This allows user to enter some parameters like cell count, telemetry source, voltage trigger level and alarm interval.

Load script onto SD Card SCRIPTS/MIXES
Enable it by adding it in the LUA Screen in your Transmitter.
There you should set parameters and see some values.
It requires telemetry to work.
Try like RxBt and Cellcount 1 to trigger alert, now select right source, like RB1V for me with HW ESC.

I did add some comments into the lua script to explain, feel free to use, play and change.

As *.lua extension is not allowed to upload, change it from .txt to .lua once downloaded.

Have fun, Adrian


Attachments:
CelLow.txt [1.95 KiB]
Downloaded 31 times

_________________
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 /


Last edited by Adrian on Wed 06. May 2020 1:23:10, edited 1 time in total.
Top
 Profile  
 
PostPosted: Tue 05. May 2020 23:17:51 
Offline

Joined: Thu 28. Aug 2014 17:01:01
Posts: 65
I don't know enough about LUA scripts to comment on yours I'm afraid, but I thought that you might like to know that there are other ways of doing this using Special Functions - I used this approach from Oscar Liang https://oscarliang.com/taranis-logical- ... age-alarm/ - it includes some clever ideas like setting a timer for the low voltage alarm so that it needs to be below a specific value for a certain time period - that way you don't get lots of warnings on power climbs where the extra draw might drop the voltage momentarily.

I use this on different helis with 3, 4 and 6 cell batteries and just change the trigger voltage level for different helis, this wouldn't work if you used different sized batteries on the same heli though..

I'm not saying that yours isn't a good approach, just showing an alternative..


Top
 Profile  
 
PostPosted: Wed 06. May 2020 1:40:07 
Offline

Joined: Thu 08. Oct 2015 14:43:12
Posts: 204
Location: Switzerland
Hi Mikej, your absolutely right, this was the way I did it and it worked great.
However I missed a clear statement on cell voltage. With different cell packs on different birds it was hard to tell how bad the level was without doing the mental arithmetic. That's why I came up with it, as cell voltages tells me more than pack voltage. I' absolutely with you. No need if you just wan't a low battery alarm.
I might think about implementing the delay as well, this is a great point you mentioned. Once ready and tested, I'll share. Thanks for your input.

_________________
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 /


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 47 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
skymiles_red v1.0.1 designed by Team -Programming forum-سيارات للبيع .