{"id":85,"date":"2011-08-02T08:54:24","date_gmt":"2011-08-02T12:54:24","guid":{"rendered":"http:\/\/fll-freak.com\/blog\/?p=85"},"modified":"2025-04-21T00:54:36","modified_gmt":"2025-04-21T04:54:36","slug":"hpm-on-an-arduino-first-tests","status":"publish","type":"post","link":"https:\/\/fll-freak.com\/blog\/?p=85","title":{"rendered":"HomePowerMonitor on an Arduino? First tests."},"content":{"rendered":"<p>Using an Arduino for my Home Power Monitor (HPM) has many advantages. It is cheap, simple, small, and has a good user base behind it. But could it meet my requirements (more on these in a future post)? To find out, I started to prototype the software last night and time it with my scope. I was pleasantly surprised.<!--more-->First test I ran was to simple take an ADC reading as an integer and toggle an IO pin in a tight loop. I found I could perform 8,929 samples per second. I then tried to read the ADC into a double expecting a significant hit on performance. I did not, the samples per second was nearly identical.<\/p>\n<p>So the next test was to see the hit that squaring a double would take on the speed. Again, no hit whatsoever. At this point I was beginning to think that since I was not using the results of the calculations that perhaps the compiler was optimizing them out. So I wrote the bulk of the power computation code. This meant for each loop reading two DAC channels; one for voltage and one for current. Then squaring the raw values and summing them in accumulators. These computations would support computing apparent power. For true power, I took the product of the raw voltage and current and accumulated a running sum. After N samples, I would divide the sums by N to get averages.<\/p>\n<p>The results show that I can take 3,680 samples of V and I every second. At a 60Hz line frequency, that means I can over sample by about 60x.<\/p>\n<p>Is a 60x over sample enough to compute a fairly accurate real power for simple resistive loads and if so, what about bizarre reactive loads? I think I can compute the accuracy loss of a resistive load. And I think I can model and numerically compute the accuracy of an arbitrary reactive load. But at only a 60x over sample a pathological reactive load will have a significant error. But do I have any such devices that might draw a spike of power in 60th of a power cycle (1\/3,600th of a second)?<\/p>\n<p>Perhaps it is now time to pop open the breaker box and sample the real signals I will be dealing with.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using an Arduino for my Home Power Monitor (HPM) has many advantages. It is cheap, simple, small, and has a good user base behind it. But could it meet my requirements (more on these in a future post)? To find &hellip; <a href=\"https:\/\/fll-freak.com\/blog\/?p=85\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,7],"tags":[],"class_list":["post-85","post","type-post","status-publish","format-standard","hentry","category-home-power-monitor","category-projects"],"_links":{"self":[{"href":"https:\/\/fll-freak.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/85","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fll-freak.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fll-freak.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fll-freak.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fll-freak.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=85"}],"version-history":[{"count":6,"href":"https:\/\/fll-freak.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/85\/revisions"}],"predecessor-version":[{"id":1073,"href":"https:\/\/fll-freak.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/85\/revisions\/1073"}],"wp:attachment":[{"href":"https:\/\/fll-freak.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=85"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fll-freak.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=85"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fll-freak.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=85"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}