2
\$\begingroup\$

I am a college level electrical physics student (and so I do not have a lot of knowledge on the topic of electronics) and I am in the midst of writing a report on a project that was done throughout this session.

The project was the conception of a synthesizer, which I did pretty much by myself (I used some videos, manuals and other as sources). I ended up being able to build a functional synthesizer on a breadboard, and everything was working fine.

Now that I am writing the report, the teacher asked me to provide a functional simulation for the circuit, and so I tried doing just that. At first, I used Falstad, and was not able to create a functional simulation, for some reason the software did not specify (so I have no clue why the Falstad simulation does not work). Next, I tried using Tinkercad, and again, it didn't work. This time though, the software provided me with an explanation as to why the simulation didn't work, but I wasn't able to make sense of it.

Hence why I am here, asking for help in order to make a working simulation of the circuit. I want to know if I am simply making a stupid mistake or if it's actually a circuit that is hard to simulate using those software (In which case I will simply report to my teacher that simulating the circuit was impossible).

Here is the circuit diagram, made in Falstad (the first simulation that ended up not working:

Here is the circuit diagram, made in Falstad (the first simulation that ended up not working) Note: the 1k resistor that is connected to the collector of the first transistor is actually 100 ohm.

Here is the Tinkercad simulation that also doesn't work: (here i didn't use the CD40106B since it is not available on the software) Link to the Tinkercad simulation Here is the Tinkercad simulation that also doesn't work

Here is the actual working circuit, built on a breadboard Here is the actual working circuit, built on a breadboard The wires that are not connected to anything are:

  • 1 red and black for power supply
  • 1 red and black for the speaker
  • one black for the oscilloscope probe used
  • 2 green (on the keyboard) to plug in the keyboard.

The electrical components used are

  • CD40106B CMOS Hex Schmitt-Trigger Inverters
  • 2N3904 BPJ NPN transistor
  • IRF510 nMOSFET transistor (I think that this is the full name?)
  • The speaker's label was erased but I know that it's a 100W with 8 Ohm entry impedance.
  • 10k Ohm potentiometer for the volume
  • A 5W 50 ohm resistor (supports higher currents)

For the values of other parts, I think I've written everything on the circuit diagram. I didn't put all of the potentiometers from the keyboard since I don't know the exact value; they are tuned for a specific note. They vary from 1k to 20k.

As can be seen on the Tinkercad simulation, there are also (ideally) a few oscilloscope screen that I would like to show. This is what they look like when I use the physical oscilloscope with the breadboard circuit:

Oscilloscope out Oscillator out (connected to the input pin of the inverting schmitt trigger)

transistor base out transistor base (current and voltage that flows into transistor base)

transistor out (collector) transistor out (collector) (this one is taken in the same place as the next oscilloscope screen but without the polarized capacitor.

After capacitor wave delay After capacitor wave delay

MOSFET out MOSFET out, what plays into the speaker.

\$\endgroup\$
11
  • \$\begingroup\$ Oh and I forgot to mention, I know the parts used in the tinkercad simulation are not the same as the ones used in the actual circuit. This is because I was limited in terms of part options on the software. The actual circuit ran on 9V, whilst the simulated circuit runs on 5V, due to the limitation of the 74HC14 inverting schmitt trigger. For the same reason, I was unable to add a 100W speaker and simply used a 8k Ohm resistor and I was unable to add a 5W 50 Ohm resistor so I used a 50k Ohm resistor. All that matters on the simulation is that the oscilloscope wave parton look the same. \$\endgroup\$
    – Boldumus
    Commented May 17 at 16:04
  • \$\begingroup\$ I managed to make a more functionnal version of the circuit on the falstab simulator. I still am having issues with the oscillator signals. The waveform that comes out of the oscillator is not the same as what I got experimentally and I am not totally sure why. The tension at the base of the transistor is also negative, and I have no idea why, and I am very confused towards why the rest of the simulation still seemingly works. Here is the simulation \$\endgroup\$
    – Boldumus
    Commented May 17 at 17:26
  • \$\begingroup\$ Those error messages would suggest you've got the outputs of the schmitt trigger IC connected to GND or Vcc.. Are you sure it's all been entered correctly? \$\endgroup\$
    – Finbarr
    Commented May 17 at 20:41
  • \$\begingroup\$ Indeed, all other entries of the schmitt trigger have been connected to ground. This is something I did in the breadboard version to remove some noise in the oscillation caused by the other inverters entering into oscillation (this is my theory at least, but whatever the case may be, connecting the other entries to the ground caused the noise I was getting to stop). Anyhow, I've tried to remove the grounds on the other entries and the same problem still happens. I have no idea what could even be pumping the 111mA into the chip. I thought it could have been the transistor or something, but no. \$\endgroup\$
    – Boldumus
    Commented May 17 at 20:50
  • 1
    \$\begingroup\$ Unused CMOS inputs always need to be tied to GND or Vdd otherwise they can float to a state where both output transistors turn on and pass a lot of current from the supply. As the inputs are high impedance this can turn into oscillations. \$\endgroup\$
    – Finbarr
    Commented May 18 at 14:28

2 Answers 2

2
\$\begingroup\$

Firstly, fantastic job on your question! You've posted everything a reader needs: a schematic, parts list, photos, waveforms, and a good explanation of your problem - so have my up-vote!

OK, now to my answer:

Problem: The Protoboard does not match your Simulation

The main problem is that the logic gate used on the board does not match what was used in the simulation. The Schmitt-trigger inverter you used on the prototyping board is a CD40106B (I can see by the photo), whereas the one you used in your simulation is a 74HC14 (from your comment). Compared to the CD40106B, the 74HC14 is much faster, has different (lower) input voltage trip thresholds, has lower output resistance, and its power supply voltage is limited to 6V maximum. So your simulation will not match your scope waveforms because of this difference.

The other problem is parasitics.

Simulators can only be as good as the component model they have been programmed with. Many real-world components are not ideal; they have what are known as "parasitic elements" (abbreviated to just "parasitics"). By "parasitics" what I mean is electrical components that you cannot touch but which exist because of the way that real components are constructed.

For example, real-world diodes have what is called a "parasitic capacitance" connected across their terminals; this parasitic capacitance comes built-in to the diode, it is not a capacitor that you can touch and remove. Some simulators take this capacitance into account, some don't - and it depends on the diode model used for the simulation as to how closely the simulation results will match the real-world results.

Also, parasitics vary considerably between the different part numbers. For example, when it comes to diodes and their parasitic capacitance, a slow diode (like a 1N4004) has a much larger value for this capacitance than a fast diode (like a 1N4148). And that is not to say that all 1N4004 diodes have the exact same parasitic capacitance; there will always be some variation from instance to instance. So even if your simulation takes this parasitic capacitance into account, how accurately your simulation matches your real-world waveforms will depend on how closely the actual parasitics of the real-world component match the values of these parasitics used in the simulation model.

I hope you can start to see that parasitics have an important role to play in determining what is a good design and what is a bad design. A good design behaves in a predictable way regardless of the variation of parasitics that will occur with real-world components. A bad design may work just fine when you build one instance of it, but then stops working when you build another one using the same component part numbers because, for example, the parasitic capacitance of one of its diodes was different from the parasitic capacitance of the diode used in the first build.

How to Proceed From Here

As I see it, you have two choices.
Option 1. Tweak your simulation to get it to closely match the behaviour of your protoboard.

Option 2. Change your design to be more robust against component tolerances and parasitics, and hence much simpler to simulate.

Option 1.
This will take a long time. You will have to select the right simulator that is capable of doing the accuracy needed, learn how to use it, then ensure you have accurate models for each component. Then you would go through an iterative process: compare the results your simulation gives with the waveforms of the protoboard, note the differences, take a guess at which components are causing those differences, change the parameters (and parasitics) of the simulation, and repeat. Keep repeating until the simulation matches the scope waveforms to the accuracy required.

Using LTspice (refer images below), I managed to get waveforms that are similar, but not identical to those on your scope, however, my results depended upon me making adjustments to the following:

  • Schmitt-trigger input voltage trip thresholds.
  • Schmitt-trigger output resistance (R9 of my schematic, below).
  • The parasitic capacitance of the diode connected to the base of the NPN (D1 of the schematic below).

enter image description here

enter image description here


.

Option 2.

As it now stands, your circuit design is not tolerant of parasitics and component variations. The main example of this problem is how the NPN is connected to the oscillator. Usually, the stage following a logic gate is connected to the output pin of the gate. However, in your circuit, the NPN base is coupled (via a capacitor) to the input pin of the logic gate, not the output pin.

So even if you were to get the Schmitt-Trigger of your sim to have the same trip voltages as the one on your protoboard, you would then need to precisely model how much the next stage loads the node at the Schmitt-Trigger input pin.

To get a more predictable design that is far more tolerant of parasitics and component variations, you should connect the base of the NPN to the output pin of the logic gate - however, this needs to be done with some caution.

Simply connecting the 100n capacitor (C1) to the output pin of the Schmitt-Trigger could damage the NPN transistor due to excessive reverse voltage applied to its base. This is because the base will now be receiving a much stronger pulse: 9V peak with fast edges. This could cause strong reverse voltage on the base of the NPN, which may damage it. If you tried this, the actual results you get on the protoboard will be very dependent on the type of diode connected to the base of that transistor, and the parasitics of various components and wiring.

So let's review your design, and look at some suggested changes.


Review of Your Schematic

I can see that your circuit is made up of three main sections:

  1. An input stage (the "keyboard").
  2. A signal processing stage (the oscillator).
  3. An output stage (the amplifier that provides electrical power to the output device, in this case, a speaker).

I have marked-up your schematic and added component identifiers, refer image below:


enter image description here

Image above: Original schematic from question (with red-ink mark-ups by answerer).


Suggested Changes to the Design

The suggested changes are captured in the schematic below. I have preserved the component IDs from the previous schematic as much as possible. Several of the components on your current design are now unused, these are shown on the schematic as the components connected by only one pin. Changes are listed below the schematic.

enter image description here

Main changes:

  1. Output of the oscillator moved to the output pin of Schmitt-trigger.
  2. Added R8 to limit the current supplied by the output pin of Schmitt-trigger into timing capacitor C3 during the brief re-charge time.
  3. Gate drive current for MOSFET Q2 is provided via a buffer stage, formed by using the previous NPN (Q1) and a new PNP (Q3), both configured as emitter-followers.

Due to these changes, the circuit behaviour is now far more tolerant of parasitics, and hence your simulation results should be a much closer match to the protoboard. The key parameters to get right are the trip voltage thresholds for the Schmitt-trigger; once these are set correctly, the simulation should match the scope waveforms quite well.


Waveforms:

enter image description here

Other Improvements:

  1. Less power is drawn from the power supply. The voltage buffer formed by Q1 & Q3 only draws significant current when the gate voltage on the MOSFET Q2 is changing. The static current is almost zero when Q2 gate is OFF, and only ~1mA when Q2 gate is ON (due to current in R4).

  2. Output of Schmitt-trigger chip is no longer heavily loaded during C3 re-charge time, R8 ensures the output current from the Schmitt-Trigger is within device limits, and not dependent upon parasitics (output resistance of chip, and resistance of diode D2).

  3. Oscillator frequency and waveform is far less dependent on the loading effect of the following stage.

Other features:

  1. Adjust the ON time of the MOSFET Q2 by adjusting R8.
  2. Adjust the "tone" of the sound by adjusting R1 & C1.
\$\endgroup\$
8
  • \$\begingroup\$ Thank you very much for all the help, and especially for the effort you put into creating a comprehensive and clear answer to my somewhat confused question. Reading your answer, I realized that providing more context about my situation could have saved you some work. Sorry about that. First of all, context: this project is for a physics class, not even an electrical physics class. The teacher doesn't really have the qualifications to help me with this project, so it was a bit of a shot in the dark when he asked us to simulate the circuit. \$\endgroup\$
    – Boldumus
    Commented May 20 at 16:30
  • \$\begingroup\$ I think it is easy to figure he mostly was looking for something on which he could evaluate us, rather than really wanting us to learn an entire program or change our entire circuit's design to make simulating even possible. Your answer has given me insight into the world of circuit simulation, and I think the easiest course of action for me will be to explain to my teacher why simulating the circuit represented a challenge I was not equipped to deal with, or that it would require too much time to make sense in an 80-hour project (a time estimate I have already exceeded). \$\endgroup\$
    – Boldumus
    Commented May 20 at 16:39
  • \$\begingroup\$ I think that instead of wanting me to spend a huge amount of time learning how to simulate the circuit, the teacher mostly wanted to see a simulation of the circuit (as it's much easier to understand). Given that he is an astrophysicist by training but still teaches an electrical physics class and directs a variety of physics student projects, I believe that the first simulation you made is likely close enough for my teacher to understand the circuit. \$\endgroup\$
    – Boldumus
    Commented May 20 at 16:47
  • \$\begingroup\$ Given that, do you believe it would be possible for you to share the first simulation you did with me. I think it is entirely sufficient in quality and yelds close enough results that it would be suited for me to present to my teacher. I would of course explain to him that it was a task I was not qualified to perform and would reference this page as a source for the simulation in my report. \$\endgroup\$
    – Boldumus
    Commented May 20 at 16:51
  • \$\begingroup\$ Interesting situation. The simulator I used is LTspice, it is available as a free download from Analog Devices website. You are welcome to try and enter the schematic and try to simulate the circuit yourself, let me know how you go. \$\endgroup\$ Commented May 20 at 20:55
1
\$\begingroup\$

I don't have tinkercad. (It is best when on a site full of sparkies to have reference designators on your schematic so that folks can refer to them.) enter image description here

Take a look at the resistor divider network circled in red above. With 9 volts for VCC, the voltage is divided down to .818 volts, turning on the diode (circled in blue) on the falling edge of the Schmitt trigger output. From the transistor base scope trace, there must be a a 0.62-volt drop across your diode. The base voltage is clamped so that it will not go below 0.2 volts. With 0.2 volts as your the baseline of your transistor base signal, you get just enough pulse height to turn on the transistor for a short time. The transistor will not turn on until your base signal rises above 0.7 volts. Your max signal from the trace is 0.958 volts, and your base signal is 0.75 v p-p. You get the skinny collector signal during the time when the base voltage is above the 0.7-volt threshold.

Now do the same analysis with Vcc = 5. The resistor divider voltage drops to .454, so your base voltage clamps at -.165. This would have the effect of shifting the entire base voltage trace on your scope by negatively by 0.365 volts. Your new baseline is -0.165 volts. Since your signal is 0.75 volts p-p, your maximum base voltage is 0.585 volts - not enough to turn on the transistor.

You will have to try to find a better simulator that has a wider range of components (LTSpice or TINA?), or change the resistor divider to get the voltage on the cathode of the diode back up close to 0.81 volts, which would not really be a simulation of your circuit.

A quick test is to lower the voltage on your breadboard to 5 volts and see if it stops working.

Good Luck!

\$\endgroup\$
1
  • \$\begingroup\$ Okay I think I get it: relative to the 9V alimentation, the 0,7V drop from the diode didn't make a big impact but since we've reduced the Vcc, it now makes it so the signal doesn't properly gets trough. On another note, I have been experimentating with some other simulation programs, since indeed the issues seem to come from the limited repertories of components. \$\endgroup\$
    – Boldumus
    Commented May 18 at 3:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.