<div dir="ltr"><div>Thanks, sorry, I still don't understand this:</div><div><br></div><div>> Each horizontal row of the chart is the waveform generated for the constant input on the y-axis.

</div><div><br></div><div>what do you mean by that?</div><div><br></div><div>BTW, it's probably useful to send these emails to the list.<br></div><div><br></div></div><br><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">dkantowitz@gmail.com</a>> wrote:<br></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">"carry-bit NCO" is how I summarized the approach Tom uses: output a pulse whenever the counter overflows.<div><br></div><div>Each horizontal row of the chart is the waveform generated for the constant input on the y-axis.</div><div>y=0 -> row of all zeros (white)</div><div>y=256 -> row of all ones (black)</div><div>y=128 -> row of alternating ones and zeros</div><div><br></div><div>The interesting parts are really:</div><div>  a) Overflow bit approach is _vastly_ better than PWM.</div><div>  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>  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><br></div><div><br></div></div><br><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">cheater00social@gmail.com</a>> wrote:<br></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"><div dir="ltr"><br></div><br><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">dkantowitz@gmail.com</a>> wrote:<br></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">The carry-bit NCO technique is also equivalent to a 1-bit first order sigma delta DAC.</div></blockquote><div><br></div><div>Sorry,what carry-bit NCO technique? The word "carry" isn't mentioned before your email.<br></div><div> </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">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">https://en.wikipedia.org/wiki/Delta-sigma_modulation</a>).<div><br></div><div>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><br></div><div>DC level is y-axis, time is x-axis.</div></div></blockquote><div><br></div><div>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></div><div> </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"><div><img src="cid:ii_lpzvn1o40" alt="image.png" width="473" height="466"><br></div><div>Repeated 4 times to help imagine the oversampling:</div><div><img src="cid:ii_lpzvncti1" alt="image.png" width="476" height="140"><br></div><div><br></div><div>For comparison basic PWM looks like:</div><div><img src="cid:ii_lpzvp9sz2" alt="image.png" width="476" height="140"><br></div><div><br></div><div>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><br></div></div><br><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">tom@electricdruid.net</a>> wrote:<br></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>
<br>
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>
<br>
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>
<br>
<br>
> On 8 Dec 2023, at 21:18, cheater cheater <<a href="mailto:cheater00social@gmail.com" target="_blank">cheater00social@gmail.com</a>> wrote:<br>
> <br>
> I don't get it. Most of the algorithm is missing.<br>
> <br>
> On Fri, Dec 8, 2023 at 10:07 PM Tom Wiltshire <<a href="mailto:tom@electricdruid.net" target="_blank">tom@electricdruid.net</a>> wrote:<br>
>> <br>
>> <br>
>> <br>
>> On 8 Dec 2023, at 20:30, cheater cheater <<a href="mailto:cheater00social@gmail.com" target="_blank">cheater00social@gmail.com</a>> wrote:<br>
>> <br>
>> On Fri, Dec 8, 2023 at 5:06 PM Tom Wiltshire <<a href="mailto:tom@electricdruid.net" target="_blank">tom@electricdruid.net</a>> wrote:<br>
>> <br>
>> <br>
>> <br>
>> <br>
>> On 8 Dec 2023, at 14:41, Matthew Skala via Synth-diy <<a href="mailto:synth-diy@synth-diy.org" target="_blank">synth-diy@synth-diy.org</a>> wrote:<br>
>> <br>
>> If PDM means PWM with bit-reversal before the comparison (such as Richie<br>
>> describes), then it does indeed lock you into a lower sampling rate, and<br>
>> that's one reason I skipped describing *that* technique.  But PWM with<br>
>> bit-reversal seems not to be what you mean when you say PDM.<br>
>> <br>
>> <br>
>> That's not what I meant when I said PDM, certainly.<br>
>> <br>
>> The way I generated it is using an NCO. The NCO generates a single-shot output pulse everytime the phase accumulator wraps.<br>
>> <br>
>> 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>
>> 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>
>> 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>
>> <br>
>> HTH,<br>
>> Tom<br>
>> <br>
>> <br>
>> I've read this a few times but I'm struggling to understand what's<br>
>> going on. Can someone type out an algorithm or something like that?<br>
>> Would appreciate it a lot. Thanks.<br>
>> <br>
>> <br>
>> Ok, it'd look something like this:<br>
>> <br>
>> phase: 16-bit variable (for example)<br>
>> freq: 16-bit variable (same as phase)<br>
>> <br>
>> So we do:<br>
>> <br>
>> // Increment phase accumulator<br>
>> phase = phase + freq<br>
>> <br>
>> // Did phase wraparound?<br>
>> If (phase>65535) { // There are probably better ways to do this test, if it's even required.<br>
>> // Ok, phase wrapped<br>
>> phase = phase % 65536<br>
>> // output a pulse a single clock in length<br>
>> <this is implementation dependent!><br>
>> }<br>
>> <br>
>> 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>
>> <br>
>> <br>
>> There's a page about NCOs in general on my website:<br>
>> <br>
>> <a href="https://electricdruid.net/direct-digital-synthesis/" rel="noreferrer" target="_blank">https://electricdruid.net/direct-digital-synthesis/</a><br>
>> <br>
>> HTH,<br>
>> Tom<br>
>> <br>
>> <br>
<br>
<br>
_______________________________________________<br>
Synth-diy mailing list<br>
<a href="mailto:Synth-diy@synth-diy.org" target="_blank">Synth-diy@synth-diy.org</a><br>
<a href="http://synth-diy.org/mailman/listinfo/synth-diy" rel="noreferrer" target="_blank">http://synth-diy.org/mailman/listinfo/synth-diy</a><br>
Selling or trading? Use <a href="mailto:marketplace@synth-diy.org" target="_blank">marketplace@synth-diy.org</a><br>
</blockquote></div>
</blockquote></div></div>
</blockquote></div>
</blockquote></div>