Truncated match.
PICList
Thread
'Reading ternary inputs'
2000\02\25@062115
by
Russell McMahon
|
This may be old hat.
Anyone care to critique my thought processes.
Ternary (3 state) inputs are handy for increasing the number of options that
one can get from strapped option inputs.
eg
3 binary inputs give 8 states (2^3).
3 ternary inputs give 27 states (3^3)
I had a discussion today with a friend who said an input could be read as
high, low or floating by using a single resistor to any of these inputs and
perhaps a hi value pullup if the pin does not have an internal pullup. I
suggested a small value capacitor was also needed at the pin.
He commented ~~ that eg an input strapped to ground "could not be pulled up
so its state is known".
Hmm, comes clear as I type.
He works often in the 8031 world to which I am not accustomed.
They have I believe a "pseudo I/O" type of pin which may be legally driven
against a hi/lo load and which is used as an input by simply setting it high
and pulling it down against the weakish high drive. I may have detail wrong
but I believe this is the case in essence.
With a high current pin this is illegal (and dangerous to the cpu's health).
So, my ternary reading then goes like this.
10k from pin to ternary input
1M from pin to eg high
100 pF from pin to ground.
10K and 100 pF form a 1uS delay (choose actual value to suit code).
1M and 100 pF form a long (100uS) delay.
So
- Set pin to output
- Drive pin high
- Set pin to input
- Read pin ->Sa
- Set pin to output
- Drive pin high
- Set pin to input
- Read pin -> Sb
10k/100 pF need to have a delay safely less than time to set pin to read
and read pin.
Values will need to be changed for most processors.
If Sa = high and Sb = low then input is O/C
If Sa = low and Sb = low then input is low
If Sa = high and Sb = high then input is high.
Because:
A floating pin will retain the last written state due to slow pin time
constant from 1M.
A pin held during 10K will be temporarily driven to the opposite state by a
write but will return to the externally driven state after a few time
constants
The large value pullup returns the pin to an eg high if it left floating as
an input. Not needed if user exercise proper discipline and leaves port as
an output most of the time. This adds power dissipation (depending on input
setting).
Any comments?
Any better ways to do this for a true bidirectional high current capable
port pin.
Russell McMahon
_____________________________
>From other worlds - http://www.easttimor.com
http://www.sudan.com
What can one man* do?
Help the hungry at no cost to yourself!
at http://www.thehungersite.com/
(* - or woman, child or internet enabled intelligent entity :-))
2000\02\25@062738
by
Alan Pearce
Read the data sheet for the Motorola MC145026/7/8 remote control transmitter and
receiver chips which implement a ternary scheme. There is a very good
description of how the chips do it.
2000\02\27@193137
by
Sean Breheny
Russell,
How about this:
Have one pin per ternay input PLUS a single additional pin. Feed your
inputs directly into your ternary input pins, and then have a 10K pull-up
from each pin to the single additional pin. To read your inputs, first pull
all of them high with the pull-ups. Read the values. Then pull all low, and
read the values. The ones that changed when you changed the pull-up state
are tri-state. The ones which were always low are low, and the ones that
were always high are high.
Alternatively, use PORTB or other such port which has internal pull-ups.
You can eliminate the additional pin, just toggle the internal pull-ups.
Sean
At 12:10 AM 2/26/00 +1300, you wrote:
>Roger Hawkins <spam_OUTrdhawkinsTakeThisOuT
wbmpl.com.au>,bill roberts
<.....billyleebobKILLspam
@spam@home.com>, ADR <info
KILLspamadr.co.nz>
>To: .....PICLISTKILLspam
.....MITVMA.MIT.EDU
>
>This may be old hat.
>Anyone care to critique my thought processes.
>
|
| Sean Breheny
| Amateur Radio Callsign: KA3YXM
| Electrical Engineering Student
\--------------=----------------
Save lives, please look at http://www.all.org
Personal page: http://www.people.cornell.edu/pages/shb7
EraseMEshb7spam_OUT
TakeThisOuTcornell.edu ICQ #: 3329174
2000\02\28@013318
by
Russell McMahon
Reading ternary inputs.
Sean suggested applying inputs to pins directly plus resistors from each
input to an "extra i/o pin"
So
Yes - this works with the use of 1 extra pin plus 1xR per pin and no need
for caps or rc timing.
One algorithm could be -
Extra pin hi
Read input to VA
Extra pin low
Read input to VB
VC = Va XOR VB - high bits are tristates
Vd = Va XOR VC - high bits are highs
Vd = Vb XOR Complement(Vc) - high bits are lows
VC, Vd etc aren't necessarily actual registers- just intermediate steps in
process.
Efficiency
Pins 1 2 3 4
Levels binary 2 4 8 16
Levels ternary 3 9 27 81
Levels as above - 3 9 27
Better than binary at 3 pins.
Always 1 pin worse than true ternary (of course).
Russell McMahon
{Original Message removed}
More... (looser matching)
- Last day of these posts
- In 2000
, 2001 only
- Today
- New search...