Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Bill Sloman Newsgroups: sci.electronics.design,comp.dsp Subject: Re: DDS question: why sine lookup? Date: Thu, 8 May 2025 22:49:47 +1000 Organization: A noiseless patient Spider Lines: 69 Message-ID: References: <3uen1khfvdihaho4vv2hf9amb09vbg77tq@4ax.com> <681bfa8e$0$13$882e4bbb@reader.netnews.com> <1t4o1k1uo8qa244fcv7jr7dnljlvp72vmq@4ax.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 08 May 2025 14:49:57 +0200 (CEST) Injection-Info: dont-email.me; posting-host="76195cc12747d407f6daf89486149dd4"; logging-data="1887178"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19LTZDrDUedjXQRtzRbz98XNXBkQ5cQ3ts=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:a7c3KSuLwd/r/mVT9Ygru3WUyhI= In-Reply-To: <1t4o1k1uo8qa244fcv7jr7dnljlvp72vmq@4ax.com> X-Antivirus: Norton (VPS 250508-2, 8/5/2025), Outbound message Content-Language: en-US X-Antivirus-Status: Clean Bytes: 4387 On 8/05/2025 12:21 pm, john larkin wrote: > On Wed, 7 May 2025 20:27:58 -0400, bitrex wrote: > >> On 5/7/2025 4:01 PM, john larkin wrote: >>> On Wed, 7 May 2025 20:32:41 +0100, Martin Brown >>> <'''newspam'''@nonad.co.uk> wrote: >>> >>>> On 06/05/2025 16:48, john larkin wrote: >>>>> A DDS clock generator uses an NCO (a phase accumulator) and takes some >>>>> number of MSBs, maps through a sine lookup table, drives a DAC and a >>>>> lowpass filter and finally a comparator. The DAC output gets pretty >>>>> ratty near Nyquist, and the filter smooths out and interpolates the >>>>> steps and reduces jitter. >>>>> >>>>> But why do the sine lookup? Why not use the phase accumulator MSBs >>>>> directly and get a sawtooth, and filter that? >>>> >>>> A saw tooth wave has a huge step like discontinuity in it which looks >>>> very ugly in the frequency domain with strong harmonics. Strong sharp >>>> features in time domain are broad in frequency space and vice versa. >>>> >>>> If you wanted something a bit different then detecting the phase >>>> accumulator overflow and reversing the count sense to get a triangle >>>> wave might be an option (at half the frequency). Needs some very careful >>>> maths at the boundary flips to avoid introducing jitter. >>>> >>>> From that triangle wave you can use HP's wizard diode shaping network >>>> trick to get a pretty good clean sine wave. >>> >>> Yes, a triangle would be better than a sawtooth... fewer nasty >>> subharmonics. But we may as well stick with the classic boring sine >>> wave. The sine lookup is trivial in an FPGA. >>> >> >> A band-limited square wave is pretty space & computation-efficient, you >> just store the Gibbs phenomena portion of the wave to whatever harmonic >> level you desire, play it back, and then sit there and wait during the >> DC parts of the wave. >> >> If you then integrate a band-limited square wave you get a band-limited >> triangle wave directly. > > If I could make a square wave from the MSBs of the phase accumulator, > I might not need the DAC and filter and comparator. > > Just using the MSB of the phase accumulator is the right frequency, > but it's very jitterey. > > So, is there a way to examine some number of MSBs and make an edge > with high time resolution, all digitally, all inside the FPGA? To even > 1 clock resolution, preferably better? > > There probably is. The existence of Direct Digital Synthesis chips is pretty convincing evidence that there isn't. If you can't do it an application specific integrated circuit, you aren't going to be able to do it an FPGA. Creating a sine wave lets you work with not-perfectly-integral divisors, with a low pass filter to smooth out the residual discontinuities. A Bessel linear phase low pass filter is apparently the preferred choice. The second editions of Williams and Taylor list up to 10th order in table 11-43, and two equiripple close approximations in tables 11-44 and 11-45. -- Bill Sloman, Sydney