Reduce ripple when measuring VBAT - Page 1
Forum section: electronics / beginners

author: Shimonu
author_rank: Regular Contributor
timestamp: April 27, 2025, 08:42:37 pm
content: I've been working on a battery project and want to monitor the battery voltage with the MCU ADC. I'm using the NPM1100 IC to manage power and they gave an example of how to monitor the battery with some transistors to enable output to a resistor divider with 1M5 and 200k resistors which would give about a 200 mV range between empty and full. I figured I would add 2x gain with an op-amp to have a bit more range, I knew this would also affect any ripple but I expected the voltage from the battery to be quite stable.It's working as designed but I'm seeing quite a bit of ripple, both before and after the op-amp. I've tried both with a LiPo battery and the supply output from the Nordic Power Profiler and they both seem quite noisy. I'm getting 150 mV or even more in ripple. It's rather high frequency too, in the 90 Mhz range, which I can see with both my Rigol DS1054Z oscilloscope(upgraded to 100Mhz of course) and the tinySA spectrum analyzer. I thought maybe I was just picking up radio stations but I don't think so.I'm still able to read the battery voltage well enough to know when the battery is getting low, which is all I wanted at first, but I figured this could be a learning moment as I'm not so used to the analog aspect of electronics.I'll attach some relevant schematics. What isn't shown is that there's also a 100n cap on the VBAT_AMP signal close to the MCU as well as a bulk cap of 4.7u or 10u for the battery, I don't remember what I actually soldered.I'm not sure about the feedback resistors for the op-amp, I really wanted to minimize any currents and I was thinking about playing with some smaller values to see if that would help but since I'm already seeing a bit of ripple on the input to the op-amp I figured it wouldn't change much.So is there a silly mistake I'm making here or is this expected and I just need to do more filtering?

author: Ian.M
author_rank: Super Contributor
timestamp: April 27, 2025, 09:11:20 pm
content: OPAMPs are generally unstable with significant capacitive loads, so put the 100nF cap on the divider tap, not the OPAMP output.

author: radiolistener
author_rank: Super Contributor
timestamp: April 27, 2025, 09:51:44 pm
content: Before trying to add more filtering circuits or software algorithms, it's critical to first analyze the ripple and noise characteristics that are causing problems. You should record and examine the signal to understand the frequency content, amplitude, and any periodic patterns in the noise.Without this information, any changes to the circuit, such as adjusting resistor values or adding capacitors - are essentially guessing, and may not effectively address the real issue. It's a bit like fighting windmills without knowing what you're actually fighting.A proper analysis will tell you whether you need a low-pass filter, a better layout, shielding, improved power supply decoupling, or something else entirely. Otherwise, you risk complicating the design without solving the root cause.Your approach of "adding 2x gain with an op-amp to have a bit more range" is not optimal. Increasing the gain does not extend the working range, instead, it reduces it by amplifying the signal along with any noise - closer to the ADC limits.Moreover, the op-amp will unnecessarily consume additional current without providing real benefits, which can negatively impact the overall power consumption of the device.If the low input voltage to the ADC is a concern, a better solution would be to adjust the resistor divider to make better use of the ADC full input scale.

author: mtwieg
author_rank: Frequent Contributor
timestamp: April 28, 2025, 12:08:42 pm
content: Overall I agree with the previous comments. It looks like this circuit is based off of the NPM1100 datasheet. If you're using it with a nRF5x SoC as the datasheet describes, then it's probably best to not mess with the circuit. If you're using it with another ADC/MCU, then adding gain might make sense (depends on the ADC). But you might be able to get the same result by just adjusting resistor values, without any op amp.I'm assuming you're working with a single Li-ion/Lipo cell. Adding a few uF of capacitance to the cell likely won't change the noise/ripple much, as the cell's own impedance is probably pretty low as well.I'd also recommend looking closer at the source of the ripple. It could be that what you're seeing is more related to your measurement method than the circuit itself.

author: Shimonu
author_rank: Regular Contributor
timestamp: April 28, 2025, 04:20:14 pm
content: Thanks for the tips!I've started by removing the 100nF capacitor which did indeed lower the ripple a bit in magnitude but I think I got a broader spectrum ripple.I have also wondered if maybe I'm inducing something by measuring. I'm going to see if I can get some statistics by just using the ADC.What could otherwise be causing the ripple, would it need to be active components like the op-amp, crystals, etc? There are certainly a few oscillating things on the board, I suppose I'd have to look for harmonics as well as sums and differences of frequencies to see what matches? Is that what you're meaning by performing analysis or is there a methodology I could read up on?

author: Shimonu
author_rank: Regular Contributor
timestamp: April 29, 2025, 05:12:25 pm
content: After doing some sampling with the ADC and checking statistics it seems like the ripple is real. I'm getting a spread of about 200 mV in my measurements. Averaging can get me within a few tens of mV but as you've said, it doesn't really solve the issue.Besides the PMIC and the MCU I have an RF transceiver driven by a 26 MHz crystal oscillator. Nothing is oscillating around the 90 MHz area as far as I know. I checked the datasheet for the NPM1100 and the PWM frequency for the inductor is 3.6 MHz. You can play a bit with the harmonics of those two frequencies and end up in the 90-100 MHz area but I'm not sure how I would confirm if those are indeed the culprits. I tried a quick test and just desoldered the crystal oscillator but that seemed to actually make the ripple worse. I also tried to put some capacitance on the resistor divider, the 100nF I previously removed and then a 22uF. It didn't seem to make a noticable difference either. I just figured I would try these things as it's quick and easy. I'm planning to also remove the op-amp and just measure the divided voltage directly to see if it's any more stable.If that doesn't help I might start to think maybe the layout of the PCB is causing issues or some of the passives? I have tried to make it small so could be that some things are not optimal, maybe look if there are large ground loops.EDIT: Of course the analog supply to the MCU is seeing the ripple as well which also needs to be handled. I'm starting to suspect the output from the NPM1100 as part of the problem. Looking a bit closer there seems to be a frequency component closer to 7 MHz contributing to the magnitude of the ripple. I checked the PWM output to the inductor and it looks to be around 2.5 MHz, but I'm not sure if that's tunable by the NPM1100 depending on load. So the 90 MHz I was seeing might just be a secondary thing. I was lazy and used the auto scaling of the oscilloscope which showed a very high resolution time base causing me to focus on that.

author: Shimonu
author_rank: Regular Contributor
timestamp: April 29, 2025, 07:47:16 pm
content: I think I'll skip the NPM1100 and redesign without it. I thought it would be nice to get a lot in one package. While I can use it without the buck converter it doesn't feel like it makes a lot of sense if I then have to add an LDO to get the VCC I want.I could keep looking into the ripple and try to filter it out but I doubt that would make a lot of sense when I want to keep the board small too as it's already cramped and I feel like it's the buck converter causing a lot of the issues. Having a more stable supply from an LDO from the beginning makes more sense to me.

author: radiolistener
author_rank: Super Contributor
timestamp: April 29, 2025, 08:19:22 pm
content: you can filter it to as much low value as you want, it is limited with max time that you allow to detect voltage change. For example if 1 hour for filter delay is ok for you and you have enough memory to store samples, you can do pretty good filtering.