Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Triple option inputs - possible?

Status
Not open for further replies.

Pommie

Well-Known Member
Most Helpful Member
I've got a project where I need to select between 3 options and only have one pin spare. I'd like any opinions on the method I'm thinking of using to select the 3 options.

Tie the pin to ground with a 100k resistor and have solder pads that can ground the pin or tie it to Vcc.
In code,
If the pin is high then it's tied to Vcc = option 1.
else, turn on WPU (20k ish) - if pin high then open circuit - option 2
else, option 3 - must be tied low.

The thing I'm worried about is the value of the WPUs as this isn't guaranteed but is stated in datasheets - as a current, not resistance.
The datasheet I'm looking at has 100uA as the typical WPU current but as low as 25uA @3.3V. 130k equiv.
The more I type the more I think this is a bad idea.

Maybe I can tie the pulldown to another pin so I can turn it on/off at boot time.

TIA,

Mike.
 
One thing I have done is use a pin that is normally an output configured as an input at startup and have it pulled high or low via a resistor. As it is only read at startup it must be set for the required option (1 of 2) before power is applied. The resistor would be such a value that it did not effect the pin when it was being used as an output. If this method is applicable in your project then together with a simple 0 or 1 on your spare pin this would give 4 options.
I like your idea. I assume you would have a high value pull down resistor (Say 100K) so that it would be pulled down when floating but pulled high enough to be seen as a logic 1 when you enabled WPU.

Les.
 
Can the pin be configured to be an analogue input?

If it can, then
0v = option 1
2.5v = option 2
5v = option 3

JimB
 
My Google powers are deficient today....

In one of the Microchip "hints and tips" papers, there a method of reading 3 states from a single digital pin. As I recall, it made use of a resistor and a capacitor, and the options were pin tied low, pin tied high or the pin connected to the cap.

To read the pin, you'd first set it to a high output, then flip it to an input. If the pin is tied low, it immediately reads low. If it reads high, the pin is either tied high, or connected to the cap that was just charged by the high output. Read it again a short time later and it will be high if the pin is tied high, or low if connected to the cap that's discharging through a resistor to ground.

It takes a few steps, but you get 3 states from one pin. Maybe your Goggle powers are better than mine today.
 
To read the pin, you'd first set it to a high output, then flip it to an input. If the pin is tied low, it immediately reads low. If it reads high, the pin is either tied high, or connected to the cap that was just charged by the high output. Read it again a short time later and it will be high if the pin is tied high, or low if connected to the cap that's discharging through a resistor to ground.
Cool... That's how the first PC joysticks worked... Time till low... Excellent suggestion... That means Jim's suggestion would work easily even on a digital pin... I kinda forgot about this.... Nigel mentions this in his tutorials as well..
 
So you could read a forth state by setting the output low and see if it goes high, if the cap resistor is connected to V+.
 
My Goggle mojo has returned. This is a great reference.

Compiled Tips 'N Tricks Guide - Microchip Technology


Screenshot_20210106-124337_Drive.jpg
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top