Voltage reading is fluctuating

Hello all,
I have a tricopter with an APM 2.5.2 running AC3.1.5.

The problem is that the voltage reading (which is obtained by a 3rd party voltage and current sensor) is very unstable. It fluctuates about 0.5V, even when the vehicle is stationary on the ground.

At first I thought it was the sensor that was causing the problem, but I then realized that the reading is perfectly stable in Mission Planner, but unstable in APM Planner 2 and my OSD (FPV image, minimOSD used).

This video demonstrates the problem: https://www.youtube.com/watch?v=V-DLXuuDym0

Could this be a bug in the way APM Planner 2 and MinimOSD read Mavlink, or is it something else?

My next thought was that some of my parameters are messing with the measurement, so I compared my own param (backup) file to the default configuration (by resetting the board in Mission planner, and re-importing my params) and only a few things differ. Most of them make sense (calibration stuff, flight modes etc) and only a few could have an influence (in my view). The SR0_ and SR1_ params are all changed. Most of them to ‘2’, apart from a couple that have value 10. Could they cause the behavior shown in the video?

What else could it be?

By the way, I tried flashing AC3.2, in case this is a bug in AC code, but verification fails :frowning: Tried 4 times…

Thanks,
Cheers,
Chris

most likely, MP is slow or takes some rounding/interpolation, or request lower data rate.
The mavlink is simple, it’s hard to mess up this simple part in software.

If you want to be really sure - let the APM log it for a while. - but remember you see much less samples /second that way.

But I can tell you right away, that this is due to too small capacitor (for your application) on current signal from the current sensor.
Also, if you have some switch mode regulators, especially those who work on lower frequencies, will manage to get their load ripple be registered by a current sensor just fine.

I use high-end hall-effect sensors, and these need tuning using R+C to smooth out data, yet get the finest data resolution possible depending on sampling rate.

Manufacturers don’t care to do that “right”. - as some circuits/application sample at ~1Khz, when smooth the data for very accurate measurement - and then you don’t really want very high capacitance.

So try adding extra capacitor between I pin and GND, start with 0.1 or 0.47uF or thereabout, impossible to say for sure as it depends on sensors source capability and resistor they used.

Thanks for your reply Andre,

my problem though is not with current. I don’t care about it at this point. I’d like to make Voltage dependable first.

Now, I’ve measured the V reading coming out of the sensor, before it goes into APM, and it is extremely stable. Less than 1mV fluctuation, if my cheap multimeters are to be trusted (two of them).

So it’s either APM’s ADC or something in software that introduces the problem. I’ll grab a log and try to average the values to see if I get the precise voltage that the pack reads. I’m afraid though that aliasing will take place…

Yeap, your hypothersis about MP averaging readings is verified. When I first plug it in, the battery voltage slowly increases towards the real voltage (15.3V in my case). It takes about 30" to get there, so I think this indicates averaging.

So, I averaged the data coming from a log, while landed and armed. Sure enough, the average is very close to the volt meter reading!

Unfortunately I only have ~10 samples, because my copter suffers from another problem, and can’t stay armed and not flying for more than a few seconds.

But this indeed looks like a sampling issue, so I should now direct my efforts towards MinimOSD-extra averaging the readings.

Thank you Andre, you helped me troubleshoot this long-standing issue! Let’s hope it will be fixed soon :slight_smile:

Cheers!

-try to smooth out the current output using capacitor rather than adding code to MinimOSD.
-MinimOSD’s microcontroller (328) is very much stuffed with code as-is , adding averaging there would not be taken into master, and you will still suffer from unstable measurements on other GCS/equipment, trigging voltage alarms imprecisely.

But current is not my problem right now. I’m talking about voltage. Or is current affecting voltage?

In any case, the reading the sensor is giving to APM is completely stable! There’s no reason for further smoothening there. It’s already smooth. Or do you imply that what my DVM sees as steady DC is actually an average of a fluctuating value?

ooops, forget all mention of current, sorry , my bad.
Current and voltage sensors are basically same technlology , voltage is even simpler.
(current sensing is always amplified, because a voltage drop of 3v across a resistor would produce lots of heat at the currents we fly.)

Both scale and deliver a voltage representing the measured value.

Voltage sensor is usually a simple voltage divider (two resistors). you input 0…30v , and get out 0…3.3v which is sampled using a 10bit DAC (I think it’s a 10 bit.) so your precision is 30/1024= ~0.03v

however, if your voltage divider is scaling down from a maximum of 200v , it would mean a step is 0.195 volt.

Your AD is 5v , so using a voltage divider that produces 0…3v3 would reduce the precision a lot too.

Anyway : still, a capacitor on the voltage sensing pin will do the trick.

I just tried putting a 1uF, 22uF and 100uF capacitor (one at a time) between the voltage reading and ground, and nothing changed. No fix :frowning:

that’s surprising. it should have been a huge overkill with 100uF even if the divider had relatively small resistors.
I would use a oscilloscope to check ripple if the signal, or 5V line used in the microcontroller, and the voltage provided. If you have access to such equipment, that’s the way to go.
Or: you can connect all thru APM power module, but provide the vsense (only) and have common ground, from your sensor. See what happens then

Nope I don’t have a scope unfortunately. A friend of mine has, but to tell you the truth, this sounds normal to many people (on DIYDrones), so I guess it’s intended to be like that.

I didn’t get the other suggestion. I don’t have a PM or a lead to tap to the PM connector…

So for now I’ll pause. Maybe I’ll work around it using battery percentage like a minim-osd-extra dev suggested.

Thanks for all the help. I’m sorry for backing out…

You can’t see ripple or other voltage small transient effects on a multimeter as they average the result. You need a scope and it needs to be under load.

We can add averaging to the voltage readings, but dips below min volt per cell won’t show, and that is critical. The issue you are seeing is Power voltage is very noisy. It’s not an error.