Filtering and Sampling

A project log for Wi-Fi Power Switch

ESP8266 based smart power switch/dimmer with Kill-A-Watt class power/power factor readings

Justin KennyJustin Kenny 11/01/2016 at 01:250 Comments

This device will have a limited sampling rate, and hence will need to filter the input signal to prevent aliasing. I've borrowed some data from here for a 9W smart LED bulb:

This is somewhat of a "worst case" since it's neither resistive nor reactive load, but a switching power supply which pulls current at nearly the peak in the voltage waveform, producing a current draw with lots of high frequency components.

I've assumed that I will sample at 600 samples per second, though I could theoretically go much higher. This means I need a 300 Hz cutoff frequency on my anti-aliasing filter. I've used TI's WEBENCH tool to get values for a "Lowpass, Multiple Feedback, Linear Phase 0.5deg" filter, which I then simulated with modeled op-amps in LTspiceIV, and imported the data back into Excel to plot and run calculations on. Results are below:

As you can see, the filtered result drops quite a bit of peak current compared to the real data, but the real power calculated remains almost the same as the original, only 1% low. The power factor got the worst hit, with a 33% difference, and hence the apparent power is quite a bit lower than expected as well. These values will get worse with sampling applied on top of the data, which I will simulate tomorrow. Based on these results I may choose to increase the sampling frequency to 1.2 ksps or higher, it will take some fiddling with actual hardware to see how fast the actual ADC can sample with Arduino on ESP8266.