Square-Triangle generator project - variable frequency

Thread Starter

LUStudent

Joined Mar 20, 2022
7
I'm working on a project for school where we must generate a square and triangle wave from fixed supplies in a lab using only RC components as well as a specific list of active components:
1647815546307.png
We are also NOT allowed to use variable capacitors or ganged potentiometers.
The circuit must have frequency adjustment (with a max of over 55KHz) as well as amplitude adjustment (The amplitude adjustment I'm not worried about, as I will just put each signal through an inverting amplifier and use pots for the feedback resistors. As you can see, I haven't gotten around to this yet).

This is my current circuit:
1647816450656.png

My obvious problem lies in the frequency adjustment. I can adjust the frequency of the oscillations with pot1, however, if I do, the bias required to remove the offset on the integrator changes and therefor, I need to somehow be able to adjust this bias in unison with pot1 to keep the triangle wave centered.

I'm wondering if someone could shed some light on possible solutions to look into. I've spent some time going through forums for possible solutions with little luck. Maybe I'm going about this wrong. Once again, we aren't allowed to use ganged pots. I picked the NE5534 because it gave me a nice square wave past 55KHz. As for the LM813, I don't have a specific reason for choosing. apart from it being in the list and its PSpice model seeming to work well for the application.

Thanks.
 

crutschow

Joined Mar 14, 2008
34,452
To avoid having to adjust the integrator offset you can use a closed negative feedback loop around the whole circuit.
Use a comparator with proper trip points to generate the square-wave from the triangle-wave output.
This square-wave goes to the integrator input to generate the triangle wave.
That way the triangle wave is automatically centered.

Adjust the comparator trip points to about 2/3 of the positive and 2/3 of the negative supply voltages using hysteresis (positive feedback from the comparator output to the plus input).
This will give the triangular-wave peak output voltages equal to the comparator trip points.
You can then adjust the frequency by having a variable resistor at the input to the integrator.

Make sense?

I have a working simulation of such a circuit, but I can't post it here since this is homework, so I will leave generating the circuit details up to you.
 

Thread Starter

LUStudent

Joined Mar 20, 2022
7
To avoid having to adjust the integrator offset you can use a closed negative feedback loop around the whole circuit.
Use a comparator with proper trip points to generate the square-wave from the triangle-wave output.
This square-wave goes to the integrator input to generate the triangle wave.
That way the triangle wave is automatically centered.

Adjust the comparator trip points to about 2/3 of the positive and 2/3 of the negative supply voltages using hysteresis (positive feedback from the comparator output to the plus input).
This will give the triangular-wave peak output voltages equal to the comparator trip points.
You can then adjust the frequency by having a variable resistor at the input to the integrator.

Make sense?

I have a working simulation of such a circuit, but I can't post it here since this is homework, so I will leave generating the circuit details up to you.

Are you referring to an actual comparator op amp such as the LM311?
 

Thread Starter

LUStudent

Joined Mar 20, 2022
7
Yes.
That or a LM339/393.
They are not op amps, they are comparators.

I have to bug you one last time. I believe I understand the method you gave me. I'm just having a difficult time getting it going.

If I understand right, the cap and positive feedback on comparator are no longer needed, since the "building" of voltage is now being done by the output of the integrator, which is fed back to the negative terminal of the comparator. The voltage will build until the trip point is reached which is set by the voltage divider on positive feedback of the comparator.

I tried using an LM311 previously in my design, and after looking through the data sheets and some other designs online, I was under the impression it isn't wired up to +/- Vcc like an op-amp, but rather Vcc & Ground, and produced an output that doesn't cross 0 volts.

Do I have the wrong impression about this device or the method you've told me? I've spent a few hours on it and I feel like it should "take off" but I just can't get it to in simulation.
 

crutschow

