Building a 50A sensor module for openXvario

Development & General Chat for the superb openxvario project.

Moderator: rainer

User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Building a 50A sensor module for openXvario

Post by jhsa »

But Mike too low of a resistance could increase the current on the analog pin? Specially in some special conditions when there is for example bad connection on a ground line somewhere. Or can we ignore that?

Kaos, if you use 6V you could connect it to the RAW input of your arduino and then power the current sensor from the arduino VCC. That would give you a more stable voltage specially if you are using bigger servos that take more current and therefore causing a bigger voltage drop. This depends of course if your arduino has a low dropout regulator.

Another idea, and I think this is the one I will start using, is to use the first 2 cells of the lipo to power the arduino/sensors assembly. This is then connected to the RAW input of the arduino of course. It will make the voltage very stable for your current sensor, giving you a much more stable reading.
The arduino and sensors don't use that much current so they won't unbalance your LiPo.

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Building a 50A sensor module for openXvario

Post by MikeB »

The analog pin is an input and very little current flows into it so you may use low value resistors OK.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Building a 50A sensor module for openXvario

Post by jhsa »

Ok, so the only problem would be the resistors loading the battery if their value was too low, which is not the case. Thanks Mike

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
kaos
Posts: 3247
Joined: Wed Dec 28, 2011 1:15 am
Country: United States

Re: Building a 50A sensor module for openXvario

Post by kaos »

Mike: Thx for the info/tutorial on the divider resistance. That makes things easier to understand. ;) so I can use either 1K/2.4K or 10K/24K, both are under 10K. mstrens suggested a 100nF cap when using 1k/2.4K, if using 10K/24K, the cap still helps or the value of cap needs to change as well?

Joao: as of now the arduino is power by BEC going to RAW, and the sensor is powered by Vcc. with a higher raw in there is some increase in Vcc as well, I have measured the Vcc with volt meter with 3 different raw input and all 3 gave 3 different Vcc which means when I change to a different model/BEC the Amp and mAh reading will not be perfectly correct. In one testing there is 0.4~0.5 A difference in Amp reading compared to my watt meter, just by varying the reference voltage from 4.64-4.98.

by the way, I found the Fuel% displayed on radio is not quit right. in config.h
#define SETUP_FRSKY_DATA_TO_SEND \
DEFAULTFIELD , ALTIMETER , 1 , 1 , 0 ,\
DEFAULTFIELD , VERTICAL_SPEED , 1 , 1 , 0 ,\
DEFAULTFIELD , CURRENTMA , 1, 1, 0 ,\
DEFAULTFIELD , MILLIAH, 1, 1, 0 ,\
Fuel, MILLIAH , -100, 2200, 100
for displaying a 2200 mah lipo, but you look at the display of 140 mah and 90% Fuel, that is not quite right. I don't understand where I was wrong. both Amp and Mah are matching my watt meter perfectly with the reference voltage I put in based on volt meter reading of Vcc on Arduino.
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Building a 50A sensor module for openXvario

Post by jhsa »

kaos wrote:Mike: Thx for the info/tutorial on the divider resistance. That makes things easier to understand. ;) so I can use either 1K/2.4K or 10K/24K, both are under 10K. mstrens suggested a 100nF cap when using 1k/2.4K, if using 10K/24K, the cap still helps or the value of cap needs to change as well?
Yes, I use a 100nF cap and the reading is stable.
Joao: as of now the arduino is power by BEC going to RAW, and the sensor is powered by Vcc. with a higher raw in there is some increase in Vcc as well, I have measured the Vcc with volt meter with 3 different raw input and all 3 gave 3 different Vcc which means when I change to a different model/BEC the Amp and mAh reading will not be perfectly correct. In one testing there is 0.4~0.5 A difference in Amp reading compared to my watt meter, just by varying the reference voltage from 4.64-4.98.
Exactly, that means that the 5V regulator on your arduino is working below it's minimum specifications. I would need to know which regulator is on your arduino so I could try to find the datasheet. But take this little example:
The 5V regulator 78L05 has a dropout voltage of around 2V (above the output voltage). That means that for a stable output of 5V it needs at least 7V at the input. If you feed it with 5V from a BEC the voltage will be much lower than 5V. If you feed it with 6V at the input (RAW pin) the voltage will be a bit higher than previously, but it will still be much lower than the 5V it should have at the output..
Then there is the problem of servos loading the BEC voltage. They will make the voltage drop even more when they move under load. So, if you can avoid it, the arduino should never be connected to the same power source as the servos. The BEC.
Try powering the arduino with the first 2 cells of your lipo. Connect it to the RAW pin. This is about 7.4V, and the regulator will regulate it to stable 5V. Sensors obviously connect to VCC.

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
kaos
Posts: 3247
Joined: Wed Dec 28, 2011 1:15 am
Country: United States

