Noise in reading data for adc, microcontroller - Page 1
Forum section: electronics / beginners

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: November 18, 2014, 11:23:49 am
content: 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:1. Init adc2. Init timer3. start timer for 1ms4. take adc reading & store result in array5. wait while timer set in step 3 expired6. repeat step 3 to 5 , 20 times for 50Hz7. in array check for highest reading. This is the peak reading3. 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.

author: Paul Price
author_rank: Super Contributor
timestamp: November 18, 2014, 04:21:40 pm
content: 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.

author: macboy
author_rank: Super Contributor
timestamp: November 18, 2014, 04:25:50 pm
content: 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.

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: November 19, 2014, 05:17:22 am
content: 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

author: Jeroen3
author_rank: Super Contributor
timestamp: November 19, 2014, 10:11:46 am
content: 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)

author: macboy
author_rank: Super Contributor
timestamp: November 19, 2014, 02:25:27 pm
content: Quote from: Vindhyachal.takniki on November 19, 2014, 05:17:22 amAs fast as possible.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.

author: Vindhyachal.takniki
author_rank: Frequent Contributor
timestamp: November 21, 2014, 06:17:27 am
content: 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