Trying to simulate this simple alarm circuit in LiveSPICE - Page 1
Forum section: electronics / beginners

author: tigrou
author_rank: Regular Contributor
timestamp: February 03, 2021, 01:21:11 am
content: I'm trying to simulate this circuit in LiveSPICE (sorry for poor quality, this is a scan from someone else and I don't have the book anymore ).It came from the manual of a educational toy kit I had as a kid.Here is what I setup in LiveSPICE :The circuit and LiveSPICE can be downloadedhereandhere.It is supposed to produce a simple alarm sound (probably a triangle/square wave).Unfortunately, it does not work. All it produce is horrible garbage noise.I have tried the following without success :- To increase speaker impedance (which by default is infinite) : it produce a different sound but still garbage.- To add an inductor in parallel or series to the speaker : act as a low pass filter but does not fix anything.The resistance values are correct. Same for the capacitors.Any idea what could be wrong ?

author: perieanuo
author_rank: Frequent Contributor
timestamp: February 03, 2021, 06:45:38 am
content: try microcap and tell us if it works

author: Zero999
author_rank: Super Contributor
timestamp: February 03, 2021, 09:41:48 am
content: Are you sure R1 should be 68k, not 680k?Try a different simulator. By the sounds of it, LiveSPICE is a real time simulator, which is never as good, as one when the simulation is run and it generates a plot. I'd go for LTSpice, which I'm told it has a steep learning curve, although I picked it up fairly easilly.

author: tigrou
author_rank: Regular Contributor
timestamp: February 03, 2021, 10:45:34 am
content: Quote from: perieanuo on February 03, 2021, 06:45:38 amI didn't know about that tool. Thanks. I tried it however I cannot find the speaker component. Is this supported ?Quote from: Zero999 on February 03, 2021, 09:41:48 amI'm pretty sure it is 680k, here is all the components available with the kit ("Widerstand" means resistor):Quote from: Zero999 on February 03, 2021, 09:41:48 amI will definitely give a try.EDIT : same question as for microcap : is there any speaker component in LTspice ? I can't find any.

author: rstofer
author_rank: Super Contributor
timestamp: February 03, 2021, 06:47:35 pm
content: You might try substituting an 8 Ohm resistor for the speaker during simulation. What you want to see is the voltage waveform feeding the speaker, relative to ground.Google for 'transistor astable multivibrator', there are plenty of references.

author: Terry Bites
author_rank: Super Contributor
timestamp: February 04, 2021, 05:39:22 pm
content: Tip. Use Microcap 12 its great, its free.https://www.spectrum-soft.com/download/download.shtm.Ltspice sucks.

author: tigrou
author_rank: Regular Contributor
timestamp: February 04, 2021, 06:03:33 pm
content: Quote from: Terry Bites on February 04, 2021, 05:39:22 pmI tried it already (from perieanuo suggestion), and recreate the whole circuit but could not find any speaker component (that would render output to audio card).Does it exists ?

author: floobydust
author_rank: Super Contributor
timestamp: February 04, 2021, 07:22:47 pm
content: In real life, a loudspeaker has resistance and inductance and (mechanical) generator action - which is part of this oscillator.Add series resistance 8-16 ohms and voice coil inductance depending on speaker size try 30uH for a tiny one.edit: the two-tone switch makes the circuit very dependent on the transistor's beta, in order to get a "VCO" effect. You might have to try different transistors to match the ones in the old kit.

author: Zero999
author_rank: Super Contributor
timestamp: February 04, 2021, 07:26:50 pm
content: Quote from: tigrou on February 04, 2021, 06:03:33 pmI don't know about Microcap, but it's possible to export waveforms to .wav files, with LTSpice. It doesn't have a speaker model, but I normally use a European resistor, of the same value as the speaker's impedance, with a trapezoid drawn next to it, to show it's a speaker. In reality a speaker isn't a simple resistor, but a complex RLC network, which depends on the enclosure, but a simple resistor is fine for most applications.http://ltwiki.org/LTspiceHelp/LTspiceHelp/_WAVE_Write_selected_nodes_to_a_wav_file_.htmhttps://www.analog.com/en/analog-dialogue/raqs/raq-issue-175.htmlhttps://www.allaboutcircuits.com/technical-articles/ltspice-simulation-using-wav-files/Now, whilst I admit that's useful, it's not necessary to prove whether the circuit works or not. A simple plot of the current, or voltage on the speaker is normally good enough. It will show you the frequency and amplitude of the sound. Once you're happy it's working, you can then worry about generating the .wav file, so you can find out what it sounds like.

author: Terry Bites
author_rank: Super Contributor
timestamp: February 05, 2021, 09:33:47 am
content: https://www.spectrum-soft.com/news/fall2011/wav.shtmimporting and exporting WAV files

author: Ian.M
author_rank: Super Contributor
timestamp: February 05, 2021, 10:21:21 am
content: You may find this article on modelling speakers useful:https://circuitdigest.com/electronic-circuits/simulate-speaker-with-equivalent-rlc-circuitThe simplified model of a speaker is just a RL series circuit. LTspice supports arbitrarily large parasitics for inductors, so you can use an inductor with Rser set to the speaker's DC resistance. This is computationally efficient.When you need the full compound RLC model,you can still take advantage of LTspice inductor parasitics. Use two LTspice inductors in series. Apply the DC resistance to one of them. Combine the two capacitors of the model and apply it and the parallel resistance to the other. You may need to override Rser if its default of one milliohm significantly damps the LC tank compared to the damping due to the parallel R.For advanced users, it would be reasonably straightforward to construct a parameterized subcircuit model for a speaker that directly accepts Thiele parameters, and calculates the required inductances, resistances and capacitance from them.

author: Zero999
author_rank: Super Contributor
timestamp: February 05, 2021, 10:54:58 am
content: I doubt such a detailed speaker model is required for this circuit.Here's a link to another thread about using a two transistor astable to drive an 8 Ohm speaker.https://www.eevblog.com/forum/beginners/need-a-speaker-a-resistor/msg1509556/#msg1509556I did a simulation using LTSpice. Note how it uses much lower resistor values, than the orignal poster's circuit. D1 and D2 protect the transistors from reverse voltages. Most circuits I've seen don't bother with them, but I like to include them to improve the reliability.astable sounder.ascI'd recommend using a higher impedance speaker than 8 Ohm, at least 64 Ohm. If you want to use 8 Ohm, then use a lower voltage power supply, or a small audio transformer.

author: tigrou
author_rank: Regular Contributor
timestamp: February 05, 2021, 09:48:23 pm
content: I finally was able to get some sound out of this circuit.To accomplish this I had to (LTSpice is hard, I had to search a lot) :- find missing model BC337S- add directive for wave output- add a SPEAKER node (so it know what to output)- increase simulation duration (instead 25ms by default)

author: Zero999
author_rank: Super Contributor
timestamp: February 05, 2021, 10:46:59 pm
content: Quote from: tigrou on February 05, 2021, 09:48:23 pmWell done! I'm impressed you managed to get it to work. By the way, you needn't have worried about looking for the BC337S model, most small transistors will work. If in doubt, type NPN in the model field, to use the default generic NPN transistor.Now how about building it in real life?

author: tigrou
author_rank: Regular Contributor
timestamp: February 07, 2021, 10:12:31 pm
content: Quote from: Zero999 on February 05, 2021, 10:46:59 pmI already did, with the same kit that schematic came from, almost 30 years ago.The fact I know it's just a astable multivibrator circuit remove a little bit of the fun

author: gnuarm
author_rank: Super Contributor
timestamp: February 07, 2021, 11:21:10 pm
content: Quote from: Zero999 on February 05, 2021, 10:54:58 amA question on the protection diodes... I've been told that exceeding the breakdown voltage can cause damage on the part, or more accurately cause changes in the characteristics even if the current is limited so the damage is not catastrophic. The series diodes have leakage which also pass through the BE junction. Does this very low leakage cause the transistor characteristics to change over time? Or is this too minor an issue to even worry about at these current levels, approximately equal to the BE leakage?To avoid this possibility the protection diodes could be anti-parallel with the BE junction passing the current around the BE junction at a very low voltage level. I assume that won't significantly impair the circuit?

author: Zero999
author_rank: Super Contributor
timestamp: February 08, 2021, 12:46:13 pm
content: Quote from: gnuarm on February 07, 2021, 11:21:10 pmI don't believe the tiny leakage current is an issue. As you said, the transistor also has leakage, which will limit the voltage.QuoteThat would compromise the operation of the circuit, which relies on the fact that the BE junctions block reverse current.https://en.wikipedia.org/wiki/Multivibrator#OperationIf you're really paranoid, you could have reverse parallel diodes in as well as in series. If a dual diode package is used, such as the BAV70, it won't take up any more room on the PCB.https://www.diodes.com/assets/Datasheets/ds12006.pdfQuote from: tigrou on February 07, 2021, 10:12:31 pmDo you have an oscilloscope? It might be fun to look at the waveforms on different parts of the circuit.

author: gnuarm
author_rank: Super Contributor
timestamp: February 08, 2021, 07:47:57 pm
content: Quote from: Zero999 on February 08, 2021, 12:46:13 pmThat depends entirely on the relative amount of leakage which varies widely. So there is no assurance this will protect the BE junction.QuoteI would hope you don't get your education at Wikipedia. They require articles to have references but do not allow references from other parts of Wikipedia. The statements you are citing have no references at all. It's just another hobbyist writing a blog on the Internet. If the behavior of the BE junction is required for such an oscillator why does this circuit work with MOSFETs?Expect to see an update to the Wiki page to correct this mistake.QuoteIf you use the anti-parallel diode the series diode is not required. The circuit oscillates because it meets the Barkhausen criteria. Adding the anti-parallel diode may alter the gain characteristics of the circuit, but it does not preclude it from working. Simply adjust the passive components to meet the Barkhausen criteria at the appropriate frequency with the diodes in place.

author: Zero999
author_rank: Super Contributor
timestamp: February 08, 2021, 08:48:14 pm
content: Quote from: gnuarm on February 08, 2021, 07:47:57 pmThe 1N4184 is very low leakage, the tiny current isn't a problem. Many people also build this circuit, without any protection diodes and say they say it works perfectly. I prefer to add them, just to be sure.QuoteI don't believe everything I read on Wikipedia, but I can confirm the article I linked to above, is factually correct. If you build it, or put it into a simulator, it works exactly as the Wikipedia article states. The Wikipedia version won't work with MOSFETs. The capacitors would just charge up. It needs the feedback resistors to be connected to the opposing drain, to provide a discharge path, as per the version I posted.QuoteYes, I stand corrected, it will work with ant-parallel diodes, but it's more stable with the diodes in series, especially at lower frequencies.