Author Topic: Noise in reading data for adc, microcontroller  (Read 2863 times)

0 Members and 1 Guest are viewing this topic.

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
Noise in reading data for adc, microcontroller
« on: November 18, 2014, 11:23:49 am »
1. I have to read Current transformer reading. CT has both +ve & -ve peaks so I have level shifted the value to 2.5V. As in attached circuit.

2. CT has 50Hz waveform & below is my algo.

Code: [Select]
1. Init adc
2. Init timer
3. start timer for 1ms
4. take adc reading & store result in array
5. wait while timer set in step 3 expired
6. repeat step 3 to 5 , 20 times for 50Hz
7. in array check for highest reading. This is the peak reading

3. Attached is my circuit.

4. Problem is there is noise in reading. For same input value i.e CT output, microcontroller reading shows huge variation.
However if I try by connecting external potentiometer reading is stable. So I think no problem on MCU side.

5. Problem is on external circuit. How to remove noise there , can I connect filter capacitor across ac signal??
Cannot add opamp since circuit is cost sensitive.
 

Offline Paul Price

  • Super Contributor
  • ***
  • Posts: 1419
Re: Noise in reading data for adc, microcontroller
« Reply #1 on: November 18, 2014, 04:21:40 pm »
Yikes, could be spikes.
A scope will tell the story.

If noise, can be fixed by adding R-C lowpass filter from output of CT to A2D input  to  limit -3dB bandwidth to <100Hz.

 

Online macboy

  • Super Contributor
  • ***
  • Posts: 2256
  • Country: ca
Re: Noise in reading data for adc, microcontroller
« Reply #2 on: November 18, 2014, 04:25:50 pm »
A 0.1 uF cap after the 1k resistor will give you a RC (one pole) filter at about 1600 Hz. This will remove high frequency noise without affecting the accuracy at 50 Hz.

You can also try filtering digitally. The simplest way is to average multiple readings. You can either just add up several measurements per reading (and optionally scale the result depending what you need to do next), or keep a running average.

Keep in mind that with only 10 samples per half-cycle, you are unlikely to capture the actual peak of the sine, and you will absolutely have variation in the measurement depending on exactly where the peak sample landed on the sine wave.
 

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
Re: Noise in reading data for adc, microcontroller
« Reply #3 on: November 19, 2014, 05:17:22 am »
Adding a 0.1U cap solved the problem. Now reading is stable

@macboy: you said that 10samples per half cycle I can miss the peak. How to calculate the optimum sampling rate for 50Hz signal
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Noise in reading data for adc, microcontroller
« Reply #4 on: November 19, 2014, 10:11:46 am »
The minimum sample rate is twice the highest frequency you want to measure.
If you want to detect short spikes, you'd need a very high samplerate.
Get the pulse width of the shortest expected spike, get at least two samples in that duration.

If you want to measure 50 Hz sine, you can theoretically use 100 Hz with a digital low pass.
But, 1 KHz for a few sine periods should work fine for easy measuring. If you can accommodate the memory/processing demand.

When you know your samplerate, you can create an RC filter, (use available tools on the net) and a opamp voltage buffer to your adc.
You cannot sample an CT directly, because the ADC impedance is too low. (most likely less than <50k, and you'd need to charge internal 5 to 10 pf hold buffer each sample)
« Last Edit: November 19, 2014, 10:16:40 am by Jeroen3 »
 

Online macboy

  • Super Contributor
  • ***
  • Posts: 2256
  • Country: ca
Re: Noise in reading data for adc, microcontroller
« Reply #5 on: November 19, 2014, 02:25:27 pm »
Adding a 0.1U cap solved the problem. Now reading is stable

@macboy: you said that 10samples per half cycle I can miss the peak. How to calculate the optimum sampling rate for 50Hz signal
As fast as possible.  8)

Actually, if you really want the peak, then use an analog peak detector (which will output the peak value of the input), and sample that with the microcontroller.

But if you are getting good enough results now, then don't worry about it.
 

Offline Vindhyachal.taknikiTopic starter

  • Frequent Contributor
  • **
  • Posts: 487
Re: Noise in reading data for adc, microcontroller
« Reply #6 on: November 21, 2014, 06:17:27 am »
Schematic as in my post #1, with 0.1uF at input with 1Khz sample i.e 20 times more than input signal freq.
This is working for me
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf