Author Topic: How do I make an LED light up using a comparator?  (Read 3562 times)

0 Members and 1 Guest are viewing this topic.

Offline renzomsTopic starter

  • Regular Contributor
  • *
  • Posts: 118
  • Country: us
  • I post everywhere lol
    • YouTube Channel
How do I make an LED light up using a comparator?
« on: October 21, 2019, 11:37:45 pm »
This is my circuit that lights up an LED for less than 4 seconds of volts using 4V. How do I make the LED light up? TLC372 comparator
« Last Edit: October 21, 2019, 11:42:29 pm by renzoms »
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: How do I make an LED light up using a comparator?
« Reply #1 on: October 21, 2019, 11:41:12 pm »
Many comparators have an open collector output, in which case you need to connect the LED (through the required resistor) from 5V to the output of the comparator. When the comparator triggers it will pull the output low and light the LED.
 
The following users thanked this post: renzoms

Offline renzomsTopic starter

  • Regular Contributor
  • *
  • Posts: 118
  • Country: us
  • I post everywhere lol
    • YouTube Channel
Re: How do I make an LED light up using a comparator?
« Reply #2 on: October 21, 2019, 11:44:01 pm »
I tried 5V to the current limiting resistor and (anode and cathode of the) LED, in series, then the output of the comparator the LED to ground. Didn't work
« Last Edit: October 21, 2019, 11:51:29 pm by renzoms »
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21658
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: How do I make an LED light up using a comparator?
« Reply #3 on: October 21, 2019, 11:46:29 pm »
+in is grounded. Connect it to the other side of C1. ;)

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 
The following users thanked this post: renzoms

Offline renzomsTopic starter

  • Regular Contributor
  • *
  • Posts: 118
  • Country: us
  • I post everywhere lol
    • YouTube Channel
Re: How do I make an LED light up using a comparator?
« Reply #4 on: October 21, 2019, 11:50:42 pm »
Greatness  :clap:. Still doesn't work.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: How do I make an LED light up using a comparator?
« Reply #5 on: October 21, 2019, 11:53:49 pm »
I tried 5V to the current limiting resistor and (anode and cathode of the) LED, in series, then the output of the comparator the LED to ground. Didn't work

What do you mean? Don't connect the LED to ground, connect it to the output of the comparator. Nothing can control it if it's connected directly to ground.

It would help to share a complete schematic of how you have it wired up
 

Offline renzomsTopic starter

  • Regular Contributor
  • *
  • Posts: 118
  • Country: us
  • I post everywhere lol
    • YouTube Channel
Re: How do I make an LED light up using a comparator?
« Reply #6 on: October 22, 2019, 12:07:09 am »
Tried these. This is what you meant, no?
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: How do I make an LED light up using a comparator?
« Reply #7 on: October 22, 2019, 12:07:53 am »
In your schematic, option 1) is the correct way to do it. Comparator output > currentlimit resistor > LED anode--LED cathode > ground .

Your schematic should work fine. When power is applied, the capacitor charges very fast through the resistor and the LED should come on. When power is removed the capacitor discharges through the other resistor to ground and when enough charge is drained off the LED should go out. If it works backwards, then your inputs should be swapped around. If the time is too short, use a larger (higher ohm) resistor across the capacitor. The greater this resistance the longer it will take for the charge on the cap to bleed down.  Doesn't TAOE use a 6 Megohm resistor here?

« Last Edit: October 22, 2019, 12:09:48 am by alsetalokin4017 »
The easiest person to fool is yourself. -- Richard Feynman
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: How do I make an LED light up using a comparator?
« Reply #8 on: October 22, 2019, 12:11:01 am »
How can you expect any of those options besides the first to work? All of the others have the output of the comparator connected directly to +5V or ground, that's like connecting a tractor directly to an immovable object and expecting it to move. You never connect an output directly to a voltage source or ground, ever. It's entirely possible that this has damaged the comparator as it will have resulted in a direct short. 

Even the first one can't work if the comparator has an open-collector output because such an output can only pull down toward ground, it cannot push up toward the supply voltage.

 