Re: Building a 50A sensor module for openXvario

Post by kaos »

OK, I will use a 100nF cap with the divider then. I found I only have 1K and 2.2K reistors. the 2.4k needs to combine 2.2+ two 0.2K and this would make the sensor side too bulky withe reagulor resistor. I will make (actually grind out) a small strip pcb to use smd resistor to keep the sensor small.
Good idea using the balance lead to power the oXs, I will check on that and if it work well I will make an adaptor connector for it.

any idea on the Fuel %?
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Building a 50A sensor module for openXvario

Post by mstrens »

As already answered, it should not make a significant difference between 1k/2.4k and 10k/24k.
There very little pros/cons
- con:
- the current that flows in the resistors is 10 X higher with the 1K/2.4k. This will contribute to discharge the battery. Still as this current will remain about 17/3.4 = 5 milliamp, it is still acceptable from my point of view.
- with 1k/2.4k, you need a higher capacitor value in order to get the same stablility for voltage on Arduino analog pin when battery voltage fluctuates.
- pro
- with 1k/2.4k, when the resistors/capacitors are far away from Arduino pin, there should be less noise on the on arduino pin resulting form the wiring.
Anyway, this does not seems me critical.

Jhsa explained why you Vcc voltage fluctuates when you use different bec.
Connecting arduino Raw pin to the second cell (so with about 7.4 V) is a good solution in order to get stable Vcc.

Still I am surprised that you current measurement fluctuates so much with arduino Vcc because:
- At zero Amp on current sensor, Arduino should always report zero Amp even if Vcc changes because current sensor should return a voltage = Vcc/2 and Arduino ADC should internally report a value of 512 (= max number of ADC steps / 2)
- I expected that the sensitivity of current sensor (millivolt/amp) does not vary so much with Vcc.
For, for the same Amp (e.g. 20 amp), the measurement should in theory be unchanged.
Please note that this is valid for current measurement but not for Voltage measurement. E.g. If you apply a fix voltage of 4 volt and you arduino ADC uses Vcc as voltage reference, then the reported voltage will varies with Vcc.

I am also surprised of the value of 90 for the fuel.
I do not know if the Tx firmware you are using calculates this data or if the firmware just displays the value sent by oXs. I presume the second but I am not sure.
Mike or jsha can probably answer.
You can also make a test using the reset key(s) on the Tx. If making a reset on Tx change the value, then the origin of the issue has to be found on Tx side.
You can also change the config of oXs in order not to send this field. If Tx displays only 0, it means that Tx just uses the value from oXs.

For the case, Tx just displays the value from oXs, then an explanation could be that you activate the option save to EEPROM with the line " #define SAVE_TO_EEPROM".
In such a case, there could be a difference between the consumption calculated by Tx (I presume the consumption displayed by Tx is the one calculated by Tx and not the one calculated by oXs) and the consumption calculated by oXs. Why this difference? Just because the save to EEPROM option is activated, oXs saves the value in such a way that, on next power on, oXs will first reload the last value and will continue to count up. So there is no automatic reset of consumption in oXs in this case. You then have to force the reset adding a push button to oXs.
If you did not activate the option save to EEPROM, I have no direct explanation. Your set up on oXs side seems me OK.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Building a 50A sensor module for openXvario

Post by mstrens »

kaos wrote:OK, I will use a 100nF cap with the divider then. I found I only have 1K and 2.2K reistors. the 2.4k needs to combine 2.2+ two 0.2K and this would make the sensor side too bulky withe reagulor resistor. I will make (actually grind out) a small strip pcb to use smd resistor to keep the sensor small.
Good idea using the balance lead to power the oXs, I will check on that and if it work well I will make an adaptor connector for it.

