Op amp comparator troubles

Braeden Hamson

Feb 18, 2016
240
Joined
Feb 18, 2016
Messages
240
upload_2022-2-25_14-11-48.png

Above is my circuit it used the LM2903 op amp

https://www.mouser.com/datasheet/2/389/cd00000534-1795799.pdf

One half of the chip is grounded and not used. The other is functioning as a comparator.

The circuit should function as a brake light switch. Such that when the BSE_IN voltage is greater than OUT7 the output of the comparator will turn off, and the P-Channel MOSFET will conduct, turning on the brake light.

OUT7 is a voltage coming from a linear regulator that I can adjust from a pot.

BSE is brake system encoder (not an actual encoder, it's a hall effect sensor with an analog output from 0-5V)

The trouble:

The problem I'm facing is when the comparator output goes low it only goes to 3V, it should go to 0V. When it goes high it goes to 5V, which is what I want.

I'm not sure why this is occurring, thank you for any help you can provide.
 

Bluejets

Oct 5, 2014
7,374
Joined
Oct 5, 2014
Messages
7,374
Output of op amp is open collector.
Your circuit does not allow for that.
Show the complete circuit.
 

Braeden Hamson

Feb 18, 2016
240
Joined
Feb 18, 2016
Messages
240
Output of op amp is open collector.
Your circuit does not allow for that.
Show the complete circuit.

This is my complete circuit. (Everything that is relevant to this system.) I understand now that I'm lacking a pull up resistor. However I tried the circuit with a pull up resistor and the behavior was the same.

I will keep trying
 

Bluejets

Oct 5, 2014
7,374
Joined
Oct 5, 2014
Messages
7,374
Show circuitry that is not shown would be helpful.
What you show cannot possibly be the complete circuit.
 

Braeden Hamson

Feb 18, 2016
240
Joined
Feb 18, 2016
Messages
240
Here's a PDF of the entire circuit.

The circuit in question is connected to an external trailer brake light. Which in turn connects to the main IO header and is grounded there. The idea is to switch on or off power to the light.
 

Attachments

  • PedalControl.pdf
    882.6 KB · Views: 8

Braeden Hamson

Feb 18, 2016
240
Joined
Feb 18, 2016
Messages
240
The pull-up resistor (e.g. 10kΩ) needs to go to the +12V to turn off the P-MOSFET.
That... Makes a lot of sense now.

However it still doesn't work when I use a pull up to 12V. I think this is because the opamp is connected to 5V.
 

crutschow

May 7, 2021
984
Joined
May 7, 2021
Messages
984
However it still doesn't work when I use a pull up to 12V. I think this is because the opamp is connected to 5V.
No.
The LM2903 comparator (not an op amp) has an open collector output, so can operate fine with the output connected to a voltage different from its operating voltage.

I suspect a wiring error.
Double check all your connections as compared to the wiring diagram.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
14,271
Joined
Nov 17, 2011
Messages
14,271
The MOSFET you use has a built.in gate protection diode. VGSmax = +- 6 V.
Your circuit applies VGS ~ -12 V when the output of the comparator goes low. This will activate the gate-source protection diode and thus lead to a high current with subsequent high voltage on the gate of the MOSFET, not ~0 V as you expect.
Two possibilities:
  1. Use another MOSFET without the gate-source protection diode
  2. Or add a resistor in series from the output of the comparator to the gate of the MOSFET. The diode will still be activated but current will be limited. I can find no data on the max. diode current in the MOSFET datasheet. Lacking this info let's assume 1 mA (should be tolerable). Let's also assume the diode has a zener voltage of 6 V (the exact value isn't in the datasheet, but that is the max VGS anyway. So we have 6 V across the series resistor and 1 mA through the resistor which makes for R = 6 V / 1 mA = 6 kΩ. Use anything you have in that ballpark. Even 10 kΩ should be fine.
It is not a problem when the diode's breakdown sets in as the gate of the MOSFET should be protected by this diode and the VGS is the high enough to fully turn on the MOSFET.
 

Braeden Hamson

Feb 18, 2016
240
Joined
Feb 18, 2016
Messages
240
I've reconfigured the circuit based on all of your advice.

upload_2022-2-28_13-20-54.png

I've added a pull up resistor, changed out the old mosfet for the BSS314PE which has a Vgs max of 20V. I changed the comparator's supply voltage to 12V. I don't have a great reason for this other than it will be slightly easier to get 12V to this IC than 5V.

An LTSpice sim in which I used, mostly similar components and replaced the comparator with an NPN BJT worked as expected.
 

Braeden Hamson

Feb 18, 2016
240
Joined
Feb 18, 2016
Messages
240
Only one thing, most automotive brake lights operate as negative return.
I'd prefer to do it that way. To be honest it's been a little while since I first made this circuit. I'm revisiting it as I need to fix it's issues. I can't remember why I did it this way. I think it's that else where in the circuit I need to know that the brake pedal isn't being pressed and that needs to be logic high.

The brake light I'm using is basically just an LED array so it does work with a positive "feed"

But I'm always happy to learn standards, thank you.
 

Braeden Hamson

Feb 18, 2016
240
Joined
Feb 18, 2016
Messages
240
As your sim worked whilst using an NPN bjt, why not use that in your circuit. Much simpler.
I'm comparing the analog position of a brake pedal to a set voltage, hence the need for a comparator. But I'm sure I could do this with a BJT. I'm always open to new ways of doing something.
 

WHONOES

May 20, 2017
1,242
Joined
May 20, 2017
Messages
1,242
Presumably your brake lights are initiated by a switch connected to your brake pedal. Or is it not?
 

AnalogKid

Jun 10, 2015
3,045
Joined
Jun 10, 2015
Messages
3,045
This is a minor nit for your circuit, but might be an issue in some future design.

At U30B, disconnect the comparator pin 7 from GND.

In general when tying off unused elements in a multi-element component (logic gate, opamp, whatever), you should leave unused outputs floating. For some components, tying the inputs to GND forces the output high, causing the part's output stage to produce maximum current into a dead short to GND, continuously. The 2903 is rated for continuous operation into a short circuit, but that is an exception rather than the norm.

In your specific case this does not matter because the output stage is open collector rather than a totem pole; it cannot source current into the load, dead short to GND or any other. But if the component were an actual opamp as your title suggests, this could be a real issue. With both inputs shorted together (to any potential), there is a 50% chance that the output will saturate high, pushing current to GND at its internally-set limit. Datasheet ratings notwithstanding, this is not a good practice for long-term reliability.

ak
 

Sunnysky

Jul 15, 2016
573
Joined
Jul 15, 2016
Messages
573
If you wanted the DMG1013 to work, the gate would have a pullup to 12V and a series R of 10k to the collector output. thus providing 6 to 12V on the gate, making the builtin zener redundant.
 
Top