BrzTit / megapirateng

Automatically exported from code.google.com/p/megapirateng
0 stars 0 forks source link

Improving FRSKY Telemetry (Open9x - firmware) with MegapirateNG #36

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Trying to transmit the voltage and current via frsky telemetry to Turnigy 9x 
running Open9x
The voltage is transmitted, but in the wrong manner. The current shows zero all 
the time.

What is the expected output? What do you see instead?
11.1V goes in, the output on the display shows 58,8V and is jumping a lot.

What version of the MegaPirateNG are you using?
MegapirateNG 2.9r6

Please provide any additional information below.
I searched the source codes.
Megapirate does something like:

// Voltage (Ampere Sensor)
   void send_Voltage_ampere(void)
   {
         uint16_t Datas_Voltage_Amp_bp;
         uint16_t Datas_Voltage_Amp_ap;
         uint16_t Datas_Current;  

                                        float volts = battery_voltage1*2; //in 0.5v resolution
         Datas_Voltage_Amp_bp = volts;
         Datas_Voltage_Amp_ap = (volts-int(volts))*100;
         Datas_Current = current_amps1;

         sendDataHead(ID_Voltage_Amp_bp);
         write_FrSky16(Datas_Voltage_Amp_bp);
         sendDataHead(ID_Voltage_Amp_ap);
         write_FrSky16(Datas_Voltage_Amp_ap);  
         sendDataHead(ID_Current);
         write_FrSky16(Datas_Current);

   }

The open9x firmware calculates:

#if defined(FAS_BSS)
      frskyData.hub.vfas = (frskyData.hub.volts_bp * 10 + frskyData.hub.volts_ap);
#else
      //frskyData.hub.vfas = ((frskyData.hub.volts_bp * 100 + frskyData.hub.volts_ap * 10) * 21) / 110;
#endif

To correct the output on the Open9x the algorithm for the voltage transmission 
should be changed like this:

// Voltage (Ampere Sensor)
   void send_Voltage_ampere(void)
   {
         uint16_t Datas_Voltage_Amp_bp;
         uint16_t Datas_Voltage_Amp_ap;
         uint16_t Datas_Current;  

                                        float volts = battery_voltage1*11/21; //to convert the voltage in something the algorithm of Open9x understands, the resolution will be in 0,2V steps
         Datas_Voltage_Amp_bp = volts;
         Datas_Voltage_Amp_ap = (volts-int(volts))*10;
         Datas_Current = current_amps1 * 10; // times ten, to show the correct value on Open9x

         sendDataHead(ID_Voltage_Amp_bp);
         write_FrSky16(Datas_Voltage_Amp_bp);
         sendDataHead(ID_Voltage_Amp_ap);
         write_FrSky16(Datas_Voltage_Amp_ap);  
         sendDataHead(ID_Current);
         write_FrSky16(Datas_Current);

   }

I am going to try this now... Maybe you can give it a shot?

best regards

Original issue reported on code.google.com by hanno.dahlhaus on 10 Mar 2013 at 5:34

GoogleCodeExporter commented 8 years ago
Alright, I tried it and it works. I contacted the people from Open9x already. 
They say that they stick to the conventions of frsky and they use the protocol 
fpr the frsky sensor hub. This is a way to make this running really nice with 
the standard settings of open9x.

Original comment by hanno.dahlhaus on 10 Mar 2013 at 6:30

GoogleCodeExporter commented 8 years ago
I corresponded to the developers from Open9x again. It looks like there is a 
possibility of adding the megapirateng as additional sensor hub to the Open9x 
software. It depends on if there is still enough space in the eeprom left...

Original comment by hanno.dahlhaus on 13 Mar 2013 at 1:00