Searching \ for ' [EE] Two LEDs on port pin - High, Low, b' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/displays.htm?key=leds
Search entire site for: 'Two LEDs on port pin - High, Low, b'.

No exact or substring matches. trying for part
PICList Thread
'[PICLIST] [EE] Two LEDs on port pin - High, Low, b'
2001\09\10@153133 by Jerome Knapp

flavicon
face
       Im trying to connect two LEDs to a pic port pin so that one lights
when the output is low, the other lights when the output is high, and they are
both off when the pin is tri-stated as an input. The first two requirements are
easily met in a lot of ways but I cannot figure out a simple way to get both
leds off when the pin is put into a hiZ state.  I am looking for a solution
that uses just a few extra transistors and resistors - not something with
PALs or OpAmps.

       I have spent a bit of time puzzling over this and I am overlooking
something obvious or it is not as simple as it seems.  I think it can be
done using both a p-channel and n-channel mosfets.

       Does anyone have any simpler, more elegant ideas?

Thanks,
Jerome Knapp

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\09\10@194730 by Andrew Warren

flavicon
face
Jerome Knapp <spam_OUTPICLISTTakeThisOuTspammitvma.mit.edu> wrote:

> Im trying to connect two LEDs to a pic port pin so that one lights
> when the output is low, the other lights when the output is high,
> and they are both off when the pin is tri-stated as an input. The
> first two requirements are easily met in a lot of ways but I cannot
> figure out a simple way to get both leds off when the pin is put
> into a hiZ state.  I am looking for a solution that uses just a few
> extra transistors and resistors - not something with PALs or
> OpAmps.

Jerome:

Use a voltage-divider to get 2.5 V.  Tie the anode of one LED and the
cathode of the other LED to that 2.5V, then tie the other LED pins to
your PIC I/O pin.  When the I/O pin is high, one diode will conduct;
when it's low, the other one will conduct.  When the I/O pin is
configured as a hi-impedance input, neither diode conducts.


                        + Vcc
                        |
                        \
             D          / R
        +---->---+      \
        |        |      |
PIC ----+        +------+
        |   D    |      |
        +---<----+      \
                        / R
                        \
                        |
                        + GND

-Andy


=== Andrew Warren -- .....aiwKILLspamspam@spam@cypress.com
=== Principal Design Engineer
=== Cypress Semiconductor Corporation
===
=== Opinions expressed above do not
=== necessarily represent those of
=== Cypress Semiconductor Corporation

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\09\10@203024 by Dwayne Reid

flavicon
face
At 02:32 PM 9/10/01 -0500, Jerome Knapp wrote:
>         Im trying to connect two LEDs to a pic port pin so that one lights
>when the output is low, the other lights when the output is high, and they are
>both off when the pin is tri-stated as an input. The first two
>requirements are
>easily met in a lot of ways but I cannot figure out a simple way to get both
>leds off when the pin is put into a hiZ state.  I am looking for a solution
>that uses just a few extra transistors and resistors - not something with
>PALs or OpAmps.

The easy way requires only 2 resistors but has the disadvantage of always
consuming current, even when both LEDs are off.  Here is how it works:  put
2 resistors (470R) in series as a voltage divider between +5V and gnd.  The
mid-point of the resistors is at 2.5V with an effective resistance of
235R.  Connect both LEDs in reverse parallel.  Tie one end of the LED pair
to the mid point of the voltage divider, the other end of the LED pair to
the port pin.

When the port pin is HiZ, neither LED can light.  When the pin goes HI, the
LED that has its anode tied to the port pin lights up.  When the pin goes
LO, the other LED lights up.  When neither LED is lit, the quiescent
current is about 10 mA.

There are other techniques that will allow something similar but that will
take more components.  But the above technique will allow you to test the
basic concept and see if it works for your application.  And, of course, if
you are running from the AC line and don't care about minimum power
consumption, this is an entirely acceptable method.

dwayne



Dwayne Reid   <dwaynerspamKILLspamplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 17 years of Engineering Innovation (1984 - 2001)

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\09\10@211845 by Russell McMahon

picon face
> Im trying to connect two LEDs to a pic port pin so that one lights
> when the output is low, the other lights when the output is high, and they
are
> both off when the pin is tri-stated as an input. The first two
requirements are
> easily met in a lot of ways but I cannot figure out a simple way to get
both
> leds off when the pin is put into a hiZ state.  I am looking for a
solution
> that uses just a few extra transistors and resistors - not something with
> PALs or OpAmps.
>
>         I have spent a bit of time puzzling over this and I am overlooking
> something obvious or it is not as simple as it seems.  I think it can be
> done using both a p-channel and n-channel mosfets.
>
>         Does anyone have any simpler, more elegant ideas?

I'll overlook the fact that you seem to be at Monsanto :-).
If you don't mind current of about 0.5 x LED on flowing when both LEDs are
off this is an easy solution:

- Calculate desired series resistor for one LED - say this is 470r in this
case.
Connect 2 x 470r in series from Vdd to ground.

- Connect the two LEDS"back to back (ie Anode to Cathode, Cathode to Anode).

- Connect one end of the LED pair to the centre point of the two resistors.

- Connect the other end of the LED pair to the PIC pin.

QED.

In this case a current of 5/(2 x 470) ~= 5 mA will flow through the
resistors when the PIC pin is high impedance.
A current of about (5-1.5)/470 ~= 7.5 mA will flow through a LED when the
PIC pin is either high or low.
Choose smaller resistors for more current.

Note that LEDs have a reverse breakdown voltage of typically around 5
volts - may be lower. If this is exceeded the LED may be destroyed if enough
current is available. In this case the other LED across the off LED will
conduct before this voltage is reached. In some other arrangements the full
PIC Vdd may be applied across a reverse biased LED. In such cases a small
series diode (eg 1N4148) in series with the LED will protect it against
destructive reverse breakdown

If you want a circuit with minimal current drain when the LEDs are off it
can easily be done with 2 transistors and 6 resistors (and probably with
less).


regards


           Russell McMahon
.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\09\10@213605 by Sean H. Breheny

face picon face
Hi Jerome,

The following is untested, but I think it will work. It requires the two
LEDs, one resistor, and two of almost any kind of slilcon diodes (1N4148
would work fine).

I think this circuit is simple enough to explain in words rather than
attempting a schematic. The LED which should come on when the PIC pin is
low should be connected from Vcc (5V) to point A, pointing away from Vcc.
Between point A and point B we should have the two silicon diodes, pointing
away from Vcc. Point B should be connected to the PIC pin by a resistor,
and then the LED which should come on when the PIC pin is high should go
between point B and ground, pointing toward ground.

When the PIC pin is high, current flows through the bottom (closer to
gnd)  LED , limited by the resistor. The voltage at point B is about 2.5 V,
and the voltage from Vcc to point B is also about 2.5, which is too low to
put significant current through the combination of the top LED and two diodes.

When the PIC pin is low, current flows through the top LED/diode
combination, lighting the top LED. The voltage at point B will be about
5-(2.5+0.65+0.65)=1.2V, which is too low to light the bottom LED.

When the PIC pin is tristated, there will be 5V across the combination of
two LEDs and two Si diodes. Since the voltage is insufficient for the
typical total voltage drop of this combination (2.5+2.5+0.65+0.65=6.3V),
only a tiny current flows and there is no light.

If your supply voltage can vary significantly (more than 0.5V, let's say),
you might have to remove the resistor on the PIC pin and replace it with
two resistors, between the top LED and Vcc and between the bottom LED and
gnd. You might also need to use three Si diodes instead of two (just
putting all three in series) if your supply voltage is higher than 5V or if
you are using red LEDs and they are high efficiency.

Please let me know if it works!

Sean


At 02:32 PM 9/10/01 -0500, you wrote:
{Quote hidden}

---------------------------------------------------------------
NetZero Platinum
Only $9.95 per month!
Sign up in September to win one of 30 Hawaiian Vacations for 2!
http://my.netzero.net/s/signup?r=platinum&refcd=PT97

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\09\10@225442 by Spehro Pefhany

picon face
At 02:32 PM 9/10/01 -0500, you wrote:
>        Im trying to connect two LEDs to a pic port pin so that one lights
>when the output is low, the other lights when the output is high, and they
are
>both off when the pin is tri-stated as an input.

Hi:-

>        I have spent a bit of time puzzling over this and I am overlooking
>something obvious or it is not as simple as it seems.  I think it can be
>done using both a p-channel and n-channel mosfets.

That's a very healthy sign, when you just *know* there's a better way. In
this case you're right.

>        Does anyone have any simpler, more elegant ideas?

Sure:
                   R1            R3              R2
           +5 ---[470R]----x---[750R]-----x----[470R]---- 0v
                           |              |
                           |              |
                           x--|>|-x--|>|--x
                             D1   |   D2
                                  |
           Port pin --------------x

Low = D1 on
High = D2 on
Hi-Z = both off

(if you want them both to appear to be on, multiplex quickly between Low
and High)

I calculated these values for super-red LEDs, for shorter wavelength
LEDs you'll want to increase the ratio of R3 to R1 + R2,
and you may wish to decrease them all in proportion to get more LED current.

Adjust R1 for the current through D1, R2 for the current through D2 and R3
to keep them both off under worst-case conditions. There is interaction,
of course.

Best regards,

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Spehro Pefhany --"it's the network..."            "The Journey is the reward"
.....speffKILLspamspam.....interlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com
Contributions invited->The AVR-gcc FAQ is at: http://www.bluecollarlinux.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\09\10@225505 by Jinx

face picon face
Do you have a particular reason why you can't use a window
comparator (eg LM393) ? It seems to me that somehow you
need to make use of a third voltage to get 3 states out of a
two-state pin. Lightly biasing the pin to 1/2 Vcc with a couple
of resistors will get you that 3rd voltage when the pin is an
input, but there's going to be some complexity making a switch
that uses the 3rd voltage out of discrete transistors which
makes a chip look attractive

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\09\10@234034 by M. Adam Davis

flavicon
face
The key here is that diodes (LEDs) have a voltage drop below which they
will not conduct..

Say you have a green and a red LED.  The voltage drop for each might be
1.5 and 1.2 respectively.  If you put both in series with a current
limiting resister at 5 volts they will both light, BUT if you put them
both in series with a current limiting resister and 2.5 volts neither
will light.

So:

Get the two LEDs, two diodes where the diodes have a 1.5v drop each, and
two resistors  Hook them up in the following order:
+5v-------/\/\/\---|>|---|>|---+---|>|---|>|---/\/\/\--------Ground
 where the plus (+) is the PIC pin controlling the LEDs.  The diodes
and LEDs can be mixed, only make sure that one LED and one diode are
between the pic and ground and one LED and one diode between the pic and +5.

The combined voltage drop of all the diodes and LEDs (1.2+1.5+1.5+1.5)
is 5.7.  This is greater than the supply voltage (5v) so when the pin is
tri-stated none of the diodes will conduct, so neither LED lights.

When the PIC pin is high, the diode and LED going to +5 will have no
current, since the voltage drop (2.7) is greater than the votlage (0),
while the diode and LED going to ground will have a full 5v across them,
and that LED will light.  The reverse is true for when the pin is low.

I hope this helps!

-Adam

Jerome Knapp wrote:

{Quote hidden}

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\09\11@051012 by Chris Carr

flavicon
face
All you need is two equal value resistors and two LED's of the same type.
Connect the Resistors in series between the 5 volt rail and 0 volts to form
a potential divider, connect the two LED's back to back (i.e. Anode to
Cathode) then connect the LED's between the centre point of the potential
divider and the output port of the PIC. I'll let you work out a suitable
resistor value.

Sorry it does not meet your requirement for elegance due to the continuous
current draw, but it's a quick and dirty method of monitoring an output
port.

Regards
Chris Carr

{Original Message removed}

2001\09\11@075140 by Russell McMahon

picon face
part 1 1329 bytes content-type:text/plain; (decoded 7bit)


> >        Does anyone have any simpler, more elegant ideas?
>
> Sure:
>                     R1            R3              R2
>             +5 ---[470R]----x---[750R]-----x----[470R]---- 0v
>                             |              |
>                             |              |
>                             x--|>|-x--|>|--x
>                               D1   |   D2
>                                    |
>             Port pin --------------x
>
> Low = D1 on
> High = D2 on
> Hi-Z = both off


That looks pretty simple.
Quiescent current is about 3 mA for on current of about 7 mA
OK in many cases.

Attached are several other idea starters each of which have good and bad
points.

LED 7/8 version (mentioned before by me and others) is probably the lowest
cost version but has similar off current drain to the above version.

LM358 is cheap and compact.
R10 & R11 could probably be merged.

LED 1/2 version draws essentially zero quiescent current.
Zeners are cheap.

A variation on LED3/4 version involves driving the bases and having the
emitters connected to a resistor divider (and needs no resistors in series
with the LEDs) but driving the emitters produces a nice obscure circuit :-)
.


E&OE


           RM




part 2 5280 bytes content-type:image/gif; (decode)


part 3 131 bytes
--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\09\11@083828 by Spehro Pefhany

picon face
At 10:39 PM 9/11/01 +1200, you wrote:

>That looks pretty simple.

Thanks!

>Quiescent current is about 3 mA for on current of about 7 mA
>OK in many cases.
>
>Attached are several other idea starters each of which have good and bad
>points.
>
>LED 7/8 version (mentioned before by me and others) is probably the lowest
>cost version but has similar off current drain to the above version.

My problem with this one is that with other than red leds, the voltage
is getting pretty marginal, even with 5V Vdd.. Vf is more than 2V on some of
them, so you have < 0.5V to work with. The zener circuit suffers from the
same
problem, worse, perhaps.

>LM358 is cheap and compact.
>R10 & R11 could probably be merged.

Provided the supply voltage is not too high, around 8-9V probably is hitting
the limits on the LED reverse voltage (though they will usually break down
far above the -5V typical spec).  You can use a higher supply
voltage for the LEDs with this circuit (but draw the reference voltage from
the Vdd for the microcontroller). The LM358 is very nice for this
sort of thing.. cheap and short-circuit proof. It does draw some supply
current, and has a fairly large voltage drop when sourcing current (suggested
improvement- make it *sink* current to the LEDs- just swap around the +'s and
-'s and connect the LEDs to +V through one or two resistors).

>LED 1/2 version draws essentially zero quiescent current.
       >Zeners are cheap.
>
>A variation on LED3/4 version involves driving the bases and having the
>emitters connected to a resistor divider (and needs no resistors in series
>with the LEDs) but driving the emitters produces a nice obscure circuit :-)

A magazine is publishing a somewhat similar circuit to the above one that I
came
up with recently (for a different purpose, but it will work fine in this
case)- it
uses three resistors (four if you want different LED currents) and two
BJTs, and (better) has "zero" quiescent current. It has only one Vce(sat) drop
(plus the dropping resistor). Unfortunately, I can't publish it according to
my contract.

Best regards
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Spehro Pefhany --"it's the network..."            "The Journey is the reward"
EraseMEspeffspam_OUTspamTakeThisOuTinterlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com
Contributions invited->The AVR-gcc FAQ is at: http://www.bluecollarlinux.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


2001\09\11@163049 by hard Prosser

flavicon
face
What I use

(An Attempt at ASCII "art")
                                              D1 (red)
                   +-----------------E C--------|<-------+------  +5V
PIC                 |          NPN     B                  | R2
Port                |                  |                  | 47k
------| R1 |--------+                  +------------------+
       1k          |                  |                  | R3
                   |          PNP    B                   | 47k
                   +----------------E C---------->|------+-------  -ve
                                               D2 (Green)
Richard P






                   Jerome Knapp
                   <JJKNAPspamspam_OUTSKCA9.MON        To:     @spam@PICLISTKILLspamspamMITVMA.MIT.EDU
                   SANTO.COM>               cc:
                   Sent by: pic             Subject:     [EE] Two LEDs on port pin - High, Low, both off
                   microcontroller
                   discussion list
                   <PICLIST@MITVMA.M
                   IT.EDU>


                   11/09/01 07:32
                   Please respond to
                   pic
                   microcontroller
                   discussion list






       Im trying to connect two LEDs to a pic port pin so that one lights
when the output is low, the other lights when the output is high, and they
are
both off when the pin is tri-stated as an input. The first two requirements
are
easily met in a lot of ways but I cannot figure out a simple way to get
both
leds off when the pin is put into a hiZ state.  I am looking for a solution
that uses just a few extra transistors and resistors - not something with
PALs or OpAmps.

       I have spent a bit of time puzzling over this and I am overlooking
something obvious or it is not as simple as it seems.  I think it can be
done using both a p-channel and n-channel mosfets.

       Does anyone have any simpler, more elegant ideas?

Thanks,
Jerome Knapp

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...