LTspice, Dflop

Discussion in 'Programmer's Corner' started by smswedenburg, Jan 15, 2016.

  1. smswedenburg

    Thread Starter New Member

    Jan 15, 2016
    7
    0
    How do I simulate a D FF in LT spice, not working except with /Q tied to D, cannot make shift register work.
    Suggestions?
     
  2. Brownout

    Well-Known Member

    Jan 10, 2012
    2,375
    998
    I suggest that you post your asc file and someone in here can run it and find out what's wrong. I also suggest you post electronic related questions in one of the technical forums, say General Electronics Chat. The 'off topic' forum is not for technical questions.
     
  3. smswedenburg

    Thread Starter New Member

    Jan 15, 2016
    7
    0
    So post in General Electronics, asc file.
    Glad to do so.
    Thank you for the pointers.
     
  4. WBahn

    Moderator

    Mar 31, 2012
    17,724
    4,788
    I'd also recommend posting a schematic image (PNG generally works best) so that people can view the circuit you are trying to work with. Many people won't have the simulator you are using or won't download files, but can identify your problem with just a quick glance at the circuit.
     
  5. smswedenburg

    Thread Starter New Member

    Jan 15, 2016
    7
    0
    Here is the asc file for divide by 2 and the file for Shift reg.
     
  6. smswedenburg

    Thread Starter New Member

    Jan 15, 2016
    7
    0
    Thank you for moving my first post, appreciate the help.
     
  7. WBahn

    Moderator

    Mar 31, 2012
    17,724
    4,788
    Could you please post an image of the schematic? I'm one of those people that, as a rule, will not download binaries.
     
  8. smswedenburg

    Thread Starter New Member

    Jan 15, 2016
    7
    0
    Gladly.
     
  9. WBahn

    Moderator

    Mar 31, 2012
    17,724
    4,788
    Next is to post a shot of your simulation results (I should have asked for that before -- sorry).

    I think your shift register is probably doing exactly what you are telling it to do -- but it depends on the initial conditions that the simulator arrives at.

    It looks like you are trying to make a power-on set by having the PRE inputs of all the FF be HI for a short amount of time after the circuit starts and then help LO after that. But the time constant of that circuit is 1 ms and your clock has a period of less than half that.

    Let's say that the power-on circuit does what you want. What does it do? It SETS all three FF to HI. You then start shifting a HI in from the left. What will each FF do? It will stay HI.

    But I suspect your power-on circuit isn't playing any role because you are driving it with a DC source, meaning that the simulator is going to try to determine the voltage on the capacitor in that circuit when driven by a DC source at time t=0, which would have it fully charged and the PRE inputs pulled LO.

    Try using a PWL source for the PRE input and a different one for the D input. That way you can have all of the input waveforms doing exactly what you want them to do.
     
  10. smswedenburg

    Thread Starter New Member

    Jan 15, 2016
    7
    0
    That makes great sense, I am a Power Conversion and RF guy.
    I will give this a try, thank you for the great pointers.
     
  11. crutschow

    Expert

    Mar 14, 2008
    13,000
    3,229
    One error is that the power-on reset circuit should go to the CLR (to set all the Q outputs low) not the PRE inputs.

    But even with that correction the circuit does not work properly.
    All the FF Q outputs go high at the first clock pulse.
    After some experimentation I determined that the problem is that the ideal FF model they use apparently has no propagation delays built-in as a normal model would. Thus when the first flip-flop output goes high it instantly propagates through the whole chain on the rise of the clock.
    I got it to work properly by putting a small (10ns) RC delay at the D-inputs to the 2nd and 3rd FF's as shown below.

    I also simulated it with a CD4013 D-FF model I have and it that works too (without the added delay circuitry).
    Suggest you download the CD4000 library from the Yahoo LTspice user's group if you want to do any more digital simulation.

    Shift Reg.PNG
     
  12. smswedenburg

    Thread Starter New Member

    Jan 15, 2016
    7
    0
    Excellent, I will get the logic from the Yahoo Group.
    Thank you for the help.
     
Loading...