Hi all,
I just bought an FrSky Taranis for my quad copter and needed to get the Mavlink data up on the Taranis LCD telemetry display. So here is my solution using a Teensy3.1 as a converter between MavLink and the S.Port on FrSky X8R.
See attached file below...
Replies
Then set the remaining to 0.0. But then I get stuck again..
i managed to solve the problem. I commented the line:
analogReference(EXTERNAL);
since, on my Teensy2.0 board, the Aref pin is not connected to any voltage source, now I get correct cell readings. I will be testing it on my taranis+pixhawk setup later
ohh, this was my faulty, i also try my 3.3v resistor network on teensy2. but to get more accurate voltage for 6S, i use on teensy2 an 3.3V reference voltage connected to aref pin. sorry, i totally forgot this:(.
/g
wolke
no problem my friend :) I am really grateful for your code. this is really something useful :) thanks again
hi,
if you use the code from this directory "MavLink_FrSkySPort_Teensy2_and_ProMini" 10bit is used. "double LIPOCELL_1TO8[13] =" is an double array with 13 elements.
simple uncomment this two lines of code.
//#define USE_SINGLE_CELL_MONITOR
//#define USE_AP_VOLTAGE_BATTERY_FROM_SINGLE_CELL_MONITOR // use this only with
info:
teensy2 can measure 5V on adac. teensy3 only 3.3. the resistor network from my git repository is constructed for 3.3V. you must adapt the resistor values to work with 5V. else on 10bit analog resolution the precision to measure 0.01 volts at 4S is not given.
/g
wolke
edit,
my tip. kick the teensy2 and use an teensy3.1. this will work perfect together with this project and save you a lot of hassle.
construct your resistor network. if your board is Teensy 3.1, max output per divider is 3.3V. Aref pin of the Teensy should be connected to 3.3V too if your code will run with ANALOGREFERENCE(EXTERNAL). connect your lipo to the resistor network (based on the diagram). then on MavLink_FrSkySPort.ino, uncomment these:
debugSerial.begin(57600);
//#define USE_SINGLE_CELL_MONITOR
//#define USE_AP_VOLTAGE_BATTERY_FROM_SINGLE_CELL_MONITOR // use this only with
and these to display analog values:
for(int i = 0; i < MAXCELLS; i++){
debugSerial.print( aread[i]);
debugSerial.print( ", ");
}
debugSerial.print("cells in use: ");
debugSerial.print(cells_in_use);
debugSerial.print( ", ");
debugSerial.print(", sum ");
debugSerial.println(alllipocells);
if you did not connect the AREF pin to any voltage source, then put a comment on this line:
analogReference(EXTERNAL);
change this according to the lipo, 4 means 4s lipo:
#define MAXCELLS 4
upload the code, then open your serial monitor. You will get something like this:
653.00, 662.00, 626.00, 655.00, cells in use: 4, , sum 16365
note that the first 4 numbers will depend on your resistor network, these numbers corresponds to each cell (cell 1 to 4 for a 4s setup). also, you may notice that the values are quite low, it was my fault since I made a resistor network designed to produce at most 3.3V, i forgot that the teensy 2.0 works with 5V. But this should work. Max analog reading on a Teensy 2.0 is 1023 (10bit resolution). for a Teensy 3.1, resolution is higher, but resistor network output should be limited to 3.3V. Now, to determine the divider value, example for cell1, you have to measure the cell1 voltage using a voltmeter. on cell1. i measured 4.11V. to get the divider value:
value = 653 / 4.11 = 158.8807786
you will put this value on this code:
double LIPOCELL_1TO8[13] =
{
158.8807786,
80.95238095,
51.01708706,
40.02440513,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0
};
for cell2, assuming I measured 8.19V:
value = 662 / 8.19 = 80.8302808
You will insert this value to:
double LIPOCELL_1TO8[13] =
{
158.8807786,
80.8302808,
51.01708706,
40.02440513,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0
};
do the same for the remaining cells. for cells not used, just place 0.0
you can confirm if the cell voltage estimation is correct by uncommenting these lines:
debugSerial.print( cell[i]);
debugSerial.print( ", ");
then check upload it again and check on the serial monitor.
yeah, I have a teensy 3.1 coming but the shipping takes a while... for now I am stuck with 2.0 :)
yes I used that code. but upon uncommenting those lines, the teensy seems to fail to respond. it does not blink fast unlike before when the lines were commented. i tried with and without the balance plug connected to the resistor network. but to no avail.
my current resistor network is designed to output < 3.3V. but as you have said, it should be 5V. could it ve the reason why my setup is not working?
then if I comment the lines again, the teensy works as it should.
Thanks Jan. I set it up and it works perfectly. For those that are wondering a status of disarmed is shown displayed by blinking the current flight mode in the header bar. The flight mode turns solid as soon as the bird is armed. Same with the display of the GPS HDOP.