Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 15, 2019, 05:38:10 17:38


Login with username, password and session length


Pages: 1 2 [All]
Print
Author Topic: Read A/D avr values in noisy enviroments  (Read 4112 times)
0 Members and 1 Guest are viewing this topic.
acinonix14
Junior Member
**
Offline Offline

Posts: 53

Thank You
-Given: 67
-Receive: 253


« on: March 28, 2015, 01:47:16 01:47 »

Hi,

I have develop a simply thermometer (PS:5V) with avr and ntc resistor 4.7K through voltage divider.
I am using the A/D channel of avr and use the Steinhart-Hart Method.This works perfectly.

However when I put it close to a/c line 220V without any connection with the line, the measured value is not steady.
Of course the temperature is not changed, so I think the A/C line creates extra parasite noise and the avr measures this?

Any ideas how to cut this noise?

Thanks,
Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1073

Thank You
-Given: 324
-Receive: 384



« Reply #1 on: March 28, 2015, 02:06:54 02:06 »

Try placing a 10Uf cap across the A/D pin and GND or a 100N cap and see if that helps
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
wellnerson1
Active Member
***
Offline Offline

Posts: 117

Thank You
-Given: 25
-Receive: 135


« Reply #2 on: March 28, 2015, 02:21:38 02:21 »

Try with a soft filter, a simple one like moving average filter. It will give good results under noisy environs.
Logged
Fab66
Newbie
*
Offline Offline

Posts: 8

Thank You
-Given: 94
-Receive: 4


« Reply #3 on: March 28, 2015, 10:34:43 10:34 »

Try with a soft filter, a simple one like moving average filter. It will give good results under noisy environs.

Hi, you can found more information here :

http://www.analog.com/media/en/technical-documentation/dsp-book/dsp_book_Ch15.pdf

And thanks for this advice, i need it also in my project.

Fab
« Last Edit: March 28, 2015, 10:38:25 10:38 by Fab66 » Logged
Gallymimu
Hero Member
*****
Offline Offline

Posts: 689

Thank You
-Given: 151
-Receive: 203


« Reply #4 on: March 28, 2015, 11:49:32 11:49 »

An analog filter with a BIG capacitor like the suggested 10uF as well as a low frequency moving average filter can work wonders for you.  Be careful as the moving average filter won't help much if it doesn't have a cutoff frequency below 50/60Hz so it is very sampling rate dependent.  i.e. if you are sampling at 1KHz then you would want a 128 point moving average filter to have a cutoff well below the line frequency.  A power of 2 filter is always a great way to go since you can summ and then just bit shift, it makes for a fast filter.

Also you could consider a digital notch filter at the frequency you want to take out.  There are IIR and FIR implementations of notch filters you could try, but if you don't have any DSP background it could be confusing to understand what it's doing.
Logged
Ichan
Hero Member
*****
Offline Offline

Posts: 833

Thank You
-Given: 312
-Receive: 387



WWW
« Reply #5 on: March 28, 2015, 01:30:02 13:30 »

PCB layout also play important role on induced noise, and try to shield your thermometer device.

-ichan
Logged

There is Gray, not only Black or White.
PeterMcMonty
Junior Member
**
Offline Offline

Posts: 99

Thank You
-Given: 154
-Receive: 119



« Reply #6 on: March 28, 2015, 07:47:28 19:47 »

I agreed with almost everybody: filter, filter and filter furthermore! Both analog (an RC lowpass is of great value in its simplicity) and digital!

Another hint: temperature variations are so slow that the filter cutoff frequency could be as low as 1 Hz, making possible a huge attenuation at 50-60 Hz. Keep the filter as close as possible to the AD converter input and keep care of PCB layout, as suggested by Ichan.

On my experience, a good average done in software helps furthermore. Depending on your application, but I don't think it should necessary be a running average.

You could take, for example, the sum of 256 measures on a two or three bytes variable and then simply discard the last significant byte.

A refinement could be rounding to the nearest integer:
if the MSB of the discarded byte is 1 then increment the result by one else continue.
Logged

That\'s not a bug, it\'s a feature!
PeterMcMonty
Junior Member
**
Offline Offline

Posts: 99

Thank You
-Given: 154
-Receive: 119



« Reply #7 on: March 28, 2015, 09:22:54 21:22 »

BTW, thanks to Fab66 for linking chapter 15 of that dsp book (obsolete in the site of Analog Device, but you can reach chapters 1 to 33 simply by changing name of pdf at the end of address line in your browser).

For those who are interested in that book, that is:

The Scientist and Engineer's Guide to Digital Signal Processing
By Steven W. Smith, Ph.D.

you can read and/or download all the chapters from 1 to 34 (yes, chapter 34 is not on Analog Device website or it has a different filename) from this page, that is the download page of the book, I think owned by the author himself:

http://www.dspguide.com/download.htm

In the same page you can also download programs and other documents as exercises.
« Last Edit: March 30, 2015, 08:43:10 08:43 by PeterMcMonty » Logged

That\'s not a bug, it\'s a feature!
Gallymimu
Hero Member
*****
Offline Offline

Posts: 689

Thank You
-Given: 151
-Receive: 203


« Reply #8 on: March 29, 2015, 01:03:51 13:03 »

BTW, thanks to Fab66 for linking chapter 15 of that dsp book (obsolete in the site of Analog Device, but you can reach chapters 1 to 33 simply by changing name of pdf at the end of address line in your browser).

For those who are interested in that book, that is:

The Scientist and Engineer's Guide to Digital Signal Processing
By Steven W. Smith, Ph.D.

you can read and/or download all the chapters from 1 to 34 (yes, chapter 34 is not on Analog Device website or it has a different filename) from this page, that is the download page of the book, I think owned by the author himself:

http://www.dspguide.com/download.htm

In the same page you can also download programs and other documents as exercises.

Hey that is a GREAT resource!!  The chapters are concise and seem pretty well organized with relevant figures.
Logged
Magnox
Active Member
***
Offline Offline

Posts: 229

Thank You
-Given: 894
-Receive: 257


Oink!


« Reply #9 on: March 29, 2015, 02:31:31 14:31 »

I have that book in my collection in a single pdf...

http://www.sonsivri.to/forum/index.php?topic=59992

now it's here.
Logged
iot
Newbie
*
 Muted
Offline Offline

Posts: 16

Thank You
-Given: 32
-Receive: 13


« Reply #10 on: March 29, 2015, 09:34:19 21:34 »

In some AVRs there is an option to sleep the MCU to reduce the noise during ADC phase.

Have you tried with that option?
Logged
Gallymimu
Hero Member
*****
Offline Offline

Posts: 689

Thank You
-Given: 151
-Receive: 203


« Reply #11 on: March 29, 2015, 10:01:06 22:01 »

In some AVRs there is an option to sleep the MCU to reduce the noise during ADC phase.

Have you tried with that option?

That is likely not his problem since the noise was only an issue when he was near line voltages.
Logged
acinonix14
Junior Member
**
Offline Offline

Posts: 53

Thank You
-Given: 67
-Receive: 253


« Reply #12 on: March 30, 2015, 07:52:48 07:52 »



Gallymim
An analog filter with a BIG capacitor like the suggested 10uF as well as a low frequency moving average filter can work wonders for you.  Be careful as the moving average filter won't help much if it doesn't have a cutoff frequency below 50/60Hz so it is very sampling rate dependent.  i.e. if you are sampling at 1KHz then you would want a 128 point moving average filter to have a cutoff well below the line frequency.  A power of 2 filter is always a great way to go since you can summ and then just bit shift, it makes for a fast filter.

Also you could consider a digital notch filter at the frequency you want to take out.  There are IIR and FIR implementations of notch filters you could try, but if you don't have any DSP background it could be confusing to understand what it's doing.
.

Is there any sample using the avr (or arduino) to build a notch filter with cutoff 60Hz? Or IIR and FIR? I am not a DSP guy but I would like to try build a filter in avr328. I make sampling every 20 msec but I can change it if its possible.

Thanks,
Logged
SteveyG
Newbie
*
Offline Offline

Posts: 22

Thank You
-Given: 3
-Receive: 9


« Reply #13 on: March 30, 2015, 10:05:00 10:05 »

If your signal source is high impedance, it's very likely to easily pick up noise from external sources. You must have an anti-aliasing filter prior to the ADC, then sample the ADC at a high enough rate that you can filter the out of band signals and have them contribute to less than 1/2 LSB error.

In very noisy environments, a single pole filter will not be sufficient unless you can sample at 100's of kHz.
Logged
mris99
Junior Member
**
 Warned
Offline Offline

Posts: 38

Thank You
-Given: 7
-Receive: 16


« Reply #14 on: April 20, 2015, 02:24:10 14:24 »

Don't forget to filter also the analog power line (AVCC) thus it can also pickup noise.
Serial 10uH / parallel 100nF for example.
It is more important if you direct derive reference voltage from that (Vref = AVCC).
Logged
Droneman1982
Newbie
*
Offline Offline

Posts: 23

Thank You
-Given: 3
-Receive: 11


« Reply #15 on: May 05, 2015, 05:16:54 05:16 »

Try to use twisted pair leads and use a 50-60 Hz notch filter. Of course use a ground plane under your signal leads. Another possibility is to average 4^n samples obtaining n more bits (oversampling) than the ADC has.

A Low pass filter would also work, but it will slow down your response to the RC time constant of your filter. It depends on your application.

The best would be to switch to a I2C digital thermometer (following closely the board layout advised by the datasheet), this way you don't need to sample your data via the internal ADC
Logged
acinonix14
Junior Member
**
Offline Offline

Posts: 53

Thank You
-Given: 67
-Receive: 253


« Reply #16 on: May 05, 2015, 11:24:11 23:24 »

Thanks guys,

I am using an extra RC filter in input and of course put 100nF to AREF pin.

Also I got 100 samples, sort all them and from sorted values I was getting the average of 20 samples between the 40 and 60 sample. With this version I cut off the spikes. The result it is impressive (about 0.1-0.2 C degree).

Logged
Vineyards
Active Member
***
Offline Offline

Posts: 137

Thank You
-Given: 44
-Receive: 28


« Reply #17 on: May 06, 2015, 08:54:14 08:54 »

As SteveyG writes the input impedance is a very important factor. You could decide on what to use depending on:

1- Input impedance
2- Input signal level
3- Input noise level
4- Type of noise (AC, DC?)
5- Coupling type (wire, air)

There might be also be a ground loop problem that would necessitate galvanic isolation...
Logged
Droneman1982
Newbie
*
Offline Offline

Posts: 23

Thank You
-Given: 3
-Receive: 11


« Reply #18 on: May 13, 2015, 10:07:16 10:07 »

I would suggest you to use a multiple of 4 for the average

with 4 samples you "get" one extra LSB
with 16  two extra bits
with 64 tree extra bits
with 256 four extra bits
Logged
Vineyards
Active Member
***
Offline Offline

Posts: 137

Thank You
-Given: 44
-Receive: 28


« Reply #19 on: May 13, 2015, 03:21:49 15:21 »

Droneman do you have a reference for that. Based on practical experience, I would say, if there is substantial noise in the signal path, going up to 256 samples, only marginally helps with the measurement accuracy. You have to tackle the problem at its roots. Perhaps a Kalman filter might help but it does demand certain prerequisites too.
Logged
titi
Active Member
***
Offline Offline

Posts: 212

Thank You
-Given: 2301
-Receive: 785



« Reply #20 on: May 14, 2015, 03:28:09 03:28 »

Hi,

I think this document explain how get more resolution for an ADC by using oversampling.

Best regards.
Logged
Vineyards
Active Member
***
Offline Offline

Posts: 137

Thank You
-Given: 44
-Receive: 28


« Reply #21 on: May 14, 2015, 02:15:14 14:15 »

I know this document. It tells about stuff like white noise and how its presence actually improves resolution etc.
However, we are not talking about noise that will affect the LSB's here (e.g. Johnson's noise). I am talking about hefty noise and there is no easy cure for it.
Logged
vern
V.I.P
Active Member
*****
Offline Offline

Posts: 107

Thank You
-Given: 7
-Receive: 27


« Reply #22 on: May 15, 2015, 03:00:57 15:00 »

Try to make the measurement differential, not referred to GND.
If you only have a ground referred input use an Op-Amp to make a differential measurement and output a Ground referred voltage to your AD converter.
That helps a lot. I would also try to make the measurement rate an exact multiple of your AC Line frequency,
i.e if your line frequency is 50 Hz you would make the rate 5 Hz, 10Hz, etc.
The two frequencies will drift apart after a while, but for the short term this will keep the noise down since your measurement will always be in sync to the AC sine wave.
Logged
Vineyards
Active Member
***
Offline Offline

Posts: 137

Thank You
-Given: 44
-Receive: 28


« Reply #23 on: June 02, 2015, 03:42:59 15:42 »

However, differential inputs have strict limitations on allowable input signal levels and if your noise problem is not moderate to small, you might damage the inputs. Use a LP filter made with two resistors hooked up to the inputs. Place three capacitors one between the differential inputs and the other two between either input and ground. Make the one in the middle 10 times greater than the value of the other two capacitors. (of course you need to calculate values) This the way to build a simple filter stage for differential amplifiers. If you are dealing with a high Z signal, you might as well forget about differential inputs or use the expensive INA series opamps.
Logged
bytraper
Newbie
*
Offline Offline

Posts: 14

Thank You
-Given: 6
-Receive: 20


« Reply #24 on: June 03, 2015, 11:50:29 23:50 »

Could you possibly use a diode and cap and take average samples? Or possibly run dual inputs routed in parallel with filtering with use some logic as a buffer? We deal with this all the time in motor control boards as the back emf plays havok with the surrounding sensitive parts!
Logged
Vineyards
Active Member
***
Offline Offline

Posts: 137

