Author Topic: Comparator Output Not As Expected  (Read 1496 times)

0 Members and 1 Guest are viewing this topic.

Offline cpitmanTopic starter

  • Newbie
  • Posts: 8
  • Country: us
Comparator Output Not As Expected
« on: September 04, 2023, 03:40:33 pm »
Hey everyone,

I'm testing a prototype PCB I've assembled, and the behavior of a LM239N comparator 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.
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 11561
  • Country: ch
Re: Comparator Output Not As Expected
« Reply #1 on: September 04, 2023, 04:09:48 pm »
Take a look at https://www.ti.com/lit/an/snoaa35c/snoaa35c.pdf

One 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:

Quote
The graph also shows the current limit, where the output voltage sharply inflects upwards in the 10-20mA region.
This region must be avoided as the specified minimum short circuit current is only 6mA (typically 12-16mA) and can vary across devices, lots and temperature.

So 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!).

« Last Edit: September 04, 2023, 04:11:23 pm by tooki »
 
The following users thanked this post: ledtester

Offline cpitmanTopic starter

  • Newbie
  • Posts: 8
  • Country: us
Re: Comparator Output Not As Expected
« Reply #2 on: September 04, 2023, 05:06:14 pm »
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.
 
The following users thanked this post: tooki

Offline tooki

  • Super Contributor
  • ***
  • Posts: 11561
  • Country: ch
Re: Comparator Output Not As Expected
« Reply #3 on: September 04, 2023, 07:40:14 pm »
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.pdf

I think Fig. 3 is literally exactly the part you're trying to make.
 
The following users thanked this post: cpitman

Offline tooki

  • Super Contributor
  • ***
  • Posts: 11561
  • Country: ch
Re: Comparator Output Not As Expected
« Reply #4 on: September 04, 2023, 07:53:13 pm »
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.
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19531
  • Country: gb
  • 0999
Re: Comparator Output Not As Expected
« Reply #5 on: September 04, 2023, 08:30:37 pm »
Take a look at https://www.ti.com/lit/an/snoaa35c/snoaa35c.pdf

One 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:

Quote
The graph also shows the current limit, where the output voltage sharply inflects upwards in the 10-20mA region.
This region must be avoided as the specified minimum short circuit current is only 6mA (typically 12-16mA) and can vary across devices, lots and temperature.

So 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!).
I'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. :palm:
 
The following users thanked this post: tooki

Offline magic

  • Super Contributor
  • ***
  • Posts: 6782
  • Country: pl
Re: Comparator Output Not As Expected
« Reply #6 on: September 05, 2023, 06:57:01 am »
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...
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19531
  • Country: gb
  • 0999
Re: Comparator Output Not As Expected
« Reply #7 on: September 05, 2023, 10:31:00 am »
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
 

Offline cpitmanTopic starter

  • Newbie
  • Posts: 8
  • Country: us
Re: Comparator Output Not As Expected
« Reply #8 on: September 05, 2023, 09:51:36 pm »
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.
 
The following users thanked this post: tooki

Offline tooki

  • Super Contributor
  • ***
  • Posts: 11561
  • Country: ch
Re: Comparator Output Not As Expected
« Reply #9 on: September 06, 2023, 11:45:41 am »
Yep, application notes, white papers, and reference designs are goldmines!
 

Offline cpitmanTopic starter

  • Newbie
  • Posts: 8
  • Country: us
Re: Comparator Output Not As Expected
« Reply #10 on: September 10, 2023, 02:02:19 am »
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.
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 11561
  • Country: ch
Re: Comparator Output Not As Expected
« Reply #11 on: September 10, 2023, 04:51:09 pm »
Excellent!

Share the final schematic?
 

Offline cpitmanTopic starter

  • Newbie
  • Posts: 8
  • Country: us
Re: Comparator Output Not As Expected
« Reply #12 on: September 11, 2023, 01:50:57 am »
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, OUT
2V, .6V
4V, 2.6V
5V, 3.6V

What am I doing wrong? Why does it seem like OUT is just a 1.4V voltage drop from +IN when +IN>-IN?
 

Offline cpitmanTopic starter

  • Newbie
  • Posts: 8
  • Country: us
Re: Comparator Output Not As Expected
« Reply #13 on: September 11, 2023, 04:23:50 am »
I've tried another chip, and am now getting the right results. I'm guessing I somehow fried the first one.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf