1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

LTSpice and oscillators: what's the secret?

Discussion in 'General Electronics Chat' started by allaccess, Sep 15, 2017.

  1. allaccess

    allaccess New Member

    Joined:
    Sep 11, 2017
    Messages:
    11
    Likes:
    0
    I am having trouble getting LTSpice to simulate oscillations. I drew a schematic of a simple DC source and resistor circuit to make sure I could get the software to work, and after running and adding a current waveform, the waveform displayed just as it should.

    Then, I tried two oscillators: a 1 transistor relaxation oscillator, and, a 2 transistor multivibrator. After running and adding a waveform, neither showed any signs of oscillation. Instead of a waveform that went up and down, I just got a flat, steady-state line. I also added the modifier "startup" to the .tran. That didn't make any difference either.

    Is there a setting or entry method I don't know about?

    Thanks, allaccess
     
    Last edited: Sep 15, 2017
  2. crutschow

    crutschow Well-Known Member Most Helpful Member

    Joined:
    Mar 14, 2008
    Messages:
    10,592
    Likes:
    477
    Location:
    L.A., USA Zulu -8
    Try the .uic Transient option (bottom option below):

    upload_2017-9-15_17-23-43.png

    Spice normally does a DC initial bias calculation with no inductors or capacitors, and that can put an oscillator in a quasi-stable state.
    Avoiding this calculation usually allows the oscillations to start.
     
    • Informative Informative x 1
  3. allaccess

    allaccess New Member

    Joined:
    Sep 11, 2017
    Messages:
    11
    Likes:
    0
    I tried your suggestion, crutshow. Still no waveform.
    Here's the circuit. I breadboarded it and it works great:
    [​IMG]
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. ronsimpson

    ronsimpson Well-Known Member Most Helpful Member

    Joined:
    Apr 17, 2007
    Messages:
    7,253
    Likes:
    961
    Location:
    Loveland, CO USA

    Please send your SPICE file. So we don't have to draw it from zero and so we can see what you are doing.
     
  6. allaccess

    allaccess New Member

    Joined:
    Sep 11, 2017
    Messages:
    11
    Likes:
    0
    Attached is the file "2 transister oscillator.asc" which is the file generated by LTSpice which contains the above circuit. If anybody can get it to show the waveforms that the actual circuit generates, I would be grateful.
    Thanks, allaccess
     

    Attached Files:

  7. allaccess

    allaccess New Member

    Joined:
    Sep 11, 2017
    Messages:
    11
    Likes:
    0
    Allaccess is mortified. I forget to draw the capacitor! :banghead:. Please disregard my thread. Ugh.
    After discovering the above, I edited this reply:
    I drew the capacitor and still can't get oscillating waveforms, so I ask again to help me figure out why I am getting just flat lines. I have attached the corrected .asc file.
     
    Last edited: Sep 15, 2017
  8. allaccess

    allaccess New Member

    Joined:
    Sep 11, 2017
    Messages:
    11
    Likes:
    0
    After discovering the above, I edited this reply:
    I drew the capacitor and still can't get oscillating waveforms, so I ask again to help me figure out why I am getting just flat lines. I have attached the corrected .asc file.
     

    Attached Files:

  9. MikeMl

    MikeMl Well-Known Member Most Helpful Member

    Joined:
    Mar 17, 2009
    Messages:
    11,047
    Likes:
    541
    Location:
    AZ 86334
    Try this:

    1. every circuit MUST have a GND node.
    2. the NPN and PNP generic transistors are too small (Ic) to be useful in a circuit like this. Use "real" transistors.
    3. B supply is for a specialized use. Not for a power supply, especially when you need to use the .startup directive.
    4. use a real LED with a forward voltage drop similar to what you use in your real circuit instead of a generic Si diode. It will not oscillate if you put a "white" LED model (Vf=3.3V is too high to ever pass any current with only a 3V battery; Red Vf=~2V works)
    5. Your sim time was 3 orders of magnitude too short.
    6. do not use .uic. It is a pile driver when a little tap will do. The .startup directive will shock the oscillator enough to get it going. (btw-the oscillator will start without the .startup directive, but it draws a lot of current for quite a while...)
     

    Attached Files:

    Last edited: Sep 15, 2017
    • Informative Informative x 1
  10. simonbramble

    simonbramble Active Member

    Joined:
    Nov 22, 2010
    Messages:
    430
    Likes:
    63
    a real oscillator relies on some disturbance in the circuit to 'get it going'. If the circuit has a resonance at one frequency as well as enough gain in the circuit to overcome the losses, it will build up to sustained oscillation.

    Now LTspice tends to apply the supply voltages before it starts the simulation, so you have no disturbance to the circuit so it does not oscillate. Try ramping the power supply up from 0V to Vsupply over 1us at the start of the simulation. You can use the PWL voltage source to do this. This might work
     
  11. atferrari

    atferrari Well-Known Member

    Joined:
    Oct 8, 2003
    Messages:
    2,812
    Likes:
    121
    Location:
    Buenos Aires - Argentina
    I vaguely recall doing something like adding an RC "cell" somewhere in the feedback path, whose resonant frequency was close to if not the same of the design. Not sure how it was actually connected but surely started the oscillations. From what I remember it meant something at start time and irrelevant afterwards.

    Simon's post made me recall the above.

    My defunct PC treasures way too many things I did in the last years. The new one not in service yet.
     
  12. allaccess

    allaccess New Member

    Joined:
    Sep 11, 2017
    Messages:
    11
    Likes:
    0
    Thank you Mike, Simon, atferrari.
    I need to understand LTSpice better before I try any further.
     
  13. atferrari

    atferrari Well-Known Member

    Joined:
    Oct 8, 2003
    Messages:
    2,812
    Likes:
    121
    Location:
    Buenos Aires - Argentina
    Besides the "official" tutorials, those by Simon Bramble are short and to the point.
     
  14. crutschow

    crutschow Well-Known Member Most Helpful Member

    Joined:
    Mar 14, 2008
    Messages:
    10,592
    Likes:
    477
    Location:
    L.A., USA Zulu -8
    That's what the ".startup" directive that MikeMl used basically does.
     
  15. allaccess

    allaccess New Member

    Joined:
    Sep 11, 2017
    Messages:
    11
    Likes:
    0
    Success! LTSpice now accurately shows the oscillations.
    However, my 1 transister relaxation oscillator still doesn't show oscillations:
    (does LTSpice not like transistors used in reverse?)
    upload_2017-9-16_17-10-41.png

    attached is the LTSpice .asc file.

    Thanks, allaccess
     

    Attached Files:

    Last edited: Sep 16, 2017
  16. MikeMl

    MikeMl Well-Known Member Most Helpful Member

    Joined:
    Mar 17, 2009
    Messages:
    11,047
    Likes:
    541
    Location:
    AZ 86334
    You are using an reverse bias avalanche mode of the transistor which is not modeled in the transistor Spice model. It is not modeled because it is usually not tested for/specified by the transistor maker, and no designer of a commercial product would ever use it for a re-produceable, manufacturable product...
     
    Last edited: Sep 16, 2017
  17. allaccess

    allaccess New Member

    Joined:
    Sep 11, 2017
    Messages:
    11
    Likes:
    0
    Much appreciated MikeMI
     

Share This Page