Triangle Wave Generator - Page 1
Forum section: electronics / beginners

author: fady232
author_rank: Contributor
timestamp: September 01, 2025, 08:00:28 am
content: Hello all, i was trying to build up a circuit that generates a triangle wave, in order to do so i've made a square wave generator, then an integrator which generates the triangle wave.I read that by removing the resistor across the ingration cap the integrator become less leaky, at this point i added a 10k resistor as feedback to add the integrator in feedback loop, now what i obtained is this:a square wave which is shifted and it doesnt go from 0 to 5V, why so?

author: Zero999
author_rank: Super Contributor
timestamp: September 01, 2025, 11:24:12 am
content: You forgot to include the symbols and models in that file, so it gives an error. Use opamp2, rather than creating your own symbol: insert component  opamp2 and enter the name of the model's subcircuit into the value field, by right-clicking on the symbol. You can either upload the model separately by appending .txt to the file name, or paste it into the .asc file; open the model's file in a text editor, select all of the text, copy it; in LTSpice click SPICE Directive and paste the text into the dialog box and click enter.If you put the Schmitt trigger into the feedback loop of the integrator, then the output will be biased around half the supply voltage, with no additional biasing resistor.Note the ic= directives set the initial voltages on the capacitors to ensure the simulator starts the circuit in an unstable state. If they're omitted, the simulator will per-calculate the voltages on the capacitors, giving half the supply voltage, so the the circuit will never oscillate.

author: MathWizard
author_rank: Super Contributor
timestamp: September 01, 2025, 05:42:14 pm
content: When using universal op-amps in LTSpice, how to you set the input bias and offset currents? Or can you directly set Ip and In ? So far I've just been placing current sources to set Ip,n.

author: Zero999
author_rank: Super Contributor
timestamp: September 01, 2025, 06:41:03 pm
content: Quote from: MathWizard on September 01, 2025, 05:42:14 pmYou should start your own thread, rather than hijacking someone else's.In this case it might be of interest to the original poster, so I'll respond.Use UniversalOpAmp5.Ibp = +input bias currentIbn = -input bias currentVos = input offset voltageThe difference between the above is the input offset current.Here's an example, with Ibp = 2nA, Ibn = 1nA and Vos = 0V. Both inputs are connected to the output or 0V, via 1M resistors.Using conventional current flow, the input bias currents flow into the op-amp's inputs. This is why, in this case, the signs of the input voltages are negative; they're being pulled below 0V by the op-amp's inputs sinking current.The op-amp adjusts its output to ensure both inputs are at equal voltages. The non-inverting input is connected to 0V via 1M and 2n is flowing into the input, which pulls the voltage down to 2mV. The output is -1mV, because the difference between the input bias currents is 1nA, which is multiplied by the resistance connected to the input, making it 1mV higher than the inverting-input.

author: fady232
author_rank: Contributor
timestamp: September 02, 2025, 07:45:15 pm
content: Ok thanks, btw yeah i saw many uses this solution of using trigger schmitt with integrator and then feedback where u take the output of the integrator and u feed It back to Schmitt trigger

author: Analog Kid
author_rank: Super Contributor
timestamp: September 03, 2025, 12:12:02 am
content: Don't mean to push this thread off track, but just as a side note, it is possible to make a triangle-wave generator only using discretes (transistors). Being a discrete kinda guy, that's my preference, at least for experimentation.For example, here's a simple (4 transistors) generator simulated in LTSpice. It actually produces a pretty good-looking triangle wave. Not sure what your requirements are here so far as accuracy and low distortion go, but maybe this could work for you. The circuit could use some improvement: for one thing, if you run it you'll notice that the wave ramps down quite a bit before stabilizing. Still, it could be a good starting point. (I have a couple other variations of this I can dig out that use current sources to make a quite good triangle wave.Spice .asc file attached.

author: Analog Kid
author_rank: Super Contributor
timestamp: September 03, 2025, 09:53:40 pm
content: Here's a slightly more sophisticated circuit, with current source/sink: 8 jelly-bean transistors. Good-looking triangle-wave output @ ~27KHz.Question: how would one go about judging the actual quality of a triangle wave, both in simulation and IRL?FFT analysis to check for spurious harmonics? something else?Or just a good-looking trace on the 'scope, with linear ramps?(I was messing around with this because at one point I wanted to try to make a discrete class D amplifier. Have to do that someday ...)

author: UnijunctionTransistor
author_rank: Frequent Contributor
timestamp: September 03, 2025, 10:27:01 pm
content: What a DANDY circuit! Discretes. Are. Not. Dead. Yet.

author: MariuszD
author_rank: Regular Contributor
timestamp: September 04, 2025, 08:56:04 am
content: Quote from: Analog Kid on September 03, 2025, 09:53:40 pmIf you are interested in linearity, input a triangular waveform into a differentiating circuit and evaluate the quality of the rectangular waveform.In the simulation, you can view the differentiated waveform, you can view the changes in the current of the current sources over time.In my example below triangle wave looks almost perfect for naked eye, but it slew rate drops by 20%. Wilson's current mirror will be better.

author: Zero999
author_rank: Super Contributor
timestamp: September 04, 2025, 10:09:27 am
content: Quote from: Analog Kid on September 03, 2025, 09:53:40 pmA couple of suggestions for improvement:A separate astable means multiple resistors need to be changed, in order to alter the frequency. If a Schmitt trigger is used with the integrator acting as the timing element, only one resistor value needs to be altered to change the frequency, so a potentiometer can be used.Current sources have a very high impedance. Any load connected to the output will dramatically affect the performance. A buffer is required to drive any sort of load.

author: tautech
author_rank: Super Contributor
timestamp: September 07, 2025, 03:37:55 am
content: Quote from: UnijunctionTransistor on September 03, 2025, 10:27:01 pm100%Ramp generators are the core of generating a timebase sweep in the oldest of scopes.Study of any old CRO schematic will show how it's done with valves or bipolars and with a minimum of components.The better schematics show waveforms and amplitude.But hell you can even do this with a 555 and a few components....

author: Andy Chee
author_rank: Super Contributor
timestamp: September 08, 2025, 07:13:15 am
content: Quote from: tautech on September 07, 2025, 03:37:55 amThe 555 triangle wave generator circuit that comes to my mind, does NOT have linear slopes, it has exponential slopes.Unless you're thinking of a different 555 circuit to what I'm thinking of.....

author: Zero999
author_rank: Super Contributor
timestamp: September 08, 2025, 08:57:55 am
content: Quote from: Andy Chee on September 08, 2025, 07:13:15 amIt's possible. I'm not sure why anyone would do it that way though.

author: tautech
author_rank: Super Contributor
timestamp: September 08, 2025, 09:09:28 am
content: Quote from: Andy Chee on September 08, 2025, 07:13:15 amCorrect and 2 mins with Mr Google shows you require a constant current charge of the timing cap to get a linear response.This is even simpler than the one I first found before my first reply.

author: Kleinstein
author_rank: Super Contributor
timestamp: September 08, 2025, 09:47:24 am
content: The ne555 with the current cource gives a ramp / sawtooth. The classic triangle is more symmetric with the same rate going up and down.The Ne555 version may have some benefit from a stable amplitude - here the classic circuit (2nd post) may not be that good (depends on the OP-amp saturation at the output.

author: Zero999
author_rank: Super Contributor
timestamp: September 08, 2025, 09:57:48 am
content: Quote from: tautech on September 08, 2025, 09:09:28 amThat's a sawtooth wave generator. The thread is about triangle wave generators.The 555 could be used to switch between a source and a sink to generate a triangle wave, but I don't know why anyone would do it that way. The current source and sink will need to be well-matched to give a symmetrical waveform and a buffer is required to drive any load.

author: Analog Kid
author_rank: Super Contributor
timestamp: September 08, 2025, 08:09:58 pm
content: Quote from: Zero999 on September 08, 2025, 09:57:48 amSo maybe the (discrete) circuit I posted above (inthis post), plus a buffer?Dang it, now I'm going to have to build this and look at the actual waveforms ...