{"id":412,"date":"2019-10-04T23:19:50","date_gmt":"2019-10-04T21:19:50","guid":{"rendered":"http:\/\/tronche.com\/blog\/?p=412"},"modified":"2022-08-07T00:08:22","modified_gmt":"2022-08-06T22:08:22","slug":"more-on-noise-in-current-measurement-actually-less-noise","status":"publish","type":"post","link":"https:\/\/tronche.com\/blog\/2019\/10\/more-on-noise-in-current-measurement-actually-less-noise\/","title":{"rendered":"More on noise in current measurement (actually less noise)"},"content":{"rendered":"\n<p>I&#8217;ve increased the sampling frequency to 23kHz and got much more stable results, stable enough to be useful.<\/p>\n\n\n\n<p>The image here shows the current measured at 100 Hz for 10 s. 100 Hz is the frequency of the power-decision loop in Almabraxas 3. The &#8220;naive&#8221; sampling just read the value (as a 12 bits ADC conversion, thus in the range 0-4095). The other curve is a 23 kHz sampling averaged by the 100 Hz loop (that is 230 samples are averaged for every point). As we can see, we have a very stable (and usable) measurement using the 23 kHz sampling, while with a naive approach, the error bar is bigger than the values we want to discriminate, making it unusable.<\/p>\n\n\n\n<p>The board is an STM Nucleo F446RE (STM32F4 \/ cortex M4), running at 180 MHz. The ADC clock is then 90 MHz. For the ADC, I&#8217;m using the biggest clock prescaler (8), and the longest sampling time (480 clock ticks per sample), thus 90 MHz \/ 8 \/ 480 = 23 kHz, counting the sampling startup time. The summation for averaging is performed directly in the ISR, without using a DMA.<\/p>\n\n\n\n<p>In this configuration, I&#8217;m not sampling voltage (yet), but I&#8217;m planning to use the ADC2 in slave mode, thus maintaining the 23 kHz frequency with almost no overhead. I&#8217;m using mbed 5 which is great in general, but for now as no provision for continuous sampling, thus I had to write large part of this mechanism using the HAL.<\/p>\n\n\n\n<p>Previously, I looked at the signal with an oscilloscope, and there are different noise components until at least 2 kHz, depending on the motors speed. NB: I haven&#8217;t used an inductor yet to filter the current noise from the motors, because 1) I&#8217;m an idiot and 2) I hadn&#8217;t suitable inductors at hand, so it was easier to fix the problem in software !<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"341\" src=\"http:\/\/tronche.com\/blog\/wp-content\/uploads\/2019\/10\/sampling-1-1024x341.png\" alt=\"\" class=\"wp-image-415\" srcset=\"https:\/\/tronche.com\/blog\/wp-content\/uploads\/2019\/10\/sampling-1-1024x341.png 1024w, https:\/\/tronche.com\/blog\/wp-content\/uploads\/2019\/10\/sampling-1-300x100.png 300w, https:\/\/tronche.com\/blog\/wp-content\/uploads\/2019\/10\/sampling-1-768x256.png 768w, https:\/\/tronche.com\/blog\/wp-content\/uploads\/2019\/10\/sampling-1.png 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>I&#8217;ve increased the sampling frequency to 23kHz and got much more stable results, stable enough to be useful. The image here shows the current measured <a class=\"mh-excerpt-more\" href=\"https:\/\/tronche.com\/blog\/2019\/10\/more-on-noise-in-current-measurement-actually-less-noise\/\" title=\"More on noise in current measurement (actually less noise)\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":415,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[60,288],"class_list":["post-412","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-almabraxas-3-prototype","tag-electronic-noise","tag-lab-log"],"_links":{"self":[{"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/posts\/412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/comments?post=412"}],"version-history":[{"count":7,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/posts\/412\/revisions"}],"predecessor-version":[{"id":421,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/posts\/412\/revisions\/421"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/media\/415"}],"wp:attachment":[{"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/media?parent=412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/categories?post=412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tronche.com\/blog\/wp-json\/wp\/v2\/tags?post=412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}