Go Down

Topic: Question regarding resolution (Read 2 times) previous topic - next topic


Two simultaneus samples will only give you an increased precision of 0.5LSB (half a bit). The following Atmel application note sheds some light on the topic of oversampling.


The map function does not increase precision in any way whatsoever. This is the simple equivalent of two lines of code to scale and offset a value.

Despite popular belief, using floats is typically faster and more efficient than using long integers on 8 bit RISC micros. Computation time is proportional to bits of precision and for longs you have 32 vs floats 24. There is an initial code size overhead of linking the float core library, but using floats typically simplifies calculatuions when the extended precision is required.


Hi BenF and thanks for replying.

I'm not sure how this is oversampling... the Arduino is sampling two different signals (voltage and current), the product of which is power. Multiplying the two respective resolutions (LSB of current and voltage) is how I got to the power resolution.

Thanks also re: the note on float calculations. One way that the external ADC will simplify things in the future is that the voltage and current are measured simultaneously, eliminating phase lag. That in turn removes some of the calculations that the Atmega has to engage in to calibrate the phase signals - as the Atmega ADC has to alternatively sample each signal, introducing phase shift.


Resolution in terms of measurement is defined as the smallest change you can detect and is related to precision. When we combine two measurements (as in V*A for W), resulting resolution is the product of the measurement's respective precision (say 2LSB * 2LSB = 4LSB). That is, you can not trust the lower bits of your computed result.

To improve resolution/precision for your power meter, you will need to improve precision of the individual samples. One way to go is oversampling as outlined in the Atmel application note I referenced above. It is typically always preferred to oversample when precision is important and so sampling rate is as essential as bits per sample.

If you want use an external ADC, you may want to look for a component that can do differential input and use an external voltage reference.  This would allow you to use the full range of the ADC (say 12 bits for the 4V range from 0.5V to 4.5V).

Accuracy again is a different animal altogether as it defines how your final result relates to the real world. This depends on additional specifications such as linearity, variations across temperature, voltage reference stability and so forth. A careful choice of components may improve on this, but typically at a significant cost.


Spot on.

The original reason to go to an external ADC was the phase shift issue as well as the question how accurate the ADC in the Atmega really is. I figured that if I lost a LSB here or there from a 12 bit signal that it would impact measurements far less than if it happened to a 10 bit ADC. Plus, I could be more generous with the range that the ADC can sample if there are more bits to play with in the first place. That is, it is not as important to exactly match the electrical ranges of signal and ADC when you have spare bits, something that helps with allowing signals that may exceed spec for whatever reason.

My current design includes a 150V MOV and 1A slow-blow fuse. The thought being that significantly higher voltages will cause the MOV to do the marimba and blow the fuse.  But I may change some of the resistor values around to allow the system to sample up to 230Vrms signals, and then add a safety margin on top of that. All AC components are actually rated for 230V use (the transformer for voltage measurements, the current transformer, as well as the on-board power supply). Thus, I would be able to use the power board for 3-wire 230V as well, a nice to have for the rare instances where it is needed. Thing is, even a 16 bit accurate resolution on the product of voltage and current would resolve to less than 0.1W on a 5000W signal.

While I could use decimation to smooth out noise and improve accuracy further, the numbers get pretty big at high sampling rates (about 6,000/s are planned) and averaging may be the way to go. Previous attempts at decimation with large numbers and high sampling rates required me to keep track of the values inside the accumulators, then subtract large numbers that were easily divisible as the limits of the unsigned long range were approached. Can be done, but it's easier to implement on a 8 bit microprocessor if one only has to sample 1024 samples at a time, rather than 4096 to get to the desired resolution. Anyhow, off to feed the kids and thanks!


OK, revised the board because the differential measurement aspects of the external ADC are confusing to say the least. So now everything is unipolar. I went back to my AC line safety exercise and changed the resistor values around to work with a 230V input. Then I added a zener diode instead of the Schottkys I was using to bias the signal and prevent the ADC from blowing up under extreme circumstances. I'd like to think that between the 275V MOV and the 450V+ input-tolerant voltage measurement circuit, we should be OK.

The only fly in the ointment is Pulse discontinuing the power transformer line and Digikey treating these transformers as non-stock. To replace them, I'd have to import them from Europe via Newark electronics. No big deal, just an additional $20, please.

The other good news is that I managed to design two power measurement boards with different add-ons but with an identical GTP file. That's one less solder paste stencil I'll have to order. I also got a e-mail back from CUI re: my grounding question. For now, I'll still plan for a 1M resistor and a 2200pF, 2.2kV capacitor in parallel connecting the GND to the 120VAC GND. I can then experiment to see what the impact (if any) there is from having these through-hole components in place. If there is no benefit, I'll simply leave the holes empty.

Go Up