Need help correctly polarizing LM393 for analog output

Thread Starter

Houseman

Joined Sep 25, 2018
22
Hi all.
In the search of generating analog PWM, I came across a module I wanted to investigate and
I have currently a problem came along.
The module is a Voltage to PWM converter (0-5 or 0-10Vin) sold for a few bucks on chinese marketplaces. Attached here the schematic.
schematic.png
The timer that produces a saw wave 0 - 3.6V I have simulated
Schermata 2024-09-06 alle 23.37.57.png
feds the inverting input of an LM393 and on the non inverting input a resistor network that accepts either 0-10 or 0-5 according to the jumper setting.
What I do not understand is the use of the 2k resistors in parallel with a 100k trimpot (used to trim the duty cycle output) that is in parallel with a 10k / 51k voltage divider... what is going on here? why use so many parallel resistors?
I understand that the 5 volts must be tuned to give at the input of the non inverting pin a voltage around 3,4V. But couldn't it be done more simple?
Any help really appreciated.
Thanks
 

crutschow

Joined Mar 14, 2008
38,316
But couldn't it be done more simple?
Yes, you could likely remove a few of the resistors and still have it work properly.
Not sure why they added so many.
But I wouldn't classify that as a "problem", which implies the design is deficient.

And your post's title makes little sense. :confused:
 
Last edited:

WBahn

Joined Mar 31, 2012
32,703
You seem to be seeing anything and everything as somehow being in parallel.

That 2 kΩ resistor is not connected in any way, shape, or form to the pot. It is the pullup resistor that is needed by the LM393, which has an open collector output and therefore can't source any current in order to drive the output HI.

You include a simulation for node t2, but don't bother to tell us which node that is. Don't make people guess!

Assuming (and that is never a good way to discuss designs) that your t2 is the voltage applied to the inverting input of the comparator, then it looks like it ramps from about 0.2 V to about 3.3 V. In order to control the pulse width of the output, you want to be able to adjust the reference voltage at the non-inverting input over that same range. Assuming the jumpers are places correctly for the input voltage range, that will put the voltage at the top of the pot ranging from 0 V to 5 V. When the pot is at the top of the range, the voltage at the pot wiper will be ~5 V and then the voltage at the non-inverting input will be ~4.2 V. At the other end of travel, it will be 0 V. You can figure out what the pot position would need to be when it is at 0.2 V and 3.3 V. As long as it is a sizeable fraction of the total travel, it will work reasonably well, though it may not be very linear given that the pot's resistance is on par with the voltage divider's total resistance. But it would be a trivial matter to produce a graph of the reference voltage as a function of pot position and, from that, the PWM duty cycle as a function of that. If the result is acceptable, then you are good to go.

Since there are already a few ICs on this board, I'd be tempted to just put an opamp on there to buffer the incoming command signal and provide scaling and offset adjustment to it. But if that's not needed for acceptable behavior, then it also isn't really justifiable, either.

But what does any of this have to do with "Need help correctly polarizing LM393 for analog output"?
 

Thread Starter

Houseman

Joined Sep 25, 2018
22
Thank You both for the replies and are for sure right about the misleading title, so I explain why. Without being too complicated at fist time, I wanted to extend the basic circuit to be able to feed the non inverting op-amp with a 0 to 5v voltage coming from a DAC (MCP4728) OR with a jumper via a fixed voltage 5V reference I can adjust with a trimpot ( what are the drawbacks for using such a method? could you suggest something else?). Of course I can use for the first case the same schematic seen on the low cost module, but when it comes to use a fixed 5V with a 100k trimpot (1terminal 5Vcc - 3terminal ground -wiper to the output) things got a little bit confused, since there are so many parallel resistors. (considering also the 1k+1k series resistors at the original schematic). and here are my "problems". Could You please help me to trace the direction (not the solution) step-by-step so I can learn and do not need to ask again? I need to drive on the output of the LM393 an N-MOS IRLM2803 connected to a load, so also the polarizing stage of the output is an issue for me.
Best regards, hope I clarified my fuzzy and confusing start. Sorry you both
 

crutschow

Joined Mar 14, 2008
38,316
I wanted to extend the basic circuit to be able to feed the non inverting op-amp with a 0 to 5v voltage coming from a DAC (MCP4728) OR with a jumper via a fixed voltage 5V reference I can adjust with a trimpot
So when using 5V, you want a fixed PWM output duty-cycle adjustable with the pot?
That should work okay.
the polarizing stage of the output is an issue for me.
If you mean the phase, that can be inverted, by reversing (interchanging) the input connections to the LM393.
 

Thread Starter

Houseman

Joined Sep 25, 2018
22
So when using 5V, you want a fixed PWM output duty-cycle adjustable with the pot?
That should work okay.
If you mean the phase, that can be inverted, by reversing (interchanging) the input connections to the LM393.
Thank You.
I either would like to choose between an input coming from a DAC that provides 0 to 5V (so the PWM will be 0-100%) OR instead of the DAC a simple 5V voltage source who's voltage I can change using a trimpot as a voltage divider (1pin-5V 3pin-GND 2-desired voltage) so PWM will be accordingly 0 to 100%.Which are the drawbacks of such a simple variable voltage source? If in the second case should I really use all of those resistors and trimpots or can I simplify the circuit?

For the second question no, phase inversion is not an issue. I have seen different ways to connect an N-MOS gate (have seen a 100ohm resistor between the amplifier output and the gate plus a 10k resistor gate to ground). But I still need the 2k from Vcc to output for the LM393... so three resistor are sufficient? howto choose the correct value? I know am lacking elementary circuit theory basis....
 

crutschow

Joined Mar 14, 2008
38,316
If in the second case should I really use all of those resistors and trimpots or can I simplify the circuit?
You could just use the pot, but the adjustment may get a little coarse.
For best adjustment resolution use a resistor at the top of the pot with a value that give 100% duty cycle at the pot max setting.
(You do understand Ohm's law and how resistive dividers work?)
I have seen different ways to connect an N-MOS gate (have seen a 100ohm resistor between the amplifier output and the gate plus a 10k resistor gate to ground). But I still need the 2k from Vcc to output for the LM393... so three resistor are sufficient? how to choose the correct value?
You just need the 2kΩ from Vcc.
 

Thread Starter

Houseman

Joined Sep 25, 2018
22
Hi folks.
Ok thanks to You I have built the circuit as shown in the LTSpice simulation:
Schermata 2024-09-08 alle 18.41.25.png
Everything works in theory, but in reality by building it on a breadboard I see some strange Voltage gates on the oscilloscope of the N-MOS I cannot understand.
The two photos attached shows the unoladed output of the LM393 (N-MOS is disconnected):
RigolDS1.png
and then some strage ramp up voltages when I connect the output of the LM393 to the N-MOS gate:

RigolDS0.png
Could You please explain me why there is initially a 2V straightline that then increases in a charging capacitor manner until it hits the 4V output?
instead of a cleaner squarewave?
Best reagrds and thanks
 

crutschow

Joined Mar 14, 2008
38,316
Could You please explain me why there is initially a 2V straightline that then increases in a charging capacitor manner until it hits the 4V output?
Yes, it's due to the Miller effect of the large gate capacitance of the MOSFET.

Here's the MOSFET spec showing the large gate charge that has to be transferred when turning the MOSFET on and off:
That's a 50A transistor. Do you need such a large one?
If you use a smaller MOSFET with lower gate capacitance, the effect will be reduced.

1725817528306.png

R14 serves no useful purpose in you circuit.
 

Ian0

Joined Aug 7, 2020
13,097
That sawtooth generator is a bit dubious. In theory, the discharge should stop when the capacitor voltage reaches Vcc/3, but it actually stops at 0.4V. The reason is the internal delays in the 555. As the internal delays are not guaranteed, the amplitude of the sawtooth cannot be guaranteed.
 
Top