Searching \ for 'Help to identify one out of 128 sw's' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/index.htm?key=help+identify+one
Search entire site for: 'Help to identify one out of 128 sw's'.

Truncated match.
PICList Thread
'Help to identify one out of 128 sw's'
1996\05\05@004305 by Juan Abba

flavicon
face
On the design of a PIC ( probably 16c65 or 16c74 ) security system,  we need to
be able to identify one of the following situations;

1> A unique closed switch out of 128 SW's ( normally open contacts)

or

2>A unique open switch out of 128 SW's ( normally close contacts)

whichever case is simpler and cheaper.

Switchs can be of any type, with cost as the only limitation .


Any ideas of designs similar to our need?????

thanks in advance


juan abba

PD. On one of the many possible system versions, a pair of IR emitter and
detector that will read a bar code on each of the 128 positions, and will send
a signal of the read reflected light changes, plus a signature type of code,
self identifying the position appears as an ideal solution, as the environment
will not only act as a SW, but also will be able to read bar code information
at each station.

Can somebody pls. identify a low cost ( below 30 cents on 5K/moth quantities )
pair of ( IR LED PLUS DETECTOR) PLUS A INTELLIGENT CHIP  THAT WILL TRANSMIT THE
MENTIONED SIGNATURE PLUS IR LIGHT CHANGES, over an SPI or I2C, allowing the PIC
that will receive it, not only identify the position but also, reading the IR
changes timing, decode the bar code being entered at each station, only one at
any given time.

1996\05\06@074502 by Paul E. Kamphuis

flavicon
face
Juan,

To identify one out of 128 SW's might be possible with a matrix
structure. I have seen it used in several keypads.
Make a structure with rows and colums with the SW's at their
intersections. By selecting one colum at the time and reading the
rows. One can identify wich SW's are open or closed.

There might be a few problems with this in your application.
1 the amount of inputs and outputs needed
  you probebly need some extra latches
2 the polling part
  you probebly want an interrupt first and then start polling
 this might work by selecting all colums and or-ing the rows
 for the interrupt


greetings,

Paul
Paul E. Kamphuis
Wilhelminastraat 9
5121 WR Rijen

0161-222362

1996\05\06@084609 by Mark K. de Jong

flavicon
face
Hello Paul,

Wat is het nut van dit mailtje ????????

{Quote hidden}

---
Mark K. de Jong                                 Tasking Software BV
email: .....markjKILLspamspam@spam@tasking.nl                         Plotterweg 31
phone: +31 33 4558584                           Amersfoort, The Netherlands

1996\05\06@165005 by Scott Dattalo

face
flavicon
face
Juan Abba wrote:
>
> On the design of a PIC ( probably 16c65 or 16c74 ) security system,  we need
to
{Quote hidden}

Juan,

Presumably you've considered the obvious: a Matrix. However, to scan 128
switches, you need at least a 12 by 11 rectangular matrix (12 * 11 = 132,
4 switches to spare). To uniquely discern simultaneously pressed switches,
you have to individually scan each row and keep track of the number of
closed switches. The reason you have to scan each row individually is because
it is possible that two or more switches are closed in a given column.
Scanning all rows at once in this case would only detect one closed switch.


A rectangular (or square) matrix is not necessarily the most efficient one.
For example, suppose we implement a 4 X 4 matrix using port B:

 B7 --+--+--+--+--
      |  |  |  |
 B6 --+--+--+--+--
      |  |  |  |
 B5 --+--+--+--+--
      |  |  |  |
 B4 --+--+--+--+--
      |  |  |  |
     B3 B2 B1 B0

The rows are B7-B4, the columns are B3-B0, and the +'s represent the 16
switches.
Actually, each intersection looks more like:

           |
 X-----0------------
        \  |
        S1 |
          \|
           0
           |
           Y
The row X and column Y are connected only if switch S1 is closed. (The
limitations of ASCII art...)

