Shop OBEX P1 Docs P2 Docs Learn Events
Button Simulation with a PC. — Parallax Forums

Button Simulation with a PC.

rwgast_logicdesignrwgast_logicdesign Posts: 1,464
edited 2012-06-13 06:13 in General Discussion
Ok so lets say your building a product that has a keypad with alot of buttons. In my case its a calculator for programmeres and hardware engineers. I want to put alot of functionality into it, It should be programmable have bluetooth have an expansion port and also usable as a basic test tool which can intergrate test reading into equations or graphs.

So they keypad is going to be hard to design from this point. I have an idea of what id like the buttons to do and how they should work but im not sure exactly nor am I sure how many buttons it acually needs!! So I had an idea to maybe write some software real quick in vb 6 to let me create a button layout as I go. Im trying to imagine the best way to interface those soft buttons to the hardware... I could need up to like 40 that have multiple functions. Maybe writing a protocal over a spi interface, but later how does that translate to hardware buttons. I really need a way to connect tons of buttons on very few pins that can somehow be emulated via a pc serial cable or something. Id like to just be able to plug the keypad in when its done and not have to change anything..

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-06-12 13:06
    I don't really have a good answer for you, but I do have a few thoughts.

    I've used these 16 button keypads. They take eight Prop pins to control but I'm pretty sure there are ways of reducing the number of pins required by using some additional chips.

    One really nice way to create buttons is with a thouchscreen. I've used Rayman's 3.5" and 4.3" touchscreens in several projects. It's really nice to be able to change the number and size of buttons based on what input is expected.

    I generally use a second Prop with touchscreen projects since the touchscreen uses so many pins and memory of the Propeller.

    I use a serial connection between the two Props so the graphics Prop knows what buttons to display where. The graphics Prop sends the touch coordinates back to the first Prop and the first Prop makes the decision based on the coordinates received.

    The touchscreen could be simulated on a PC and a serial keypad could also be simulated on a PC but many of the other keypad options would be more difficult to simulate.

    I don't know of a way to directly simulate an SPI interface with a PC. If I were trying to make an SPI simulated keypad, I'd probably use a second Prop between the PC and first Prop.

    I can see an advantage of having a virtual keypad being read by the Prop in the same fashion as the real keypad, but it might be easier just send the virtual keypad over a serial link and then modify the code to use the hardware keypad when it's time to add one.

    One of the questions that I had to deal with when using a 16-button keypad is that of button press buffering. If the user presses a second button before the program is ready for the new input, will the press be lost or will you have some sort of buffer to keep keypresses in memory for the program to use when ready.

    If you do have a buffer, how long to you keep the information in the buffer?

    I decided to limit the amount of time keypress data would be stored. This was my attempt at I writing a buffered 4x4 keypad object. I haven't looked at it lately so I'm not sure if it's buggy or not. I think it was the first time I had used a circular buffer.

    Edit: I have one project where I used both a touchscreen and keypad. Using both shouldn't be neccessary, but I liked the results.
  • stamptrolstamptrol Posts: 1,731
    edited 2012-06-12 16:16
    Heres a possible solution a possibly a higher cost.

    Its a controller with an integrated touchscreen function. You can draw wahatever keypad or other control buttons you need.

    http://www.youtube.com/watch?v=0nV_h5yeobQ&list=UUoxpQdBX6BlisKUM3i3Ea_A&index=1&feature=plcp

    The version of Basic used is similar to PBasic.

    Cheers,
  • kwinnkwinn Posts: 8,697
    edited 2012-06-12 20:25
    Output the key codes from your VB6 software to a Prop and have the Prop output whatever format you want.
  • rwgast_logicdesignrwgast_logicdesign Posts: 1,464
    edited 2012-06-12 22:14
    well to be perfectly honest i havent thought through a great deal of the technical details of this project yet as im in the middle of another one. this is just gonna a killer product hopefully people will be as exccited about it as i am.

    im not sure why i was even kicking around the idea of spi for the keypad. it doesnt require any speed oor anything fancy like simatanious keypress. if you have an android and care check out a free prog called hexcalc basically its my base reference. so im gonna need at least 32 hardware keys with one or two alternate functions toggled by shift keys. i had planned on using a bunch of normally opened push buttons and some kind of shift registers or port expanders which will most likely save the keypresses in either an area of hi eeprom or sram just depending on things pan out as the design goes on.

    im thinking that if it were possible id like to use a one wire serial interface. this could easily bebdone via pc right? as far as hardwate id probably have to connect the buttons to shift registers connected to an attiny or similar cheap micro to do the serial translation to the prop.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-06-13 06:13
    Look at the specs for the 1-wire interface before you throw that term around so casually. It's complex and the timing is tight.

    If you want to be able to read individual keys simultaneously, a 74HC164 8-bit serial shift register would work fine. You'd need 4 of them for the 32 keys plus another for any shift keys. This requires a 3-bit interface. One pin to load all the shift registers from their keys and two pins (clock & data) to shift out the data. The Prop can handle this directly over a distance of a foot or so since the speed doesn't have to be that high (KHz).
Sign In or Register to comment.