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

0 Members and 1 Guest are viewing this topic.

#### alsetalokin4017

• Super Contributor
• Posts: 1927
• Country:
##### Re: How do I make an LED light up using a comparator?
« Reply #25 on: October 22, 2019, 12:42:43 am »
5V rail > resistor > LED cathode - anode > Pin 1

Shouldn't the anode be on the + 5v side?
The easiest person to fool is yourself. -- Richard Feynman

The following users thanked this post: renzoms

#### renzoms

• Contributor
• Posts: 46
• Country:
##### Re: How do I make an LED light up using a comparator?
« Reply #26 on: October 22, 2019, 12:55:42 am »
You are correct. I mixed up the names

#### renzoms

• Contributor
• Posts: 46
• Country:
##### Re: How do I make an LED light up using a comparator?
« Reply #27 on: October 22, 2019, 01:02:17 am »
Got it to work although the timing is not accurate. Not looking into it rn.

If my + voltage is higher than my reference voltage at - then output at Pin 1 should be High, so for this n channel open drain output, that means ??

When the reference voltage, -, is higher than the voltage at the + terminal, the output at Pin 1 should be Low, so for this n channel open drain that means???

#### renzoms

• Contributor
• Posts: 46
• Country:
##### Re: How do I make an LED light up using a comparator?
« Reply #28 on: October 22, 2019, 01:21:37 am »
The timing is about over 4 seconds but it is calculated at 3.7s....

#### Audioguru again

• Regular Contributor
• Posts: 115
• Country:
##### Re: How do I make an LED light up using a comparator?
« Reply #29 on: October 22, 2019, 01:31:33 am »
5V rail > resistor > LED cathode - anode > Pin 1
No, you have the polarity of the LED connected backwards. The LED anode must have its current-limiting resistor connected to +5V and the LED cathode gets pulled to ground by the comparator output pin 1.

#### Audioguru again

• Regular Contributor
• Posts: 115
• Country:
##### Re: How do I make an LED light up using a comparator?
« Reply #30 on: October 22, 2019, 01:35:17 am »
When the output goes HIGH.
No, the output of this comparator never goes high, instead it floats disconnected or it goes low. The LED does not light when its cathode is disconnected from ground.

The following users thanked this post: renzoms

#### alsetalokin4017

• Super Contributor
• Posts: 1927
• Country:
##### Re: How do I make an LED light up using a comparator?
« Reply #31 on: October 22, 2019, 01:45:39 am »
Got it to work although the timing is not accurate. Not looking into it rn.

If my + voltage is higher than my reference voltage at - then output at Pin 1 should be High, so for this n channel open drain output, that means ??
It means Pin 1 is floating when HIGH, that is, not connected to anything inside the chip. (you could connect it externally to bias it to some other level but for your application it is just disconnected.)
Quote

When the reference voltage, -, is higher than the voltage at the + terminal, the output at Pin 1 should be Low, so for this n channel open drain that means???
It means Pin 1 is connected to Ground inside the chip. Look at the "internal schematic" of the chip in the data sheet. When Pin 1 is LOW it is really low: grounded.

When the output goes HIGH.
No, the output of this comparator never goes high, instead it floats disconnected or it goes low. The LED does not light when its cathode is disconnected from ground.
Yes, that is right. Although the two states of a digital output are called High and Low, in this case High means "not connected internally", while Low means "grounded". Sorry for my confusion, I wasn't looking at the right data sheet.

I have the circuit working on my bench using 1/4 of a LM339 quad comparator with open collector output, otherwise with same values as the schematic in the OP.

Since the capacitor is being charged through a 22 k resistor, it takes a finite time to charge fully. So the length of time the output LED is ON varies a bit, depending on how fully charged the cap was when you took your finger off the button.
« Last Edit: October 22, 2019, 01:47:14 am by alsetalokin4017 »
The easiest person to fool is yourself. -- Richard Feynman

The following users thanked this post: renzoms

#### alsetalokin4017

• Super Contributor
• Posts: 1927
• Country:
##### Re: How do I make an LED light up using a comparator?
« Reply #32 on: October 22, 2019, 01:50:16 am »
The timing is about over 4 seconds but it is calculated at 3.7s....

Component tolerances, capacitor charge level. The actual value of a capacitor can be different from the nominal value. Ditto resistors.
The easiest person to fool is yourself. -- Richard Feynman

The following users thanked this post: renzoms

#### alsetalokin4017

• Super Contributor
• Posts: 1927
• Country:
##### Re: How do I make an LED light up using a comparator?
« Reply #33 on: October 22, 2019, 01:53:19 am »
If you need some more exact timing... and even just for fun and learning ... you could substitute a 50k potentiometer for the fixed voltage divider made of the 10k and 47k resistors.

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

The following users thanked this post: renzoms

#### renzoms

• Contributor
• Posts: 46
• Country:
##### Re: How do I make an LED light up using a comparator?
« Reply #34 on: October 22, 2019, 02:16:40 am »
When the output goes HIGH.
No, the output of this comparator never goes high, instead it floats disconnected or it goes low. The LED does not light when its cathode is disconnected from ground.
Thanks, easy to understand!

It means Pin 1 is connected to Ground inside the chip. Look at the "internal schematic" of the chip in the data sheet. When Pin 1 is LOW it is really low: grounded.
Lol.

The timing is about over 4 seconds but it is calculated at 3.7s....

Component tolerances, capacitor charge level. The actual value of a capacitor can be different from the nominal value. Ditto resistors.
Thanks that is comforting!

If you need some more exact timing... and even just for fun and learning ... you could substitute a 50k potentiometer for the fixed voltage divider made of the 10k and 47k resistors.

Will do tomorrow! Good idea! Sounds fun.

Smf