Now, consider the triangular arrangement:

 B7 --+--+--+--+--+--+--+-
      |  |  |  |  |  |  |
 B6 --+--+--+--+--+--+- |
      |  |  |  |  |  |  |
 B5 --+--+--+--+--+- |  |
      |  |  |  |  |  |  |
 B4 --+--+--+--+- |  |  |
      |  |  |  |  |  |  |
 B3 --+--+--+- |  |  |  |
      |  |  |  |  |  |  |
 B2 --+--+- |  |  |  |  |
      |  |  |  |  |  |  |
 B1 --+- |  |  |  |  |  |
      |  |  |  |  |  |  |
     B0 B1 B2 B3 B4 B5 B6
      (B0 - B6 are shown
       again for clarity)


In this case, there are 7+6+5+4+3+2+1 = 28 switches, an improvement of 12!
In general, the number of detectable switches is N*(N-1)/2, where N is the
number of available I/O pins (8*7/2 = 28). The trick is now the I/O pins
are dynamically switched as inputs and outputs, where as before they were
statically programmed as input only or output only.

The scanning algorithm would go something like:

1) Let i=1
2) make I/O i an output and all other I/O's inputs.
3) Output a logic high on I/O i.
4) read the rest of the I/O's. You will need to keep track of a) the total
number of
  closed switches b) which switch (if there's only one) is closed.
5) i = i + 1
6) if i>#of I/O's quit else goto step 2


Note that pull-down resistors are recommended on all of the I/O lines. 100K
is more than sufficient, however you probably can get by with 1Meg. You don't
need to worry about parasitic capacitance since you can drive the I/O lines
before making them inputs. In other words, you are only counting on the
resistors to keep the inputs close to ground and not to switch you to ground.

The number of I/O lines, N, needed in your case is:

  128 = N*(N-1)/2

The closest integer that satisfies this quadratic equation is N=17. This is
an improvement of 6 from the rectangular matrix. 17 I/O lines will give you
17*16/2 = 136 switches.


Scott

P.S. See the recent thread on checksums/Manchester encoding to get a fast
algorithm
to count bits.

1996\05\06@210201 by Prashant Bhandary
flavicon
picon face
At 01:42 AM 5/05/96 -0300, you wrote:
>On the design of a PIC ( probably 16c65 or 16c74 ) security system,  we need to
> be able to identify one of the following situations;
>
>1> A unique closed switch out of 128 SW's ( normally open contacts)
>
>or
>
>2>A unique open switch out of 128 SW's ( normally close contacts)
>
>whichever case is simpler and cheaper.
>
>Switchs can be of any type, with cost as the only limitation .

As others have mantioned a matrix is one solution. You would probably need
a 16x8. To save on PIC lines you could put a decoder on 4 lines
to give you 16 outputs for a matrix and use 8 input lines to sense it. If
only one of the 128 switches are closed/open, you could use a priority encoder
on the input to use 3 inputs to sense 8 lines. So 7 I/O lines should be adequate
for a 16x8 matrix with an extra input for a data ready from the encoder.

Regards

Prashant
+----------------+  -------------------------------------------------
|                |    Prashant Bhandary
|   +---+        |    Spatial Information Systems Section
|   |   |        |    Roads and Traffic Authority
|   |   |        |    Rosebery NSW 2018, AUSTRALIA
|   |   |        |    Tel:  +61-2-662 5299
|   |   +----+   |    Fax:  +61-2-662 5348
|   |        |   |    Email: prashbspamKILLspamrta.nsw.gov.au
|   +--------+   |
| Still a newbie |    "2b|!2b" - William Shakespeare
+----------------+  -------------------------------------------------

1996\05\06@213103 by Clyde Smith-Stubbs

flavicon
face
"Paul E. Kamphuis" <.....P.E.KamphuisKILLspamspam.....stud.tue.nl> wrote:
>
> To identify one out of 128 SW's might be possible with a matrix
> structure. I have seen it used in several keypads.
> Make a structure with rows and colums with the SW's at their
> intersections. By selecting one colum at the time and reading the
> rows. One can identify wich SW's are open or closed.

Yes, but you will need an isolating diode in series with each switch, otherwise
the closure of three switches can create the effect of a fourth switch
being closed.

To scan 128 switches you will need 24 bits of I/O - probably the easiest
way to achieve this is to use 3 8-bit shift registers - 2 74HC164's for
16 bits of output, driving 16 columns, and one 74HC165 to get 8 bits
of input, reading 8 columns. For the output bits, you can cascade the
two '164s, so you only need two I/O pins (data and clock) to drive
the 16 columns. For the input bits - 8 rows, you will need 3 pins -
shift/load, clock and data. The sequence of events will be:

