Direct Frsky telemtry data from MW FC

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: Direct Frsky telemtry data from MW FC

Post by haydent »

just a little x8r update, its s.port (smart port) uses 57600 baud rate . also the sensor ids are different i believe. i posted here the id's requsted by the x8r: viewtopic.php?p=46710#p46710

also the "header" is "126" (0x7e)

ie code in this thread will not work with x8r

more: http://code.google.com/p/telemetry-conv ... rtProtocol

1eleven
Posts: 6
Joined: Mon Jun 03, 2013 7:17 pm

Re: Direct Frsky telemtry data from MW FC

Post by 1eleven »

Using the files that vpb posted, everything works until using vbat.
I am trying to send sensed voltage. VBAT is defined in Config.h. The following is commented out

Code: Select all

//#define FAS_100

When compiling, I get 'vbat' was not declared in this scope
I'm at a loss of where to look. I see that vbat is declared in types.h, so I added

Code: Select all

#include "types.h"
with no change.
I'm using the released version of MultiWii 2.3 from the downloads. Is there a different version of Telemetry or MultiWii files I should be using?

UPDATE - vbat is part of a typedef struct from types.h. Use "analog.vbat" and it now compiles.

Anyone know if A1 and A2 voltages can be manipulated through this code?

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: Direct Frsky telemtry data from MW FC

Post by QuadBow »

In my view, the Frsky telemetry integration is suffering from being excluded from the official release.
That leads to several Frsky implementations with small, but significant differences leading to the errors described.
The integration into the next offcial release would be the better solution - the code is stable enough.

Why has the Frsky telemetry not been taken into account by multiwii developers right now?

1eleven
Posts: 6
Joined: Mon Jun 03, 2013 7:17 pm

Re: Direct Frsky telemtry data from MW FC

Post by 1eleven »

If it made it into the main trunk, would everyone download Fryskytelemetry files with standard MultiWii downloads? If so, I can understand why people may not want it in the main distribution. If there were a separate branch or repository for just FrSky telemetry, that would be great.

I worked out most of the bugs in the latest post and even added a fuel bar functionality. For those interested, I'll share....
using vpb's post on Thu Nov 14, 2013 7:49 am, I changed "VBAT" to "analog.vbat" in order for the sketch to compile correctly. This is due to VBAT being part of a "typedef struct" definition in types.h named "analog".

Since it seems like A1 and A2 cannot be overridden, I want to get some sort of use of my fuel bar on my FLD-02 to indicate my battery pack capacity. The fuel bar only accepts values of 0, 25, 50, 75, and 100, so we need a little if, else if, else routine to indicate the battery capacity. Changing the send_Fuel_Level routine worked really nicely:

Code: Select all

   // Fuel level
   void send_Fuel_level(void)
   {
      uint16_t Datas_Fuel_level;

      Datas_Fuel_level = int((analog.vbat-136)*(100/32));
     
      if (Datas_Fuel_level > 75) {
   Datas_Fuel_level = 100; }
      else if ((Datas_Fuel_level <= 75) && (Datas_Fuel_level > 50)) {
   Datas_Fuel_level = 75; }
      else if ((Datas_Fuel_level <= 50) && (Datas_Fuel_level > 25)) {
   Datas_Fuel_level = 50; }
      else if ((Datas_Fuel_level <= 25) && (Datas_Fuel_level > 0)) {
   Datas_Fuel_level = 25; }
      else {Datas_Fuel_level = 0;}

      sendDataHead(ID_Fuel_level);
      write_FrSky16(Datas_Fuel_level);
   }


136 signifies 13.6 volts as empty. Knowing 4s is 16.8 at full charge, 168 - 136 = 32. We want that difference of 32 to scale over 100, so the formula becomes
Datas_Fuel_level = int((analog.vbat-136)*(100/32))
I'm not a programmer, but I figured if Datas_Fuel_level is an integer type, I better do the int() operation on that formula to be safe.

Took this up today and it worked great! The fuel bar finally gives me an indication of my electric "fuel".

Thanks to everyone that made this happen. It is really nice to have this data coming back natively from the FC.
The # Satellites and DFH on the 1st screen is an awesome mod.
**Disclaimer - I'm using a ReadyToFlyQuads Ez3 FC which is a Mega 2560. I'm not sure how many processor cycles this fuel bar mod takes, so I have no idea if this could adversely affect less powerful FCs.

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: Direct Frsky telemtry data from MW FC

Post by QuadBow »

Hi 1eleven,

I'm afraid your approach is a bit dangerous, since the characteristic curve of the accu is rather non-linear.
Thus, it doesn't give you a good feeling of the remnant energy.

Firstly, the Frsky devices like FLD-02 calculate the total amount of energy if a current sensor is attached.

If not, a better solution would be to make use of the powermeter since this estimates (powermeter soft) or calculates (powermeter hard) the energy which is a better indication for the "fuel" status.

1eleven
Posts: 6
Joined: Mon Jun 03, 2013 7:17 pm

Re: Direct Frsky telemtry data from MW FC

Post by 1eleven »

I learn something new every day. I had no idea this feature existed. Grasshopper now has more research to do. Thank you, Quadbow!

Quick question - the wiki says to set DIV values to 5000, but in 2.3, the values are way different. Also, I see these values changing all over the forum. Any insight into what values work?

From 2.3:

Code: Select all

  #define PLEVELDIVSOFT 100000
  #define PLEVELDIV 36000

scf
Posts: 6
Joined: Sat Oct 12, 2013 9:00 pm

Re: Direct Frsky telemtry data from MW FC

Post by scf »

Hey haydent!

Do you have some progress with telemetry via x8r smart port?

I've done some reading and if I understand right current implementation doesn't wait for start byte (probably not needed by old protocol) and just sends the telemetry data? Smart port implementation should only send it when the magic byte is received. Is adding that, changing the data ids, change the code to send 32 bits should be enough to make it work? Also after value the checksum byte should follow. Is this what check_FrSky_stuffing() does? How the sensor tells that there is no more data values available?

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: Direct Frsky telemtry data from MW FC

Post by haydent »

hi scf, im going well with it but cant say much due to nda. not that im working on what this thread is mainly about anyway.

these links will help you hopefully:
https://code.google.com/p/telemetry-con ... rtProtocol
https://code.google.com/p/opentx/source ... _sport.cpp
http://projects.onomato.biz/projects/an ... rameFormat

scf
Posts: 6
Joined: Sat Oct 12, 2013 9:00 pm

Re: Direct Frsky telemtry data from MW FC

Post by scf »

haydent wrote:hi scf, im going well with it but cant say much due to nda. not that im working on what this thread is mainly about anyway.

these links will help you hopefully:
https://code.google.com/p/telemetry-con ... rtProtocol
https://code.google.com/p/opentx/source ... _sport.cpp
http://projects.onomato.biz/projects/an ... rameFormat


Thanks haydent! I've seen first two links but the last one is new for me.

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: Direct Frsky telemtry data from MW FC

Post by haydent »

i overlooked the second one thinking it was not compatible with arduino, but you can literally copy paste the code into arduino as its all C

scf
Posts: 6
Joined: Sat Oct 12, 2013 9:00 pm

Re: Direct Frsky telemtry data from MW FC

Post by scf »

I should receive my taranis tomorrow - will have some coding try/trial session :)

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: Direct Frsky telemtry data from MW FC

Post by haydent »

also if you dont have a serial inverter yet, you can use the software serial library without one

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: Direct Frsky telemtry data from MW FC

Post by haydent »

also theres this
Frame Protocol of FrSky Telemetry Hub System (V2.0)
[removed]
Last edited by haydent on Mon Feb 17, 2014 11:12 pm, edited 1 time in total.

scf
Posts: 6
Joined: Sat Oct 12, 2013 9:00 pm

Re: Direct Frsky telemtry data from MW FC

Post by scf »

haydent wrote:also if you dont have a serial inverter yet, you can use the software serial library without one

I have one, use it with D8R-XP :)

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: Direct Frsky telemtry data from MW FC

Post by haydent »

cool, im not sure how compatible softwareserial is with multiwii, particularly sending, as that is blocking...

scf
Posts: 6
Joined: Sat Oct 12, 2013 9:00 pm

Re: Direct Frsky telemtry data from MW FC

Post by scf »

haydent wrote:also theres this
Frame Protocol of FrSky Telemetry Hub System (V2.0)
http://www.rcgroups.com/forums/attachme ... id=6266364

I guess this is old protocol?

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: Direct Frsky telemtry data from MW FC

