??? 03/10/12 13:49 Read: times |
#186554 - options, options Responding to: ???'s previous message |
"My qus. is: what is outcomes if i will not use full dynamic range? "
Already covered. Loss of resolution. You thow away your "best" bit of the ADC. This making you more dependant on the "worst" (least significant) bit of the ADC. It's the least significant bits that contains the noise, and the non-uniform stair steps. "But I will try to increase DC level upto 1.36 V and check it " Why 1.36V? Why not 3.3/2 = 1.65V? "how to take samples?" How to take samples should be obvious. Start a conversion. Wait. Get result. It is totally separate from how many samples or how often. But the DC component can be either computed by simplify everything and take the middle value of the highest and lowest samples you get. Obivously requiring you to sample often enough that you do catch both the minima and maxima with reasonable precision. Or you can perform many samples through one or more full periods and compute the DC level using mean-square or other methods. "Every 20mS/1023 = 19uS " Why something odd like 1023 samples/period? Wouldn't it be better to have a sampling speed of 20ms / 2^10? That would mean that you do 1024 samples * number of periods. And that if first sample is on a "zero-crossing", then the last sample is one sample interval before a "zero-crossing" n periods later. By the way - where did you get the value 1023 from? Have you used a pocket calculator (or a tiny PC program) and figured out that your required precision do require 1024 samples/period? Or did you just pick a value randomly? Set up a table where you compute the amount of error if you do 128, 256, 512, 1024 samples/period. Or maybe 419 samples/period if you like more odd counts ;) Don't pick numbers randomly. Make sure there is a formula somewhere showing that you really need a specific sample speed. And that you then selects the best sample speed (taking clock frequency, timer divisors etc into account) that fulfills your requirements. Obviously - many samples are needed if you have a ADC with lots of resolution (and well calibrated) and you want to take full advantage of this to get a high precision. If you have bad precision in the hardware or bad resolution of the ADC, then it isn't meaningful to sample fast. The resulting errors will still be dominated by the calibration, noise, sampling errors etc. "how to use adc measurement in background. i have to check in my MCU. " Both internal and external ADC normally support that you start a conversion and then have the processor do something else until there is an interrupt that signals that the ADC conversion has finished and a value can be picked up. "I will check Zero crossing before DC level Adding for Refernce so we can know at which place i can take SAMPLES. " But that can introdue a measurement error. What if your zero-detection detects at +5mV? Then you have potentially introduced (depending on what type of measurements/calculations you do) a DC offset error of 5mV. A hw zero-crossing detection is best for catching the frequency if the input signal. But not always usable for measuring amplitude or rms. Another thing you can consider, if your program is not fast enough, but the AC signal is changing amplitude very slowly, is to subsample the signal. So you sample 100 samples from one period of the signal. Then you sample 100 samples from next period, but with a time offset (maybe 1/4 sample interval) Then you sample 100 samples from third period, but with twice as large time offset. Then you sample 100 samples from fourth period, but with three times as large time offset. Now you have 400 samples that are evenly spread around one period of the signal. The data would represent the "average" of four full periods, so there is a bit of extra delay in the output result. But it is possible to perform this calculation continuously, i.e. every full period you throw away 100 samples and make 100 new samples, and produce a full measurement result every full period. There are an almost infinite number of ways to measure. But your flowchart (that you have already done) should tell you one solution - have you implemented code according to that flowchart yet? What was the result? |