01-Mar-2022, 06:41 PM
I was working on a build recently and had everything working well, but the current values in the OSD were jumping around so much they were worthless. Typically, current sensors work by measuring the voltage drop across a shunt resistor. This voltage drop is measured using an analog to digital converter in the MCU. Using a voltage divider and OpAmp, this voltage usually ranges from 0-3.3v over the range of currents the sensor is designed to measure. If there is electrical noise in the system, as is very common on quad builds, the voltage measured by the ADC will not be constant for a given current but will vary in frequency and amplitude.
Betaflight allows you to set the current sensor lpf period to reduce noise, but I found the signal was just as noisy but updated slower. Instead, as I was fairly confident the issue was electrical noise, I decided to add a filtering capacitor to the ADC input hoping that would help stabilize the signal.
I was using the Flywoo F411 micro stack for this build, which uses pins to connect the FC to the ESC and provide connections between battery, ground, motor outputs, and current sensor. Fortunately, the board also has the current sensor broken out to a pad adjacent to a ground pad, which seemed like the perfect place to add a small filtering cap.
I had an assortment of 0805 ceramic capacitors, and after a quick consult with an EE on the ELRS Discord I decided to use a 0.1uF and 1uF cap. Soldering 0805 SMD components is a bit fiddly, but I gave it a shot and managed to get it on the first try.
Current sensor before: Current sensor after:
Pretty striking difference in noise! After adding the capacitor, the current sensor in my OSD does not jump around constantly and is actually usable. Additionally, I've verified it accurately reports the current at different motor loads using a benchtop DC power supply. In hindsight, I probably would've been fine with just the 0.1uF capacitor, and will try that in future builds.
Betaflight allows you to set the current sensor lpf period to reduce noise, but I found the signal was just as noisy but updated slower. Instead, as I was fairly confident the issue was electrical noise, I decided to add a filtering capacitor to the ADC input hoping that would help stabilize the signal.
I was using the Flywoo F411 micro stack for this build, which uses pins to connect the FC to the ESC and provide connections between battery, ground, motor outputs, and current sensor. Fortunately, the board also has the current sensor broken out to a pad adjacent to a ground pad, which seemed like the perfect place to add a small filtering cap.
I had an assortment of 0805 ceramic capacitors, and after a quick consult with an EE on the ELRS Discord I decided to use a 0.1uF and 1uF cap. Soldering 0805 SMD components is a bit fiddly, but I gave it a shot and managed to get it on the first try.
Current sensor before: Current sensor after:
Pretty striking difference in noise! After adding the capacitor, the current sensor in my OSD does not jump around constantly and is actually usable. Additionally, I've verified it accurately reports the current at different motor loads using a benchtop DC power supply. In hindsight, I probably would've been fine with just the 0.1uF capacitor, and will try that in future builds.