Post by haydent »

yes sorry, removed. try this one attached
Attachments
FRSKY.pdf.zip
Two-way system protocol
(60.51 KiB) Downloaded 1419 times

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: Direct Frsky telemtry data from MW FC

Post by haydent »

though its not latest, as sport runs at higher speed and theres more too it, alot i looks more similar than the old protocol

Rangarid
Posts: 6
Joined: Thu Jul 28, 2011 6:45 pm

Re: Direct Frsky telemtry data from MW FC

Post by Rangarid »

vpb wrote:As Multiwii 2.3 is completely changed in code structure, Frsky Telemetry cant work with MW 2.3 (it can work with 2.2). I make some changes to the FrskyTelemetry.ino, now it turns into 2 files FrskyTelemetry.cpp & FrskyTelemetry.h. Those just need to be copied to MultiWii folder.

In MultiWii.cpp,
line 28, add this line

Code: Select all

#include "FrskyTelemetry.h"


line 556 (at the end of annexCode function) add those lines

Code: Select all

  #if defined(TELEMETRY_FRSKY)
     telemetry_frsky();
  #endif


In config.h, line 462

Code: Select all

  /******                Serial com speed    *********************************/
    #define TELEMETRY_FRSKY
 
    /* This is the speed of the serial interfaces */
    #define SERIAL0_COM_SPEED 115200
    #define SERIAL1_COM_SPEED 115200
    #define SERIAL2_COM_SPEED 115200
    //#define SERIAL3_COM_SPEED 115200
    #define SERIAL3_COM_SPEED 9600


I also made small changes that will send the distance-to-home & number of satellites in the temp1 & temp2 boxes.


I get ACC_1G missing and when i deselct FAS_100 i get vbat was not declared. Fixed this by including "Sensors.h" for ACC_G1 and vbat should be analog.vbat

Oh and BTW, you should use

Code: Select all

#if defined (FAS_100){
...
} #elif defined (VBAT)
...
}

Instead of just else. if you dont use the FAS_100 it does not mean you have VBAT declared.

Rangarid
Posts: 6
Joined: Thu Jul 28, 2011 6:45 pm

Re: Direct Frsky telemtry data from MW FC

Post by Rangarid »

Tested it today. Works great:
IMG_20140310_203418.jpg

IMG_20140310_203628.jpg


Here are my settings:

Pro Mini TX <-> RX Frsky Receiver
GPS TX <-> RX Pro Mini

You need a small RS232<->TTL converter. Costs about 2$ from china on ebay.

Settings in Multiwii:
#define GPS_PROMINI_SERIAL
#define GPS_BAUD 9600
#define NMEA

#define TELEMETRY_FRSKY

In FrskyTelemetry.cpp
// Serial config datas
#define TELEMETRY_FRSKY_SERIAL 1

szakacs
Posts: 18
Joined: Wed Dec 11, 2013 11:53 pm
Location: Sydney, NSW Australia

Re: Direct Frsky telemtry data from MW FC

Post by szakacs »

I am just getting into this C++ so please bare with me.
I am wishing to extract the time from the GPS nmea. In the current MW 2.3 is there a variable I can get a source from i.e. in GPS.cpp ??

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: Direct Frsky telemtry data from MW FC

Post by QuadBow »

szakacs wrote:I am wishing to extract the time from the GPS nmea

No, that is not foreseen in the current implementation of MW.
However, it can be easily implemented by adding a line to gps.ino dealing with the time.
But, for what purpose do you need the UTC time? In my view it is better to have the time of arming available in order to estimate the remnant accu capacitv.

szakacs
Posts: 18
Joined: Wed Dec 11, 2013 11:53 pm
Location: Sydney, NSW Australia

Re: Direct Frsky telemtry data from MW FC

Post by szakacs »

QuadBow wrote:
szakacs wrote:I am wishing to extract the time from the GPS nmea

No, that is not foreseen in the current implementation of MW.
However, it can be easily implemented by adding a line to gps.ino dealing with the time.
But, for what purpose do you need the UTC time? In my view it is better to have the time of arming available in order to estimate the remnant accu capacitv.


