Voltage from high impedence? (Newbie)

They'll probably send him a lifetime supply of free samples for the asking. But to the extent it's an interesting problem, let's not.

I have a clean solution with a dual MOSFET and four or five resistors. Only limitation is that one LED current has to be somewhat higher than the other- which is usually ok with red/green LEDs since one is typically a lot less bright than the other. No part of the LED current flows through the port pin, and Iq is very low. It should only be used on a uC port pin with a Schmitt 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
Reply to
Spehro Pefhany
Loading thread data ...

I understand from studying electrical science that the "ideal volt meter" would have infinite resistance and that it would draw no current whatsoever.

However I know in reality that our volt meters have a little bit of conductance and thus a tiny bit of current flows thru them. It seems the higher the resistance of the volt meter, the less the circuit is interfered with, leading to a more accurate reading.

Let's say we had a circuit consisting of just two 4 megaohm resistors in series. If the supply voltage is a 20 volts, then we should have 10 volts across each 4 megaohm resistor. Consider tho if we had a volt meter that had a resistance of 2 megaohms. When this volt meter is put across one of the four megaohm resistors, you'll get much more current flow overall in the circuit, and I presume the meter will give a dodgy reading.

Anyway... the reason I'm talking about all this is that I'm working with tri-state microcontroller pins with the following three states: Output, High (5 volts) Output, Low (0 volts) Input

When a pin is set as an "input", it is said to be "high impedence". When you put a volt meter across an input pin of the PIC16F684 microcontroller, it measures something like 3 V. Now I'm wondering if this is *actually* 3 volts, or whether it's 5 volts but that our volt meter is experiencing what I've described above?

Getting down to the crux of it, I'll describe what I'm trying to do:

I have a tri-colour LED. It has three pins altogether. Internally it consists of two different colour LED's that have a common cathode. The anodes are separate.

I have a microcontroller pin. I want to use transistors to make it so that the pin's three states correspond to: Pin Output High = Green LED on Pin Output Low = Red LED on Pin High Impedence = Both LED's off

I can take an NMOS and a PMOS transistor and connect their gates together. I can then connect a uC pin to the gates. When the uC pin is high, it will turn on the NMOS which will allow current to flow thru the green LED. When the uC pin is low, it will turn on the PMOS which will allow current to flow thru the red LED. When the uC pin is set to high impedence... well... I'm not sure what would happen, I don't know whether this "phantom 3 volts" will be enough to turn on either of the transistors.

Has anyone ever done this before? Any pointers?

Reply to
Tomás Ó hÉilidhe

Measure the voltage between the signal and an adjustable reference voltage (with low impedance). Adjust reference until volt meter reads zero. Disconnect volt meter, and measure your reference voltage.

If you just want to know if a high impedance signal is 5V, put the volt meter between your 5V supply and the signal.

Reply to
Arlet

All you need is Ohms law. That's why galvanometer style meters are usually rated in terms of ohms per volt (full scale), and digital voms have a fixed input impedance, usually in the 1 to 10 megohm region.

--
 [mail]: Chuck F (cbfalconer at maineline dot net) 
 [page]: 
            Try the download section.


** Posted from http://www.teranews.com **
Reply to
CBFalconer

You want a window comparator.

Put resistors of equal value from your pin to v+ and gnd. Pin Output High = v+ Pin Output Low = 0 Pin High Impedence = v+/2

Then take a window comparator like TCA965, set the center of the window to v+/2 and the width of the window maybe 0.5V to allow for tolerances. The window comparator will output: v(pin) < v+/2 - v(win)/2 -> low v(pin) > v+/2 + v(win)/2 ->high v+/2 - v(win)/2 < v(pin) < v+/2 + v(win)/2 -> Z

For real projects you are wasting your time. Simply take a microcontroller with enough pins. Its that easy.

Mit freundlichen Grüßen

Frank-Christian Krügel

Reply to
Frank-Christian Kruegel

It's generally A Bad Thing to leave uC inputs floating. I don't have a good layout of that PIC's input circuitry but, generally, high impendence inputs (no pull-up or -down) can oscillate or draw excessive current when they are in the "gray zone" between max logic low and min logic high. Tying that together with the high impedence inputs on the MOS transistors should be ... interesting.

--
Rich Webb     Norfolk, VA
Reply to
Rich Webb

I have looked at this sort of circuit before and my take is that it can be tricky to make work correctly. In fact, I built one similar to this, but without the FETs. My LED has four pins and I tied an anode to a cathode then a low value resistor between this point and my output. I expected that neither LED would turn on using a PSU of 3.3 volts. I was almost right. There is a very faint glow from the green LEDs when the output is high impedance. I can only just see it with the lights on. With the room lights off, it turns out that the red LED is also barely on so dim that it would pretty much never be seen.

This circuit has a problem in that the supply voltage and LED voltage variation may cause the LEDs to be brighter than what I am seeing now. But if a Schottky diode were added in series with the two LEDs, that would lower the sneak current to a level where the LEDs would not be seen.

Your circuit will have a similar problem. The turn on voltage of the FETs is not well defined. So when the voltage is somewhere in the middle it is likely that both LEDs will be on. Since you are using a

5 volt supply, you can make this work with bipolar transistors. The trick is to make the voltage across the LED and transistor more than half of the supply voltage.