any idea on the Fuel %?
2.4k is not a standard resistor value.
You can replace it by 2.7k if you have one.

One attention point : if you use the balance connector to power on oXs, take care not to forget to disconect it when not flying otherwise the lipo will discharge and become defect.
Another solution is to use a separate volatge in order to drop the total lipo voltage to e.g. 8 volt and connecting this 8 volt to the Raw pin of Arduino.
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Building a 50A sensor module for openXvario

Post by jhsa »

Yes, an 8V voltage regulator is also a good idea. At least when using a 3 cell lipo.. When using more than 3 cells, we must pay attention to the maximum voltage allowed for that regulator. In this case, I believe that using the first 2 cells is the best option..

About the FUEL, that is how I receive the mA/h on my plane with current sensor. But I have an old version of oXs on it. It is working well, so I never changed. Having to fine tune the current sensor takes quite a while and I couldn't be bothered to do it again :)
But I will soon be changing all my sensors to read single cells instead of the total voltage..

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Building a 50A sensor module for openXvario

Post by mstrens »

Number of cells should not be an issue. E.g. a classical (TO-220 packaging) 7808 voltage regulator accept up to 35 Volt on input pin.

Do you know if FUEL displayed on Tx is calculated by the Tx firmware (based on current + battery capacity) or does the Tx firmware just display the value sent by oXs?
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Building a 50A sensor module for openXvario

Post by jhsa »

mstrens wrote:Number of cells should not be an issue. E.g. a classical (TO-220 packaging) 7808 voltage regulator accept up to 35 Volt on input pin.
Big and heavy :)
I think I bought some SMD ones..Gotta check the specs ;)
Do you know if FUEL displayed on Tx is calculated by the Tx firmware (based on current + battery capacity) or does the Tx firmware just display the value sent by oXs?
I'm not sure, but here is the config file of my plane using the old version of oXs

João

Code: Select all

#ifndef OXS_CONFIG_h
#define OXS_CONFIG_h
// openxvario http://code.google.com/p/openxvario/
// started by R.Schloßhan 

/***************************************************************************************/
/* Other Configuration Options  => various different values to take influence on       */
/*                    various stuff. Normaly you do not have to change any of these    */
/***************************************************************************************/
//#define FORCE_ABSOLUTE_ALT // If defined, the height offset in open9x will be resetted upon startup, which results 
// in an absolute height display in open9x . (You can still change to a relative display 
// by pressing [MENU] in the telem.screens
// If not defined, open9x will use the first transmitted altitude as an internal offset, 
// which results in an initial height of 0m

/***************************************************************************************/
/* Which data to send in which telemetry field                                         */
/* ==> choose freely one value per Telemetry field                                     */
/***************************************************************************************/
//**************** the DIST field (GPS Distance) (choose only one)**********************/
//#define SEND_AltAsDIST 0   // 0 Altitude in DIST the numeric value (in cm) is an offset that will
// be subtracted from the actual height for higher display precision.
// e.g: Actual height is 456,78 Meters ( DIsplay in DIst would be 456 7)
// if we subtract 300 display will be 156 78
// This is due to the fact that the highest precission in this field
//  will only be transmitted up to an altitude of 327.68 m
//#define SEND_SensitivityAsDist // sensitivity in DIST
//#define SEND_PressureAsDIST    // pressure in DIST field
//#define SEND_mAhAsDist
//#define SEND_VRefAsDist // send the internal measured voltage as DIST
//#define SEND_DividerVoltageAsDist // send the calculated voltage on the voltage divider as DIST

//**************** the FUEL field  (choose only one)**********************/
//#define SEND_SensitivityAsFuel // sensitivity in DIST
//#define SEND_PressureAsFuel   // pressure in DIST field
#define SEND_mAhAsFuel         // send the absolute consumed mAh value as fuel.
//#define SEND_mAhPercentageAsFuel 4000  // send a percentage of used capacity in the fuel field
                                       // this can be used in openTX to display a Fuel bar graphic.
                                       // the numeric is the usable capacity of your battery in mAh 
                                       // That value is 100%, the transfered value will be the capacity left in %
                                       
//#define SEND_VRefAsFuel // send the internal measured voltage as Fuel
//#define SEND_DividerVoltageAsFuel // send the calculated voltage on the voltage divider as Fuel

