<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">He's plotted the output from the algorithm as black and white pixels (the x axis) for each "DAC output value" (the y-axis).<div class=""><br class=""></div><div class="">The difference between the "carry-bit NCO" approach (or whatever we want to call it) and the PWM output (the final diagram, half black, half white) is clear to see.</div><div class=""><div class=""><br class="webkit-block-placeholder"></div><div class=""><div>The important thing is the way that the black and white pixels are far more mixed up- e.g. the noise is of much higher frequency, and therefore much easier to filter out.</div><br class="Apple-interchange-newline">

</div>
<div><br class=""><blockquote type="cite" class=""><div class="">On 11 Dec 2023, at 08:59, cheater cheater via Synth-diy <<a href="mailto:synth-diy@synth-diy.org" class="">synth-diy@synth-diy.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Thanks, sorry, I still don't understand this:</div><div class=""><br class=""></div><div class="">> Each horizontal row of the chart is the waveform generated for the constant input on the y-axis.

</div><div class=""><br class=""></div><div class="">what do you mean by that?</div><div class=""><br class=""></div><div class="">BTW, it's probably useful to send these emails to the list.<br class=""></div><div class=""><br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Dec 11, 2023 at 3:01 AM David Kantowitz <<a href="mailto:dkantowitz@gmail.com" class="">dkantowitz@gmail.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class="">"carry-bit NCO" is how I summarized the approach Tom uses: output a pulse whenever the counter overflows.<div class=""><br class=""></div><div class="">Each horizontal row of the chart is the waveform generated for the constant input on the y-axis.</div><div class="">y=0 -> row of all zeros (white)</div><div class="">y=256 -> row of all ones (black)</div><div class="">y=128 -> row of alternating ones and zeros</div><div class=""><br class=""></div><div class="">The interesting parts are really:</div><div class="">  a) Overflow bit approach is _vastly_ better than PWM.</div><div class="">  b) Most microcontrollers have a timer/counter peripheral where you can implement this in hardware, having almost no s/w cost, and runnig around the uC's clock rate (several MHz).</div><div class="">  c) 1st order sigma delta converters are garbage: need a hefty oversampling rate and noise rises like a 45 degree line through the passband.</div><div class=""><br class=""></div><div class=""><br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Dec 10, 2023 at 12:43 PM cheater cheater <<a href="mailto:cheater00social@gmail.com" target="_blank" class="">cheater00social@gmail.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class=""><div dir="ltr" class=""><br class=""></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Dec 10, 2023 at 8:36 PM David Kantowitz <<a href="mailto:dkantowitz@gmail.com" target="_blank" class="">dkantowitz@gmail.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class="">The carry-bit NCO technique is also equivalent to a 1-bit first order sigma delta DAC.</div></blockquote><div class=""><br class=""></div><div class="">Sorry,what carry-bit NCO technique? The word "carry" isn't mentioned before your email.<br class=""></div><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class="">Probably doesn't make it much easier to understand, but it does make the design conclusions from sigma delta usable.  Ex. noise shaping curves, required Over Sampling Rates vs ENOB, reconstruction filtering (see: <a href="https://en.wikipedia.org/wiki/Delta-sigma_modulation" target="_blank" class="">https://en.wikipedia.org/wiki/Delta-sigma_modulation</a>).<div class=""><br class=""></div><div class="">To help myself visualize this, I plotted the output bit patterns for each input level.  Both modulation algorithms (1-bit carry NCO and SD-1) produced the same chart.</div><div class=""><br class=""></div><div class="">DC level is y-axis, time is x-axis.</div></div></blockquote><div class=""><br class=""></div><div class="">I'm having trouble understanding these graphs. What's going on in them? "DC level is y-axis" doesn't seem to make sense in a plot that has multiple y values per one x value. What am I missing here?<br class=""></div><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class=""><div class=""><span id="cid:ii_lpzvn1o40"><image.png></span><br class=""></div><div class="">Repeated 4 times to help imagine the oversampling:</div><div class=""><span id="cid:ii_lpzvncti1"><image.png></span><br class=""></div><div class=""><br class=""></div><div class="">For comparison basic PWM looks like:</div><div class=""><span id="cid:ii_lpzvp9sz2"><image.png></span><br class=""></div><div class=""><br class=""></div><div class="">By looking across a horizontal line, you can easily see the carry-bit approach has a vast reduction in low frequency content compared to PWM.  That is, the digital signal 'noise' is being pushed into higher frequencies.  However, there's still plenty of repeating pattern in the NCO/SD-1 </div><div class=""><br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Dec 8, 2023 at 1:43 PM Tom Wiltshire <<a href="mailto:tom@electricdruid.net" target="_blank" class="">tom@electricdruid.net</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Honestly, it's not. It's just that damn simple. The version I actually wrote was all hardware module set-up specific to the device, and basically nothing else, so wouldn't tell you anything. Turning it all into software loses a lot of the benefit, so doesn't make much sense, except to explain it.<br class="">
<br class="">
Play with some NCOs a bit, and then get them to make a single pulse when they wrap. And then - Bingo! You're there!<br class="">
<br class="">
If you thought something was missing, what exactly? Ask a more specific question and perhaps I can help fill in a blank. I well remember how weird this stuff seemed when I first met it, so I think I understand the position you're in now.<br class="">
<br class="">
<br class="">
> On 8 Dec 2023, at 21:18, cheater cheater <<a href="mailto:cheater00social@gmail.com" target="_blank" class="">cheater00social@gmail.com</a>> wrote:<br class="">
> <br class="">
> I don't get it. Most of the algorithm is missing.<br class="">
> <br class="">
> On Fri, Dec 8, 2023 at 10:07 PM Tom Wiltshire <<a href="mailto:tom@electricdruid.net" target="_blank" class="">tom@electricdruid.net</a>> wrote:<br class="">
>> <br class="">
>> <br class="">
>> <br class="">
>> On 8 Dec 2023, at 20:30, cheater cheater <<a href="mailto:cheater00social@gmail.com" target="_blank" class="">cheater00social@gmail.com</a>> wrote:<br class="">
>> <br class="">
>> On Fri, Dec 8, 2023 at 5:06 PM Tom Wiltshire <<a href="mailto:tom@electricdruid.net" target="_blank" class="">tom@electricdruid.net</a>> wrote:<br class="">
>> <br class="">
>> <br class="">
>> <br class="">
>> <br class="">
>> On 8 Dec 2023, at 14:41, Matthew Skala via Synth-diy <<a href="mailto:synth-diy@synth-diy.org" target="_blank" class="">synth-diy@synth-diy.org</a>> wrote:<br class="">
>> <br class="">
>> If PDM means PWM with bit-reversal before the comparison (such as Richie<br class="">
>> describes), then it does indeed lock you into a lower sampling rate, and<br class="">
>> that's one reason I skipped describing *that* technique.  But PWM with<br class="">
>> bit-reversal seems not to be what you mean when you say PDM.<br class="">
>> <br class="">
>> <br class="">
>> That's not what I meant when I said PDM, certainly.<br class="">
>> <br class="">
>> The way I generated it is using an NCO. The NCO generates a single-shot output pulse everytime the phase accumulator wraps.<br class="">
>> <br class="">
>> Now consider what happens with a simple 8-bit NCO. If our frequency increment is 2, for example, we get a single output pulse every 128 clocks, or 2 pulses per 256 clocks. Notice that they will be nicely spaced apart, not next to each other like PWM. The output frequency would be (clock frequency / 128) in this situation.<br class="">
>> If the increment is 8, we get a output pulse every 32 clocks, 8 pulses per 256 clocks, and again, they're nicely spaced out. The output frequency is now up to (clock /32) so there's been a big improvement, just by getting away from those extreme values a little bit.<br class="">
>> As the increment climbs, the accumulator wraps more and more often. At freq=128, every other clock is an output and we reach our maximum output frequency of (clock/2). As the increment goes above half, we start staying high for more than a single pulse, and the waveform effectively turns the other way up and we get a mirror image of the effect we've seen from 0-128.<br class="">
>> <br class="">
>> HTH,<br class="">
>> Tom<br class="">
>> <br class="">
>> <br class="">
>> I've read this a few times but I'm struggling to understand what's<br class="">
>> going on. Can someone type out an algorithm or something like that?<br class="">
>> Would appreciate it a lot. Thanks.<br class="">
>> <br class="">
>> <br class="">
>> Ok, it'd look something like this:<br class="">
>> <br class="">
>> phase: 16-bit variable (for example)<br class="">
>> freq: 16-bit variable (same as phase)<br class="">
>> <br class="">
>> So we do:<br class="">
>> <br class="">
>> // Increment phase accumulator<br class="">
>> phase = phase + freq<br class="">
>> <br class="">
>> // Did phase wraparound?<br class="">
>> If (phase>65535) { // There are probably better ways to do this test, if it's even required.<br class="">
>> // Ok, phase wrapped<br class="">
>> phase = phase % 65536<br class="">
>> // output a pulse a single clock in length<br class="">
>> <this is implementation dependent!><br class="">
>> }<br class="">
>> <br class="">
>> All you need to do is run this code at a fast clock rate and you're off. Of course, the better way is if you can hand some of this overhead to hardware, and some modern uPs include NCOs as a peripheral and can be set up for this "single shot pulse output" mode, which means that the while thing boils down to simply updating the "freq" frequency increment variable with your current output. It's dead simple.<br class="">
>> <br class="">
>> <br class="">
>> There's a page about NCOs in general on my website:<br class="">
>> <br class="">
>> <a href="https://electricdruid.net/direct-digital-synthesis/" rel="noreferrer" target="_blank" class="">https://electricdruid.net/direct-digital-synthesis/</a><br class="">
>> <br class="">
>> HTH,<br class="">
>> Tom<br class="">
>> <br class="">
>> <br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
Synth-diy mailing list<br class="">
<a href="mailto:Synth-diy@synth-diy.org" target="_blank" class="">Synth-diy@synth-diy.org</a><br class="">
<a href="http://synth-diy.org/mailman/listinfo/synth-diy" rel="noreferrer" target="_blank" class="">http://synth-diy.org/mailman/listinfo/synth-diy</a><br class="">
Selling or trading? Use <a href="mailto:marketplace@synth-diy.org" target="_blank" class="">marketplace@synth-diy.org</a><br class="">
</blockquote></div>
</blockquote></div></div>
</blockquote></div>
</blockquote></div>
________________________________________________________<br class="">This is the Synth-diy mailing list<br class="">Submit email to: <a href="mailto:Synth-diy@synth-diy.org" class="">Synth-diy@synth-diy.org</a><br class="">View archive at: <a href="https://synth-diy.org/pipermail/synth-diy/" class="">https://synth-diy.org/pipermail/synth-diy/</a><br class="">Check your settings at: <a href="https://synth-diy.org/mailman/listinfo/synth-diy" class="">https://synth-diy.org/mailman/listinfo/synth-diy</a><br class="">Selling or trading? Use <a href="mailto:marketplace@synth-diy.org" class="">marketplace@synth-diy.org</a><br class=""></div></blockquote></div><br class=""></div></body></html>