Shop OBEX P1 Docs P2 Docs Learn Events
How can I get more (144) inputs? — Parallax Forums

How can I get more (144) inputs?

PepzPepz Posts: 20
edited 2008-02-03 23:57 in Propeller 1
I need 144 inputs that are controlled from 144 (12 x 12 matrix) touch buttons RC-timed inputs.
(that is: changing the resistance between 2 close sitting metal pins by touching them with your finger)

The "buttons" have to be read in "Real-time" (max 1 ms delay)

I have to be able to read several buttons at the same time (like a finger combination)
so i dont think I can use a scanned grid like a keypad, because different fingers would "short" or interfere
with other scanrows/cols because of the "touch" buttons, or can I?

I know it can be done with 144 transistors or op-amps and some resistors and parallell-to-serial converters to
shift in the bits, but I am thinking of using 5 or 6 propeller chips with RC-timed inputs because it would mean
much less soldering and just a bit more expensive.

I have it running with a 4-input (2-by-2 matrix), but as said, i need more inputs.


Ideas?
«1

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2008-02-01 09:23
    Some questions:
    Are you in absolute control of the layout or the internal routing of all connections?
    When you say you have a 12x12 Matrix I assume you do not mean that, but you mean you will try to (or have to) arrange the buttons in such a way.

    If you have an (electrical) matrix than you have to scan it, there is no other way. When you have 288 ends to connect, then there are many possibilities.

    (2) Moste of those "many possibilities however will require an "additional element" (generally a diode) for each switch, it that o.k.? The most simple arrangement . but also quite complex layout! - is what the Charlieplexing people as Clemens did around Chistmas. Have a look at their works of soldering.

    (3) You will generally chose a combination of (partial) matrix scanning and serialization of transfered data. Very practical for the latter are I2C "port expanders", they come in sizes of 8 or 16 lines. Checking all 144 lines will take 9 of them (around $18). But they will sense digital signals only!

    (4) As I2C polling with SPIN works around 30kHz you will easily get all the matrix data each 10 ms.

    (5) However I am not sure in what way you want to use this RC-business.. Can you explain more or make a timing/signal sketch?
  • PepzPepz Posts: 20
    edited 2008-02-01 11:41
    I do have 288 ends to connect as you said.
    Now I use the parallax example routines in RCtime to detect if an input is somewhat "grounded" to I/O-GND through my finger.
    This gives a shorter discharge time than if my finger is "off" the "switch".

    I try to keep electrical components down to a minimum. If I go the "RC"-way, the inputs just need a resistor an a capacitor each.
    The "matrix" is totally "analog", just bare metal and cables.

    All inputs have to be read in a few ms. (Preferably 1ms = 144000 readings/sec).

    I am in control of the layout since i am building it. The layout is 6-by-24.
    xxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxx


    Sketch: Ignore the dots.. spaces didnt work...

    "Switch"
    ---||
    [noparse][[/noparse]Res]
    Prop Pin X input
    | . . . . . . . . . . . . . . . . . . |
    | . . . . . . . . . . . . . . . . . . |
    | . . . . . . . . . . . . . . . . . . = Cap
    | . . . . . . . . . . . . . . . . . . |
    |
    | Prop GND
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-01 13:34
    Can you give some typical R-values for the switch? Untouched, lightly touched, firmly pressed? Do you need to differ between those touches (when it shall become a musical instrument e.g.)
  • PepzPepz Posts: 20
    edited 2008-02-01 14:03
    You got it! wink.gif *Impressed*
    Yeah, it's a fretboard, as you might have figured out. (6 "strings" x 24 "frets")
    The "switches" do NOT need to be velocity sensitive (lightly or firmly), I was planning on having another device to control the velocity parameter, just digital on/off to see wich notes I am going to send to a midi device.
    So, R and C values are: best match to "as fast as possible detect a touch or no touch", if you see what I mean?

    My problem is just "Simplest and cheapest way to read too many inputs for one (or more) propellers".
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-01 14:21
    (1) It will be important to know that you need one signal per string only, i.e. when more that one of the keys from one string is pressed, the data can be "highest","lowest", or even undefined? In that case you can use "encoder" chips...

    (2) Can you please give some R-values you have measured? The methode you are now using is not optimal when you just want to know whether touched or non-touched

    (3) What is your idea of the "chip count"? 3 to 4 additional chips? I am personally a fan of using a Propeller even for simple decoding, as it has these nice 32 general purpose pins. But it will cost much more that 3 MSI chips
  • PepzPepz Posts: 20
    edited 2008-02-01 14:57
    I do not measure R values.
    I count "#Number of 1:s" and "#Number of 0:s" in a given time period (during discharge).
    If #Hi >1, the "switch" is "ON".
    if #Lo >X (about 200_000), the "switch" is "OFF".

    I believe that I want to read ALL keys, and then (via another switch) determine if i want to play all notes or just the "highest" on one "string".

    So, it is important that the discharge time is fast.

    My guess is that if I use "encoder cirquits", I will need to add some amplifying cirquits before the "encoder".
    Am I right? If so, the cost will rise with 144 * (Preamp cirquits). Plus a LOT of soldering.
    With extra propellers the price will be 5 * $11.

    I don't know anymore... tell me what I want? turn.gif
  • PepzPepz Posts: 20
    edited 2008-02-01 15:27
    Is it possible to use a multiplexer to charge a bunch of capacitors, and then another MUX to sweep them fast to see if they have "gone LO yet"?
    Any suggestions for such chips?
  • DroneDrone Posts: 433
    edited 2008-02-01 15:49
    Isn't this just a 6X24 cross-point switch keypad matrix-like application? If so, just 6+24=30 scan I/O pins required; maybe I'm missing something. Anyway - here's a link to a cool digital guitar project:

    http://innovexpo.itee.uq.edu.au/2003/projects/s354320/thesis.pdf

    David
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-01 16:13
    David, the difference is we are not having "switches" here but some very delicate "things" which Pepz now reads in a very complicated (and expensive) way, and I am not yet sure whether this is really called for, or how to substitute it.... Thus my questioning for R-values..

    @Pepz: I hev to know the capacitance to compute the resistance with your time values...
  • DroneDrone Posts: 433
    edited 2008-02-01 16:47
    Hi deSilva,

    Ya - I agree with you, we need more info on Pepz's physical layer. I suspect something more complex than a simple matrix -hence the prior link to the Guitar Thesis .pdf in this thread; nicely done with capacitive sensors etc. The ball is in Pepz's court IMO.

    Hope you are well deSilva....

    Rgds, David
  • PepzPepz Posts: 20
    edited 2008-02-01 18:09
    @Dave:
    Dave, I looked at the PDF, nice work.
    But I have it running already.
    All I really want is to read the discharge time for a bunch of caps.
    And that is what i am doing now with 4 inputs using 4 caps and 4 resistors and some wire.

    Now i just need 140 more of them... 4-note music tends to be a bit annoying... wink.gif


    @deSilva:
    My values are: R=220 ohm C=1nF My finger=MegaOhms
    I may have to use a lower C if I want to increase discharge speed / (decrease discharge time).
  • WurlitzerWurlitzer Posts: 237
    edited 2008-02-01 18:26
    I have been doing this for a few years on my pipe organ·using a BasicX-24 and now working on a Prop solution.
    I am scanning 4 keyboards of 61 notes each and a pedal board of 32 notes with 2nd touch so that is 64 notes. At the same time I am scanning all the stops and combination action push buttons, swell pedal, toe pistons.... with a total of over 400 inputs.

    I send a single high into the shift register and then clock it with each output connected to a group of keys. For example @ count # 1 every low "C" key is pulled low by the output of the shift register's Output #1 pin. If any of those low "C" notes are pressed, the corresponding common line will be pulled low. In this manner I scan 8 switches with every count.

    I use a pair of 6832 32 bit shift registers (Allegro) to scan the keys or switches and have 8 commons (left over from the BasicX-24 design). As the switches are scanned, I look at an 8 bit word generated by the 8 commons and can determine which key/switch has been pressed. Obviously multiple key/switch presses are not problem or the system would never work.

    Based on the switch pressed, I generate a MIDI message. My current problem, on another thread, is reading the MIDI message but that has to be something I am doing wrong. It should be straight·forward serial communication but.....

    ·I have one Prop scanning and generating all MIDI messages for the console and a 2nd Prop for driving all the pipes and percussion in the pipe chamber using the same 32 bits shift register chips from Alegro. Currently the Pipe driver Prop circuit is designed to output into 16 groups of 3-32 bit shift registers in series (96/group)·or 1536 outputs. Not bad for a little Prop!
  • VIRANDVIRAND Posts: 656
    edited 2008-02-01 19:19
    The use of a few 4051 multiplexer chips and a 4040 binary counter and perhaps a diode for each row can be used to
    interface the Propeller to the analog inputs very cheaply while using very few pins. All the possible connections can be
    quickly scanned and if there are any connections then they can be individually measured as if they were only one.
    The pins would be used for:
    -Reset the 4040 counter (so the Propeller knows it's at zero)
    -Clock the 4040 counter
    -Analog connection to a row at a time thru the multiplexers
    -Analog connection to a column at a time to the multiplexers

    Since you have more than 8 frets you will need an extra multiplexer for the fret multiplexers.
    You can then have 64 frets and 8 strings. Each multiplexer can connect to 8 contacts, and
    the binary counter will count through all the connections in order as you output 010 on the clock line...
    Fret0:String 01234567
    Fret1:String 01234567
    ...to...
    Fret 63:String 01234567 (This is way beyond your needs)
    Fret 0:String 01234567 (it would roll over and repeat)

    The 4051 and 4040 chips work at 3 volts, and again the 4051 can switch analog signals.
    Again, this tests each connection one at a time according to the counter:

    Binary counter bits represent:
    XX XX XX M2 M1 M0 F2 F1 F0 S2 S1 S0
    or
    XX XX XX F5 F4 F3 F2 F1 F0 S2 S1 S0
    M-multiplexer for fret multiplexers (0-7) , is the same exact thing as part of the fret number.
    F-fret number (0-7 or 0-63)
    S-string number(0-7)

    You should leave out the 4051's that don't connect to frets. I think you need 5 of them instead of 10 for the 144 notes.
  • PepzPepz Posts: 20
    edited 2008-02-01 20:03

    @Wurlitzer:

    Just to make sure... are you checking for this?:

    "Midi devices can use a technique called running status to make data transmission faster.
    Running status allows a device to send a stream of messages of the same kind
    without repeating the status byte for each message."

    The shift registers: I am not sure that they will work with my "touch" switches without additional hardware since they are using 2-way communication to Charge/Discharge the caps. With real "On/off"-switches they will work ok though.

    @Virand and @everyone:

    I think that analog output DE-Multiplexers may work to charge them caps.
    And then use analog input Multiplexers to "read" the caps to see if they are "Still HI or LO"

    Like the attached gif animation but connected the other way around, instead of "MANY-to-ONE-to-MANY" i connect them as "ONE-to-MANY-to-ONE". Then ONE or TWO I/O could be used for 8 "touch-switches". Interesting!

    Can this be done, Electronics Experts out there?

    300 x 90 - 22K
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-01 20:57
    All principles and detailed solutions discussed here are fine and well known and come to mind immediately.

    However when using a MATRIX the decoupling of the single elements is the main issue. It is absolutely fine when you have LEDs to light - it is just the dual view, no real difference. It becomes more tricky when you have bi-directional switches, you need A LOT of diodes when multiple key presses have to be detected.

    It needs many parts when you transfer those ideas to analogue matrix elements: You will need not only a cap but an opamp, a CMOS gate, or at least an FET to decouple them. Charging the caps is not such a problem, as you can do it each - say - 10 ms globally and then scan during the next 10 ms through all values. Using an (no: 144!) opamps has the advantage to have a handy comparator, so there are true digital outputs for the matrix scan.

    But I think this is not only too complex, but too expensive as well...
    It is technically possible to use 1 nF and 74HC1G ... SMDs (144 x 10 cents = $14)

    Pepz said he counts to 200_000 until a typical discharge is noticed @ 1nF. I asume a count each 12.6 ns = 2.5 ms, which is an R of 2.2m/1n = 2.2 MOhm which is much.. Wet fingers generally have less ...

    But this is not a value to handle digitally. In fact this is also not a value the correcponding current of which to be lead through analogue multiplexers smile.gif

    BTW: To check just organisational aspects, I should suggest to dis-assemble a cheap P/C keyboard... I did it the other day and the flexible matrix inside is quite instructive...

    Post Edited (deSilva) : 2/1/2008 9:06:29 PM GMT
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-02-01 21:19
    Here are a couple links that might provide inspiration in a slightly different direction:

    ····Linear Position Touch Sensors
    ····A Guitar-inspired Touch Pad Controller

    -Phil
  • WurlitzerWurlitzer Posts: 237
    edited 2008-02-01 21:24
    @Pepz/deSilva
    Yes my system handles running status and everything works fine once the MIDI bytes are properly received. The problem was I had copied a bad line of code for the waitpne opcode (deSilva thought that might be the cause and it was. Thanks deSilva) and it did strange things. It works perfect now. The rest is straight forward scan->process MIDI->Ouptut MIDI for the console.
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-01 21:44
    @Phil: Those were the ideas I waited for: Not a Zither - a Violin! Alas also not inexpensive... so typical for violins as it were smile.gif
  • VIRANDVIRAND Posts: 656
    edited 2008-02-02 08:27
    Regarding the animation I'm not sure if it's exactly relevant to the fret/string matrix,
    but be assured that the 4051 chips are Bidirectional analog multiplexers (and Demultiplexers)
    and the lines that connect through them to each "fret" and "string" contact point should be suitable for
    measuring each connection with any ADC method I'm aware of, such as for timing and charging a capacitor.
    (They can work like the switches in the animation.)
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-02 10:04
    @VIRAND: The datasheet says the input current as well as the OFF-leakage current is sub nA which will do for this application, discharging the caps by around 1 µA. Even the stated worst case (but when?) of 200 nA wouldn't influence that too much.

    However I do not understand how you want to accomplish the decoupling of the matrix elements... I have to re-read your former posting....
    ----
    Edit:
    A 74HC4051 is less expensive than I thought (just 20 Eurocents...), so adding 20+ of them would be just a matter of a few $$

    Post Edited (deSilva) : 2/2/2008 11:15:22 AM GMT
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-02 11:11
    @VIRAND
    So it is a tree you are proposing
    331 x 316 - 12K
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-02 11:35
    This is an optimized proposal.. As the propeller would need 2 digital lines to address one of the second tiere multiplexers (plus 1 analogue connection) this can be simplified to 3 analogue connections with less parts. The additional benefit is a faster access, as three switches are addressed simultaniously.

    The 6 adress bits can easily be generated by a 8 bit port expander - say a I2C PCF8574

    This looks like a $5 for parts solution - plus $5 for the caps smile.gif

    Post Edited (deSilva) : 2/2/2008 11:40:51 AM GMT
    423 x 316 - 14K
  • PepzPepz Posts: 20
    edited 2008-02-02 14:31
    @deSilva: Bingo!
    That was exactly what I had in mind. Thanks to you and to VIRAND for the 4051 tip.

    I'm dropping an 4051 order at my local dealer. 25 pcs for 11 bucks.

    The decoupling detection is just a homebrew "has the cap been discharged in this amount of time,
    then the "switch" is ON"

    1. Set DATApin to "OUT" and HI

    2. "Mux" DATApin to "I/O 1"

    3. Wait x time (just enough to charge cap1 to "HI" without "finger-on").
    If finger is present on the "touch-switch", current would leak so that the cap wouldnt reach "HI" voltage.
    (lower than without finger, anyway)

    4. Repeat step 2 for next cap. During all steps, current leaks through my finger to ground,
    discharging "fingered" caps even more.

    5. Set DATApin to "IN".

    6. "Mux" DATApin to "I/O 1"

    7. Check if DATApin is "LO", then a finger must have been present on the "touch-switch", SWITCH[noparse][[/noparse]X]:=1
    If still "HI", no or very little leaking has occurred. No finger has been on that line. SWITCH[noparse][[/noparse]X]:=0

    (8. A "Reset-all-caps-to-zero-sweep" to start at the same voltage (0) every loop?)

    Loop to step 1.

    Does this make sense?? Remember, I am just an amateur with stupid ideas...
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-02 17:06
    Things to consider:
    (a) geometry: The points of contact should be close to the chips. There is an option to use 24 chips at the lowest tier, connected only 6 of the 8 lines, then you will have one chip for each semi-tone. This needs 6 chips more, though

    (b) You need no shunt for the Propeller I/O, as the 4051 have internal resistance of some 100 ohms when the signal runs through two or three of them. That means charging one nF cap will take 1µs

    (c) Using three analogue lines at a time makes the program a little bit more complex, but more reactive.
    You have now to switch through 48 address patterns only, which gives you nearly 1 ms per triple (Note that most of the time most of the switches will NOT be pressed!)

    (d) You should check how to use the "inhibit line", if ever

    (e) When you have enough Propeller lines you can connect the 6 address lines directly... Ading a 47595 PISO or a I2C port expander can be accomplished later.
  • PepzPepz Posts: 20
    edited 2008-02-02 20:10
    Thank you all!
    You can expect some results during the next week.
  • VIRANDVIRAND Posts: 656
    edited 2008-02-02 23:05
    This is my idea of how to use the 4051's.
    What I left out is the ADC or capacitor charging part, which is needed since the Propeller doesn't have analog inputs.
    I imagine the possibility of either using real frets and strings,
    or carbon rubber buttons that are sensitive to variable pressure,
    or maybe even touch contact points.
    It wasn't clear to me what kind of physical interface you are using on the guitar (or the "matrix").
    424 x 568 - 51K
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-02 23:31
    Nice sketch! I like them more than these semi-professional Eagle diagrams smile.gif

    Using a 4040, stepwise controlled by the Propeller is the third possibility besides an I2C port expander and a SIPO shift register as a '595. It has the simplest programming interface of the three I think.

    Still it is not clear to me how you want to decouple multiple keys... That is why I choose a full tree, needing considerably more parts than a matrix...

    It is arguable whether a cap per key is necessary.. However it will allow a very stable and robust interface. The cap-less alternative - sensing a sub-µA current through the 2 MOhms touch - will most likely work, only needing one FET-opamp for the sensing Propeller input pin.
  • VIRANDVIRAND Posts: 656
    edited 2008-02-03 06:05
    I think I've seen this method used in such a way that a keyboard test could display individual keys even if
    many of them were pressed, for example on a QWERTY keyboard, with all ten fingers, ten keys would register
    as the counter does 'address' each contact point. Diodes may or may not be necessary, I'm not sure.

    I'm aware of the ambiguous situation in most methods of reading a matrix where if you press a certain 3 keys,
    a phantom 4th key might register. I THINK this method is not susceptible to it, but I'm not certain.
    If not, maybe chords could be recognized and phantom keys rejected.
    Phantoms tend to be 4th corners of rectangles when rows and columns are shared by 3 keys.
    Whether or not more software is a cheaper solution than more hardware depends on the skill of the engineer I guess.
    I also guess that phantom 4th keys might have higher resistance in this case if they happen at all since this
    method focuses on each possible fret-string contact and phantoms would have to go through 3 other contacts to register.

    If there were 144 diodes, I don't think phantom keys are possible.
    But I hope that much less diodes (on each fret and/or string line only), or no diodes are necessary.
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2008-02-03 08:36
    Another way to get 144 'inputs': use·three 48-channel versions·of these·interesting chips. http://www.qprox.com/products/Page-16051/qt60168.html

    Saelig has the 32 ch chips for about $8 each. They don't seem to carry the 48 ch ones (yet. The links are there but no enabled).
    http://www.saelig.com/miva/merchant.mvc?Screen=PROD&Product_Code=IC3018&Category_Code=IC3

    Digikey has the 48-ch for 9.86 each. http://www.digikey.com/scripts/us/dksus.dll?Detail?name=427-1110-ND



    Post Edited (Fred Hawkins) : 2/3/2008 8:44:15 AM GMT
  • OzStampOzStamp Posts: 377
    edited 2008-02-03 09:16
    Hi

    Another spanner in the works ..
    What about the PCF8575 I2C interface 16 inputs per unit ( 8 can be chained a0-a1-a2 giving 128 inputs)
    connect these to pins 28 and 29 and 1 more on a separate I2C bus.
    Scan the INT signals from the PCF8575 units so you know if a button has been pressed...

    cheers ron mel oz
Sign In or Register to comment.