
Purple
USA
Asked
— Edited

I have about 5 adc units of noise on my 256 adc analog inputs. Also the battery voltage and cpu temperature are noisy. I have checked my incoming battery voltage and it is steady. I tried to filter the analog inputs but no luck there. Thanks oops I guess I can not go back and fix my typo in the title.
It fluctuates ... mine does it too... This is because the V4 is drawing power at various rates (data like battery and CPU temp being sent back and forth over WiFi is one cause )..... of course it's going to fluctuate.... when using a millimeter there is no power demands on the battery so the voltage will be relatively static....
Does it fluctuate when there is no load on the battery? i.e. when no servos are being used, when no LEDs are being lit, when no motors are being run?
A slight voltage drop is normal and will look like fluctuation. When the battery is under load the voltage will drop, this can sometimes be by quite a lot. 0.3v is very slight.
As for the CPU temperature, how much does it fluctuate and how often? Again, is this while the EZ-B is carrying out tasks or while sitting idle?
That is not "noise". The microcontroller on the EZ-B v4 is a very reliable, expensive and trusted ARM from STM. The ADC ports on the STM32 processor are 12 bit resolution and recorded directly into memory via hardware DMA.
If you see the values of the ADC moving, that is because the input is moving.
For example, the battery supplies a specific voltage at varying consumptions. So if your robot is consuming power, the voltage will vary. Additionally, the temperature of the chip with vary with usage.
Any adc input you provide to the ezb may have some fluctuation (which is not noise). The adc ports of any chip are not able to internally generate a fluctuation because they are floating. That means they are internally separated from a digital source and connected to the adc buffer during power on configuration. The dma and peripheral settings configure the ports on power on.
Please examine your input for voltage fluctuation. You can either use our adc on the ezb, or an external device such as an oscilloscope.
Additional information on adc and voltage fluctuation caused by consumption demand can be found on google.
I have checked my incoming voltage on my board and it is steady. I have no scripts or any loads at all on any io or analog pins. The voltage fluctuate s about .6 volts and the temperature fluctuate s about .5 a degree on each update that occurs every 3 or 4 seconds. Another way to observe the noise is to ground any analog input pin to gnd and you will see fluctuations, on the adc display, the readings should be a steady zero with a grounded analog input pin. If there is any fluctuations then you do not have a stable 8 bit input. In other words some of your 256 adc counts get eating up in the noise. So if you do not have a stable 8 bit result then how can you expect to go to 12 bit 4096 adcs? Don't get me wrong, I am not trying to say you do not have a great board with quality components.
Hi @Purple,
Digital Multimeters are likely not to update as fast as an analog pin will, so the noise you are describing is likely correct. The adc values do not show you an average like a Mulitmeter will but instead they will give you an instantaneous snap shot.
Even though you are trying simulate without a load inherently the EZ-B itself draws a load since we have an audio amplifier, camera and WiFi module that all need to be powered up from 3.3V, so unfortunately you can't really simulate a no load situation with the EZ-Bv4. Particularity with the WiFi module, the transmission power (aka current consumption from the battery) will change with signal strength as it tries to boost power to get a better signal.
Grounding out an adc line does not guarantee that you will have a value of 0 as there are always variations on the ground line as well (albeit usually small) but they are there. DJ proved this to me a couple years back by simply doing stall current sensing by attaching an adc line directly to ground and was able to get readings.
My suggestion is that if you aren't comfortable seeing these instantaneous readout fluctuations is to then do some averaging on the code side. For example take 10 samples of an adc port add them together divide the sum by 10 and then input that value into your conditional statements to get a stable value.
I have used this method in the past with other microcontrollers, like Arduinos, when I wanted a stable adc value.
One other thing to keep in mind is that adc lines have a lot less fluctuations when fed a constant voltage source, so try placing a sensor on an adc line and see what values it gives you, they should be pretty stable as long as the sensor is in a steady state.
Sorry Purple, i'm unable to add any more information from what jeremie and myself have both written on this topic. My suggestion is to recognize the behaviour that you are witnessing is standard, the values are accurate, and there is a great deal of information and educational material on the internet.
Keep in mind that the temperature voltage which you are witnessing is actually built into the STM32 ARM Microcontroller and not an external sensor - if you feel STM has issues with their chips that are being used in nearly every smart device around the world, they have a very active forum with a great community who will be able to explain in greater detail how a raw unaltered ADC reading is more accurate than your multimeter.
I would recommend learning another microcontroller and writing a small program to display ADC voltages from varying sources to witness the fluctuating values. However, you would get the same results as if using the EZ-B
As jeremie recommended, using multiple samples and averaging the values is one way to smooth a fluctuating input. However, another way that uses less processing (and how multimeters work) is to use a small capacitor to filter voltage fluctuations.
Also, I should add that many digital devices which have a DAC or PWM to simulate an adjustable voltage range will be funny with a raw ADC input. You would very much need a small capacitor on any PWM or DAC generated voltages. I imagine you can suspect why
This is actually an interesting topic for me. I've been using all available ADC ports on my EZB to monitor pots and switches on my B9. The first thing I noticed was this fluctuation and had to learn to adapt my variables in my statements to be within these swings.
I also noticed that the farther the switch or pot is from the EZB's ADC port the higher the ADC reading be (or was it lower? Cant remember now). I think it was about two to three feet of wire. Then when the switch was thrown the reading wouldn't hardly move. I figured this was due to the resistance of the wire. I solved this by bringing the switch closer the ADC port but it was a pain and a disappointment as I had to redesign. This is probably a totally different cause then what Purple is seeing but I thought is was interesting to mention in this context.
@DJ, your suggestion of a small cap is interesting and sounds like a simple solution. How would you wire this cap into the ADC circuit? Signal pin to Ground pin? Would you need to do this to each port being used where you need a steady signal?
Connect a 0.1uF capacitor from signal to ground - that will make the ADC work more like a multimeter.
As for analog sensors (i.e. accelerometers, sharp IR distance sensor, etc..) do not use a capacitor.