Module voltage "bounce" - sample averaging

Another possibility - is (part of) the problem noise on Aref by virtue of the un-bypassed zener diode D1? I appreciate that bypassing it will necessitate a delay in reading the voltage while it stabilises, and it will cost a little in energy as the charge on the capacitor is largely wasted.

I think averaging the voltage reading will also help during charging as most chargers also introduce noise on the cell voltage. In bad cases it might kick in bypass and switch of the charger based on peaks in the noise.

I see some people write " on my multimeter voltage is stable", that is correct as a millimeter needs time to measure see this Link for some information on how much time a multimeter needs to measure and display voltage values

The output of the pin is actually quite stable, there isn’t any serial data comms going on when we take voltage readings (given the way the packets of data flow between modules) and the ATTINY is put into deep sleep to reduce noise when the sampling occurs.

If you connect the R3 to the VCC rail, it will be always “on” and using a small amount of current through the voltage divider resistors - obviously these modules need to be as frugal with energy as possible, hence the switching of the input voltage.

From what I see, the voltage is stable on the scope, and the different between true voltage and the pin output is calibrated for in software (to also cater for the voltage divider resistor tolerance)

Are there any other people had this problem? Because if I am the only one, then there should be something wrong with my setup.
And I noticed today, even disconnected from the load, voltages bounce but not this much. About 0.005v change each time. I have an old controller board and 4.4 modules also. I’ll try with them too. Didn’t have time to do the soldering all the parts.

I have the same or similar issue. Voltage fluctuation.

My system is based on 16x 280ah lifepo4 with
Victron inverter charger.
I found 3 cell have high internal resistance, so on these cell it’s easy to get fluctuation depending on the current.
On the multimeter isn’t seen such fluctuation.
I’m looking to see the result of these implementation.

This is to be expected, the 10 bit ADC in the module has a resolution of 0.004V.

The new sample average code which j published earlier should help to hide this.

If the cell voltage is on the ‘edge’ between steps in the ADC you often see this voltage movement.

The multimeter will take several hundred reading over a period of time and then show the average. That’s who the voltage looks stable.

If you looked with an oscilloscope you would see the bounce.

@stuart, would this code also also work for the esp8266 version of the controller?
That’s what I have.
I see it’s in the ESP32 repo though…
I’d love to see the averaging put in!
And where does one find this hex file on github?

Nevermind about the file location… I keep forgetting to look in the releases section! duh

Yes it should work fine with the 8266 version of the controller. Give it a go.

Ok… Will do…
Now I just have to remember how to program a specific hex file! lol

You could always just read the manual :slight_smile:

[GitHub - stuartpittaway/diyBMSv4Code: Software for diyBMS v4]

1 Like

I did remember… By reading the manual!! :grin:

@stuart, out of curiosity… in looking at the code changes… why are you doing 5 readings in a row vs just doing the rolling average of the last 5 regular readings? Are the regular readings too far apart that might give too stale data?

The readings in a large system could be many seconds apart, so this is averaging 5 readings in a few milliseconds.

So I loaded the averaging code in 1/2 my modules. I was hoping to get smooth transitions between points with the averaging code. It looks like it doesn’t do what I was hoping.
To the left is standard code, to the right is the averaging code.




This last one is a std code for reference…

It still bounces between two values

As you are really zoomed in there, that’s just how ADCs work, when you have a voltage halfway between steps it’s going to bounce.

Do you need such a small resolution?

The voltage steps should be 0.004V with the standard setup and the 10bit ADC in the attiny.

Did the sampling make a difference, I can’t tell which graphic is which?

If you want smooth graphs, perhaps try an add on filter to the data?

Yeah I know that’s how they work… I was hoping the averaging would smooth it out.

No… it would just look better…

No… the averaging didn’t seem to do anything.

I’m not sure how I would add the filter to grafana. I’m not an expert there… (or even average!)

I forked the code. Maybe I’ll play with different averaging schemes…
I also should check to make sure I down loaded the averaging hex file! I’m pretty sure I did!

To explain the graphs… The first three are three different cells… to the left of the purple line is the old code… To the right of the purple line is the new averaging code. They look the same to me.
The last graph is one of the cells that had no code change.

All these images have only 0.005v differences. That is nearly the resolution of the ADC. I was talking about bouncing of voltage with larger values.