Shop OBEX P1 Docs P2 Docs Learn Events
Human input device - reducing pin count — Parallax Forums

Human input device - reducing pin count

JBWolfJBWolf Posts: 405
edited 2014-04-03 16:31 in General Discussion
Hello,
I have a prop running as the controller on my latest project which is very tight for space (12mm diameter casing).
Had to design and CNC my own boards using the QFP chip to just barely squeeze in there, but it works great!
It's been just a standalone system that has to be taken out and re-programmed for any kind of software changes.

What I would like to do is add a port for connecting the prop (without removing from the case) a control pad so I could interface with the controller when changes are needed
I wish I had the room to use a keypad system such as the one offered in the parallax store... but I just dont have the room for that many pins on the PCB.
I have managed to get 3 output pins available on the prop for external use... but I could really use more than just 3 buttons for input.
Is there a device or method that I can use with 3-pins or less to get say 6+ buttons?
Ideally I would like to enter a code that will correspond to preset functions I have pre-programmed into the controller software.
for example if the buttons were labeled 1 through 6.... I could use button 6 for entering/exiting 'user input mode' and then proceed to enter a numerical value such as 2534253.
There are thousands of possible configuration permutations, which is why I could use more than 5 buttons.
The key is that the input device can only use 3 prop pins. Since it would be connecting externally, only the connector need be small (which I have plenty of tiny 3 and 4 pin connectors).
Any ideas?

Heres a pic of the controller... as you can see, the width of the board is exactly the width of the QFP chip pins. A delicate soldering task indeed!
The crystal and eeprom are on the other side of the board (through hole)... everything else is right here including resistors, caps & 3.3v regulator.
I already have started on a new revision that uses SMC eeprom and crystal to get all components on one side.
IMG_3526.jpg
1024 x 1392 - 125K

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-03-17 12:48
    Cool, gutsy board!

    I think this will do what you want:

    attachment.php?attachmentid=107644&d=1395085672

    Each group of two switches is connected to a different pair of pins. By raising one pin high and reading the other, you can tell if the switch is closed.

    -Phil
    280 x 354 - 3K
  • kwinnkwinn Posts: 8,697
    edited 2014-03-17 12:48
    A '165 shift register can be used to provide as many as 8 switches/push buttons, or you could use a prop and serial data to use as many buttons as you want.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-03-17 13:05
    I haven't tried it myself, but I've been told there's an object to read a 4x4 keypad with a single I/O pin in the OBEX.

    I'm pretty sure I heard about it in this thread though I didn't see the reference from a quick glance through the posts.
  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2014-03-17 13:13
    You could always use different value resistors and utilize RCDecay methods. That should get you to a single pin.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-03-17 13:26
    One potential gotcha with RC timing methods is that the result depends not only upon which button is pressed, but when the switch contact is first made (or released) relative to the sample interval.

    -Phil
  • JBWolfJBWolf Posts: 405
    edited 2014-03-17 14:17
    Ah that is an interesting idea Phil... that schematic would give 8 independent conditions by my count:
    HHH
    HHL
    HLH
    HLL
    LLL
    LLH
    LHL
    LHH

    given that LLL (all low) would be a base condition and HHH could be the 'user input mode' activator... thats 6 independent buttons
  • JBWolfJBWolf Posts: 405
    edited 2014-03-17 14:24
    actually, looking again... it looks to me like there is a short condition on each pin directly to ground... wouldnt it take the path of least resistance and completely bypass the diodes?
  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2014-03-17 14:52
    One potential gotcha with RC timing methods is that the result depends not only upon which button is pressed, but when the switch contact is first made (or released) relative to the sample interval.

    -Phil

    Good point. That makes perfect logical sense. A few years ago I did an 5 button RCDecay setup but never had mis-reads. I can't find my project code, but I think I may have experienced this so my project was set up so that a "valid button press" required two consecutive readings in the same value bracket. I guess my version of RCDecay Debouncing? :lol: My Cap/Resistor values were such that an RCDecay cycle was very quick, so a button press didn't take an unnatural amount of time and worked very well. I think it's somewhere in my garage still.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-03-17 17:35
    I would just use a PCF8574 I2C port expander or something similar to have 8 I/O (maybe 6 buttons and couple of LEDs) and still have the 3 I/O available as you would just use the I2C lines from the EEPROM.

    Now there has been some mention of RC inputs and this is a technique I used to couple switches on vending machines back in the 90's as it simplified the harness having only to run two wires around the door and back. This method works well enough assuming you do multiple reads until you have a stable reading and it also helps if the end of the line has a reference resistor so the system can calibrate and check itself.

    BTW, I also used RC technique for sensing cards being dispensed from machines as I would have a 1"sq copper that the cards would pass underneath between that and the chassis and I could tell how far the card was under as well, it was that sensitive.
  • TCTC Posts: 1,019
    edited 2014-03-18 03:19
    First off, very nice board. I bet it sucked soldering it. Second, Have you looked into a GPIO expander? Just looking around I found Maxim's MAX7370 GPIO expander. The chip offers up to a 8x8 key matrix, or configurable GPIO with constant current driver for LED's. For example: Using parallax's key pad, you could use the key pad and have up to 4 LED's, or 4 GPIO for other things. While only using 3 pins on the propeller.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-03-18 04:51
    TC wrote: »
    First off, very nice board. I bet it sucked soldering it. Second, Have you looked into a GPIO expander? Just looking around I found Maxim's MAX7370 GPIO expander. The chip offers up to a 8x8 key matrix, or configurable GPIO with constant current driver for LED's. For example: Using parallax's key pad, you could use the key pad and have up to 4 LED's, or 4 GPIO for other things. While only using 3 pins on the propeller.

    Hey, nice find, and they are only around $1 a piece 100off, sweet.

    BTW, the INT pin is optional as it's easy enough to poll whenever so effectively zero I/O as it would be dumb to use other I/O as I2C is a bus so it would just share P28 & P29.
  • JBWolfJBWolf Posts: 405
    edited 2014-03-18 05:01
    Peter: that would work great as I could extend the 4-pins used for programming with the prop clip instead.
    do you have any more info on using one of those? I am new to that
  • TCTC Posts: 1,019
    edited 2014-03-18 05:05
    Hey, nice find, and they are only around $1 a piece 100off, sweet.

    BTW, the INT pin is optional as it's easy enough to poll whenever so effectively zero I/O as it would be dumb to use other I/O as I2C is a bus so it would just share P28 & P29.

    Thank You.

    I agree with you there.

    @JBWolf, So that would offer a GPIO, and still have your 3 pins from the Prop.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-03-18 05:59
    JBWolf wrote: »
    Peter: that would work great as I could extend the 4-pins used for programming with the prop clip instead.
    do you have any more info on using one of those? I am new to that

    I only knew about as much as you do, but Google is a great equalizer.

    Even though these things have quite a number of registers it is straightforward enough. You can have an 8x4 keymatrix and 4 PWM LED lines with this chip and of course you can just connect a 4x4. The sweet thing about this chip as opposed to a dumb I2C GPIO is that it scans and buffers the keys for you so whenever you are ready you just poll the chip for another key. Once you have written your configuration into the chip you only need to read register 0 in the device by the look of it, pretty simple.

    Personally I would just do a very small pcb and mount it to the keypad so that you only need a 4-pin connector to mate up to your controller (I2C+PWR).

    EDIT: The other way I might do it is to program a small PIC chip and just run two wires in 1-wire bus fashion.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-03-18 06:18
    Duane Degn wrote: »
    I haven't tried it myself, but I've been told there's an object to read a 4x4 keypad with a single I/O pin in the OBEX.

    I'm pretty sure I heard about it in this thread though I didn't see the reference from a quick glance through the posts.

    Requires resistors and capacitor

    http://obex.parallax.com/object/715
  • JBWolfJBWolf Posts: 405
    edited 2014-03-18 15:58
    oh wow that is a very nice obex find... 1 pin and rc decay is brilliant.
    Being able to use the 4x4 keypad available in the store on one prop pin by making a small adapter to include the resistors and cap is very very nice!
    Thanks Duane and Ron!
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-03-18 16:44
    JBWolf wrote: »
    oh wow that is a very nice obex find... 1 pin and rc decay is brilliant.
    Being able to use the 4x4 keypad available in the store on one prop pin by making a small adapter to include the resistors and cap is very very nice!
    Thanks Duane and Ron!

    A keypad that needs to be calibrated? Spend a buck and save yourself all that trouble unless this is a one-off.
  • WBA ConsultingWBA Consulting Posts: 2,934
    edited 2014-03-18 16:48
    Requires resistors and capacitor

    http://obex.parallax.com/object/715

    That is a really slick object for the 4x4 keypad!
  • JBWolfJBWolf Posts: 405
    edited 2014-03-18 17:19
    Peter: I really like your idea. I already have the 4-pin port available for programming the prop, so making a small pcb to attach to the 4x4 keypad would be perfect.
    Which way were you referring to achieve this? using the PCF8574 I2C port expander?

    edit: ah my bad, you mean the MAX7370 correct? sorry im a bit tired at the moment.
    I will have time to look at the datasheet and get into more detail tomorrow.
    One question about using the max370...
    I plan to write PC software (either just a basic display with the PST, or maybe VB when i get more time to create a nice graphic display) to allow the controller to interface through the prop clip to a PC for more complex manipulations prior to use in the field.... for example creating multiple 'profiles' that contain very large groups of configurations. I will be using the keypad (while in the field where a pc/laptop is not available) to quickly make basic manipulations and also choosing from the many custom profiles.
    would using the MAX370 interfere with PST communication?

    edit again: oh duh... no it wouldnt because it would be on the keypad.
    ok im goin to take a nap lol
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2014-03-18 18:32
    JBWolf wrote: »
    Peter: I really like your idea. I already have the 4-pin port available for programming the prop, so making a small pcb to attach to the 4x4 keypad would be perfect.
    Which way were you referring to achieve this? using the PCF8574 I2C port expander?

    edit: ah my bad, you mean the MAX7370 correct? sorry im a bit tired at the moment.
    I will have time to look at the datasheet and get into more detail tomorrow.
    One question about using the max370...
    I plan to write PC software (either just a basic display with the PST, or maybe VB when i get more time to create a nice graphic display) to allow the controller to interface through the prop clip to a PC for more complex manipulations prior to use in the field.... for example creating multiple 'profiles' that contain very large groups of configurations. I will be using the keypad (while in the field where a pc/laptop is not available) to quickly make basic manipulations and also choosing from the many custom profiles.
    would using the MAX370 interfere with PST communication?

    edit again: oh duh... no it wouldnt because it would be on the keypad.
    ok im goin to take a nap lol

    ... and then again this is still not the way I would do it either. It's easier for me to hang one of my Bluetooth serial modules off the coms port and just use Blueterm on my smartphone to talk to the system. Since I use Forth then that means I have complete access and I can even change the software.

    But If I did use a keypad then the MAX7370 would be a good choice, but then with a keypad you really need a display etc.
  • JBWolfJBWolf Posts: 405
    edited 2014-03-21 13:11
    Alright I ordered parts from digikey to test both the MAX3730 chip and the single pin resistor array.
    Letcha know how these turn out



    5
    1
    27899_tmb.jpg
    27899PAR-ND
    4X4 MATRIX MEMBRANE KEYPAD


    1
    Immediate
    0

    6.99000
    $6.99


    6
    1
    24-QFN%20Exposed%20Pad_tmb.jpg
    MAX7370ETG+-ND
    IC CTRLR KEY-SW I2C 24TQFN


    1
    Immediate
    0

    2.16000
    $2.16


    7
    10
    MFG_RMC%20SERIES_tmb.jpg
    RMCF1206FT200RCT-ND
    RES 200 OHM 1/4W 1% 1206


    10
    Immediate
    0

    0.04400
    $0.44


    8
    10
    MFG_RMC%20SERIES_tmb.jpg
    RMCF1206FT300RCT-ND
    RES 300 OHM 1/4W 1% 1206


    10
    Immediate
    0

    0.04400
    $0.44


    9
    10
    MFG_RMC%20SERIES_tmb.jpg
    RMCF1206FT390RCT-ND
    RES 390 OHM 1/4W 1% 1206


    10
    Immediate
    0

    0.04400
    $0.44


    10
    10
    RNCP1206FTD2K80_tmb.jpg
    RNCP1206FTD604RCT-ND
    RES 604 OHM 1/2W 1% 1206


    10
    Immediate
    0

    0.06500
    $0.65


    11
    25
    CRSM%20PT1206_tmb.jpg
    311-100FRCT-ND
    RES 100 OHM 1/4W 1% 1206 SMD


    25
    Immediate
    0

    0.02280
    $0.57


    12
    10
    ERJ-1206%20Pkg_tmb.jpg
    P1.10KFCT-ND
    RES 1.1K OHM 1/4W 1% 1206 SMD


    10
    Immediate
    0

    0.10000
    $1.00


    13
    10
    CRSM%20PT1206_tmb.jpg
    311-1.60KFRCT-ND
    RES 1.60K OHM 1/4W 1% 1206 SMD


    10
    Immediate
    0

    0.03000
    $0.30


    14
    10
    CL%20Series%201206%283216%20Metric%29%2018_tmb.jpg
    1276-3085-1-ND
    CAP CER 1UF 25V 5% X7R 1206


    10
    Immediate
    0

    0.14000
    $1.40

  • JBWolfJBWolf Posts: 405
    edited 2014-03-21 13:24
    Just noticed that the description for object 715 calls for a 600 ohm resistor (which dont exist, so I ordered a 604ohm).... but in the actual spin file it says a 620 ohm resistor instead.
    I'm sure both resistors will work fine with calibration... but I went ahead and added 620ohm resistors to my order.
    Digikey pn: RMCF1206FT620RCT-ND
  • jmgjmg Posts: 15,173
    edited 2014-03-21 19:01
    JBWolf wrote: »
    The key is that the input device can only use 3 prop pins. Since it would be connecting externally, only the connector need be small (which I have plenty of tiny 3 and 4 pin connectors).

    You have somewhat skipped over the issue of Power and Ground ?
    If you are limited to 4 pins on a connector, that's only 2 IO lines, unless you use signal-line powering.

    The PCF8574 mentioned is usable, but they always seem expensive for what they are.
    A modern small 8 bit Micro in SO16, can cost about the same.

    The simplest expander device, is the HEF4014,
    http://www.nxp.com/documents/data_sheet/HEF4014B.pdf
    which can connect CLK, PE, and join DS.Q7 to a Bidirectional Prop pin, for a 3 IO wire reader, that can read up to 32 buttons.

    In use, you shift in to define Q5,Q6.Q7 output pins, and then PE and CLK to load the IPx pattern, and repeat that for new Q5..7 values, until you have scanned all needed buttons. At 3V the 4000 series CMOS has very light drive, so a Prop Pin can over-rule Q7 in IP mode, Tristate the Prop pin to read.
  • JBWolfJBWolf Posts: 405
    edited 2014-04-01 13:03
    Alright I went with the resistor array method first just to see how well it works (object 715)....
    After calibrating the ranges, I am getting a >95% answer rate, the only misses I am getting are occasionally on the '0' and '#' buttons.... but I believe I can refine their range values a bit more and i think it will be 100%... might change some of the resistors to create a larger difference.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-04-02 15:33
    JBWolf wrote:
    can someone tell me what the easier methods of making a nice gui in place of the PST.
    I would like to be able to add graphics and click-able buttons to send data responses to the prop.
    Is it easier with VB? or some other language? maybe someone knows of a basic tutorial?

    JB has asked that same question in another thread. Please answer it there.

    -Phil
  • JBWolfJBWolf Posts: 405
    edited 2014-04-03 16:31
    sorry, I deleted that last post... figured it was too off topic so i started a new thread
Sign In or Register to comment.