Button Simulation with a PC.
rwgast_logicdesign
Posts: 1,464
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..
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
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.
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,
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.
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).