Initially:
Shift out 16 bits, all high except for the last bit to select column
zero;

Now repeat 16 times:
Set the shift/load input on the '165 to load, hold for a microsecond or
so;
Set the shift/load pin to shift;
Shift in 8 row bits. Examine them to determine which switches on
the selected column are closed.
Keep the data output pin (to the '164) high, strobe the '164 clock
once - this will shift the column select bit to the next column

You will need pull-up resistors on the row inputs to the '165 (or pull-down,
since this is CMOS - suit yourself - you just need to arrange the diode
direction and column drive levels accordingly).

So now you can scan 128 switches with just 5 I/O lines and 3 additional
16 pin ICs. Actually with the same hardware it would be possible to
scan 153 switches using the same number of I/O pins. And it's pretty
fast - you could scan 128 switches in under 200uS using a 10MHz PIC.
Switch debounce time will be far greater than that.


--
Clyde Smith-Stubbs       | HI-TECH Software,       | Voice: +61 7 3300 5011
EraseMEclydespam_OUTspamTakeThisOuThitech.com.au      | P.O. Box 103, Alderley, | Fax:   +61 7 3300 5246
http://www.hitech.com.au | QLD, 4051, AUSTRALIA.   | BBS:   +61 7 3300 5235
----------------------------------------------------------------------------
For info on the World's best C cross compilers for embedded systems, point
your WWW browser at http://www.hitech.com.au, or email infospamspam_OUThitech.com.au

1996\05\06@222004 by John Payson

flavicon
face
> To scan 128 switches you will need 24 bits of I/O - probably the easiest
> way to achieve this is to use 3 8-bit shift registers - 2 74HC164's for
> 16 bits of output, driving 16 columns, and one 74HC165 to get 8 bits
> of input, reading 8 columns. For the output bits, you can cascade the
> two '164s, so you only need two I/O pins (data and clock) to drive
> the 16 columns. For the input bits - 8 rows, you will need 3 pins -
> shift/load, clock and data. The sequence of events will be:

In exchange for some slight loss of versatility (probably not an issue here)
you could probably use three I/O pins: wire the "data" of the 164 to the
"shift/load" of the 165, and wire the two "clock" pins together.  You would
have to time your signals right, but I think this should allow you to do
everything you need in this application.

1996\05\07@010009 by Ben L Wirz

flavicon
face
How about a series of switches wired in parallel.   Each switch would
add a different amount of resistance. Apply +5V to one side and read the
output voltage returned with a A/D convertor.  A clever choice of resistor
values would yield indentifable results even if multiple switches were
pressed.  If higher value resistor were chosen, you could probably ignore
wire resistance also.  This setup also of course has the advantage of a
very low pin count.

           R1       R2      R3
+5V -----/\/\/\----/\/\/\----/\/\/\---........
     |          |         |
   \          \         \
S1  \      S2  \     S3  \
     |          |         |
A/D----------------------------------..........

Ben,

Ben Wirz                Check out My Home Page for Great Deals on Bulk Buy's
                       Nitinol Wire, LMD 18200 H Bridge and 10 Mhz PIC 16C84
@spam@blw2KILLspamspamcec.wustl.edu      http://cec.wustl.edu/~blw2/index.html

1996\05\07@012711 by Todd Peterson

picon face
At 11:59 PM 5/6/96 -0500, you wrote:
>How about a series of switches wired in parallel.   Each switch would
>add a different amount of resistance. Apply +5V to one side and read the
>output voltage returned with a A/D convertor.  A clever choice of resistor
>values would yield indentifable results even if multiple switches were
>pressed.  If higher value resistor were chosen, you could probably ignore
>wire resistance also.  This setup also of course has the advantage of a
>very low pin count.
>
>            R1       R2      R3
>+5V -----/\/\/\----/\/\/\----/\/\/\---........
>      |          |         |
>    \          \         \
> S1  \      S2  \     S3  \
>      |          |         |
>A/D----------------------------------..........
>