Offline renzomsTopic starter

  • Regular Contributor
  • *
  • Posts: 118
  • Country: us
  • I post everywhere lol
    • YouTube Channel
Re: How do I make an LED light up using a comparator?
« Reply #9 on: October 22, 2019, 12:13:30 am »
Well itt would have been damaged, or not damaged, if I connected it all of these ways, no? There's not a dice in there, rolling, and breaking the IC if it rolls a 6.
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: How do I make an LED light up using a comparator?
« Reply #10 on: October 22, 2019, 12:14:48 am »
Looks like the noninverting input (3) is connected to the ground side of the RC instead of the top side?   Sure won't work right that way.

The easiest person to fool is yourself. -- Richard Feynman
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: How do I make an LED light up using a comparator?
« Reply #11 on: October 22, 2019, 12:16:25 am »
What's the value of the R5 resistor?

The easiest person to fool is yourself. -- Richard Feynman
 

Offline renzomsTopic starter

  • Regular Contributor
  • *
  • Posts: 118
  • Country: us
  • I post everywhere lol
    • YouTube Channel
Re: How do I make an LED light up using a comparator?
« Reply #12 on: October 22, 2019, 12:17:46 am »
That doesn't sound right, to me. The IC has two inputs and one output on each side, both work the same, as far as I know. And as far as I know, there isn't difference in the sides where the GND pin is and the Vcc pin is.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: How do I make an LED light up using a comparator?
« Reply #13 on: October 22, 2019, 12:18:23 am »
Well itt would have been damaged, or not damaged, if I connected it all of these ways, no? There's not a dice in there, rolling, and breaking the IC if it rolls a 6.

There kind of is actually. Some ICs are very tolerant of abuse like having their outputs shorted to ground or supply rails, some can tolerate it for a while but may eventually fail, others will let the magic smoke out instantly if this happens. I don't recall seeing mention of the particular IC being used but it's still worth connecting it correctly in order to find out.

Let us know what IC it is, also study the datasheet, make sure you understand how it works. It will say whether the output is open collector or not and it will list absolute maximum parameters.
 
The following users thanked this post: renzoms

Offline renzomsTopic starter

  • Regular Contributor
  • *
  • Posts: 118
  • Country: us
  • I post everywhere lol
    • YouTube Channel
Re: How do I make an LED light up using a comparator?
« Reply #14 on: October 22, 2019, 12:20:04 am »
It is a TLC372CP and someone told me The outputs are n-channel open-drain configuration
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: How do I make an LED light up using a comparator?
« Reply #15 on: October 22, 2019, 12:23:12 am »
Search engines are your friend.

https://www.ti.com/lit/gpn/tlc372

Open-drain is the MOSFET equivalent to open collector, this means that the output can only pull in one direction, down toward ground. So you must connect the LED to +5V through a resistor, and connect the free end to the output of the comparator. When the comparator triggers, the output will become ground, prior to that it is floating (open circuit).
 
The following users thanked this post: renzoms

Offline renzomsTopic starter

  • Regular Contributor
  • *
  • Posts: 118
  • Country: us
  • I post everywhere lol
    • YouTube Channel
Re: How do I make an LED light up using a comparator?
« Reply #16 on: October 22, 2019, 12:24:52 am »
The LED is ON when I turn on the 5V power supply. When the capacitor is connected to 5V, it turns OFF.

When the capacitor is discharging the LED remains off for ~4 seconds, and then turns back ON.

(the opposite of what I want is happening)
« Last Edit: October 22, 2019, 12:26:28 am by renzoms »
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: How do I make an LED light up using a comparator?
« Reply #17 on: October 22, 2019, 12:26:59 am »
That doesn't sound right, to me. The IC has two inputs and one output on each side, both work the same, as far as I know. And as far as I know, there isn't difference in the sides where the GND pin is and the Vcc pin is.