Put the LED and current resistor in the Emitter leg of the NPN and PNP transistors. Tie the Base leads together and the Collectors to the appropriate supply. When the output is low, the PNP will be turned on with the Base grounded so the Emitter will be around 0.7 to 1.1 volts depending on the drive capability of the output. Size the resistor for a 2 to 2.4 volt drop at the current you want. When the output is high the NPN will be on with 3.9 to 4.3 on the Emitter. Again size the resistor for a 2 to 2.4 volt drop. Like my other circuit there is a sneak path with a very small voltage on the resistors allowing 1.8 volts on the LED and resistor. This will be about 0.1 or 0.2 volts on the resistor which will be a pretty low quiescent current. But it may be enough to be trouble. Again, adding a diode in series with one diode will reduce the total voltage to a point where the LEDs will not light in the high impedance mode. You will need to adjust the resistor value in that leg.

You might try simulating this in a spice program. LTspice is pretty good and free.

Rick

Reply to
rickman

Hi. Seems like you're still working on the same old topic...

Anyway, if you really want to do your stuff with single CPU pin you can do the following:

Connect you µC output pin to a voltage divider of high restistance, e.g. somthing like this:

You'll get the following voltages from that:

µC-Pin Outut high Vcc low gnd tri-state Vcc/2

This will at least give you three different and defined states (as long as you load the voltage divider down at last).

The next step is to turn these steps into two different control-voltages to drive your LEDs. You can generate these using two "long-tailed pair" tranny-circuits. These can be configured as voltage comparators. To get them working you'll also need two reference-voltages. I'd say Vcc*2/3 and Vcc*1/3 will do (places the compare-points exactly at the middles).

These reference-voltages can be generated with a 3 resistor voltage divider.

In the end you'll need half a dozen resistors and four transistors. With tranny-arrays and resistor-arrays this is half as bad as it sounds, but that's the price to pay if you want to spare an µC-pin.

I may post a circuit do to this later...

Nils

Reply to
Nils

Maybe we should all take up a collection. Once we reach our goal of $3.50 we can order a PIC16F887 from Digikey and have it shipped to his house. :)

Reply to
Tom

Sounds like the best idea yet!

--
 [mail]: Chuck F (cbfalconer at maineline dot net) 
 [page]: 
            Try the download section.


** Posted from http://www.teranews.com **
Reply to
CBFalconer

But he would just burn it up in no time and we would have to start all over again. I'll send him a 64 pins uC if he promise never to post again.

Reply to
linnix

My Pickit1 can only program chips with up to 14 pins, otherwise I'd use the PIC16F72.

Reply to
Tomás Ó hÉilidhe

er

They make chips called I/O expanders. It uses two I/Os on your CPU for communications and adds 8 or 16 I/Os under software control. Or, you can roll your own I/O expander by using a second CPU and connecting it to the first the same way!

Rick

Reply to
rickman

Don't those PICs have a serial programming mode (long time since I used one)? Then all you'd need would be an adapter socket (if the SW can handle it).

--
Stef    (remove caps, dashes and .invalid from e-mail address to reply by mail)
Reply to
Stef

Why can't you just write a traffic lights application for that silly little microcontroller like every other newbie? Then get yourself a proper microcontroller with an appropriate number of pins, and appropriate debugger and programming tools so that you can make your connect 4 game.

Decent choices for micros with cheap tools are AVR and msp430. You can even stick to brain-dead PIC16, but get real working tools. Even if you value your own time at about twenty pence and hour, you would still have saved money over all. And don't think you've invested in learning - no one in the real world would ever go through the loops and jumps you've been doing to multiplex pins, so it's all wasted effort.

Even better, with a change of architecture and tools you'll be able to see what "portability" *really* means as you transfer your code.

Once you've got a better match for the combination of project, choice of microcontroller (and starter board), and developer competence, you'll find life a lot easier - and I expect your newsgroup threads to be more useful too.

Reply to
David Brown

An easier approach may just be to use multiple uCs to do this. Using multiple communicating microcontrollers is not at all uncommon: one to handle the user interface, one (possibly the same one) acting as an overall supervisor, and then distributed processors to handle the low level interfaces to batteries, sensors, actuators, etc.

--
Rich Webb     Norfolk, VA
Reply to
Rich Webb

Don't bring up another can of worms. Real traffic lights LEDs are over 300mA. He might try to be realistic to do so. In fact, we are looking into some high power LED that you can't even drive half of it with an uC.

Reply to
linnix

I've seen this mentioned a few times, but haven't been able to find any info about it!

What kind of adapter socket would I need? Where can I get info on this kind of stuff?

Reply to
Tomás Ó hÉilidhe

Did you try google for: pic serial programming

This link sounds useful:

formatting link

Free software and schematics. The horse sound can be disabled.

Reply to
Arlet Ottens

I find BJT transistors easy to understand because you can easily see what the base current is going to be, and it's the base current that decides whether it'll be "on" or "off".

My knowledge on FET's is a little wishy-washy though. I know that 5 V will turn on an NMOS, and 0 V will turn on a PMOS, but that's if those voltages are applied directly to the gate. I don't know what happens if there's a resistor on the gate.

When a uC pin is set as an input, I was thinking that maybe it's a 5 V supply that just has a massive internal resistance (a few megaohms or so), but I'm wondering what will happen if you connect this uC pin to the gate of a FET? Will it turn on an NMOS?

I had a module in college where we did very accurate measurements of the voltage and current flow of FET's. From those measurements, I saw that no current whatsoever flowed into the gate. (Now I'm not sure if "no current whatsoever" is accurate, but I definitely remember that our measurements were zero, and we definitely measured as low as microamps). This would lead me to believe that the "internal resistance" of the voltage applied to the gate is irreleavant, and so this would further lead me to believe that a uC pin set as an input would turn on an NMOS transistor.

But I suppose this only applies to microcontrollers that have input pins that are 5 volts with a massive internal resistance.

Reply to
Tomás Ó hÉilidhe

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.