<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>SAADC sampling at different rates, but not simultaneously</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/113129/saadc-sampling-at-different-rates-but-not-simultaneously</link><description>OK, I&amp;#39;m working with the nRF52832 and NCS V2.6.0, and I have two different actions I need to complete at various times with the SAADC: 
 
 Every ~ 3 seconds, I need to sample one ADC input (called &amp;quot;RMS Voltage&amp;quot;) for 32 samples, at 312usec between each</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 22 Jul 2024 06:33:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/113129/saadc-sampling-at-different-rates-but-not-simultaneously" /><item><title>RE: SAADC sampling at different rates, but not simultaneously</title><link>https://devzone.nordicsemi.com/thread/494965?ContentTypeID=1</link><pubDate>Mon, 22 Jul 2024 06:33:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f544264-4964-4e35-bdde-54a2c043f5f9</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Yeah, went down that rabbit hole a few months ago.&amp;nbsp; Problem is, my signal sits at 1V without stimulation, then will go either up towards 2V or down towards 0V.&lt;/p&gt;
&lt;p&gt;So, I really need a window comparator, but can&amp;#39;t implement that function with the COMP peripheral on the nRF52832.&amp;nbsp; I did attempt to do something using the COMP and LPCOMP, but of course you can&amp;#39;t use both of those together.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m about 95% of the way getting the functionality I need using the approach you essentially triggered for me, so thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC sampling at different rates, but not simultaneously</title><link>https://devzone.nordicsemi.com/thread/494936?ContentTypeID=1</link><pubDate>Sun, 21 Jul 2024 14:14:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d537c6b-27ae-4a8f-93a1-0cb52fde9657</guid><dc:creator>DougR</dc:creator><description>&lt;p&gt;One other idea: since you don&amp;#39;t actually use the sampled LIMIT channel data, other than to do the comparison with your set limit values, this might be an application for the COMP peripheral. Set it up to trigger your events for high or low deviation, and let it run. Then the SAADC peripheral can be set up for the line voltage measurement only. Now you have independent hardware working on your two inputs.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC sampling at different rates, but not simultaneously</title><link>https://devzone.nordicsemi.com/thread/494450?ContentTypeID=1</link><pubDate>Thu, 18 Jul 2024 02:17:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f148219-09bb-49c0-b38a-87dcf2bb1315</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/members/dougr"&gt;DougR&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for your input.&amp;nbsp; My FFT measurement isn&amp;#39;t (or in fact doesn&amp;#39;t need to be) anywhere near as precise as yours.&amp;nbsp; I&amp;#39;m only really concerned about the 3rd and 5th harmonic content of a 50Hz (or 60Hz, depending on where this thing is deployed) AC signal.&lt;/p&gt;
&lt;p&gt;And I believe if I&amp;#39;m going to use PPI, I&amp;#39;m forced to use the Nordic SAADC drivers, rather than the Zephyr ones.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve had all of this working on a Cypress IC for years, but of course with all the issues with supply chains, couldn&amp;#39;t get any more of the IC we were using, so we took a punt and moved everything over to Nordic about 2 years ago.&amp;nbsp; I&amp;#39;m frantically porting all my Cypress stuff over to Nordic, which kinda explains the background of why I&amp;#39;ve been approaching this as I have - a bit of &amp;quot;that&amp;#39;s how I did it before&amp;quot;.&lt;/p&gt;
&lt;p&gt;Anyway, with some modification, I think your idea would be the best approach.&amp;nbsp; That is:&lt;/p&gt;
&lt;p&gt;1.&amp;nbsp; Sample my two channels as fast as I need to for the LIMIT channel to do what I need it to do, using PPI to trigger the SAADC in advanced non-blocking mode&lt;/p&gt;
&lt;p&gt;2. When I need to do an RMS voltage measurement, grab the contents of the buffers and do a bunch of averaging to get the information I need. Then do my RMS calc as per normal.&lt;/p&gt;
&lt;p&gt;We&amp;#39;re pretty limited with the amount of RAM we have left, so can&amp;#39;t just have a bunch of 2000 element buffers that we then copy over to another buffer for post-sampling processing (We&amp;#39;re using 12 bit resolution). So we would need to be doing some processing of the info in each buffer once its filled, grab an average or something out of that, and then store that elsewhere.&amp;nbsp; One idea I did have, and I&amp;#39;m not sure if its going to work, is to have a dual buffer, each buffer only storing one sample for each channel, and things rapidly swapping back and forth between them as samples are collected.&amp;nbsp; Then, I can trigger an event where I save one of those samples into my 32 sample array using my Counter/Timer as I currently am.&amp;nbsp; Not sure how much overhead the buffer swapping process adds to the acquisition process and what that would mean for the maximum sampling rate I can achieve.&amp;nbsp; I&amp;#39;m only interested in fast sampling for the LIMIT channel, to detect when its outside my limits.&amp;nbsp; I don&amp;#39;t actually need to know what value that channel is at any point.&lt;/p&gt;
&lt;p&gt;The other thing I haven&amp;#39;t yet been able to get my head around, just looking at the saadc examples, is how to configure the buffers that are used in the&amp;nbsp;NRFX_SAADC_EVT_BUF_REQ event.&amp;nbsp; I&amp;#39;m needing to set up a dual buffer, with however many elements for the number of samples I need to take, and for the two channels I am sampling.&amp;nbsp; I could use a bit of help understanding the mechanics of how to get that right&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC sampling at different rates, but not simultaneously</title><link>https://devzone.nordicsemi.com/thread/494422?ContentTypeID=1</link><pubDate>Wed, 17 Jul 2024 16:24:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ef4cd76-7d69-4141-83c2-0c1245575659</guid><dc:creator>DougR</dc:creator><description>&lt;p&gt;My first comment is that working with a half-cycle of an AC signal seems problematic, at least to me. Signals with frequency near or below the bandwidth of the window you&amp;#39;ve selected are not easy to analyze with FFT. Something like 5 or 6 cycles would give ~0.1 s of data to work with, and more accurate determination of the fundamental for comparison with the harmonics.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;My second comment is that it&amp;#39;s not clear to me that you&amp;#39;re taking advantage of the hardware&amp;#39;s ability to sample all the channels into a buffer using a sequence, and unpack after during processing. Sampling at 200 kHz will be much faster and noisier than you want for the &amp;quot;RMS Voltage&amp;quot; input, but you can do the averaging in software. You might find&amp;nbsp;&lt;a href="https://github.com/KalynaEnergy/mv/blob/main/src/adc.c"&gt;this code&lt;/a&gt;&amp;nbsp;I wrote&amp;nbsp;helpful, which does something similar, or at least related. I think we&amp;#39;re using different drivers, however.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>