Curiosity and learning curve ...
My Turnigy 9x is flashed with er9x, so it does a timing based a throttle use.
I have been playing with a FrSky FLD-02 Telemetry Display Screen and FrSky FSH-01 Telemetry Sensor Hub through a FrSky D8R-II PLUS and XJT module. I seen that the hub sends a utc time to the display and I was looking at doing the same using the MW FC as the source. I have been able to modify some of data to suit me. i.e. RPM -- instead of motor revolutions I display a stick value between min throttle and max throttle.
So any hints and pointers with the gps stuff would be appreciated ..

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: Direct Frsky telemtry data from MW FC

Post by QuadBow »

szakacs wrote:So any hints and pointers with the gps stuff would be appreciated ..

Assuming that you are using a gps device running NMEA code (#define NMEA in config.h and not UBLOX or MTK_BINARY) and that you got a mega based board (without an additional i2c_gps_nav module required) you can add one line in the two existing lines in gps.ino:

Code: Select all

      } else if (frame == FRAME_GGA) {
        if      (param == 1)                     {GPS_time = (uint32_t) grab_fields(string,0);}
        if      (param == 2)                     {GPS_coord[LAT] = GPS_coord_to_degrees(string);}

Firstly, you have to declare GPS_time as uint32_t.
Lastly, you have to calculate hours, minutes and seconds of local time out of it.

PS: the code has not been tested yet.

szakacs
Posts: 18
Joined: Wed Dec 11, 2013 11:53 pm
Location: Sydney, NSW Australia

Re: Direct Frsky telemtry data from MW FC

Post by szakacs »

Thank you for your time. It is appreciated.. Using your pointers I have been able to achieve what I was after.
I can now display either utc or local time on the FrSky FLD-02 Telemetry Display Screen.

wilco1967
Posts: 156
Joined: Thu Aug 18, 2011 6:04 pm
Location: Winterswijk, Netherlands

Re: Direct Frsky telemtry data from MW FC

Post by wilco1967 »

I finally got hold of a Taranis to replace my 9X

Taranis works exellent, but now I have some small issues with the Frsky telemetry from multiwii.

All was working fine with my old 9X running openTX.
Using the same receiver (D4R-II / D8R-II), the telemetry data is visible on the Taranis, however some of the values are odd...

For example, Alt seems to move alright, but often the value turns negative (approx minus 655 meters, with the copter on the ground, and after I reset the alt to 0 using reset telemetry).
Also Hdg rolls over to 65536 whenever the actual heading becomes negative (-1 .. -179).

Also Spd seems to have another unit.... I was getting km/h correctly on the 9X (with some correction factor in the Frsky telemetry to convert cm/s to knots, which is than shown as km/h, at least on 9X). With the Taranis, the Spd value I'm getting is a lot higher.... still have to investigate how much, but something like 2...3x...

Is there anything that needs to be done on the MW side, or is this purely a openTX issue?
Seems like there is a difference between openTX for 9X and Taranis...

Nothing was changed on the MW side.
I've tried the original firmware the Taranis arrived with (opentx-x9d-v1.1.02), as well as the most recent openTX (R2940), both having the same issue.

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: Direct Frsky telemtry data from MW FC

Post by haydent »

as ive pointed out in previous posts, taranis uses different telemetry code (hub vs hubless) and is not compatible with this mod currently

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: Direct Frsky telemtry data from MW FC

Post by haydent »

also in case it hasnt been pointed out, you can use this as an inverter: https://www.hobbyking.com/hobbyking/sto ... Cable.html
it does not convert the logic voltage level, but it still works
24523-main.jpg

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: Direct Frsky telemtry data from MW FC

Post by QuadBow »

haydent wrote:it does not convert the logic voltage level

It would be strange if this inverter did not convert the voltage level (Vcc <=> Gnd).
Otherwise it wouldn't happen to work...
Thus, it is most problably not only a cable, but a cable with integrated converter in the middle.

Quentin
Posts: 3
Joined: Wed Jan 01, 2014 12:54 pm
Location: Pessac, France

Re: Direct Frsky telemtry data from MW FC

Post by Quentin »

Hi everyone,

First, thanks for the work done here !

I've read as carefully as i could this thread, but still can't get the FrSky telemetry working.

I use QuadBow code. Telemetry is sent on serial 1.

I've a DIY QuadX 450, with MWii 2.2
- Crius AIOP v2
- AIOPIO extension board which, if i believe this schema, have an inverter for frsky telemetry
- a Voltage / current sensor (rctimer) plugged on A1 / A3 on AIOPIO
- GPS - ublox cn-06, on serial 2 (AIOPIO)
- a D8r-II plus receiver and it's mate transmitter on a 9xR
- a FLD-02 LCD beautifully taped on the 9xR

All sensors look ok in MWiiConfig (gps and Vol/Curr).
On the AIOPIO, the select jumper for FrSky telemetry is soldered, in order to link serial 1 and the telemetry output ( ground and Tx pins are plugged on D8R-II).

and... still nothing on the FLD-02. If I plug the Volt/Current sensor directly on the D8R-II, on A1/A2 pins, I've the results on the LCD.
I've measured variable signal on the AIOPIO telemetry output.

I'm not using Mwii 2.3 cause I can't keep the quad in air. After takeoff, the FC continuously lower the thrust signal on ESC.

Any suggestion ?

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: Direct Frsky telemtry data from MW FC

Post by QuadBow »

Hi Quentin,

Actually, it should run in this configuration.
Most problably it is just a simple mistake.

1. Have you set in config.h
#define SERIAL1_COM_SPEED 9600 ?
and
#define TELEMETRY_FRSKY ?
and
#define TELEMETRY_FRSKY_SERIAL 1 ?

2. Have you connected
- GND and VCC to the receiver's servo outputs (not to the side pins which are only for telemetry) ?
- the output of the extension board to the RX pin at the telemetry side ?

3. Have you soldered the jumper SJ4 at the extension board ?

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: Direct Frsky telemtry data from MW FC

Post by haydent »

QuadBow wrote:
haydent wrote:it does not convert the logic voltage level

It would be strange if this inverter did not convert the voltage level (Vcc <=> Gnd).
Otherwise it wouldn't happen to work...
Thus, it is most problably not only a cable, but a cable with integrated converter in the middle.


as i said, i have measured it and it does not, and i have also successfully used it both for sbus and x8r s.port communication with mega. here is a photo of its guts:

P1050328_Edit.JPG

P1050329_Edit.JPG

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: Direct Frsky telemtry data from MW FC

Post by QuadBow »

haydent wrote:i have measured it and it does not


Haydent,
The hardware you are presenting shows 2 direct connections betweeen the ground (black) and vcc cables (red).
Between the white signal cables is no direct connection, but a transistor acting as a converter.
Thus, it will convert/invert the voltage level...otherwise there were a malfunction.

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: Direct Frsky telemtry data from MW FC

Post by haydent »

ok well you put some doubt in my mind, so i will have to test it again

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: Direct Frsky telemtry data from MW FC

Post by haydent »

haydent wrote:ok well you put some doubt in my mind, so i will have to test it again


well i just hooked it up to my scope again and it measures 3.4v peak to peak

i would take a photo, but my camera couldnt focus on the lcd writing

so that seems to support my point :idea:

User avatar
Gartenflieger
Posts: 65
Joined: Sat Oct 01, 2011 10:07 pm
Location: Dortmund, Germany

Re: Direct Frsky telemtry data from MW FC

Post by Gartenflieger »

i'd guess an INVERTER will swap the low and high levels of the signal, whereas a LEVEL CONVERTER will shift the high level to a different voltage. Am I right ?

Gartenflieger

Quentin
Posts: 3
Joined: Wed Jan 01, 2014 12:54 pm
Location: Pessac, France

Re: Direct Frsky telemtry data from MW FC

Post by Quentin »

QuadBow wrote:Hi Quentin,

Actually, it should run in this configuration.
Most problably it is just a simple mistake.

1. Have you set in config.h
#define SERIAL1_COM_SPEED 9600 ?
and
#define TELEMETRY_FRSKY ?
and
#define TELEMETRY_FRSKY_SERIAL 1 ?

Yes
QuadBow wrote:2. Have you connected
- GND and VCC to the receiver's servo outputs (not to the side pins which are only for telemetry) ?
- the output of the extension board to the RX pin at the telemetry side ?

Yes
QuadBow wrote:3. Have you soldered the jumper SJ4 at the extension board ?

and yes

I've a steady 4.51 V on telemetry output (after the inverter) and a moving 3.9~4.3V on Tx (Serial 1, before the inverter). Besides, I'v just noticed that i've 4.51V on the +5V.
So Frsky out = +5v . Should i look around the SJ4 one more time ?

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: Direct Frsky telemtry data from MW FC

Post by QuadBow »

Hi Quentin,

Quentin wrote:Should i look around the SJ4 one more time ?

Yes, your measurements indicate that the signal does not reach the transistor in the upper right corner of the schematics.
So, the output signal is bent to +5V via the 1k-resistor and remains at +5V without input signal at the transistors basis.
The connecting element SJ4 could be the problem - or a bad soldering.

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: Direct Frsky telemtry data from MW FC

Post by haydent »

Gartenflieger wrote:i'd guess an INVERTER will swap the low and high levels of the signal, whereas a LEVEL CONVERTER will shift the high level to a different voltage. Am I right ?

Gartenflieger


a level converter will just convert the voltage
an inverter will just invert it

and a rs232 to ttl (which i believe you guys are using) does both

Abbe
Posts: 1
Joined: Sat Apr 05, 2014 7:13 am

Re: Direct Frsky telemtry data from MW FC

Post by Abbe »

Hi!

Going nuts trying to clarify some stuff here.

I got:

dji flamewheel f450

turnigy 9x diy dht with fld-02 screen coonected to pins on the module (original FW, waiting for my solderless board)

HK Multiwii 328p FC

d8r-II plus reciver

Edit: when binded i get readings in page 1 the two top squares show voltage. but thats it no arm time or anything else


What if any readings can i get to the fld with this setup? soft serial?

I want to know step by step what to do and connect?

What code do i have to edit in arduino?

The setup now so far works i conected everything but nothing done or connected between the a1/a2 sideports except the jumper.


(I do not want telemetry on the built in screen)


Last thing if i want to by some sensors in the future wich should i get?

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: Direct Frsky telemtry data from MW FC

Post by QuadBow »

Hi Frsky telemetry users,

I just want to inform you that I have integrated the measurement of lipo cell voltages. This part has been titled "to be done" for a significant period of time.
To use this you have to use the multiwii telemetry (files telemetry.cpp/h) extension mentioned in this thread and to adapt it.
Since you have to use a free analog pin for each cell and some more flash memory, it will most problably run only on an ATmega2560-based board.

First you have to add/change the function send_cell_volts() in the file telemetry.cpp as follows.

Code: Select all

// Cell voltage (not longer to be done)
void inline send_cell_volt(void) // Data FrSky FLVS-01 voltage sensor
{
  uint16_t Data_Volt;
  static uint8_t cell_counter = 0;

  #if defined(VCELLS) // indeed this was not that easily to be found out...
      Data_Volt = (cell_voltage[cell_counter] << 8) + (cell_voltage[cell_counter] >> 8) + (cell_counter << 4);
  #endif
  if (++cell_counter >= CELLNUMBER)
    cell_counter = 0;
  sendDataHead(ID_Volt);
  write_FrSky16(Data_Volt);
}


You have to configure the functionality by following definitions in config.h:

Code: Select all

// voltage of cells
#define VCELLS              // activate measurement
#define CELLNUMBER       2 // current number of cells, maximum: 6 cells
#define CELL0PIN        A3 // analog pin for voltage of cell 0
#define CELL1PIN        A0 // analog pin for voltage of cell 1, same as for vbat in mycase
#define CELL0SCALE      10 // scale multiplied by 10 => 10 means scale 1:1
#define CELL1SCALE      31 // scale multiplied by 10 => 31 means scale 1:3.1

I got only a 2S-equipment, if you have 3 cells or even more (up to 6 are possible) you have to add CELL2PIN and CELL1SCALE due to your configuration.
Be aware that you can only attach the first cell (cell 0 in my counting) directly to the analog pin. The others require a voltage divider, the division ratio is described by CELLxSCALE.

Furthermore you have to define the cell voltages in multiwii.cpp:

Code: Select all

#if defined VCELLS
  uint16_t cell_voltage[CELLNUMBER];             // voltage of each cell in 0.1V steps
  uint8_t cell_pin[CELLNUMBER]   = {
  CELL0PIN,
  #if CELLNUMBER > 1
    CELL1PIN,
  #endif
  #if CELLNUMBER > 2
    CELL2PIN,
  #endif
  #if CELLNUMBER > 3
    CELL3PIN,
  #endif
  #if CELLNUMBER > 4
    CELL4PIN,
  #endif
  #if CELLNUMBER > 5
    CELL5PIN
  #endif
  };
  uint8_t cell_scale[CELLNUMBER] = {
  CELL0SCALE,
  #if CELLNUMBER > 1
    CELL1SCALE,
  #endif
  #if CELLNUMBER > 2
    CELL2SCALE,
  #endif
  #if CELLNUMBER > 3
    CELL3SCALE,
  #endif
  #if CELLNUMBER > 4
    CELL4SCALE,
  #endif
  #if CELLNUMBER > 5
    CELL5SCALE
  #endif
  };
#endif


and to access them via the following entry in telemetry.h:

Code: Select all

extern uint16_t cell_voltage[];


Now, the most important item is to calculate the voltages in the function annexCode of the file multiwii.com.
The scheduler is extended from 3 to 4, so you have to search for the first both lines and to change the third one:

Code: Select all

// query at most one multiplexed analog channel per MWii cycle
  static uint8_t analogReader =0;
  switch (analogReader++%4) {

Then you have to add the following switch statement. Don't touch the definitions below.

Code: Select all

case 3:
  {
  static uint8_t analogSubReader = 0;
  static uint8_t SubCounter;
  SubCounter = (analogSubReader++ % (CELLNUMBER + 1));
  if (SubCounter != CELLNUMBER) {
    #if defined(VCELLS)
      #define VCELLS_SMOOTH 22
      static uint8_t cind[CELLNUMBER];
      static uint16_t cvvec[CELLNUMBER][VCELLS_SMOOTH], cvsum[CELLNUMBER];
      uint16_t cv = analogRead(cell_pin[SubCounter]);
      cvsum[SubCounter] += cv;
      cvsum[SubCounter] -= cvvec[SubCounter][cind[SubCounter]];
      cvvec[SubCounter][cind[SubCounter]++] = cv;
      cind[SubCounter] %= VCELLS_SMOOTH;
      cell_voltage[SubCounter] = ((cvsum[SubCounter] / 9) * cell_scale[SubCounter]) / 10;
      if (SubCounter > 0)
         cell_voltage[SubCounter] = cell_voltage[SubCounter] - cell_voltage[SubCounter-1];
      debug[SubCounter] = cell_voltage[SubCounter];
    #endif // VCELLS
    }      // end of if
   break;
   }       // case 3


Finally, the result can be displayed with the Frsky display FLD-02. I have only my 2 cell copter prepared with cell lipo telemetry.
Is there anybody being able to test the code even for more cells? (The issue might be the missing female adapter for the lipo, like it is used in the lipo balancers.)

Have fun!
Attachments
SDC10132.jpg

User avatar
haydent
Posts: 583
Joined: Sun Jun 17, 2012 1:35 am
Location: NSW, AU

Re: Direct Frsky telemtry data from MW FC

Post by haydent »

well done

Udeste
Posts: 6
Joined: Sat Feb 08, 2014 1:09 pm

Re: Direct Frsky telemtry data from MW FC

Post by Udeste »

QuadBow wrote:Is there anybody being able to test the code even for more cells? (The issue might be the missing female adapter for the lipo, like it is used in the lipo balancers.)

I can test it for 3 cell battery. But how can I calculate my voltage divider ratio to put in your code? :D

Quentin
Posts: 3
Joined: Wed Jan 01, 2014 12:54 pm
Location: Pessac, France

Re : Direct Frsky telemtry data from MW FC

Post by Quentin »

QuadBow wrote:The connecting element SJ4 could be the problem - or a bad soldering.


Hi,

The soldering was bad. I've now something moving between 3.4 and 3.45v, and still nothing correct on the fld-02.

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: Direct Frsky telemtry data from MW FC

Post by QuadBow »

Hi Udeste,

Thank you for your support.
Below I show you some examples for the voltage divider via resistors:

Code: Select all

#define CELL0SCALE      10 // scale multiplied by 10 => 10 means scale 1:1 => no resistors required (direct connection to first cell)
#define CELL1SCALE      20 // scale multiplied by 10 => 20 means scale 1:2 => R1=22k (to ground) and R2=22k (to second cell, up to 8.4V, requires scale of more than 1:1.7), scale = 22/(22 + 22) = 1:2
#define CELL2SCALE      31 // scale multiplied by 10 => 31 means scale 1:3.1 => R1=22k (to ground) and R2=47k (to third cell, up to 12.6V), requires scale of more than 1:2.6), scale = 22/(22+47) = 1:3.13

turismo05
Posts: 3
Joined: Mon Apr 14, 2014 8:43 am

Re: Direct Frsky telemtry data from MW FC

Post by turismo05 »

1eleven wrote:Can someone clarify exactly where this goes?
vpb wrote:line 556 (at the end of annexCode function) add those lines

Code: Select all

  #if defined(TELEMETRY_FRSKY)
     telemetry_frsky();
  #endif



Line 556 in my download of MW2.3 is

Code: Select all

  #if !defined(GPS_PROMINI)


Guessing that if this goes at the end of annexCode, then line 551 - 558 should be

Code: Select all

    #endif
  }
    #if defined(TELEMETRY_FRSKY)
     telemetry_frsky();
    #endif
}

