RC Timer Voltage & Current Sensor not working

Post Reply
Autonym
Posts: 12
Joined: Wed Nov 06, 2013 7:05 pm

RC Timer Voltage & Current Sensor not working

Post by Autonym »

Hey guys.

Total noob here. I'm slowly getting this thing working, but I'm not ready to fly yet.

I'm having the darnest time getting my voltage/current sensor working. I am running stock MultiWii 2.2 code (I tried 2.3 and things... didn't go well).

I've read other posts, but frankly, it's gibberish to me - it literally doesn't make sense to me.

I have a Crius AIOP v2 + the RC Timer Voltage & Current sensor, which looks to be a copy of the AttoPilot sensor.

I have it set up so I can put the sensor in-line between the LiPo and the power distribution board or not - it's got TX60 plugs so I can swap it in or out as-needed for calibration.

I have the ground pin from the sensor output side piped to my board through an AOIPIO board that gives me adjacent Ground, Analog 1, and Analog 2 pins nice and neat. I have Ground->GND, V->A1 and I->A2.

I have set

Code: Select all

#define OVERRIDE_V_BATPIN                   A1 


So that the V pin is read correctly on the correct pin. I've found in the code that the power meter pin is A2, so I think I'm good there as well.

I have all the VBAT stuff set to default (with the exception of turning on VBAT):

Code: Select all

    #define VBAT              // uncomment this line to activate the vbat code
    #define VBATSCALE       131 // (*) change this value if readed Battery voltage is different than real voltage
    #define VBATNOMINAL     126 // 12,6V full battery nominal voltage - only used for lcd.telemetry
    #define VBATLEVEL_WARN1 107 // (*) 10,7V
    #define VBATLEVEL_WARN2  99 // (*) 9.9V
    #define VBATLEVEL_CRIT   93 // (*) 9.3V - critical condition: if vbat ever goes below this value, permanent alarm is triggered
    #define NO_VBAT          16  // (*) Avoid beeping without any battery


It talks about the resistor divisor in the comments above, but I'm using this hardware sensor instead. When I looked at the schematic for it, however, I saw it basically has a resistor divisor inside it, so apparently I'm good to go there.

I also have POWERMETER stuff enabled:

Code: Select all

    //#define POWERMETER_SOFT
    #define POWERMETER_HARD
    /* PLEVELSCALE is the step size you can use to set alarm */
    #define PLEVELSCALE 50 // if you change this value for other granularity, you must search for comments in code to change accordingly
    /* larger PLEVELDIV will get you smaller value for power (mAh equivalent) */
    #define PLEVELDIV 5000 // (*) default for soft - if you lower PLEVELDIV, beware of overrun in uint32 pMeter
    #define PLEVELDIVSOFT PLEVELDIV // for soft always equal to PLEVELDIV; for hard set to 5000
    #define PSENSORNULL 510 // (*) set to analogRead() value for zero current; for I=0A my sensor gives 1/2 Vss; that is approx 2.49Volt;
    #define PINT2mA 13 // (*) for telemtry display: one integer step on arduino analog translates to mA (example 4.9 / 37 * 100


So, now my problems:

Problem 1:

I get a Battery Voltage reading though the GUI of 1.6 volts, even though my LiPo is currently showing 11.4, when I have the sensor in-line with the LiPo. When the sensor is bypassed, it reads zero volts, which makes sense. Later, when my battery had discharged more (down to 10.9 volts), the GUI voltage reading finally dropped to 1.5 volts.

From seeing the voltage reading finally drop from 1.6v to 1.5v on the display, it looks like my 'scale' is off by a factor of ~7.2x - that is, if I multiplied the display voltage (1.6, 1.5, etc.) by 7.2, I'd be a lot closer to what the real voltage is. Is there a scale setting somewhere I can tweak to get this working right? I've looked all over, and I can't find it. There's a value called "VBATSCALE" which looks interesting, but I've changed it to make it 10x larger and 10x smaller and nothing changes - the display continues to read 1.6v-1.5v.

Problem 2:
I get a "Power Sum" incrementing, but it doesn't make any sense compared to the draw the quad is doing - it's just counting up at the same rate, regardless of whether I'm running full RPM on all engines or sitting still, disarmed. Furthermore, the Power Sum increments even when the sensor is disconnected, so something's definitely not right there.

According to the datasheet for this sensor, I get 63.69mV/Volt and 36.60mV/Amp, so my pINT2mA should be set correctly.

Any help with these two issues is greatly appreciated - perhaps a bit of a primer on what I'm supposed to be doing for calibration would also help.

Thanks!

Autonym
Posts: 12
Joined: Wed Nov 06, 2013 7:05 pm

Re: RC Timer Voltage & Current Sensor not working

Post by Autonym »

Just as a follow-up: I realized later that all the voltage levels for nominal, warn1, warn2, and crit are set up for a 4S LiPo as a default, and I'm running 3S, so I should scale those down, but since my VBAT is reading 1.6-1.5v, that's hardly the real issue for the moment. Any ideas why my voltage sensor is reading so low?

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

Re: RC Timer Voltage & Current Sensor not working

Post by QuadBow »

Autonym wrote:Any ideas why my voltage sensor is reading so low?


The issue is that the RC Timer Voltage&Current Sensor is designed neither for 3S nor for 4S, but for 51.8V ! http://www.rctimer.com/product_861.html
Furthermore, the internal voltage of that device scales down to 3.3V. That may result in a total factor of 6 or 7.

Thus, you have to adapt the VBATSCALE parameter. This parameter has to stay in the range 0...255.
Firstly, 12.6V*3.3V/51.8V result in 0.8V to be measured.
The 0,8V*1023/5.0V result in a ADC value of 164.
This value 164 is multiplied by 16 = 2627.
Now you can calculate VBATSCALE=2627/126=21.

Important: to make the new VBATSCALE work you have to reset the EEPROM in multiwiiconf first!

Due to your configuration the accuracy is a bit weak. Therefore, it is recommended to build up an own voltage divider instead of the internal of the RC timer voltage&current sensor.

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

Re: RC Timer Voltage & Current Sensor not working

Post by haydent »

i have this sensor, it works fine

JoJo86
Posts: 1
Joined: Mon Jun 30, 2014 9:51 pm

Re: RC Timer Voltage & Current Sensor not working

Post by JoJo86 »

Hi,

I'm trying to set up this sensor too.
I have the Attopilot sensor for 90A.
I found out, that the factor you wrote it is about 7 is 7.4
This can be found in the code sample on the sparkfun site:
http://dlnmh9ip6v2uc.cloudfront.net/dat ... seDemo.pde

I hope getting this sensor to work in the next few days... :D

Post Reply