At 01:28 PM 4/23/2004 -0400, you wrote: >OK so let's rethink the problem. I think my posting on using an opamp made >it to the list. It should be possible to configure an opamp as a inverting >comparator that's close to rail to rail. Let's start with the opamp mantra: > >The output tries it very best to equalize the voltages on the + and - inputs. > >OK. Since we want to invert the output we need a situation where the output >will drive low when an input is high and vice-versa. We use the game plan >of putting one input at 2.5V using 47-100k voltage divider and using the >PIC output to swing the other terminal. In fact if we wanted to we could >use a dual opamp like a 1458 and drive the two LED terminals, one positive >and one negative. But back to the issue. > >To drive the opamp output low the + terminal needs to negative in >reference to the - terminal. So that means we can either ground the >+ terminal and have the - @ 2.5V or have the + terminal @ 2.5V and make >the - terminal high (+5V). > >To drive the opamp output high the + terminal needs to positive in >reference to the - terminal. So that means we can either ground the >- terminal and have the + @ 2.5V or have the - terminal @ 2.5V and make >the + terminal high (+5V). > >One last thing is that the PIC output needs to be the opposite polarity of >the opamp output. So in the first instance the PIC output is high and in >the second the PIC output is low. > >So we have a winner. The + terminal needs to be 2.5V with the divider and the >PIC output connected to the - terminal. That way the opamp drives low when >the PIC output is high and vice-versa. A inverting comparator. > >Hope this helps, 2 resistors and a 8 pin package opamp/comparator will do the >trick. Sure, plus a series resistor for the LED. Note that some op-amps don't play well when you use them as comparators (they may have diodes from V+ to V-, for example). Comparators are often open-collector. Many op-amps will work fine. >BAJ Or my posting to the EE thread, where we have this 1.5 component solution: LED A +---|<--+-------+ | | | +--->|--+ .-. | LED B | | Rs | | | | '-' | |\ | PIC ---------+---| >O--------+ |/ 1/2 SN74LVC2G14 PIC pin: High-Z: both LEDs off Low LED A on High LED B on The SN74LVC2G14 dual ST inverter is about 0.48 one-off, 0.27 in 100's, and is housed in a compact SOT-23-6, so it won't break the bank. By floating the PIC port pin, both LEDs can be turned off, with essentially zero current drain (thanks the the ST input). Best regards, Spehro Pefhany --"it's the network..." "The Journey is the reward" speff@interlog.com Info for manufacturers: http://www.trexon.com Embedded software/hardware/analog Info for designers: http://www.speff.com -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.