clever, but he wanted some 138 switches!  that's a lot of resistors, even in
10-pin SIP packages...
if you DO decide to use this method, instead of using the +5 volt line to
power them,
put about 20 switches per I/O port, and sequentially step through the ports.
this will cut
down on the resistors (several switches share the same resistor) as well as
widen the gap between the voltage drops.

Hopefully you've already implemented some sort of matrix or shift register
scheme.

-Todd Peterson

===========================================================
*** Developers of the PICPlusú Microcontroller Board ***        

Todd Peterson, Computer Engineer   (KILLspamtpetersonKILLspamspamnetins.net)
E-LAB Digital Engineering, Inc.          
                                         
P.O. Box 246                            
Lawton, IA 51030-0246                                      
(712) 944-5344                            
                                         
Visit us at: http://www.netins.net/showcase/elab/          
                                         
E-Mail Now for Your Free PICPlusú Information Packet!
TO: RemoveMEtpetersonTakeThisOuTspamnetins.net   (include POSTAL mailing address)
===========================================================

1996\05\07@013753 by Clyde Smith-Stubbs

flavicon
face
Ben L Wirz <spamBeGoneblw2spamBeGonespamcec.wustl.edu> wrote:

> How about a series of switches wired in parallel.   Each switch would
> add a different amount of resistance. Apply +5V to one side and read the
> output voltage returned with a A/D convertor.  A clever choice of resistor

Yes, but this requires an A/D converter - seems a little like overkill.
Plus, it would be failure prone, since if any resistor changed value
you'd be stuffed.

But then, maybe I'm just taking the suggestion too seriously :-) Where
was your tongue, Ben?

Clyde

--
Clyde Smith-Stubbs       | HI-TECH Software,       | Voice: +61 7 3300 5011
TakeThisOuTclydeEraseMEspamspam_OUThitech.com.au      | P.O. Box 103, Alderley, | Fax:   +61 7 3300 5246
http://www.hitech.com.au | QLD, 4051, AUSTRALIA.   | BBS:   +61 7 3300 5235
----------------------------------------------------------------------------
For info on the World's best C cross compilers for embedded systems, point
your WWW browser at http://www.hitech.com.au, or email RemoveMEinfospamTakeThisOuThitech.com.au

1996\05\07@023509 by Ben L Wirz

flavicon
face
Clyde,

       You are right, just because I said this solution would work
doesn't mean it is the best one.  It's definately a different approach
though.  I like to consider a analog solution every once in a while so
I don't get caught up in the trend to make everything under the sun
digital.  It reminds about an AD I saw in one of those magazines that
sells products that didn't quite make it in the real marketplace.  The AD
was for an Electronic Cat Litter Box.  It boasted that the box was
computer controlled to clean itself 10 minutes after your cat exited.
What A Waste of Processor Power! :)  Price you ask:  $149 US (On Closeout)

       Seriously though, he could use an 8 channel serial A/D
convertor.  (Sorry don't have any part number but I know they exist)  An
8 bit A/D convertor would have no trouble recognizing 20 distinct voltage
levels, yielding a max total of 160 switches.  This would only require
2-3 I/O pins and cost ~$1-3.00.  Also I think it might be possible to use
the same value resistor for all the switches, and so it could just be
built into the switch.  This also has the advantage of using less hookup
wire then a matrix approach, just one set of wires for each of the eight
sections.

Ben,

Ben Wirz                Check out My Home Page for Great Deals on Bulk Buy's
                       Nitinol Wire, LMD 18200 H Bridge and 10 Mhz PIC 16C84
blw2EraseMEspam.....cec.wustl.edu      http://cec.wustl.edu/~blw2/index.html

On Tue, 7 May 1996, Clyde Smith-Stubbs wrote:

{Quote hidden}

1996\05\07@050135 by Keith Dowsett

flavicon
face
> To scan 128 switches you will need 24 bits of I/O - probably the easiest
> way to achieve this is to use 3 8-bit shift registers - 2 74HC164's for
> 16 bits of output, driving 16 columns, and one 74HC165 to get 8 bits
> of input, reading 8 columns. For the output bits, you can cascade the
> two '164s, so you only need two I/O pins (data and clock) to drive
> the 16 columns. For the input bits - 8 rows, you will need 3 pins -
> shift/load, clock and data. The sequence of events will be:
>
I think I would go for an array (with diodes) and use a 4 bit counter and an
LS154 to strobe 16 lines (rows) in sequence. If you can be certain that only
one button will be depressed at a time an LS148 encoder can be tied to the
columns and straight into a three bit port.

A neater solution is to use an eight bit port (or a latch if you want to
share the port) with the top bit as an input, then four bits as column
select and three bits as row select. Use a 154 to strobe the rows as before
and an LS151 to multiplex all eight columns onto an input pin in turn. A
counter then automatically checks each switch in turn and will detect any
combination of keypresses.

The code goes something like this.


       keypressed_flag=false
       Key_counter=0x80
       repeat
          Decrement key_counter
          Move to output (& latch if sharing port)
          If input bit is set then
             If keypressed_flag then
                Illegal entry, more than one key pressed
             else
                key_code=key_counter
                keypressed_flag=true
       until keycounter=0



Just a few early morning musings,

Keith.
==========================================================
Keith Dowsett         "Variables won't; constants aren't."

E-mail:      RemoveMEkdowsettTakeThisOuTspamspamrpms.ac.uk
Phone:       0181-740-3162
Fax:         0181-743-3987

Snail mail:  MRC Clinical Sciences Centre, Cyclotron Unit.
                Hammersmith Hospital. London W12 0NN.

1996\05\08@053711 by Jim Main

flavicon
face
Hi Juan

>On the design of a PIC ( probably 16c65 or 16c74 ) security system,  we need to
> be able to identify one of the following situations;
>
>1> A unique closed switch out of 128 SW's ( normally open contacts)

You could use a couple of keyboard encoder IC's which will make your chip
count and programming overhead very low.

The chip I'm using at the moment in a project is Standard Microsystem's
9600-PRO, which will encode 90 keys, outputing a 7 bit code, along with a
Data Ready strobe pulse.  The chip will debounce your keys (variable delay
via external C) and can do N-key rollover (needs a diode on each switch) or
N-key lockout depending on your requirements.  There's also an
'Any-Key-Down' output which you can use.  It's a 40 pin chip and works by
scanning the keys in a  10 x 9 matrix.

As it's only 90 keys, you'd need a pair of them feeding two ports with
DataReady's and AnyKeyDowns going to a third port - or if you're pushed for
I/O, into the same port via a couple of tri-state octal buffers.  I use PB0
on the 16C74 to interrupt the processor (with DataReady) and grab the data
on PB[6:0]..

Hope this is of help

Jim

1996\05\08@083940 by Don McKenzie

flavicon
face
>On the design of a PIC ( probably 16c65 or 16c74 ) security system,  we need to
> be able to identify one of the following situations;
>1> A unique closed switch out of 128 SW's ( normally open contacts)

I missed the original post of this question so I hope I don't quote it
out of context, but it seems to be gathering that much steam that perhaps
the required answer lies in the fact that it is for a 128 station
security system.                             ^^^^^^^^^^^^^^^^^^^^

If so, it may well be a large office, factory, wharehouse, or Airport
Terminal and will need some long line drivers that will rule out most of
the simple approaches that would be satisfactory for a simple keyboard type
matrix.

Don...

Don McKenzie EraseMEdonmckspamspamspamBeGonelabyrinth.net.au
DonTronics Tullamarine, Australia
http://www.labyrinth.net.au/~donmck

PIC Basic Compiler available now. PIC Programmers starting at $15US
PicoSaurus, the 40 pin ETI PIC Basic with 8K EEPROM Free Windows Dev Sys

1996\05\08@130038 by Paul Haas

flavicon
face
On Wed, 8 May 1996, Don McKenzie wrote:

> >On the design of a PIC ( probably 16c65 or 16c74 ) security system,

> If so, it may well be a large office, factory, wharehouse, or Airport
> Terminal and will need some long line drivers that will rule out most of
> the simple approaches that would be satisfactory for a simple keyboard type
> matrix.

> Don...

We're missing some design details, so we make them up.

If the system is going in a public space, then the biggest cost is in wiring
the switches, since the wires have to be hidden.  In that environment a 2
wire system is probably best.

If the wires are short enough, they can use Dallas Semiconductor serial
number chips.  The chips use a 1 wire plus ground connection and there can be
many of them on a single connection.  Connect the chips to normally closed
switches and have the PIC poll them all and report the chips that don't
answer.

Possible problems:

 1. I think the serial numbers are 48 bits which means a table of 128
    chips would take 768 bytes.  Memory is scarce in PIC's.
 2. There are length restrictions on the wiring, plus limits on total
    number of chips per wire pair.  It might take 4 strands for 128
    chips.
 3. A lightning strike would be bad.

--
Paul Haas RemoveMEpaulhKILLspamspamHamjudo.com

1996\05\08@163827 by Kalle Pihlajasaari

flavicon
face
Hi all,

>
> On Wed, 8 May 1996, Don McKenzie wrote:
>
> > >On the design of a PIC ( probably 16c65 or 16c74 ) security system,
>
> > If so, it may well be a large office, factory, wharehouse, or Airport
> > Terminal and will need some long line drivers that will rule out most of
> > the simple approaches that would be satisfactory for a simple keyboard type
> > matrix.
>
> > Don...
>
> We're missing some design details, so we make them up.

I just love the irreverence of the PICLIST :-)))

> If the system is going in a public space, then the biggest cost is in wiring
> the switches, since the wires have to be hidden.  In that environment a 2
> wire system is probably best.

Quite right, a matrix will not distribute very well.

{Quote hidden}

There are a few other cute Dallas devices, one of them is much like the
silicon serial number but has an input pin that can be polled or can
cause an alarm condition when in a selected state.  Another has 2(1) inputs
and a further EPROM area that can be written with a simplified numbering
scheme for a static installation which would allow for just looking for
the missing or alarming device in a short list.  The write only device
could be used as well and might be the most cost effective in such an
application.  As far as I know all of these devices are in the US$2
to $10 range in small quantities.

The lengths that one can go to (about 300 m and 40 devices on a leg) with
the Dallas stuff is probably better than anything you can do into raw
CMOS inputs without serious reliability concerns (the Dallas stuff has
static protection) you can add avalanch diode (Tranzorb (r)) protection on
the line across all the devices keeping capacitive limits in mind.

Lightning is always BAD, current loops via Opto isolators are about the
most tolerant.

It the 128 devices are local and one gets to select dual contact switches
one could make a (mess or wires) '3D' network with 16 pins, perhaps
a few less still with the mixed I/O matrix configuration described earlier.

There are also dedicated Alarm controller ICs out there (see Maplin catalog
and look hard) that are also line powered and probably more tolerant
to spikes &c.

Cheers
--
Kalle Pihlajasaari     kalleSTOPspamspamspam_OUTdata.co.za
Interface Products     Box 15775, Doornfontein, 2028, South Africa
+27 (11) 402-7750      Fax: +27 (11) 402-7751

1996\05\09@094101 by terogers

flavicon
face
Hey, wait a minute...

Aren't we getting this all backwards? Isn't the point of the PIC series
the price per chip? This whole discussion seems to be losing sight of
the objective, at least in my humble opinion.

Consider: what is the bandwidth needed for the switch scan? If it's for
a security system (detecting doors & windows & such) then the actual
bandwidth necessary is low; low bandwidth translates to long runs of
cheap wiring without special drivers.

Of course, you would need a custom protocol, but this is getting to
exactly what is attractive about the PIC family. Wouldn't this be an
ideal application for a distributed system, with local PIC's handling
short runs to a few switchs (I like the Dallas stuff, myself) and then
communicating the data to a central system? This would cheap up the
whole design, especially if you partitioned on the basis of chip count.
I think I would try to do it without any extra scanning logic, given the
lower limit of the price per chip is set by mechanical rather than
functional considerations. Low end PIC processors are awfully cheap, and
they can be made to consume such small amounts of power & run over such
a wide voltage range that distributed power for the whole system seems
possible.

-- Tom Rogers  VP - R&D  Time Tech, Inc.

More... (looser matching)
- Last day of these posts
- In 1996 , 1997 only
- Today
- New search...