Square Wave Generator using LM2903B

Thread Starter

electronicsenjoyer089

Joined Feb 24, 2025
182
Hello all, i was trying to build a circuit that uses LM2903B, which is a comparator, what i wanna obtain is a square wave with 50% dutycycle and frequency at 10KHz.

First of all i calculated the symmetry point at V+ pin, which has to be 50% of vcc, which is 2.5V, i chose to put 2 resistors of 51kOhm as voltage divider to do so, then i calculated the RH needed in order to have the hysteresis which creates a voltage divider beetwen Vref and Vout. we want to have that the capacitor charges from 1/3vcc to 2/3vcc and discharges from 2/3vcc to 1/3vcc, the vcc is 5V so we got VT+ = 3.33V and VT- = 1.67V
so V+ = Vref + ( VCC - Vref ) * Rdiv/RH+Rdiv, by putting the numbers and doing calculations i get that RH has to be 51kohm for 50% duty cycle
for the frequency i used this formula:
f = 1/2R5C*ln ( VCC-VT-/VCC-VT+) and by choosing the capacitor as 10nF i found R5=7.21kOhm

But i got an issue, when im making the simulation i dont see a square wave , but a d.c wave fixed at 2.5V? can u explain me? consider that im not that good so please try to explain in simple way :D thanks
 

Attachments

Thread Starter

electronicsenjoyer089

Joined Feb 24, 2025
182
Hello all, i was trying to build a circuit that uses LM2903B, which is a comparator, what i wanna obtain is a square wave with 50% dutycycle and frequency at 10KHz.

First of all i calculated the symmetry point at V+ pin, which has to be 50% of vcc, which is 2.5V, i chose to put 2 resistors of 51kOhm as voltage divider to do so, then i calculated the RH needed in order to have the hysteresis which creates a voltage divider beetwen Vref and Vout. we want to have that the capacitor charges from 1/3vcc to 2/3vcc and discharges from 2/3vcc to 1/3vcc, the vcc is 5V so we got VT+ = 3.33V and VT- = 1.67V
so V+ = Vref + ( VCC - Vref ) * Rdiv/RH+Rdiv, by putting the numbers and doing calculations i get that RH has to be 51kohm for 50% duty cycle
for the frequency i used this formula:
f = 1/2R5C*ln ( VCC-VT-/VCC-VT+) and by choosing the capacitor as 10nF i found R5=7.21kOhm

But i got an issue, when im making the simulation i dont see a square wave , but a d.c wave fixed at 2.5V? can u explain me? consider that im not that good so please try to explain in simple way :D thanks
I managed to understand what was happening, basically the pull-up on the VOUT wasnt actually "working" probably cus of net names problem, now i found out another issue, the wave isnt perfect, and the duty cycle isnt really 50% and i dont understand why, also as second thing as output i get maximum 3.6V, while the pull up is tied at 5V, the output shouldnt be at around 5V?
 

Thread Starter

electronicsenjoyer089

Joined Feb 24, 2025
182
Take another comparator that has a CMOS output.
it actually works with a comparator that has CMOS output, can u explain me why tho? the fact that i use a comparator with open collector output shouldnt be fine still? like the output can be driven only low, but if i put a pull-up, when the cap discharges the output shouldnt go low? ( same for when it charges it should go at a voltage near to VCC, or im wrong?

with cmos comparator
1756385368589.png
 

AnalogKid

Joined Aug 1, 2013
12,045
Back to the 2903 circuit -

The reason the output is not symmetrical is that the timing capacitor is being discharged through R5, but charged through R5 + R4, modified by the current through R3. This is because in the high state the 2903 output is basically an open circuit, so the currents through the three resistors interact. The 3201 has a totem-pole output, so the output is a very low impedance to Vcc in the high state.

In the charge-up phase, the 2903 output is an open circuit. In this state, R5 and R4 are in series to Vcc.

In the discharge phase, The 2903 output is basically tied to GND. This isolates the R5 and R4 currents from each other. It sinks both the discharge current from the timing cap (through R5) and the current through R3, which in this state is basically just a resistor from Vcc to GND. All of this is confused by the current through R3 to the R1-R2 node.

The solution is to make the 2903 output impedance in the high output state to *appear* to be very low. This is done by making pull-up resistor R4 much smaller than any of the other resistors connected to the output. For example, decrease C1 by 10x, increase R5 by 10x, and decrease R3 to something like 1 K.

BTW, look into something called the Thevenin equivalent resistance. From the point of view of the device output, R1, R3, and R3 combine to look like a single 76.5 K resistor tied to a 2.5 V voltage source. This reduces the complexity of the full-blown equations for the circuit currents.

ak
 
Last edited:

Thread Starter

electronicsenjoyer089

Joined Feb 24, 2025
182
Back to the 2903 circuit -

The reason the output is not symmetrical is that the timing capacitor is being discharged through R5, but charged through R5 + R4, modified by the current through R3. This is because in the high state the 2903 output is basically an open circuit, so the currents through the three resistors interact. The 3201 has a totem-pole output, so the output is a very low impedance to Vcc in the high state.

In the charge-up phase, the 2903 output is an open circuit. In this state, R5 and R4 are in series to Vcc.

In the discharge phase, The 2903 output is basically tied to GND. This isolates the R5 and R4 currents from each other. It sinks both the discharge current from the timing cap (through R5) and the current through R3, which in this state is basically just a resistor from Vcc to GND. All of this is confused by the current through R3 to the R1-R2 node.

For a symmetrical output, make R3 much smaller than R5. For example, decrease C1 by 10x, increase R5 by 10x, and decrease R3 to something like 1 K.

ak
I tried doing like that , theorically ur hypothesis has sense and i got it, but no idea why it doesnt work out, btw with a CMOS comparator it works fine only when its open collector there is this issue
 

Thread Starter

electronicsenjoyer089

Joined Feb 24, 2025
182
Back to the 2903 circuit -

The reason the output is not symmetrical is that the timing capacitor is being discharged through R5, but charged through R5 + R4, modified by the current through R3. This is because in the high state the 2903 output is basically an open circuit, so the currents through the three resistors interact. The 3201 has a totem-pole output, so the output is a very low impedance to Vcc in the high state.

In the charge-up phase, the 2903 output is an open circuit. In this state, R5 and R4 are in series to Vcc.

In the discharge phase, The 2903 output is basically tied to GND. This isolates the R5 and R4 currents from each other. It sinks both the discharge current from the timing cap (through R5) and the current through R3, which in this state is basically just a resistor from Vcc to GND. All of this is confused by the current through R3 to the R1-R2 node.

The solution is to make the 2903 output impedance in the high output state to *appear* to be very low. This is done by making pull-up resistor R4 much smaller than any of the other resistors connected to the output. For example, decrease C1 by 10x, increase R5 by 10x, and decrease R3 to something like 1 K.

BTW, look into something called the Thevenin equivalent resistance. From the point of view of the device output, R1, R3, and R3 combine to look like a single 76.5 K resistor tied to a 2.5 V voltage source. This reduces the complexity of the full-blown equations for the circuit currents.

ak
ok i read about thevenin, so u mean the resistors r1,r2,r3,r5 , where if we replace the voltage source with a shortcircuit to gnd we obtain R1||R2 in series to r3 and r5? so around 76k?
 
Top