Joined Mar 14, 2008
34,452
If I understand right, the cap and positive feedback on comparator are no longer needed, since the "building" of voltage is now being done by the output of the integrator, which is fed back to the negative terminal of the comparator.
Not a correct understanding of the circuit operation.
It does not need the capacitor since that is part of the comparator being using as an oscillator, but I would not have said the comparator needs positive feedback for hysteresis if it didn't.
The value of the hysteresis voltage determines the amplitude of the triangle-wave (as I stated in post #2).
Otherwise the amplitude of the triangle-wave would be just a fraction of a volt since there would be only one trip-point voltage in both directions.

And the output of the integrator must be fed back to the positive input of the comparator, otherwise the circuit will not oscillate but just end up at one of the rails (remember the integrator provides a signal inversion).

See the two waveforms below from the simulation of my circuit implementation.
In this case I am using a single 5V power supply with a 2.5V virtual ground, and the comparator hysteresis trip points are about 0.8V and 4.1V.
Also note the relative signal polarities.

Understand now?

1647837876644.png

I tried using an LM311 previously in my design, and after looking through the data sheets and some other designs online, I was under the impression it isn't wired up to +/- Vcc like an op-amp, but rather Vcc & Ground, and produced an output that doesn't cross 0 volts.
It can be connected either way.
If you connect the comparator power and common to +V and -V, then the output will go between those two voltages.
 
Last edited:

Thread Starter

LUStudent

Joined Mar 20, 2022
7
Not a correct understanding of the circuit operation.
It does not need the capacitor since that is part of the comparator being using as an oscillator, but I would not have said the comparator needs positive feedback for hysteresis if it didn't.
The value of the hysteresis voltage determines the amplitude of the triangle-wave (as I stated in post #2).
Otherwise the amplitude of the triangle-wave would be just a fraction of a volt since there would be only one trip-point voltage in both directions.

And the output of the integrator must be fed back to the positive input of the comparator, otherwise the circuit will not oscillate but just end up at one of the rails (remember the integrator provides a signal inversion).

See the two waveforms below from the simulation of my circuit implementation.
In this case I am using a single 5V power supply with a 2.5V virtual ground, and the comparator hysteresis trip points are about 0.8V and 4.1V.
Also note the relative signal polarities.

Understand now?

View attachment 263330

It can be connected either way.
If you connect the comparator power and common to +V and -V, then the output will go between those two voltages.

My mistake. My message should have read "the cap and negative feedback" not positive.

This is where I've gotten with the current design. I'm still dealing with setting the threshold voltages through the positive feedback. Something I will further deal with after class. I'm going to attempt hold 2 of the resistors in the positive feedback path at a specific value and solve for the 3rd to give me a desired threshold voltage at the + node. Which ones should be held at the same value I'm still unsure of.

1647876616155.png

am I missing anything in this design? I'm confused as to where you used your virtual ground.

Thanks for all your help by the way.
 

crutschow

Joined Mar 14, 2008
34,452
You still are showing the incorrect feedback polarity from the integrator, which is now the third time that has been mentioned.
The integrator output needs to go to the (+) comparator input, along with the hysteresis feedback from the comparator output.
(Please read carefully what I tell you as I dislike having to repeat myself due to your inattention to the details. If you are planning on being an engineer, the devil is in the details)
I'm confused as to where you used your virtual ground.
Since I was using only a single supply, I generated a virtual ground voltage of 1/2 the supply voltage (using a resistor divider) to bias the (+) inputs of the comparator and and op amp, to give the bias needed for proper circuit operation.

Speaking of that, you need to operate the comparator from the plus and minus supplies, the same as the op amp, for your circuit to work.
As shown, the integrator will never get the negative input voltage it needs to generate the positive triangle-wave slope.

You need to really take some time to understand how the circuit works, as you still don't seem to.
 

Thread Starter

LUStudent

Joined Mar 20, 2022
7
You need to really take some time to understand how the circuit works, as you still don't seem to.
Do you know where I can learn more about this circuit? I've been scouring the web for most of the day but I've had a difficult time finding anything that uses the positive feedback you've mentioned from the integrator.

Thanks for the help
 

crutschow

Joined Mar 14, 2008
34,452
Do you know where I can learn more about this circuit? I've been scouring the web for most of the day but I've had a difficult time finding anything that uses the positive feedback you've mentioned from the integrator.
It's not positive feedback, as I've already said.
Here's a description of the basic circuit.
Note the the loop feedback from the integrator is negative, since the integrator inverts the signal.
 
Last edited:

Thread Starter

LUStudent

Joined Mar 20, 2022
7
In order to not leave this thread unsolved I figured I would post my solution thus far. I'm headed into the lab to test it today. I'm not sure if its the exact circuit that Crutshow was getting at, but it appears to be working for my application in simulation:

1647956445301.png

I have frequency control from Pot3, appear to have some duty cycle control with Pot2 and output offset voltage control with pot 1. I also fed each signal through an inverting amplifier to give amplitude control of each signal individually through Pot4 and Pot5. I went with the NE5534 as it seemed to handle higher frequency switching of the square wave better than some of the other op amps in the list.

I also took a shot at the same design Ronsimpson posted, however, using the lm13700 data sheet and Spice model (since there was one available from Ti). I didn't have any luck with the circuit though in simulation. I believe it was due to issues with the Spice model but I didn't dig into it. I may try implementing tjhe LM13700 design in the lab using this chip if the design I posted above doesn't work.

Thanks for the help folks
 
Last edited:
Top