There is only one GND and one Vcc pin for the whole chip, powering both comparators. The inverting and noninverting inputs to the two comparators have nothing to do with the chip's power. You are using one comparator of the pair.  Your schematic is correct but your breadboard is incorrectly wired because the noninverting input to the comparator you are using is grounded. It must be moved to the high side of the RC pair in order for it to see the voltage on the capacitor.
The easiest person to fool is yourself. -- Richard Feynman
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: How do I make an LED light up using a comparator?
« Reply #18 on: October 22, 2019, 12:28:02 am »
The LED is ON when I turn on the 5V power supply. When the capacitor is connected to 5V, it turns OFF.

When the capacitor is discharging the LED remains off for ~4 seconds, and then turns back ON.

(the opposite of what I want is happening)

Is that before or after you corrected the breadboard error?

If after:
So swap the connections to the inverting and noninverting inputs!!! Put the wire that goes to Pin 3 into Pin 2 instead, and the wire that goes to Pin 2 into Pin 3 instead.
The easiest person to fool is yourself. -- Richard Feynman
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: How do I make an LED light up using a comparator?
« Reply #19 on: October 22, 2019, 12:28:10 am »
Swap the + and - input pins of the comparator, this will reverse the action.

It sounds like you do not really understand how a comparator works, it will save you time to grasp the basics from the beginning, study the datasheet, it contains all the information you need.
 

Offline renzomsTopic starter

  • Regular Contributor
  • *
  • Posts: 118
  • Country: us
  • I post everywhere lol
    • YouTube Channel
Re: How do I make an LED light up using a comparator?
« Reply #20 on: October 22, 2019, 12:30:35 am »
This is what I have. I believe it's correct.
 

Offline renzomsTopic starter

  • Regular Contributor
  • *
  • Posts: 118
  • Country: us
  • I post everywhere lol
    • YouTube Channel
Re: How do I make an LED light up using a comparator?
« Reply #21 on: October 22, 2019, 12:33:47 am »
Ok, well if you don't mind helping me here is what I think about this comparator. The + terminal is higher than the - terminal for 4 seconds => the output is "high" for 4s == the output is shorted to ground for 4s.

So the output being at "high" for 4s in this case is open circuited? (because the LED is ON, then OFF for 4s, then ON after testing.)

I've connected the + terminal at 4V at fully charged capacitor, and the - terminal at .1V.
« Last Edit: October 22, 2019, 12:36:01 am by renzoms »
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: How do I make an LED light up using a comparator?
« Reply #22 on: October 22, 2019, 12:35:21 am »
Search engines are your friend.

https://www.ti.com/lit/gpn/tlc372

Open-drain is the MOSFET equivalent to open collector, this means that the output can only pull in one direction, down toward ground. So you must connect the LED to +5V through a resistor, and connect the free end to the output of the comparator. When the comparator triggers, the output will become ground, prior to that it is floating (open circuit).

Thanks, I missed that. So option 1) in the top schematic won't work after all. But he's got the LED lighting up so he must have that part wired correctly anyhow as open drain.  +4v rail > resistor > LED anode -- LED cathode > Pin 1 , right?
The easiest person to fool is yourself. -- Richard Feynman
 

Offline renzomsTopic starter

  • Regular Contributor
  • *
  • Posts: 118
  • Country: us
  • I post everywhere lol
    • YouTube Channel
Re: How do I make an LED light up using a comparator?
« Reply #23 on: October 22, 2019, 12:38:11 am »
5V rail > resistor > LED cathode - anode > Pin 1
 

Offline alsetalokin4017

  • Super Contributor
  • ***
  • Posts: 2055
  • Country: us
Re: How do I make an LED light up using a comparator?
« Reply #24 on: October 22, 2019, 12:40:47 am »
This is what I have. I believe it's correct.
Yes, that's right.

When the output goes HIGH, no current can flow because the LED+resistor are also at that same voltage  (or the output is simply open). So the LED turns on when the output goes LOW. So you have to swap the inverting and noninverting inputs until you get the behaviour you are looking for. There are only two choices!
« Last Edit: October 22, 2019, 12:43:16 am by alsetalokin4017 »
The easiest person to fool is yourself. -- Richard Feynman
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf