LTSPICE square wave

Is there a way to make a square wave using the LTSPICE ac voltage source which doesnt have a DC offset, i.e. alternates between -5 and +5, say? I can't seem to figure it out. Thanks.

--
----Android NewsGroup Reader---- 
http://usenet.sinaapp.com/
 Click to see the full signature
Reply to
bitrex
Loading thread data ...

two voltage sources in series, one doing PULSE() and the other with negative Von/2

Reply to
Przemek Klosowski

You don't use an _AC_ source to make a square wave, you use a Vpulse source.

The notation is:

Vx PosNode NegNode PULSE -5V 5V {TD} {TR} {TF} {PW} {PER}

The timings should be obvious. However there is a trickiness...

Pulse-width {PW} is set to be true desired pulse width minus {TR}

I have created a true pulse source which has smooth TANH rise and fall (natch ;-), and {PW} is the real-deal, no scratching of head required. I haven't ported it to LTspice yet. ...Jim Thompson

--
| James E.Thompson                                 |    mens     | 
| Analog Innovations                               |     et      | 
 Click to see the full signature
Reply to
Jim Thompson

And you DO want to have some real rise and fall time in there: Tha solver can get cranky if you don't.

--
www.wescottdesign.com 


----Android NewsGroup Reader---- 
 Click to see the full signature
Reply to
Tim Wescott

Sure.

Voff = -5 Von = 5

Cheers

Phil Hobbs

--
Dr Philip C D Hobbs 
Principal Consultant 
 Click to see the full signature
Reply to
Phil Hobbs

One handy gadget is BV, the behavioral voltage source. It allows you to type an equation to make a voltage from something else. You can square up a sine wave like this:

Version 4 SHEET 1 880 680 WIRE 96 96 48 96 WIRE 128 96 96 96 WIRE 320 96 272 96 WIRE 352 96 320 96 WIRE 48 144 48 96 WIRE 272 144 272 96 WIRE 48 256 48 224 WIRE 272 256 272 224 FLAG 48 256 0 FLAG 272 256 0 FLAG 96 96 VX FLAG 320 96 OUT SYMBOL voltage 48 128 R0 WINDOW 0 55 73 Left 2 WINDOW 3 27 110 Left 2 WINDOW 123 0 0 Left 2 WINDOW 39 0 0 Left 2 SYMATTR InstName V1 SYMATTR Value SINE(0 1 1) SYMBOL bv 272 128 R0 WINDOW 0 63 61 Left 2 WINDOW 3 29 106 Left 2 SYMATTR InstName B1 SYMATTR Value V=5*sgn(V(VX)) TEXT -144 224 Left 2 !.tran 5 TEXT -200 112 Left 2 ;Sine to Square TEXT -176 152 Left 2 ;JL Jan 2016

That lets you specify the frequency in Hz, as opposed to the pulse source which makes you work in pulse width and period.

--
John Larkin         Highland Technology, Inc 
picosecond timing   precision measurement  
 Click to see the full signature
Reply to
John Larkin

Indeed, there is no such thing as an "ideal square wave"; a real, physical signal must be continuous (including derivatives blah blah), and therefore must have a nonzero rise/fall time.

The solver "getting cranky" is a subtle hint that you're trying to model something that cannot exist. :)

Tim

--
Seven Transistor Labs, LLC 
Electrical Engineering Consultation and Contract Design 
 Click to see the full signature
Reply to
Tim Williams

--
There is, but why would you want to when you could use a pulse source 
with a V initial of -5 volts and a Von 0f 5 volts? 
 Click to see the full signature
Reply to
John Fields

There doesn't appear to be any option for that with the v pulse source, just "v_initial" and "v_on"

--
----Android NewsGroup Reader---- 
http://usenet.sinaapp.com/
 Click to see the full signature
Reply to
bitrex

That solution is too simple! :-)

It's the same thing. Give it a try.

--
Regards, Joerg 

http://www.analogconsultants.com/
Reply to
Joerg

Setting V_initial at -5 doesnt seem to do anything.

--
----Android NewsGroup Reader---- 
http://usenet.sinaapp.com/
 Click to see the full signature
Reply to
bitrex

You can make almost any part behavioral, like a resistor whose value depends on the local rain forecast. As long as one does keep in mind when LTSpice becomes a princess on the pea, such as when resistor values drp to zero or get too close to it.

--
Regards, Joerg 

http://www.analogconsultants.com/
Reply to
Joerg

It does in all my schematics where I needed that. Can you post yours here as an ASCII list?

--
Regards, Joerg 

http://www.analogconsultants.com/
Reply to
Joerg

Can a resistor value track some node voltage in real time?

--
John Larkin         Highland Technology, Inc 
picosecond timing   precision measurement  
 Click to see the full signature
Reply to
John Larkin

Pulse sources are a minor nuisance to program, if what you care about is frequency.

--
John Larkin         Highland Technology, Inc 
picosecond timing   precision measurement  
 Click to see the full signature
Reply to
John Larkin

I found the problem! The voltage source was feeding a voltage doubler and I had only put the ground on the other side of the rectifiers. I forgot to add another ground symbol at the voltage source. It worked but it didn't know where ground was...

--
----Android NewsGroup Reader---- 
http://usenet.sinaapp.com/
 Click to see the full signature
Reply to
bitrex

Only problem is, now it doesn't double correctly as the diodes are connected to ground and not AC. Hmmm...

--
----Android NewsGroup Reader---- 
http://usenet.sinaapp.com/
 Click to see the full signature
Reply to
bitrex

[...]

Sort of. You can use a behavioral current source like below. This only works for transient analysis.

Jeroen Belleman

------------------------- Version 4 SHEET 1 880 680 WIRE -16 112 -96 112 WIRE 48 112 -16 112 WIRE 240 112 192 112 WIRE 272 112 240 112 WIRE -96 144 -96 112 WIRE 48 144 48 112 WIRE 192 144 192 112 WIRE 272 144 272 112 WIRE -96 256 -96 224 WIRE 48 256 48 224 WIRE 192 256 192 224 WIRE 272 256 272 224 FLAG 272 256 0 FLAG 48 256 0 FLAG 192 256 0 FLAG 240 112 resistance FLAG -96 256 0 FLAG -16 112 val SYMBOL voltage 48 128 R0 WINDOW 123 0 0 Left 2 WINDOW 39 0 0 Left 2 SYMATTR InstName V1 SYMATTR Value SINE(0 1 10) SYMBOL voltage 272 128 R0 WINDOW 123 0 0 Left 2 WINDOW 39 0 0 Left 2 SYMATTR InstName V2 SYMATTR Value PULSE(1 2 1 1 1 3) SYMBOL res 176 128 R0 SYMATTR InstName R1 SYMATTR Value 1R SYMBOL bi -96 144 R0 WINDOW 3 22 159 Left 2 SYMATTR InstName B1 SYMATTR Value I=v(val)/v(resistance) TEXT 88 56 Left 2 !.tran 10

Reply to
Jeroen Belleman

Yes. In the same way you did it you just enter an expression such as R=((V(X))*1MEG) in place of the resistor value and then it'll follow node X with whatever formula you drape around it. Quite handy for simulating LDRs, strain gauges or potmeter actuation.

--
Regards, Joerg 

http://www.analogconsultants.com/
Reply to
Joerg

Not sure what you are trying to do but if you need a part of a circuit to float where SPICE does not like it you can connect it via 100MEG or some other high value that doesn't matter much. Just not too high so the solver doesn't hit a ceiling.

--
Regards, Joerg 

http://www.analogconsultants.com/
Reply to
Joerg

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.