acinonix14
Junior Member
Offline
Posts: 53
Thank You
-Given: 71
-Receive: 253
|
|
« on: March 28, 2015, 07:47:16 07: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
Posts: 1203
Thank You
-Given: 553
-Receive: 409
|
|
« Reply #1 on: March 28, 2015, 08:06:54 08: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
Posts: 123
Thank You
-Given: 34
-Receive: 152
|
|
« Reply #2 on: March 28, 2015, 08:21:38 08: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
Posts: 10
Thank You
-Given: 127
-Receive: 5
|
|
« Reply #3 on: March 28, 2015, 04:34:43 16: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.pdfAnd thanks for this advice, i need it also in my project. Fab
|
|
« Last Edit: March 28, 2015, 04:38:25 16:38 by Fab66 »
|
Logged
|
|
|
|
Gallymimu
Hero Member
Offline
Posts: 704
Thank You
-Given: 152
-Receive: 214
|
|
« Reply #4 on: March 28, 2015, 05:49:32 17: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
Posts: 833
Thank You
-Given: 312
-Receive: 392
|
|
« Reply #5 on: March 28, 2015, 07:30:02 19: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
Posts: 99
Thank You
-Given: 154
-Receive: 119
|
|
« Reply #6 on: March 29, 2015, 01:47:28 01: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
Posts: 99
Thank You
-Given: 154
-Receive: 119
|
|
« Reply #7 on: March 29, 2015, 03:22:54 03: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.htmIn the same page you can also download programs and other documents as exercises.
|
|
« Last Edit: March 30, 2015, 02:43:10 14:43 by PeterMcMonty »
|
Logged
|
That\'s not a bug, it\'s a feature!
|
|
|
Gallymimu
Hero Member
Offline
Posts: 704
Thank You
-Given: 152
-Receive: 214
|
|
« Reply #8 on: March 29, 2015, 07:03:51 19: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.htmIn 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
|
|
|
|
|
iot
Newbie
Offline
Posts: 16
Thank You
-Given: 32
-Receive: 13
|
|
« Reply #10 on: March 30, 2015, 03:34:19 03: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
Posts: 704
Thank You
-Given: 152
-Receive: 214
|
|
« Reply #11 on: March 30, 2015, 04:01:06 04: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
Posts: 53
Thank You
-Given: 71
-Receive: 253
|
|
« Reply #12 on: March 30, 2015, 01:52:48 13: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
Posts: 23
Thank You
-Given: 4
-Receive: 9
|
|
« Reply #13 on: March 30, 2015, 04:05:00 16: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
Offline
Posts: 35
Thank You
-Given: 7
-Receive: 16
|
|
« Reply #14 on: April 20, 2015, 08:24:10 20: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
Posts: 23
Thank You
-Given: 3
-Receive: 12
|
|
« Reply #15 on: May 05, 2015, 11:16:54 11: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
Posts: 53
Thank You
-Given: 71
-Receive: 253
|
|
« Reply #16 on: May 06, 2015, 05:24:11 05: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
Posts: 168
Thank You
-Given: 64
-Receive: 37
|
|
« Reply #17 on: May 06, 2015, 02:54:14 14: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
Posts: 23
Thank You
-Given: 3
-Receive: 12
|
|
« Reply #18 on: May 13, 2015, 04:07:16 16: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
Posts: 168
Thank You
-Given: 64
-Receive: 37
|
|
« Reply #19 on: May 13, 2015, 09:21:49 21: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
Posts: 230
Thank You
-Given: 3807
-Receive: 834
|
|
« Reply #20 on: May 14, 2015, 09:28:09 09:28 » |
|
Hi,
I think this document explain how get more resolution for an ADC by using oversampling.
Best regards.
|
|
|
Logged
|
|
|
|
Vineyards
Active Member
Offline
Posts: 168
Thank You
-Given: 64
-Receive: 37
|
|
« Reply #21 on: May 14, 2015, 08:15:14 20: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
Posts: 146
Thank You
-Given: 7
-Receive: 42
|
|
« Reply #22 on: May 15, 2015, 09:00:57 21: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
Posts: 168
Thank You
-Given: 64
-Receive: 37
|
|
« Reply #23 on: June 02, 2015, 09:42:59 21: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
Posts: 29
Thank You
-Given: 9
-Receive: 60
|
|
« Reply #24 on: June 04, 2015, 05:50:29 05: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
|
|
|
|
|