How can I do a 10 khz square wave with LtSpice ?

Status
Not open for further replies.
Add a voltage source to your circuit. Right click on it. A window like below should pop up. The values below gives a 10kHz square wave. Adjust for 31kHz.
 

Attachments

  • sq.jpeg
    sq.jpeg
    48.4 KB · Views: 21,919
You can leave Ncycles alone since thats only how many cycles it'll give before it stops, leaving it blank will make a continous pulse train.

On Nperiod you put in the equivalent time for 31 kHz and Ton will be half of that value to define 50% duty cycle.

Rise and fall can be set to 1µ.
 
Tperiod would be 1/31000.
Ton will be half that

You may do:
Ton = {0.5/<value in Hz>}
and
Tperiod = {1/<value in Hz>}

I would also use rise/fall times of 0.01u as this will give you a "perfect" square wave with no percievable rise/fall time.
 
clik on the attachment thumbnail?

the line:

.param f = 31k, t_edge=1u

has to be entered in the <.op> tool pop up window (far right on toolbar)

the line:

PULSE(-1 1 0 {t_edge} {t_edge} {1/2/f-t_edge} {1/f})

is the "value" entry for the Vsource, usually entered in the dialog window but can be pasted in the pop up box when rt clking on the value

[edit: paste the line in a Vsouce "Value", then rt cik Vsource body, you will see filled in parameters in window]

add new named params to control additional sources, you can have f1 = 10k, f2 = 31k on the same schematic with the Vsources each using the appropriate parameter name
 
Last edited:
Hi

The 31 khz square wave are working but it's all down on the negative side like you can see in my image.

I've only used Ltspice with sine wave in amps simulations.

Thanx

Paul
 

Attachments

  • Capture3.jpg
    Capture3.jpg
    154.9 KB · Views: 1,633
  • Capture2.jpg
    Capture2.jpg
    161 KB · Views: 4,561
Last edited:
yes it shows some more advanced spice feautures, but I thought I was clear on how they can be copy/pasted from my post

learning how to get the Spice SW do the calculation seems worth the complication if you're using oddball frequencies with primes too big to count on fingers in their factorizations
 
Status
Not open for further replies.