Asked — Edited
Resolved Resolved by Rich!

Noisy Analog Dat On The V4

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.


ARC Pro

Upgrade to ARC Pro

ARC Pro will give you immediate updates and new features needed to unleash your robot's potential!

#1  

EZB4 has a built in voltage and cpu temp control.... No need to use analog and a separate voltage meter... Not sure what you mean by noisy... what are the 5 analog sensors and what type of interference are they causing?

United Kingdom
#2  

Do you have any pull down resistors between signal and ground?

#3  

The reason you would use an external one is if you are using say a 7.4v battery, then limiting the input into the ezb using something like an ubec. You would do this if you have only 5v devices and don't want to limit after the ezb to every device. This kills the ability of the V4 to monitor power. Nothing against the v4, just a robot design thing.

An option would be to build a power distribution panel and have the ubec in line before this panel that you would use for devices and power the V4 off of the battery directly. This would allow the power monitoring in the V4 to work and allow you to ditch the other device.

#4  

.... Check your analog sensors to see if they can operate below 5v as the V4 analog output pin is 3.3V... I had an issue with a cheap PIR sensor and my V4 board because it needed 5v....

PRO
Synthiam
#6  

What do you mean noisy?

#7  

I think he means he plugged it up to a occilliscope and sees "noise" through the connections. But if wires are not shielded and grounded they are always going to have some. I guess we will wait for a better explanation.

#8  

Thanks for all the replies. What I mean by noise is unwanted signal. For example on the V4 window that shows battery voltage and cpu temp, on mine the numbers are not steady. My battery is at 12.51 volts and steady on my multimeter but on the V4 information window it changes at each update from about 12.33 to 12.61, this is the noise. The cpu temperature is a little jittery too. Thanks for all the help.

#9  

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....

United Kingdom
#10  

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?

PRO
Synthiam
#11  

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.

#12  

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.

PRO
Canada
#13  

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.

PRO
Synthiam
#14  

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 :)

#15  

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?

PRO
Synthiam
#16  

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.

United Kingdom
#17  

The Sharp IR sensors work perfectly fine with very little fluctuation, at least mine do. Yes there is some fluctuation in the readings but it's minimal.

My old battery monitor wouldn't have much fluctuation either but the script for this used ranges rather than specific values (i.e. battery percentage 100%, 80%, 60% etc.) so I guess I wouldn't have even noticed the fluctuation in the voltage.

#18  

I was also going to say something similar to what Rich said... All my analog sensors (Various sharp IRs, PIR and potentiometers) that I use work perfectly... I guess I don't need the precise resolution that Purple does....

PRO
Synthiam
#19  

It's not that @Purple needs precision. Because he is taking ADC readings from potentiometers and unusual sources for "testing", there is further understanding required to know what the readings are - and why the readings are what they are. Google searches will help understand why ADC will return fluctuating voltages. This is because they are indeed, fluctuating :)

The question should not be "EZ-B has noisy ADC"... The question should be "EZ-B v4 has very accurate ADC"

#20  

@DJ Ha, Ha.... See what happens when you make things too good?... That'll learn ya'... I do notice the difference between quality analog sensors vs cheap (I'll say it) Chinese ones.... For instance a $11 Parallax PIR detector is rock solid compared to $1.97 eBay Chinese equivalent... In fact I ended up buying a bunch of Parallax PIRs and just threw out the Chinese ones...

#21  

Ok, let me try another way. On my V3s I have fluctuations on the analog inputs. I have potentiometers connected to them and to filter the noise I put 47microfarad caps between the input pins and ground. This works perfectly. Now on my V4 there is no way to filter this noise. I have tried. Any suggestions on how to get my analog inputs on my V4 to perform as well as they do on my 2 V3s ?

PRO
Synthiam
#22  

To get your v4 to perform as bad as the v3, I would recommend trying a variety of caps - and a few google searches. Please read my previous post with google links :)

#23  

Ok, I will do that. Thanks for the help.

United Kingdom
#24  

Take multiple readings and find the average is my advice if you want to avoid using capacitors to smooth out the fluctuations in the readings.

$reading1 = GetADC(ADC0)
Sleep(10)
$reading2 = GetADC(ADC0)
Sleep(10)
$reading3 = GetADC(ADC0)
Sleep(10)
$reading4 = GetADC(ADC0)
Sleep(10)
$reading5 = GetADC(ADC0)
Sleep(10)
$reading6 = GetADC(ADC0)
Sleep(10)
$reading7 = GetADC(ADC0)
Sleep(10)
$reading8 = GetADC(ADC0)
Sleep(10)
$reading9 = GetADC(ADC0)
Sleep(10)
$reading10 = GetADC(ADC0)

$reading = Round((($reading1 + $reading2 + $reading3 + $reading4 + $reading5 + $reading6 + $reading7 + $reading8 + $reading9 + $reading10)/10), 2)

Print("ADC Value: " + $reading)
#25  

Wow @Rich, you just saved me a stressful hour or two resurrecting my math skills. I was just going to sit down and try to write this same script. Thanks!

#26  

Thanks Rich, I'll be sure to give this a try.

United Kingdom
#27  

I could have done it a quicker way too by making a loop that goes around 10 times adding the ADC value each time then diving it at the end... But I wrote that without thinking too much.

This is a more economical method.


$x = 0
$ADCValue = 0
RepeatUntil($x = 10)
$x++
$ADCValue = $ADCValue + GetADC(ADC0)
Sleep(10)
EndRepeatUntil
$ADCValue = Round($ADCValue/10,2)

Print("ADC: " + $ADCValue)

You could, if you wanted to, increase the number of readings easily by changing the 10 in the repeatuntil and the 10 in the $ADCValue = Round($ADCValue/10,2)

You could also go for more or less decimal places by changing the 2 in the Round($ADCValue/10,2)

You may even be able to remove or reduce the sleep(10) or increase it if you aren't checking every 100ms.