//************************** the T1 (temperature 1) Field? (choose only one) **********/
//#define SEND_TEMP_T1         // MS5611 temperature as Temp1
//#define SEND_PressureAsT1 9000 // pressure in 1/10th of mBar in T1 Field subtracted by
// the number in the define statment. 
// e.g. 950mbar => 9500 -offset of 9000 => 500 in display
//#define SEND_MilliampsAsT1 // send the measured current as T1


//************************** the T2 (temperature 2) Field? (choose only one) **********/
//#define SEND_TEMP_T2    // MS5611 temperature as Temp2
//#define SEND_SensitivityAsT2  // Kalman Param R in Temp2
//#define SEND_PressureAsT2 9000 // pressure in 1/10th of mBar in T1 Field subtracted by
// the number in the define statment. 
// e.g. 950mbar => 9500 -offset of 9000 => 500 in display
//#define SEND_MilliampsAsT2 // send the measured current as T2
//#define SEND_LoopTimeAsT2 // for debuging /developing purposes only
//************************** the RPM Field? (choose only one) *************************/
//(unprecise field! resolution is in steps of 30RPM!)
//#define SEND_AltAsRPM      // Altitude in RPM ;-)
//#define SEND_SensitivityAsRPM  // Kalman Param R in RPM
//#define SEND_PressureAsRPM // pressure in RPM Field

/***************************************************************************************/
/* Hardware settings=>Here you can change which pins will be used for which connection */
/*                    and the I2C address of the connected MS5611 module               */
/*                    Normaly you do not have to change any of these                   */
/***************************************************************************************/
#define PIN_SerialTX        4  // 4  the pin to transmit the serial data to the frsky telemetry enabled receiver

#define PIN_PPM 2              // default: 2 the pin to read the PPM Signal on coming from the receiver.           
                               // you can uncomment this line if you want to completly disable the remote control functionality
                               
#define PIN_CurrentSensor   2  // the Analog pin the optional current Sensor is connected to 
#define PIN_VOLTAGE_DIVIDER 3  // Optional! a voltage divider to measure the battery pack voltage > 5v (see below)

#define I2CAdd           0x77 // 0x77 The I2C Address of the MS5611 breakout board 
                               // (normally 0x76 or 0x77 configured on the MS5611 module 
                               // via a solder pin or fixed)
                               
#define PIN_PushButton     10  // an optional push button to control the oXv          
                               // comment out to cpmpletly disable button code

#define PIN_LED            13  // The Signal LED (default=13=onboard LED)

/***************************************************************************************/
/* sensitivity / data filtering / Kalman filter parameters                             */
/* The Kalman Filter is being used to remove noise from the MS5611 sensor data. It can */
/* be adjusted by changing the value Q (process Noise)                                 */
/***************************************************************************************/
#define KALMAN_R 300  
//#define KALMAN_R 250  // default:300   change this value if you want to adjust the default sensitivity!
                      // this will only be used if PIN_PPM is NOT defined
                      //  50 = fast but lot of errors (good for sensor testing...but quite a lot of noise)
                      // 300 = medium speed and less false indications (nice medium setting with 
                      //       a silence window (indoor)of -0.2 to +0.2)
                      // 1000 = conservative setting ;-)
                      // .. everything inbetween in relation to these values.

/***************************************************************************************/
/* Optional Feature Current Mesaurement                                                */
/* Uncomment the #define sendCurrent toenable this feature.                            */
/***************************************************************************************/
//#define SendCurrent  // Uncomment to enable a connected Current Sensor

//#define IdleMillivolts 2500        // Specify the mV value your sensor outputs for 5V supply bvoltage at 0A current flowing
//#define MillivoltsPerAmpere 185    // Specify the mv increase you get per 1Ampere current flowing
#define IdleMillivolts 598
#define MillivoltsPerAmpere 60

/***************************************************************************************/
/* Voltage Divider Setup - Measure your battery VOltage > 5V with your oXv             */
/* you can add an optional voltage divider to the oXv.                                 */
/* its only 2 resistors. One from an Analog pin defined above with the                 */
/* #define PIN_VOLTAGE_DIVIDER                                                         */
/* above. The first resistor goes from the analog pin (Default:A3) to GND.             */
/* The second resistor goes from the analog pin to the battery pack you want to measure*/
/***************************************************************************************/
//#define RESISTOR_ANALOG_TO_GND 3900        // 33kOhm resistor  Maximum allowed Voltage allowed on Voltage Divider=20.38
//#define RESISTOR_ANALOG_TO_BATTERY 12000   // 56kOhm resistor  Maximum allowed Voltage allowed on Voltage Divider=20.38

