Filter out noise from ADC acquisitions

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm using an atmega 328p with two joysticks and I have some noise problems with the acquisitions. How can I solve it? Is it possible to solve it by software with the adc noise reduction or I need to add something in the circuit?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What is the source of the noise? Is it from AC power or synchronous with AC power, such a SCR power controllers?

 

Or, is it from relays  or motors? Or other electronic  equipment such as power supplies or radio transmitters?

 

And, how does the noise compare with what you are trying to measure? Is the noise very large, for example? Are you trying to measure an AC voltage that is similar in frequency to the noise? Or, are you measuring DC?

 

What are you using for the ADC reference? Do you have a bypass capacitor on the ADC reference pin?

 

You have to tell us a lot more before we can help.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

Last Edited: Sun. Mar 1, 2020 - 10:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am using an arduino nano to measure the value of the joysticks. The numbers I get from them continuously change around the value acquired.

I don't know which can be the source of the noise.
I am using a standard 10 bit adc with the Ref0 bit set (AVCC with external capacitor at AREF pin)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you have a decent filter cap on your ADC signal pin?   Pots are crummy & noisy if moving around...add a 0.1uF cap for starters (and perhaps a 1k ohm series resistor between the pot & avr pin).

The cap also is needed to ensure you don't have noise coming in (signal or noise) that is aliased with the sampling rate.

 

Where is your schematic?  Why did you not provide it???

 

After you add a cap, you can also do some sample smoothing...just calc: result=  (15*result+ ADC reading)/16     ...this would be great if you are doing, say, 200 samples/sec.

 

The numbers I get from them continuously change around the value acquired.

Why are you vague about such things?  20 counts or 200 counts--give at least some sense of what you see.  A few counts (like +/-2) will be normal & expected, unless you take more aggressive design actions in every aspect of the conversion.

 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Mon. Mar 2, 2020 - 12:11 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It MAY be necessary to do some filtering because there will typically be a little noise, even when measuring a good, stable, DC source. Potentiometers are typically worse. Some sort of running average or a simple FIR low-pass digital filter should do it.

 

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I tried to make the average of the acquisitions and the the problem slightly  improves but the application becomes too slow (I am driving a servo for the steering of a car).

I also tried to add an low-pass filter with a 10k resistor and a 10uF cap but it makes no difference. Should I use different values? (I only have these cap at the moment). 

And what about the adc noise reduction?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

nico444 wrote:
I don't know which can be the source of the noise.

Ok, you need to show us your schematic, and a clear picture of your setup.

How does your car receive the steering info, wired or wireless?

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As mentioned above, how many counts does the ADC reading vary?

+/- a few counts is normal, and shouldn't matter for your application.

10K & 10 uF will likely not work well at all.

You need to measure the resistance of the Pots on the joystick.

As you go to the low end, the 10K will become very significant, so without some additional circuitry that is a poor design that won't do what you want it to do.

As was mentioned above, just putting a 0.1 uF cap from the ADC pin to ground would be a good start.

 

10 bits = 0-1023 counts.  If your car steering servo goes through 180 degrees then that is about 5.7 ADC counts / degree of steering position.  It could be more or less, depending upon the mechanical linkages, but use that as a starting point.  That means that if you use a direct, linear correlation between the joystick (pot) position and the steering angle you have an 11 ADC count spread to bounce between and specific steering angle and the adjacent angle, (+/- 1 degree). 

If, merely as an example, your ADC count was Noisy / bouncing around +/- 2 counts, then the actual value will occasionally be right on the border between two different steering angles.  So the control algo will always have (for this type system) some fine +/- 1 degree "jitter".  It is inherent to the hardware design.

 

Now put that in perspective for the real world application.  If your car is driving around, you has a human using visual tracking of the moving car can't distinguish 1 degree steering increments, and your brain / vision / hand don't make for a very precise PID controller, so some jitter in the system is insignificant for this application.

 

Next realize that your hand can't hold the joystick (pot) position perfectly still, even for testing.  The mechanical leverage on the joystick is significant, so the pot wiper will be moving a bit even when you think you are holding it still.  This problem is made worse if the pot is wire wound, although I'd think that most joysticks would use a composite band resistive element.

 

For testing your software I think putting a pot on a breadboard and displaying the ADC counts on an LCD or a PC terminal program would be a good approach.  You want to do your testing on a truly stationary pot, not one that is spring loaded.

 

Sounds like a fun project.

 

 JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why are you vague about such things?  20 counts or 200 counts--give at least some sense of what you see.  A few counts (like +/-2) will be normal & expected, unless you take more aggressive design actions in every aspect of the conversion.

 

 add an low-pass filter with a 10k resistor and a 10uF cap but it makes no difference

 

Saying adding 10k & 10uF makes no difference does not make a lot of sense, since that is a very long 100ms time constant...exactly how did you have it wired....a schematic is necessary for further help.   Ensure your RC is at the adc pin.  10k  is a bit high for the ADC, 1k would be preferable.  what size of pot are you using?  It must also be 10k or less and the wiper will feed your RC.  The values you mentioned should be 99.9% noise free, but will be too sluggish.  However, you should not see any undulations--so how can you say you see no difference?

Are you sure your ADC Vref is set properly?  Does the Vref pin have a cap to gnd?

 

I tried to make the average of the acquisitions and the the problem slightly  improves but the application becomes too slow 

That is also somewhat nonsensical.  problem slightly  improves ...what exactly do you mean?      You can do an exponential filter like:  result=  (15*result+ ADC reading)/16 & take a few hundred (to even 1000) readings a second....it will be relatively fast responding.  How slow/fast do you need?  

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Mon. Mar 2, 2020 - 04:18 PM