Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Triangle wave generator for pwm

Status
Not open for further replies.

maicael

Member
If I wanted to use a dual opamp to generate a triangle wave of 5000hz because the triangle wave circuit needs just two opamps but I have a quad opamp(LM324,4 in one) can I still use it since I will just leave the remaining pins alone.
2)what would be the right value for a dc cut off capacitor to eliminate offset at that frequency.am thinking of using 1uf cap
Here is the link to the circuit am implementing
**broken link removed**
With R=1k and C=100nf
The wave needs to be as high as possible since I want to compare it with a sine wave.
 
If I wanted to use a dual opamp to generate a triangle wave of 5000hz because the triangle wave circuit needs just two opamps but I have a quad opamp(LM324,4 in one) can I still use it since I will just leave the remaining pins alone.
Ground the two unused inverting inputs, and the two unused non-inverting inputs; let the outputs float.

2)what would be the right value for a dc cut off capacitor to eliminate offset at that frequency.am thinking of using 1uf cap
Depends entirely on the load downstream from the coupling capacitor.

Here is the link to the circuit am implementing
**broken link removed**
With R=1k and C=100nf
The wave needs to be as high as possible since I want to compare it with a sine wave.
I would use 10K and 10nF
The LM324 can only pull high about 1.2V below the positive supply rail. I would find a modern rail-to-rail CMOS opamp, which can pull within 10mV of both rails.
 
4QD used to have excellent tutorials on generating PWM with Op-amps (https://www.4qd.co.uk/). I relied on its wisdom. Unfortunately, those tutorials seem to be gone. Nevertheless, while searching for them, I came across this interesting note: **broken link removed** Scroll down to the PWM section. It uses just one op-amp, so you will have to ground the input for another op-amp. Such a waste of silicon ;)

John

Edit: Found it! https://www.4qdtec.com/pwm-01.html Browse around. There is some good information there.
 
Last edited:
The lousy old LM324 quad and LM358 dual opamps have trouble above only 2kHz. They also have crossover distortion which produces a blip in the center of a triangle wave or a sine wave.
For 5khz, use a fairly modern audio opamp that works well up to 100kHz and has no crossover distortion.

I made a PWM circuit with triangle waves using a low power MC33172 dual opamp that works well up to 35kHz, has no crossover distortion and its output swing is high and is symmetrical. LM324 crossover distortion4.PNG

I wish the new software on this forum would not put my thumbnail image smack in the MIDDLE of my text!
Where is the POST REPLY button?
 
If I wanted to use a dual opamp to generate a triangle wave of 5000hz because the triangle wave circuit needs just two opamps but I have a quad opamp(LM324,4 in one) can I still use it since I will just leave the remaining pins alone.
2)what would be the right value for a dc cut off capacitor to eliminate offset at that frequency.am thinking of using 1uf cap
Here is the link to the circuit am implementing
**broken link removed**
With R=1k and C=100nf
The wave needs to be as high as possible since I want to compare it with a sine wave.

Hi there,

I noticed you asked about generating a triangle wave, but not just that alone as you have mentioned that you want a triangle wave for PWM. If you wanted just a triangle wave i might agree that the two op amp circuit could be a good idea, but since you seem to want to use it for PWM then you have a much simpler option.

That second option is to just use a capacitor and resistor that charges from the output of an op amp. The voltage across the cap increases (or decreases) exponentially which means it looks like a curved ramp, but if the time constant is long enough relative to the frequency you get a somewhat straighter line ramp that looks more like a one-sided triangle wave. That's all you need for PWM. In fact, you can use a comparator like the LM339 and dont actually need an op amp.

I've used this idea on commercial power supply and battery charger designs as well as a few of my own home built stuff like a triac 'dimmer' controller. I wish i could say this was my idea but it was used long before i started to use it.

For PWM the triangle does not have to ramp up and ramp down, it only has to ramp up (or down) and then suddenly shoot back up (or down) to create a one-sided triangle otherwise known as a sawtooth wave.
 
A Wein Bridge oscillator using an op-amp. Take the signal from across the capacitor from ground to the op-amp input and buffer it. That is a sawtooth waveform.
 
A Wein Bridge oscillator using an op-amp. Take the signal from across the capacitor from ground to the op-amp input and buffer it. That is a sawtooth waveform.

No it isn't. Look at V(b)
 

Attachments

  • Wein.jpg
    Wein.jpg
    209.4 KB · Views: 649
The sawtooth wave MrAl referred to in post #5 can be produced simply as below:
SimpleSawtooth.gif

The left circuit is as simple as it gets but has a limited output amplitude (yellow trace). The right circuit increases the hysteresis and hence both the amplitude and period (blue trace).
 
is there a site where i can see a list of mordern dual and quad opamps.i have seen some but need to explore further.thanks so far
 
All of the major electronics suppliers' sites (in no particular order Farnell, Digikey, Mouser, ......) have a parametric search facility for selecting from hundreds of different types of opamp.
 
Last edited:
Hi,

Nice circuit there Ken.

Often these circuits dont need anything better than a good ol' LM324 orLM339 as the frequency of operation is often not that high anyway.

My triac controller circuit used one LM358 op amp which is a dual op amp, and that's about it. That only had to operate with PWM at 60Hz.
 
I used a modification of that to add a pulser to my TIG welder. Controls pulse frequency, pulse width, and current %. The LM324 was fine from 0.5-20Hz
Ken.
 
The lousy old LM324 quad and LM358 dual opamps have trouble above only 2kHz. They also have crossover distortion which produces a blip in the center of a triangle wave or a sine wave.
For 5khz, use a fairly modern audio opamp that works well up to 100kHz and has no crossover distortion.

I made a PWM circuit with triangle waves using a low power MC33172 dual opamp that works well up to 35kHz, has no crossover distortion and its output swing is high and is symmetrical.View attachment 81106

I wish the new software on this forum would not put my thumbnail image smack in the MIDDLE of my text!
Where is the POST REPLY button?
Pls what circuit did you use for the triangle wave.the link I gave people seem to have problem with the circuit especially with the offset and the transistor biasing which amplifies the signal.applying voltagesup to 12v causes the triangle to be skewed while atimes making it oscillate between 0 & 12v is hard due to difficultyin choosing cutoff capacitor.
Am confused as I need a 5000-6000Hz perfect triangle with peak to peak 12V(supply voltage) starting from the 0V line.
I have been searching some but their peak voltage is not as high.anyone with tested circuit.thanks
 
Pls what circuit did you use for the triangle wave?
A PWM circuit does not need a triangle-wave that goes from 0V to the supply voltage. I
PWM for motor speed control.png
ts voltage swing from an ordinary opamp just needs to have enough amplitude to switch the switching transistor or Mosfet on and off.
I used the standard one opamp as a positive feedback square-wave oscillator that feeds a second opamp as an integrator.
My PWM frequency was about 3kHz which is very audible, it could have been ultrasonic.
I used this circuit to drive a 4A motor on an electric model airplane:
 
I need a 5000-6000Hz perfect triangle with peak to peak 12V(supply voltage) starting from the 0V line.
Why must it be a perfect triangle?
Why must it go 0V-12V with a 12V supply? That will be a challenge, since not all opamps, even the so-called rail-to-rail ones, can get very close to one or other of the rail voltages. And many comparators don't cope well with inputs very close to one or other of the rail voltages.
 
Why must it be a perfect triangle?
Why must it go 0V-12V with a 12V supply? That will be a challenge, since not all opamps, even the so-called rail-to-rail ones, can get very close to one or other of the rail voltages. And many comparators don't cope well with inputs very close to one or other of the rail voltages.
am sorry if I sound silly I just thought that since am comparing it with a 50hz sine wave it should be high as possible to get good pwm meaning the triangle signal needs to be as high as possible.u guys are d experts so I raise my hands to say I still need to learn alot as am a beginner.thanks for the insight am grateful.
 
A PWM circuit does not need a triangle-wave that goes from 0V to the supply voltage. IView attachment 81267 ts voltage swing from an ordinary opamp just needs to have enough amplitude to switch the switching transistor or Mosfet on and off.
I used the standard one opamp as a positive feedback square-wave oscillator that feeds a second opamp as an integrator.
My PWM frequency was about 3kHz which is very audible, it could have been ultrasonic.
I used this circuit to drive a 4A motor on an electric model airplane:
Nice circuit.couple of questions
1)what does the reference voltage do or why d reference voltage.
2)how do you determine frequency.
 
Nice circuit, couple of questions:
1)what does the reference voltage do or why d reference voltage.
2)how do you determine frequency.
Opamp circuits always have a reference voltage that is a bias voltage. In this circuit it is at half the supply voltage so the square-wave and triangle-wave can swing symmetrically with equal up and down amplitudes, using the symmetrical opamp I used.

The 47nF timing capacitor is charged by and is discharged into the 5.6k resistor. The current in the resistor is constant and is determined by the square-wave amplitude provided to the resistor by the first opamp (0V plus 0.7V and the supply voltage minus 0.7V).

My PWM circuit compares the triangle-wave to a DC voltage, not a sine-wave.
My description before wrongly said that the triangle-wave drives the Mosfet gate. Actually, the triangle-wave is compared to a DC voltage and the output of the comparator drives the Mosfet gate.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top