Thank You
-Given: 44
-Receive: 28


« Reply #25 on: June 04, 2015, 02:24:17 02:24 »

Are you talking about snubber diodes? A LP filter does averaging anyway. In my opinion, there is not a magical solution that answers all the questions. As I wrote before, it depends on signal characteristics environment etc.

For example, diodes are leaky components. They will effectively short a High Z signal if they are used as clamp etc. You need a buffer but then how will you protect the buffer. If it is an opamp you could put resistors on the input and if it is a voltage follower you could place a resistor between  non-inverting input and output rather than shorting these two. This way you could prevent excessive current flow through that component.

Posted on: June 04, 2015, 09:22:31 09:22 - Automerged

If problems persist, you need to galvanically isolate input from the rest of the circuit and the known methods for that are optical, inductive, capacitive isolation (ic's) as well as V/F, F/V converters.
Logged
Vineyards
Active Member
***
Offline Offline

Posts: 137

Thank You
-Given: 44
-Receive: 28


« Reply #26 on: June 04, 2015, 06:23:09 06:23 »

Check out this link. There you can choose an opamp and see if it will work within desired voltage levels: http://analogplayground.com/diamond/
Logged
2N5109
Junior Member
**
Offline Offline

Posts: 65

Thank You
-Given: 26
-Receive: 14


« Reply #27 on: October 26, 2015, 08:24:38 20:24 »

Put 100uF capacitor across ntc 4.7k resistor. The noise is driving the ADC nonlinear so DSP filtering is not effective. Also need to determine if magnetic or electric field of AC 60 Hz is being pickupped. Could try metal shield around resistor+avr.
    --2N5109
Logged
kreutz
Active Member
***
Offline Offline

Posts: 129

Thank You
-Given: 403
-Receive: 110


« Reply #28 on: October 27, 2015, 09:11:58 09:11 »

The complete DSP book (2nd Edition), mentioned early in the thread,  is in here:
 
http://ft-sipil.unila.ac.id/dbooks/The%20Scientist%20and%20Engineer's%20Guide%20to%20Digital%20Signal%20Process.pdf
Logged
2N5109
Junior Member
**
Offline Offline

Posts: 65

Thank You
-Given: 26
-Receive: 14


« Reply #29 on: December 01, 2015, 08:21:57 20:21 »

Current in 220v AC circuit is probably relatively high and coupling voltage into ADC input via its magnetic field and flux, v=-d(phi)/dt.  We need to know more about circuit arrangement. At low frequencies of 50 Hz, conductive shielding is not effective against magnetic fields, and probably interferes with whatever temperature measurement you make.

You could try to reduce  flux (INT(B*dA)) by considering the area that magnetic field is operating on and reducing it by putting wires close together.  Twisting them so there is cancellation in net integral will help also. It is difficult to know unless there is more detail description of problem.  

Attacking the problem at the source is important in this case since large induced voltage from 220VAC line could cause nonlinear response in the ADC which cannot be filtered by linear means described above.

--2N5109    
Logged
witsanukai
Junior Member
**
 Muted
Offline Offline

Posts: 36

Thank You
-Given: 13
-Receive: 7


« Reply #30 on: January 06, 2016, 02:02:19 02:02 »

Can refer to below document too.

http://www.st.com/web/en/resource/technical/document/application_note/CD00211314.pdf

but almost on power line noise induce just apply 0.1uF capacitor at AVCC and ADC input and also implement moving average problem must disappear base on my experince.
Logged
Vineyards
Active Member
***
Offline Offline

Posts: 137

Thank You
-Given: 44
-Receive: 28


« Reply #31 on: January 09, 2016, 06:05:41 18:05 »

Could you possibly use a diode and cap and take average samples? We deal with this all the time in motor control boards as the back emf plays havok with the surrounding sensitive parts!
Are you talking about snubber diodes? I think a simple LP filter would be a better choice for analog measurement circuits. However as mentioned earlier everything depends on what you want to measure. The difficulty here being, as input resistance and capacitance increase it becomes more and more difficult to put anything between the signal and the input. Because most components are tremendously leaky when high Z is involved. Even the high input capacitance or low input resistance of an opamp makes it unfeasable for use in high Z applications. For example, a typical pH probe produces 414mV which is not a very low level signal however as the current from the pH probe is usually in the femtoampere range, you can not measure it correctly if you use an opamp having too high a Input bias current, or capacitance or too low resistance as much or all of the energy that is output will be leaked to the ground (or wherever) causing faulty measurements. Under such conditions it will take ages for the measurement stabilize if it ever can.

As a result leakage rate of a component will become very important. Diodes are particularly notorious for being leaky components so are electrolyte condensers.
Logged
Pages: 1 2 [All]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC