GPIO pin puzzle

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Often in microcontroller-Systems jumpers are used
to select options. Now assume the following setup:

You can use two GPIO pins of an AVR. These pins
have no additional functinalities. Only these
two pins are accessible, no connections to GND
or VCC are possible.

The question now is: How many options can you
select/detect by connecting different electrical components/networks to the two pins ?

The simplest are: open/short.

Or you may use a resistor. Can you differentiate
some resistance values (the internal pullup
is not very accurate)? What can you do with
capacitors and peraps diodes ?

What ideas come to your mind ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Two diodes selectively connected in anti-parallel between the two pins can give you four states which can be detected:

State 0 = no diodes
State 1 = a diode connected from PIN1 (cathode) to PIN2 (anode)
State 2 = a diode connected from PIN1 (anode) to PIN2 (cathode)
State 3 = both diodes connected between pins

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A DIP-SW and a shiftreg, and some SPI, gives you a lot ;-)

HM

HM

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Interesting question.

Late responders to the thread will have a harder time, as the "easy" solutions will have already been discussed.

Note that if the generic AVR includes the Xmega, then both pull up and pull down resistors are available.

If you have one device, not mass produced, and you allow calibration, then you could have many selectable states.

Pin A has pull up resistor active.
Pin B is output low, (~Gnd).
Put a cap between the two pins.
Pin A is output low, (~Gnd).
Cap is discharged.
Pin A is now input, with pull up resistor. Start Timer.
Time how long it takes to charge the RC to hit the minimum Hi logic level, at which point Pin A transitions from reading low to high.

Can use different caps for different RC time constants.

Of course I like HM's answer better than mine!

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm eager to see an SPI solution without connection to GND/VCC :D:D:D

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have once thought exactly the same thing - how to select different test modes in a board with extra 2-pin header.

Thought about pins being open, short, diodes one way or another too, just like you.

And you could put resistor and capacitor there (perhaps in series so current is limited by resistor, instead of parallel), but in essence you could keep other pin low and see how long it takes to charge or discharge the RC time constant. A potentiometer even? But remember component tolerances can be huge so maybe only few different values, like four pushbuttons?

With two GPIO pins, you could even make a capacitive touch button a la Qtouch. So you are able to measure different capacitances based on charge transfer to reference capacitance.

Or put a LED there with resistor, and you have a bidirectional data link (led can emit light or detect it by measuring how long it takes to discharge reverse biased led capacitance).

What would be possible with inductor?

SPI shift register input could be possible. Put a schottky diode bridge and capacitor to power the shift register, to give it power keep one pin high and another low some time.
Something then needs to be done to make it latch inputs and clock out the data. Maybe another microcontroller for the job?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Make a simple multivibrator. Change the frequency by straps, on time and / or off time. Messure time(s).

HM

HM

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You could control a 2-wire 18B20 temperature sensor with those 2 pins. Then you put the sensor into your microwave and voila: just by selecting the duration and power at your microwave, you will have 100s of different states.

Einstein was right: "Two things are unlimited: the universe and the human stupidity. But i'm not quite sure about the former..."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

One could set one pin as OUTPUT LOW effectively ground.

The other pin as INPUT.

Ground of a serial data stream connected to the output pin.

Serial data stream into INPUT pin.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Don't suppose we're allowed to use a GPIO+ADC pin? ;-)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ossi wrote:

You can use two GPIO pins of an AVR. These pins
have no additional functinalities. Only these
two pins are accessible, no connections to GND
or VCC are possible.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

like clawson I opt for one or perhaps 2 pins with ADC support.
with a resistor and some diodes you could do a lot

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But as Mbedder pointed out that's outside the scope of the "puzzle". (I simply didn't read ossi's post carefully enough :oops:)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for all contributions. I especiallly like
the hint that something like the Dallas 1-wire bus
could be used to get infinite possibilities.
I can also think of a NE555 multivibrator
that is first powered using the two lines.
Then, while the supply cap is still charged, the AVR
could read the frequency.