# Can I use LM339 to generate a triangular and sine waveforms?

#### nma

Joined Feb 1, 2016
15
Please can I use LM339 to generate a triangular and sine waveforms?

#### wayneh

Joined Sep 9, 2010
16,549
Not by itself, no. But you can get a sawtooth wave and a square wave with simple op amp circuits. Sine waves require a more complex circuit.

#### crutschow

Joined Mar 14, 2008
26,060
What is the maximum frequency you need?

#### Brevor

Joined Apr 9, 2011
297
LM339 is a comparator, an op amp would be a better choice.

#### nma

Joined Feb 1, 2016
15
Not by itself, no. But you can get a sawtooth wave and a square wave with simple op amp circuits. Sine waves require a more complex circuit.
Thanks for the response. I had used LM339 to generate 100kHz square wave but having issues with using it to generate triangular and sine wave.

What is the maximum frequency you need?

LM339 is a comparator, an op amp would be a better choice.
Okay. Please which of the op-amps for 100kHz?

Last edited by a moderator:

#### dannyf

Joined Sep 13, 2015
2,197

#### nma

Joined Feb 1, 2016
15
Thanks. Good to know. I will send my circuit please so you help me check what I have done wrong.

The op-amp in the schematic is used for design in multisim but I used LM339. Thanks

#### Attachments

• 91.5 KB Views: 56
Last edited:

#### dl324

Joined Mar 30, 2015
12,266
The op-amp in the schematic is used for design in multisim but I used LM339.
Did you substitute comparators for both opamps? Did you add pull-up resistors to the comparator output(s)?

Post waveforms of the input/output of the integrator.

#### nma

Joined Feb 1, 2016
15
Did you substitute comparators for both opamps? Did you add pull-up resistors to the comparator output(s)?

Post waveforms of the input/output of the integrator.
Yes I did substitute comparators for both opamps. I did not add a pull up resistor to the output of the integrator. I did not get an output. Attached is the input to the integrator.

#### Attachments

• 271.7 KB Views: 18

#### KL7AJ

Joined Nov 4, 2008
2,229
Not by itself, no. But you can get a sawtooth wave and a square wave with simple op amp circuits. Sine waves require a more complex circuit.
Actually, most el-cheapo function generators start with a square wave, and then use subsequent integration to obtain triangle and sine waves. The 339 is fine for generating the first square wave.

#### shortbus

Joined Sep 30, 2009
8,206
Yes I did substitute comparators for both opamps. I did not add a pull up resistor to the output of the integrator. I did not get an output. Attached is the input to the integrator.
Not using a pull up is why you didn't get an output. the 339/393 can only sink current not source it, there for they need a pullup resistor.

#### nma

Joined Feb 1, 2016
15
Not using a pull up is why you didn't get an output. the 339/393 can only sink current not source it, there for they need a pullup resistor.
Thanks for the responses. I will add a pullup resistor and give you a feedback on the waveform.

#### nma

Joined Feb 1, 2016
15
Actually, most el-cheapo function generators start with a square wave, and then use subsequent integration to obtain triangle and sine waves. The 339 is fine for generating the first square wave.

#### dannyf

Joined Sep 13, 2015
2,197
I did not add a pull up resistor to the output of the integrator.
sounds like you know where your problem is - the said comparator has OC output.

#### shortbus

Joined Sep 30, 2009
8,206
Thanks for the responses. I will add a pullup resistor and give you a feedback on the waveform.
Also, while a 339/393 is based on an opamp, its internal circuit is modified to be a comparator. You would be better off using a real opamp.

#### dl324

Joined Mar 30, 2015
12,266
Integrating a square wave will give a triangle wave, integrating a triangle wave will give a sine wave.

Do you understand the circuit you're simulating? Do you have R2 and R3 connected to the output of the first opamp? I don't see a connection dot.

What is the purpose of R6?

#### Alec_t

Joined Sep 17, 2013
11,814
integrating a triangle wave will give a sine wave.
Well, an approximation to one.

#### nma

Joined Feb 1, 2016
15
Integrating a square wave will give a triangle wave, integrating a triangle wave will give a sine wave.

Do you understand the circuit you're simulating? Do you have R2 and R3 connected to the output of the first opamp? I don't see a connection dot.

What is the purpose of R6?
Yes. The two resistors are connected to the output of the first opamp. R6 is a pull-up resistor to sink the current. I still do not get an output that is triangular wave form. I used a breadboard to connect but cannot get anything.

#### Alec_t

Joined Sep 17, 2013
11,814
R6 should connect to +12V from the comparator output pin, not from the supply pin, if you're using a comparator instead of the opamp as per the circuit in post #1.

Last edited: