A question about a circuit simulation using LM331 in LTspice

I'm trying to convert 0..10V analog voltage to frequency by using an LM331. Since LM331 works at 5V supply, I can scale 0..10V to 0..5V and feed it as the voltage input to the LM331.

I came across this circuit and this forum. I followed the instructions to use LM331 in LTspice and simulated the circuit below:

But I'm getting 5V constant output when I use 5V supply. LM331 should work with 5V supply. But in simulation with 5V it doesn't work. It works when I use 10V supply.

Can someone explain me how this circuit works? I mean C1 and R1 sets the frequency but thats all I know. What else sets what here? How can I set the duty cycle to around 50%? How can I modify this circuit so I can run the simulation for 5V supply?

• The function of the chip is described in detail in section 8.1.1 of the data sheet. May 17, 2017 at 19:05
• Side note: if ncl and nct are just the chip's pins, not the node's labels, then those .ic conditions are useless. If the actual labels are 1 and 5, then you may wish to change the directive to .ic v(1)=0 v(5)=0. May 18, 2017 at 6:45

Looking through the link to the forum you've posted I see that the initial schematic uses LTspice comparators (instead of the simpler [Digital]/Schmitt) and a bunch of other logic gates. There is also a comment in there saying:

For A1, A2, A3, set value Vhigh = Vs

Given that the supply in that example is 10 V my guess is that the .SUBCKT you're using needs adjusting those values (e.g. set vhigh=5). Maybe it's not set as a parameter, maybe it's not visible, maybe it's not even the case, but if you can provide a link for the exact subcircuit, or hierarchical schematic that you're using, it will be easier to tell if that is the problem.

From page 4, 7.1 Absolute Maximum Ratings table in the datasheet, the range of input voltage is -0.2V to +Vs.

• Yes so I can use it with 12V supply as well then since Vs is max 40V. But on the on the other hand, on the first page it says "Operates on Single 5-V Supply" But it doesnt work at 5V supply in simulation. May 17, 2017 at 18:42
• While Vs at 5V, did u ensure that your input does not cross 5V? May 17, 2017 at 18:46
• Yes sure, I tried 1V 0.1V 2V and 4V for inputs and in all cases output was 5V. Do you think this circuit is correct? I also want more 50% like duty cycles. May 17, 2017 at 18:48
• The LM331 works by putting out fixed-width pulses and there is nothing you can do to change this. You can, however, follow the 331 with a divide by 2 circuit, using something like a 74HC74. This will give you a square wave at half the frequency. May 17, 2017 at 19:01
• @WhatRoughBeast Do you think the circuit in my simulation is correct? What is that poti for? And are the values of components dependent on supply voltage? May 17, 2017 at 19:07