Comparator Output Not As Expected - Page 1
Forum section: electronics / beginners

author: cpitman
author_rank: Newbie
timestamp: September 04, 2023, 03:40:33 pm
content: Hey everyone,I'm testing a prototype PCB I've assembled, and the behavior of aLM239Ncomparator is confusing me, and I believe different from what I got when breadboarding a similar circuit earlier.The end goal is to take a 0-5V 1KHz square wave (with varying duty cycle) and translate it into a -12V-12V square wave. I'm not actually testing with the square wave yet, the initial test is with a steady 5V signal (or a 100% duty cycle). The varying signal is fed to an IN+ pin, and a 2.5V reference voltage from a voltage divider goes to IN-. VCC is connected to a 12V power supply, and GND to -12V from a charge pump.With the setup above, voltage on the OUT pin is ~.7V. It's not near either of the two rails. All the input voltages have been verified with a multimeter.I've attached a schematic showing the immediate vicinity of the comparator. I feel like I must be doing something fundamentally wrong, please help me understand where my thinking is off.

author: tooki
author_rank: Super Contributor
timestamp: September 04, 2023, 04:09:48 pm
content: Take a look athttps://www.ti.com/lit/an/snoaa35c/snoaa35c.pdfOne thing that sticks out is the pull-up resistor value. 1K ohm is too low a value: the recommended maximum current is 5mA, but 12V/1Kohm = 12mA. But the higher the current, the higher the Output Low voltage. Look at graph Fig. 3-1: you're right in the region between 10-20mA, where the Output Low voltage goes from about 0.2V to nearly 1V. TI notes:QuoteSo your getting 0.7V at 12mA is something they kinda predict with that statement.Using a much larger pull-up should lower the output sink current, and thus also the Output Low voltage.Also, what are you doing with the unused inputs? Don't leave them dangling (and don't tie them directly to Vcc or Gnd, use a resistor!).

author: cpitman
author_rank: Newbie
timestamp: September 04, 2023, 05:06:14 pm
content: Thanks for linking the Application Design Guidelines. There's a lot to chew on in here, and sounds like I need to go back to the drawing board. The 1K resistor is required by the spec I am implementing (J1772, EVSE/charging), and is part of a voltage divider (the car side varies resistance based on its state, and that should result in a specific voltage range in the net after the 1K resistor).All 4 comparators are actually replicas of the same circuit, just did not include them in the schematic for clarity.

author: tooki
author_rank: Super Contributor
timestamp: September 04, 2023, 07:40:14 pm
content: How do other open-source projects accomplish it? You're not the first person to design a J1772 controller.Show your whole circuit, not just snippets. There may be more wrong with it that isn't obvious.Also, take a look at this reference design from TI:https://www.ti.com/lit/ug/tiduer6/tiduer6.pdfI think Fig. 3 is literally exactly the part you're trying to make.

author: tooki
author_rank: Super Contributor
timestamp: September 04, 2023, 07:53:13 pm
content: P.S. More thoughts for your ±12V: H-bridges, RS-232 line drivers, ADSL line drivers... there are all sorts of ways of generating ±12V signals.

author: Zero999
author_rank: Super Contributor
timestamp: September 04, 2023, 08:30:37 pm
content: Quote from: tooki on September 04, 2023, 04:09:48 pmI've recently been bitten by this. I accidentally picked up a 1k resistor, rather than a 10k resistor for use in an LM393 comparator circuit and wondered why it didn't work. I spent awhile measuring the voltages around the circuit, until I realised my error.

author: magic
author_rank: Super Contributor
timestamp: September 05, 2023, 06:57:01 am
content: Looks like a PNP emitter follower could help you, if you can accept only -11V output swing.Otherwise, I guess it's time for another open collector (or open drain) comparator. There is zillions of proprietary ones...

author: Zero999
author_rank: Super Contributor
timestamp: September 05, 2023, 10:31:00 am
content: Perhaps a comparator with a push-pull output such as the TLV1814, would be better, as no pull-up resistor would be required.https://www.ti.com/lit/ds/symlink/tlv1812.pdf

author: cpitman
author_rank: Newbie
timestamp: September 05, 2023, 09:51:36 pm
content: Yeah, planning on trying again with a TLV1805DBVR, which is push-pull. I'll let you know how it works!This is really showing me how much documentation there is out there beyond datasheets though. I've been learning by looking at open source hardware, but they don't really explain the design, so it takes some trial and error to learn what is important and what is not.

author: tooki
author_rank: Super Contributor
timestamp: September 06, 2023, 11:45:41 am
content: Yep, application notes, white papers, and reference designs are goldmines!

author: cpitman
author_rank: Newbie
timestamp: September 10, 2023, 02:02:19 am
content: It works! At least on my breadboard, so I'm feeling really good about reworking my pcb. Thanks everyone!Here's the mess of wires that is my breadboard. +/-12V on the right side, GND on the left.

author: tooki
author_rank: Super Contributor
timestamp: September 10, 2023, 04:51:09 pm
content: Excellent!Share the final schematic?

author: cpitman
author_rank: Newbie
timestamp: September 11, 2023, 01:50:57 am
content: Looks like I called the game a little early. On the breadboard I was using Ground as the -IN input and +-12V as the +IN input, and got the expected results. Now that I am trying it with -IN at 2.5V and +IN with a 0-5V square wave, the output is, again, not what I expected. When +IN is 0V, output drops all the way to the negative rail, so that is good. But when it is 5V, I am only getting ~3.5V on the output, not 12V from the positive rail.Using an Analog Discovery, I've hooked up the chip to try to characterize the behavior I am seeing. It looks as if the output voltage when +IN>-IN is proportional to +IN. Isn't it supposed to go up to the V+ power supply?Attached is the output from the Analog Discovery. Its power supply only supports +-5V, so I've scaled down the square wave and reference voltage to be proportional to the 12V case. When +IN is 2V and -IN is 1V, Out is only .6V. Here's a table with the voltages I've tried so far:+IN, OUT2V, .6V4V, 2.6V5V, 3.6VWhat am I doing wrong? Why does it seem like OUT is just a 1.4V voltage drop from +IN when +IN>-IN?

author: cpitman
author_rank: Newbie
timestamp: September 11, 2023, 04:23:50 am
content: I've tried another chip, and am now getting the right results. I'm guessing I somehow fried the first one.