//#define RESISTOR_ANALOG_TO_GND 33000        // 33kOhm resistor Maximum allowed Voltage allowed on Voltage Divider=13.48
//#define RESISTOR_ANALOG_TO_BATTERY 56000   // 56kOhm resistor Maximum allowed Voltage allowed on Voltage Divider=13.48
#define RESISTOR_ANALOG_TO_GND 46740        // 33kOhm resistor Maximum allowed Voltage allowed on Voltage Divider=13.48
#define RESISTOR_ANALOG_TO_BATTERY 81800   // 56kOhm resistor Maximum allowed Voltage allowed on Voltage Divider=13.48
#define VOLTAGE_DIVIDER_CALIBRATION_OFFSET_MV -50 // you can define this one and set it to an apropiate millivolt value. 
                                                   // the value will be added to the calculated millivolt value
/***************************************************************************************/
/* Parameters for the remote control option of the vario sensitivity                   */
/* These are parameters that can be used to fine tune the behaviour.                   */
/* ==>read the WiKi for details.                                                       */
/***************************************************************************************/
#define PPM_Range_min 981   // the toatal range min of the ppm input (Pulse legth in microseconds )
#define PPM_Range_max 1999  // the toatal range max of the ppm input (Pulse legth in microseconds )

// The KALMAN_R_MIN+MAX Parameters define the range in wehich you will be able to adjust 
// the sensitivity using your transmitter
#define KALMAN_R_MIN 30     // 1    the min value for KALMAN_R
#define KALMAN_R_MAX 800  // 1000 the max value for KALMAN_R

/***************************************************************************************/
/* Optional Feature: Persistent memory.                                                */
/* If defined, some telemetry values will be stored in EEProm every 10 seconds.        */
/* These values will be restored every powerup. (e.g. mAh counted...                   */
/* By doing this we will get ongoing data counts even if the you turn off the modell   */
/* between flights                                                                     */
/***************************************************************************************/
//#define SAVE_TO_EEPROM      // Uncomment this to disable the persistent storage 
//#define SEND_MIN_MAX_ALT
//#define SEND_MAX_CURRENT

#endif



My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Building a 50A sensor module for openXvario

Post by mstrens »

For sure 7808 is big but it can be usefull to dissipate the heat generated by the voltage regulator (useful only if input voltage is high).

In you set up you have : #define SEND_mAhAsFuel // send the absolute consumed mAh value as fuel.
This means that oXs will send the consumption in the field FUEL. So the Tx will normally display a value starting at 0 and that will increase over time (normally up to the capacity of the battery) .
If it works this way, I presume that the Tx is just displaying the value received from oXs.

The set up used by Kaos is different. oXs should send a value starting from 100 (meaning 100% full) and going down over time. In theory, when value becomes 0, the consumption reachs the total capacity of the battery.
Then when 140 mah has be consumed from a 2200 mah battery, the Tx should display a fuel equal to 93 (and not 90).
I can explain the difference only if option save to EEPROM has been activated and if the TX displays his own calculation of consumption based on the current being sent by oXs.
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Building a 50A sensor module for openXvario

Post by jhsa »

Yes, mine starts at zero and counts up.. I never read about this new way with a percentage. I hope the with the new versions of oXs I can still send it the way I do now. :o

According to my experience, which is already a couple years using this sensor in the same plane, and with the same batteries, The current we can draw from the battery is never the same at the point the low voltage alarm is triggered.
Temperature for example has a big impact on how deep we can discharge a battery. Where I live, in winter, my model's flight time can be reduced considerably, so I'm not able to discharge the battery as much as in the summer for the same low voltage alarm setting..

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
kaos
Posts: 3247
Joined: Wed Dec 28, 2011 1:15 am
Country: United States

Re: Building a 50A sensor module for openXvario

Post by kaos »

wow, all good info.
mstrens:
I think I did not write very clear, the current change so much is because applying different raw voltage (from BEC) and the Vcc varies according to the raw from something like 4.62 and 4.94, AND without change the parameter in oXs that caused the variation in current difference. but if I change the Vcc in sketch to match the actual Vcc then the current reading is spot on.
I redid the measuring just now on the Vcc from different raw:
raw --> Vcc
5.87 -->4.94 5.63-->4.94 5.06-->4.62
looks like when raw is >= 5.63 the Vcc is constant 4.94 but at 5.06 it drops to 4.62. so a 2S solution to power pro mini is a good idea the 4.94 is constant and the sketch does not need to be changed once entered. I do have a small adjustable volt regulator can handle 4.5~28v --->1.3~17V at a size of slightly larger than gy-63. I may consider using that.

I dumped out all my resistors and caps in regular form or smd, I found I don't have any 2.7K resister either form. so I have to combine a 2.2 and one 200 ohm resistor to get 2.4K, I think I am going to use smd which I have all the resistors and caps. I realize i have a few prototype circuit boards seem to be perfect for smd mounting. I can put smd on and make all the wires more secure and smaller than it is now going from ACS758 legs. But this will take me a while to get the smd on there. Last time I did the smd thing almost blinded me. :mrgreen:

We just need to figure out how oXs communicate with Ersky9X r217 for that Fuel % thing and the sensitivity thing ( see viewtopic.php?f=7&t=40&start=2040#p102442 )
, both are very new and has gone through a lot of changes. I am sure Mike will be to answer that when he gets around.
User avatar
kaos
Posts: 3247
Joined: Wed Dec 28, 2011 1:15 am
Country: United States

Re: Building a 50A sensor module for openXvario

Post by kaos »

Joao:
do you remember if there is a menu in ersky r217 related to select the unit for telemetry like feet, inches, mA, volts? or that only existed in r178?
I know I have done somthing about that just can't remember it is on r178 or on r217. :(
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: Building a 50A sensor module for openXvario

Post by MikeB »

I expect a value between 0 and 100 for the fuel value, both hub and SPort.
If you set a Current source and a mAh alarm limit, I calculate how much "FUEL" has been used and fill in the FUEL value from that.

I thought only Scalers have ever had a cusotm telemetry unit.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Building a 50A sensor module for openXvario

Post by jhsa »

kaos wrote: I redid the measuring just now on the Vcc from different raw:
raw --> Vcc
5.87 -->4.94 5.63-->4.94 5.06-->4.62
looks like when raw is >= 5.63 the Vcc is constant 4.94 but at 5.06 it drops to 4.62. so a 2S solution to power pro mini is a good idea the 4.94 is constant and the sketch does not need to be changed once entered. I do have a small adjustable volt regulator can handle 4.5~28v --->1.3~17V at a size of slightly larger than gy-63. I may consider using that.
You have an arduino with a low dropout regulator on it which is good. Voltage from 2 cells is more than enough, or an 8V regulator connected to the battery output (Amp sensor) and powering the arduino also using the RAW pin.. Either way will work fine.
I realize i have a few prototype circuit boards seem to be perfect for smd mounting.
A little bit of some strip board would also work.. That's how I build my voltage sensors..
Last time I did the smd thing almost blinded me. :mrgreen:
Get yourself a pair of some good reading glasses :)

Ahh something else. The ACS758 needs some filter on the output, according to the datasheet. A resistor and a capacitor. I'm not sure the value I have used for the resistor (maybe 47K), but the capacitor can not be bigger than 10nF. I've attached the datasheet for you.
Joao:
do you remember if there is a menu in ersky r217 related to select the unit for telemetry like feet, inches, mA, volts? or that only existed in r178?
I know I have done somthing about that just can't remember it is on r178 or on r217. :(
I don't remember being able to change the units.. :o Maybe you used A1 or A2 in the past?

But you can program a Scaler with FUEL as source, both multiplier and divider at 1, give it a name, and choose a unit. Then just use this Scaler on the custom telemetry screen. That is one the reasons Mike implemented the Scalers..

João
Attachments
ACS758-Datasheet.pdf
(644.15 KiB) Downloaded 201 times
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
kaos
Posts: 3247
Joined: Wed Dec 28, 2011 1:15 am
Country: United States

Re: Building a 50A sensor module for openXvario

Post by kaos »

OK, finished the smd circuit and yeh-- a scucess, now sensor for current and total voltage is like this (15g vs Frysky FASV 31g):
20151013_130156 (800x450).jpg
20151013_130317 (800x450).jpg
I have retested the current sensing part, perfect, reading just like before. the 100nF cap for current sensor is now replaced with smd on the "PCB" ;), all I have to do is add one line to the open tab(3rd from the right) where goes to A6 for total voltage from 2S-4S. I checked all the resistance for all 3 resistors and they are in exact spec.
If you wonder how the R2 is connect to the (+) of ASC758, it is the left column connected to R2 which is actually a 90 connector pin at top end and going down connecting to (+) of ASC758, and it also servo as anchor for the "PCB" board. The solder column on the right is the same only it is not connect to PCB circuit, the back side is soldered to the (-) of ASC but no connection to circuit board, just for anchorage of the board.

I need a little help on the sketch config.h file. I read the description but can't quite understand exactly what those multiple numbers in each line means.
My R1=1K, R2=2.4K (in the pic you probably can see I use one 200 ohm+2.2K for 2.4K and one 1K smd resistor, there is a 100nF cap between A6 and Gnd). the intended voltage is for 2S-4S ~6V-17V

Here is my current part and the voltage part of the sketch:
// ***** 6.1 - Voltage Reference to measure voltages and current *****
//#define USE_INTERNAL_REFERENCE // uncomment this line if you use 1.1 volt internal reference instead of Vcc
#define REFERENCE_VOLTAGE 4940 // set value in milliVolt; if commented, oXs will use or 1100 (if internal ref is used) or 5000 (othewise) **My Vcc is 4.94V

// ***** 6.2 - Voltage parameters *****
#define PIN_VOLTAGE 8 , 8 , 8 , 3 , 8 , 8 // set this line as comment if no one voltage have to be measured, set a value to 8 for the voltage(s) not to be measured.
#define RESISTOR_TO_GROUND 12 , 20 , 30 , 19.8 , 50 , 60 // set value to 0 when no divider is used for a voltage, can contains decimals
#define RESISTOR_TO_VOLTAGE 50 , 100.1 , 200 , 39 , 500 , 600 // set value to 0 when no divider is used for a voltage, can contains decimals
#define OFFSET_VOLTAGE -1 , 0 , 0 , 0 , 0 , 0 // optionnal, can be negative, must be integer
#define SCALE_VOLTAGE 1.1 , 1 , 1 , 1.004, 1 , 1 // optionnal, can be negative, can have decimals

// ***** 6.3 - Max number of Lipo cells to measure (and transmit to Tx) *****
#define NUMBEROFCELLS 1 // keep this line but set value to 0 (zero) if you do not want to transmit cell voltage.

// ***** 6.4 - Current parameters *****
#define PIN_CURRENTSENSOR 7
#define MVOLT_AT_ZERO_AMP 2470 // in millivolt ** My Vcc is 4.94 so 4940/2
#define MVOLT_PER_AMP 40 // in milliVolt per Amp
//#define RESISTOR_TO_GROUND_FOR_CURRENT 19.8 // put as comment or set to 0 if no divider is used
//#define RESISTOR_TO_CURRENT_SENSOR 39 // put as comment or set to 0 if no divider is used
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Building a 50A sensor module for openXvario

Post by mstrens »

When you look at the voltage section (in oXs_config.h) in the new version of oXS, you can see 6 parameters on each line.
The first parameter refers to the first voltage measurement, the second parameters to the second voltage measurement, ...
So, you can have max 6 measurements (max depends also on the number of analog pins on your board and on the presence or not of a current sensor).
Here a config that you could use (asuming that you measure only one voltage on pin 6 with a divider with 1k and 2.4k)
#define PIN_VOLTAGE 6 , 8 , 8 , 8 , 8 , 8 // set this line as comment if no one voltage have to be measured, set a value to 8 for the voltage(s) not to be measured.
#define RESISTOR_TO_GROUND 1000 , 0 , 0 , 0 , 0 , 0 // set value to 0 when no divider is used for a voltage, can contains decimals
#define RESISTOR_TO_VOLTAGE 2400 , 0 , 0 , 0 , 0 , 0 // set value to 0 when no divider is used for a voltage, can contains decimals
#define OFFSET_VOLTAGE 0 , 0 , 0 , 0 , 0 , 0 // optionnal, can be negative, must be integer
#define SCALE_VOLTAGE 1 , 0 , 0 , 0 , 0, 0 // optionnal, can be negative, can have decimals


I read in a post drom Mike that the Tx can calculate the FUEL (in some conditions). I think it is better to use this option (instead of letting it being calculated by oXs) because:
- if your change the type of battery being used (with a model having a different capacity), it is easier to change the value on Tx side than having to reprogram the arduino.
- probably the Tx allows you also to reset the consumption when you want (so you do not need a push button on oXs).
User avatar
kaos
Posts: 3247
Joined: Wed Dec 28, 2011 1:15 am
Country: United States

Re: Building a 50A sensor module for openXvario

Post by kaos »

wow, fast response. Thank you!
I think I understand the other 4 lines, but this line:
#define PIN_VOLTAGE 6 , 8 , 8 , 8 , 8 , 8

what 6 and 8s means?
Ah.., I think I got it. 6 means the 1st voltage is measure at pin number(A6) and 8 means no voltage measured, correct?
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Building a 50A sensor module for openXvario

Post by mstrens »

Indeeed, 6 in the first position means that the first voltage as to be measure using pin A6.
8 on the second position means that there is no second voltage to measure, etc...
I used 8 because it had to be a numeric value, 0 represent already Analog 0 and there are no analog pin 8 on AVR 328p
User avatar
kaos
Posts: 3247
Joined: Wed Dec 28, 2011 1:15 am
Country: United States

Re: Building a 50A sensor module for openXvario

Post by kaos »

Got it. Thank you very much. I will run a test. Will get back with you again.
No need for a inline resistor on the A6 line right? In A7 (for current, I had a 10K resistor)
User avatar
kaos
Posts: 3247
Joined: Wed Dec 28, 2011 1:15 am
Country: United States

Re: Building a 50A sensor module for openXvario

Post by kaos »

Got it. Thank you very much. I will run a test. Will get back with you again.
No need for a inline resistor on the A6 line right? In A7 (for current, I had a 10K resistor)
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Building a 50A sensor module for openXvario

Post by mstrens »

The inline resistor for A7 is mainly used to build a low pass filter (with the capacitor). It avoid to fast fluctuations.
For the voltage, you currently have no low pass filter (no capacitor between A6 and ground) but even if you add one (what makes sense in order to filter the signal too), there would be no need to add an inline resistor because you already have the divider resistors.
User avatar
kaos
Posts: 3247
Joined: Wed Dec 28, 2011 1:15 am
Country: United States

Re: Building a 50A sensor module for openXvario

Post by kaos »

hmmm..... when I add this line in sketch for voltage transmission
#define SETUP_FRSKY_DATA_TO_SEND \

Vfas , VOLT1 , 1 , 1 ,0

Auduino compile error message: expected "}" before numberic constant

and this line is highlighted:
#define SCALE_VOLTAGE 1 , 0 , 0 , 0 , 0 , 0 // optionnal, can be negative, can have decimals


Before I put the define data to send line, it did not give me this error message.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Building a 50A sensor module for openXvario

Post by mstrens »

I presume that you are using version 5.0
Could you please attach your oxs_config.h file so I can try to reproduce
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Building a 50A sensor module for openXvario

Post by jhsa »

You might have deleted a "}" by mistake.
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
User avatar
kaos
Posts: 3247
Joined: Wed Dec 28, 2011 1:15 am
Country: United States

Re: Building a 50A sensor module for openXvario

Post by kaos »

mstrens:
yes, I am using V5
here is my oxs_config.h file:
oXs_config.h
(9.11 KiB) Downloaded 294 times
jhsa:
I only used copy and paste then change variables.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: Building a 50A sensor module for openXvario

Post by mstrens »

I have just reproduced the error (even with my own config file).
It is late now in Belgium. so I will analyse to morrow.
User avatar
kaos
Posts: 3247
Joined: Wed Dec 28, 2011 1:15 am
Country: United States

Re: Building a 50A sensor module for openXvario

Post by kaos »

OK, thank you.

Post Reply

Return to “OpenXVario - an open source vario supported by the open source firmwares!!”