• DDS, again

    From john larkin@21:1/5 to All on Tue Dec 10 18:38:18 2024
    I have been unsuccessful in getting LT Spice to simulate a DDS
    frequency generator. It's bad enough trying to make the NCO part, but
    whenever I get close it stalls or throws convergence errors.

    So I wrote a PowerBasic program that's the 32-bit NCO... GC_Num.exe.

    Making a proper .WAV file would be a nightmare, so it outputs as a
    text file with just time data per line, where data is the
    selected number of MS bits of the phase accumulator.

    LT Spice can read the file, and then do whatever it wants: sine, DAC,
    filter, comparator, FFTs.

    https://www.dropbox.com/scl/fo/o0mdxxqvxupg6ynz7i7rx/AMPMbv9NOY4mJFXggTGUqJ8?rlkey=9ecl38npbgy8kxuzd9bako4kr&dl=0

    Spice reads the file as a piecewise-linear thing, so wrecks the nice
    MSB data steps. I had to fool it by outputting each clocked phase
    accumulator value twice, as

    bits time
    bits time+0.9*clock_period

    same data bits both lines. Looks pretty steppy.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jeroen Belleman@21:1/5 to john larkin on Wed Dec 11 10:02:13 2024
    On 12/11/24 03:38, john larkin wrote:
    I have been unsuccessful in getting LT Spice to simulate a DDS
    frequency generator. It's bad enough trying to make the NCO part, but whenever I get close it stalls or throws convergence errors.

    So I wrote a PowerBasic program that's the 32-bit NCO... GC_Num.exe.

    Making a proper .WAV file would be a nightmare, so it outputs as a
    text file with just time data per line, where data is the
    selected number of MS bits of the phase accumulator.

    LT Spice can read the file, and then do whatever it wants: sine, DAC,
    filter, comparator, FFTs.

    https://www.dropbox.com/scl/fo/o0mdxxqvxupg6ynz7i7rx/AMPMbv9NOY4mJFXggTGUqJ8?rlkey=9ecl38npbgy8kxuzd9bako4kr&dl=0

    Spice reads the file as a piecewise-linear thing, so wrecks the nice
    MSB data steps. I had to fool it by outputting each clocked phase
    accumulator value twice, as

    bits time
    bits time+0.9*clock_period

    same data bits both lines. Looks pretty steppy.


    On Linux, we have 'sox' that can convert between time-value
    pairs and .wav in either direction. I suppose there must be
    a Windows version. I suspect the piecewise-linear problem
    will still be there.

    As for the convergence problems: LTspice doesn't like
    discontinuities. Jim Thompson approximated everything with
    smooth functions. His favourite was tanh.

    Jeroen Belleman

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From john larkin@21:1/5 to jeroen@nospam.please on Wed Dec 11 02:31:08 2024
    On Wed, 11 Dec 2024 10:02:13 +0100, Jeroen Belleman
    <jeroen@nospam.please> wrote:

    On 12/11/24 03:38, john larkin wrote:
    I have been unsuccessful in getting LT Spice to simulate a DDS
    frequency generator. It's bad enough trying to make the NCO part, but
    whenever I get close it stalls or throws convergence errors.

    So I wrote a PowerBasic program that's the 32-bit NCO... GC_Num.exe.

    Making a proper .WAV file would be a nightmare, so it outputs as a
    text file with just time data per line, where data is the
    selected number of MS bits of the phase accumulator.

    LT Spice can read the file, and then do whatever it wants: sine, DAC,
    filter, comparator, FFTs.

    https://www.dropbox.com/scl/fo/o0mdxxqvxupg6ynz7i7rx/AMPMbv9NOY4mJFXggTGUqJ8?rlkey=9ecl38npbgy8kxuzd9bako4kr&dl=0

    Spice reads the file as a piecewise-linear thing, so wrecks the nice
    MSB data steps. I had to fool it by outputting each clocked phase
    accumulator value twice, as

    bits time
    bits time+0.9*clock_period

    same data bits both lines. Looks pretty steppy.


    On Linux, we have 'sox' that can convert between time-value
    pairs and .wav in either direction. I suppose there must be
    a Windows version. I suspect the piecewise-linear problem
    will still be there.

    As for the convergence problems: LTspice doesn't like
    discontinuities. Jim Thompson approximated everything with
    smooth functions. His favourite was tanh.

    Jeroen Belleman

    LT will input a binary .wav file without the piecewise thing, I think,
    but I didn't want to add the conversion step. Or learn yet another
    program. And I sure didn't want to write the PowerBasic code to make a
    .wav file.

    The irony is that after some nontrivial amount of coding, I think I'll
    just use the MSB of my 40 MHz 32-bit phase accumulator as our waveform
    clock. Nobody important will notice the jitter.

    The "RF" mindset, that one has to do the sine and dac and hi-rent
    lowpass filter and comparator, is not only a bunch of work and
    expense, it gets really nasty at low frequencies.

    Oh well, the project was educational and will probably be useful some
    other day, when clock purity matters more.

    It would be interesting to try to stay all on-chip in the FPGA, to
    digitally filter the MSBs of my 40 MHz NCO with some digital filter
    running on a faster clock.

    My guys say that they could run the phase accumulator at at least 100
    MHz in an Efinix FPGA, and that offers ideas too.

    Tanh is indeed slick. I have some logical statements in my LT Spice
    NCO that it may not like.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Klaus Vestergaard Kragelund@21:1/5 to john larkin on Wed Dec 11 14:07:45 2024
    On 11-12-2024 03:38, john larkin wrote:
    I have been unsuccessful in getting LT Spice to simulate a DDS
    frequency generator. It's bad enough trying to make the NCO part, but whenever I get close it stalls or throws convergence errors.


    I think you have the funds to buy Cadence Pspice. It has auto
    convergence build in. It's seldom I see problems with convergence after
    they added that feature.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From john larkin@21:1/5 to klauskvik@hotmail.com on Wed Dec 11 08:49:20 2024
    On Wed, 11 Dec 2024 14:07:45 +0100, Klaus Vestergaard Kragelund <klauskvik@hotmail.com> wrote:

    On 11-12-2024 03:38, john larkin wrote:
    I have been unsuccessful in getting LT Spice to simulate a DDS
    frequency generator. It's bad enough trying to make the NCO part, but
    whenever I get close it stalls or throws convergence errors.


    I think you have the funds to buy Cadence Pspice. It has auto
    convergence build in. It's seldom I see problems with convergence after
    they added that feature.

    LT Spice is usually pretty good. It just didn't like my trying to make
    a 32-bit phase accumulator with an analog circuit.

    I once fixed a convergence problem by adding one resistor to the
    circuit. 1K, one ended grounded, the other end open.

    LT is horrible with digital stuff. Imagine making a 32-bit phase
    accumulator with its parts. There isn't a screen big enough.

    Qspice is I hear better at mixed-signal sims.

    I can always have one of my kids Matlab the hard stuff.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From john larkin@21:1/5 to john larkin on Wed Dec 11 10:50:00 2024
    On Tue, 10 Dec 2024 18:38:18 -0800, john larkin <JL@gct.com> wrote:

    I have been unsuccessful in getting LT Spice to simulate a DDS
    frequency generator. It's bad enough trying to make the NCO part, but >whenever I get close it stalls or throws convergence errors.

    So I wrote a PowerBasic program that's the 32-bit NCO... GC_Num.exe.

    Making a proper .WAV file would be a nightmare, so it outputs as a
    text file with just time data per line, where data is the
    selected number of MS bits of the phase accumulator.

    LT Spice can read the file, and then do whatever it wants: sine, DAC,
    filter, comparator, FFTs.

    https://www.dropbox.com/scl/fo/o0mdxxqvxupg6ynz7i7rx/AMPMbv9NOY4mJFXggTGUqJ8?rlkey=9ecl38npbgy8kxuzd9bako4kr&dl=0

    Spice reads the file as a piecewise-linear thing, so wrecks the nice
    MSB data steps. I had to fool it by outputting each clocked phase
    accumulator value twice, as

    bits time
    bits time+0.9*clock_period

    same data bits both lines. Looks pretty steppy.

    Given a 40 MHz phase accumulator, one could spin up a clock at some
    mutiple, 160 MHz maybe, and fake the dac/lowpass/comparator thing to
    reduce jitter.

    I think it's just a lookup table on some MSBs of the 40 MHz phase
    accumulator. Of course the new fake DDS clock output would be
    quantized to the 160 MHz clock domain. Maybe.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Klaus Vestergaard Kragelund@21:1/5 to john larkin on Wed Dec 11 21:47:25 2024
    On 11-12-2024 17:49, john larkin wrote:
    On Wed, 11 Dec 2024 14:07:45 +0100, Klaus Vestergaard Kragelund <klauskvik@hotmail.com> wrote:

    On 11-12-2024 03:38, john larkin wrote:
    I have been unsuccessful in getting LT Spice to simulate a DDS
    frequency generator. It's bad enough trying to make the NCO part, but
    whenever I get close it stalls or throws convergence errors.


    I think you have the funds to buy Cadence Pspice. It has auto
    convergence build in. It's seldom I see problems with convergence after
    they added that feature.

    LT Spice is usually pretty good. It just didn't like my trying to make
    a 32-bit phase accumulator with an analog circuit.

    I once fixed a convergence problem by adding one resistor to the
    circuit. 1K, one ended grounded, the other end open.

    LT is horrible with digital stuff. Imagine making a 32-bit phase
    accumulator with its parts. There isn't a screen big enough.

    Qspice is I hear better at mixed-signal sims.

    I can always have one of my kids Matlab the hard stuff.

    If you buy Pspice Advanced, you can run c++ code in each time step, or
    whatever timestep you like. I am doing that to simulate a digital SMPS
    in spice

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lasse Langwadt@21:1/5 to Klaus Vestergaard Kragelund on Thu Dec 12 01:05:50 2024
    On 12/11/24 21:47, Klaus Vestergaard Kragelund wrote:
    On 11-12-2024 17:49, john larkin wrote:
    On Wed, 11 Dec 2024 14:07:45 +0100, Klaus Vestergaard Kragelund
    <klauskvik@hotmail.com> wrote:

    On 11-12-2024 03:38, john larkin wrote:
    I have been unsuccessful in getting LT Spice to simulate a DDS
    frequency generator. It's bad enough trying to make the NCO part, but
    whenever I get close it stalls or throws convergence errors.


    I think you have the funds to buy Cadence Pspice. It has auto
    convergence build in. It's seldom I see problems with convergence after
    they added that feature.

    LT Spice is usually pretty good. It just didn't like my trying to make
    a 32-bit phase accumulator with an analog circuit.

    I once fixed a convergence problem by adding one resistor to the
    circuit. 1K, one ended grounded, the other end open.

    LT is horrible with digital stuff. Imagine making a 32-bit phase
    accumulator with its parts. There isn't a screen big enough.

    Qspice is I hear better at mixed-signal sims.

    I can always have one of my kids Matlab the hard stuff.

    If you buy Pspice Advanced, you can run c++ code in each time step, or whatever timestep you like. I am doing that to simulate a digital SMPS
    in spice

    qspice and also run c++ or verilog modules

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bill Sloman@21:1/5 to john larkin on Fri Dec 13 00:27:57 2024
    On 12/12/2024 5:50 am, john larkin wrote:
    On Tue, 10 Dec 2024 18:38:18 -0800, john larkin <JL@gct.com> wrote:

    I have been unsuccessful in getting LT Spice to simulate a DDS
    frequency generator. It's bad enough trying to make the NCO part, but
    whenever I get close it stalls or throws convergence errors.

    So I wrote a PowerBasic program that's the 32-bit NCO... GC_Num.exe.

    Making a proper .WAV file would be a nightmare, so it outputs as a
    text file with just time data per line, where data is the
    selected number of MS bits of the phase accumulator.

    LT Spice can read the file, and then do whatever it wants: sine, DAC,
    filter, comparator, FFTs.

    https://www.dropbox.com/scl/fo/o0mdxxqvxupg6ynz7i7rx/AMPMbv9NOY4mJFXggTGUqJ8?rlkey=9ecl38npbgy8kxuzd9bako4kr&dl=0

    Spice reads the file as a piecewise-linear thing, so wrecks the nice
    MSB data steps. I had to fool it by outputting each clocked phase
    accumulator value twice, as

    bits time
    bits time+0.9*clock_period

    same data bits both lines. Looks pretty steppy.

    Given a 40 MHz phase accumulator, one could spin up a clock at some
    mutiple, 160 MHz maybe, and fake the dac/lowpass/comparator thing to
    reduce jitter.

    I think it's just a lookup table on some MSBs of the 40 MHz phase accumulator. Of course the new fake DDS clock output would be
    quantized to the 160 MHz clock domain. Maybe.

    The whole point about DDS frequency synthesis scheme is that it isn't
    limited to the master clock edges.

    The sine-look-up table gives you a staircase approximation to the
    desired sine wave, which is limited in just that way, but as soon as you low-pass filter the staircase steps into a smooth slope, your
    zero-crossings can move smoothly and continuously.

    Faking that stage is - at least in theory - doable, but it's going to be messier than the DAC-low-pass filter scheme, which has the advantage of
    being popular (so that there are lots of standard parts available) and
    easier to explain.

    --
    Bill Sloman, Sydney

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris Jones@21:1/5 to john larkin on Fri Dec 13 21:17:13 2024
    On 11/12/2024 9:31 pm, john larkin wrote:
    The "RF" mindset, that one has to do the sine and dac and hi-rent
    lowpass filter and comparator, is not only a bunch of work and
    expense, it gets really nasty at low frequencies.

    Then don't do it at low frequencies. Do it at 2^N times the low
    frequency that you want, and then after the comparator divide by 2^N.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From john larkin@21:1/5 to lugnut808@spam.yahoo.com on Fri Dec 13 09:09:57 2024
    On Fri, 13 Dec 2024 21:17:13 +1100, Chris Jones
    <lugnut808@spam.yahoo.com> wrote:

    On 11/12/2024 9:31 pm, john larkin wrote:
    The "RF" mindset, that one has to do the sine and dac and hi-rent
    lowpass filter and comparator, is not only a bunch of work and
    expense, it gets really nasty at low frequencies.

    Then don't do it at low frequencies. Do it at 2^N times the low
    frequency that you want, and then after the comparator divide by 2^N.

    I think that can be done, but very carefully. We need long-term phase
    coherence to simulate a complex geared machine, and we need frequency
    changes to happen at a selected phase angle, like top-dead-center of
    some waveform of some part of a mechanism.

    Using the MSB of the phase accumulator is sure appealing. Going
    off-chip to a DAC and a filter and a comparator adds time lag and
    jitter.

    Most DDSs are RF oriented so don't care about time. Maybe some exotic
    radars would.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Joe Gwinn@21:1/5 to john larkin on Fri Dec 13 13:42:01 2024
    On Fri, 13 Dec 2024 09:09:57 -0800, john larkin <JL@gct.com> wrote:

    On Fri, 13 Dec 2024 21:17:13 +1100, Chris Jones
    <lugnut808@spam.yahoo.com> wrote:

    On 11/12/2024 9:31 pm, john larkin wrote:
    The "RF" mindset, that one has to do the sine and dac and hi-rent
    lowpass filter and comparator, is not only a bunch of work and
    expense, it gets really nasty at low frequencies.

    Then don't do it at low frequencies. Do it at 2^N times the low
    frequency that you want, and then after the comparator divide by 2^N.

    I think that can be done, but very carefully. We need long-term phase >coherence to simulate a complex geared machine, and we need frequency
    changes to happen at a selected phase angle, like top-dead-center of
    some waveform of some part of a mechanism.

    Using the MSB of the phase accumulator is sure appealing. Going
    off-chip to a DAC and a filter and a comparator adds time lag and
    jitter.

    Most DDSs are RF oriented so don't care about time. Maybe some exotic
    radars would.

    Big radars in general care about time and phase a lot, not to mention
    phase noise. And long-term stability over time.

    Joe Gwinn

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)