void setup() {
[/quote

I'm having trouble getting this to work.

Does the above code go as shown?

I'm not getting any data on the serial port I have assigned to telemetry.

Thanks in advance.

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: Direct Frsky telemtry data from MW FC

Post by QuadBow »

Hi turismo05,

It also should run at the place you have proposed.
What about your hardware configuration - board, receiver, level shifter/inverter, etc?

turismo05
Posts: 3
Joined: Mon Apr 14, 2014 8:43 am

Re: Direct Frsky telemtry data from MW FC

Post by turismo05 »

QuadBow wrote:Hi turismo05,

It also should run at the place you have proposed.
What about your hardware configuration - board, receiver, level shifter/inverter, etc?


Hi Thanks for the reply

I'm using 'Multiwii and Megapirate AIO Flight Controller w/FTDI (ATmega 2560) V2.0'
https://www.hobbyking.com/hobbyking/sto ... duct=31138

with NEO-6M GPS Module
https://www.hobbyking.com/hobbyking/sto ... duct=31135

with tll/rs232 converter
https://www.hobbyking.com/hobbyking/sto ... rface.html


FrSky D4R-II 4ch 2.4Ghz ACCST Receiver (w/telemetry)

Mutliwii 2.3

I have gps on serial 3 and working
Bluetooth on serial 0 and working
Added the lines to multiwii.cpp and config.h
set telemetry to serial 2 and set serial 2 to 9600 in config.h

I'm not getting anything on serial 2 at all. I have even tried a ttl - usb adaptor on there and no activity.

does telemetry run all the time? I have tried arming as well and still no activity.

Many thanks

QuadBow
Posts: 532
Joined: Fri Jan 04, 2013 10:06 am

Re: Direct Frsky telemtry data from MW FC

Post by QuadBow »

@turismo05,

I guess you have the files telemetry.cpp/h in the same directory - otherwise the compiler would complain - and
you have defined TELEMETRY_FRSKY in config.h. You told that also you set serial 2 to 9600 baud with #define SERIAL2_COM_SPEED 9600 in config.h.

Under those conditions everything should work fine.
Maybe it is just a simple error.
Which devices are connected to the level converter?
Have you tried to change RX2/TX2?
What kind of telemetry display do you use - FLD-02?

turismo05
Posts: 3
Joined: Mon Apr 14, 2014 8:43 am

Re: Direct Frsky telemtry data from MW FC

Post by turismo05 »

QuadBow wrote:@turismo05,

I guess you have the files telemetry.cpp/h in the same directory - otherwise the compiler would complain - and
you have defined TELEMETRY_FRSKY in config.h. You told that also you set serial 2 to 9600 baud with #define SERIAL2_COM_SPEED 9600 in config.h.

Under those conditions everything should work fine.
Maybe it is just a simple error.
Which devices are connected to the level converter?
Have you tried to change RX2/TX2?
What kind of telemetry display do you use - FLD-02?


I've got it working. I never noticed the defined TELEMETRY FRSKY statement in config.h, I missed it thinking that bit was just setting com speed.

Thanks for pointing that out.

I also have a FAS100 connected into the RX of my Telemetry port on the multiwii but not getting any info from that. I'm not sure how complete that part of the code is as it says todo next to it. Not had much time to look at that but at least the other bit is working.

Thanks again Quadbow

Post Reply