Question about simulating Square waves with QSpice

Objective: check the square wave output of 10w amp design.
I've copied from Mike Engelhardt quick start video which uses "pulse 0 1 0 1u 1u .5m 1m" expression
I also include:
.tran 3
.plot V(out)
.four 1K V(out)
Result-
Fatal error: This .four requires 0.001 second of time but only 0 second was simulate

1) I'm wondering if I'm misinterpreting the QSpice quick start guide!
2) I placed a 6ohm resister load to OUT - should I delete this? Without shows a broken square wave of sorts!

Thanks
 
Administrator
Joined 2007
Paid Member
I've just tried those commands on an amp I have set up and it runs OK. Your .tran 3 is a bit of a long run for 1kHz squarewave but it does run. Maybe something with the amp sim is causing an issue.

Screenshot 2024-01-25 181219.png


Screenshot 2024-01-25 181249.png


And .tran at 10ms

Screenshot 2024-01-25 181356.png
 
Are there any other error messages, for example about convergence errors, too small time steps or not found bias points?
Just for a fraction of a second, as it ran, an error message flashes but gets masked by the resulting output - a flat line at 0V.
Mooly showed it works so the error message is caused an issue with my circuit - thanks to both you and Mooly I can now focus on problem solving the error in my circuit. I'll include a screenshot should any one wish to play with the circuit in the future. What I like about it is, even with such a simple forward resistor from output to base emitter, X-over distortion looks quite benign.
 

Attachments

  • error-01-25.PNG
    error-01-25.PNG
    33.7 KB · Views: 24
Administrator
Joined 2007
Paid Member
Where are you getting your opamp model from? I haven't put the hours in with Qspice to figure out how to create and add models as yet :)

If you can post the sim file (.qsch files will attach directly to the forum just like other files) we might be able to figure it out.
 
Where are you getting your opamp model from? I haven't put the hours in with Qspice to figure out how to create and add models as yet :)

If you can post the sim file (.qsch files will attach directly to the forum just like other files) we might be able to figure it out.
Agh - I discovered this under a different tab Fatal error: Timestep too small(1.25e-19) at t=0
Now I'm trying to determine t=0
SOLVED - think! - changed first digit to "9" now have square waves (I think) - grin

OP-amp model is from NJM (Japan) product site https://www.nisshinbo-microdevices.co.jp/en/
 

Attachments

  • Class_B_unbiased_single_channel_SGC6144SG-pulse-test-Keep.qsch
    17.2 KB · Views: 26
Last edited:
Administrator
Joined 2007
Paid Member
Thanks for the link :)

So.... I can get your sim to run... the amplitude is perhaps to high and a 1 volt input will drive it into the rails. If I reduce the amplitude it runs OK.

Try 0.1 volt amplitude and:

Code:
tran 0 200m 180m

to allow the sim to run for 180ms before showing data to allow the coupling cap to charge and settle.

Screenshot 2024-01-26 110814.png
 
To reduce the amplitude do I reduce the negative feedback gain? I tried this and got the sim output
Try 0.1 volt amplitude and:
Thank you for this information. I've read through the Help Docs looking for info to set voltage amplitude. I tried adding .param=V0.1 and changed the gain to below 1V. Result is "Timestep too small(1.25e-19) at t=0".
May I ask you to write the step you did to change the amplitude? Many thanks.
 
Administrator
Joined 2007
Paid Member
1/ Right click the word 'Pulse' and click the 'Edit This Attribute' on the flyout menu'.

2/ Change the '1' to say '0.1' which reduces the amplitude from 1 down to 0.1 volt.

For info...

Do step 1 above and delete everything in the attribute. Now type Pulse and a space and you should then see all the prompts for each bit of info. Leave number of cycles blank for it to run continually.

Now try again and type Sine and you will get the prompts for that.

Screenshot 2024-01-26 143103.png


Screenshot 2024-01-26 143428.png
 
Do you understand what sort of values to enter to create say a 10kHz square wave or a 4kHz sine for example?
Thanks, Wooly.This is my retirement project. I'm still searching for a tutorial to guide me to the values I should be inputting. Searched Ask Linda and Coursera for a course to enrol to but haven't found a recommended one to date. Online I found some student packs with electrical engineering lessons building amps blah but none use SPICE sim. SINE I have taught myself from trial and error, PULSE I'm still working on and I've still got hair left to pull!
 
To generate a 10K square wave with 0.1V I've used Tperiod=10u, (1/10) trise=.01u, tfall=.01u, and Ton=? I've put this value arbitrarily. pulse 0 0.1 0 0.01 0.01 1µ 10µ
The output looks like shark fins so I'm guessing Ton value s my problem. How does one calculate Ton value?
 
Administrator
Joined 2007
Paid Member
To generate a 10K square wave with 0.1V I've used Tperiod=10u, (1/10) trise=.01u, tfall=.01u, and Ton=?

You take the frequency you want and find its reciprocal (divide F into 1) So we get 1/10,000 which is 0.0001 seconds or 0.1ms. That gives the period of 1 cycle. If we want it to be a 50:50 square wave we set TPeriod to 0.1m and Ton to half that which is 0.05m.

Code:
Pulse 0 0.1 0 1µ 1µ 0.05m 0.1m

Working back if we look at one cycle we see it takes 0.1ms and so if we find the reciprocal of that we derive the frequency. 1/0.1E-3 is:

Screenshot 2024-01-26 183452.png


Screenshot 2024-01-26 183323.png

Trise and Fall determine how fast the signal rises and falls.

Set at 10n here and we are looking at the voltage source. I set the start voltage at -0.1 and the on voltage at 0.1 here.

Screenshot 2024-01-26 184713.png
 
Fantastic! I couldn't find this sort of explanation with a browser search, thank you for making time to explain.
BTW have you a website to recommend suitable for learners?
Very slightly off topic - I have found information presented on a free Coursera course (Sound Engineering) interesting
https://www.coursera.org/learn/audio-engineering?#modules.
I could post it in a different section for others if this thread is not ideal.
 
Administrator
Joined 2007
Paid Member
You're welcome :) Fwi it took me a very long time to figure anything out with LTspice and it was Bob Cordells book on Audio Amplifier Design that covered a lot of the ground work for me. I couldn;t find answers either...

I don't know of any particular sites for Qspice beyond the Qorvo tech forums:
https://forum.qorvo.com/

I'll ask over your link, first thought was the 'Electronic Design' forum:
https://www.diyaudio.com/community/forums/electronic-design.200/

but I will ask because it might be considered more advertising as much as anything else.