Hey,
I’m hacking into an old vending machine to make it run with a particle.
Rather than get deep into the low level controls, I decided to simply build a particle powered number pad to replace the existing one.
To get started, I bought a replacement number pad to see how it works. It turns out it’s the same as all the ones in the Keypad.h library. Got it up and running, and I can now read key presses. Pretty easy. HOWEVER, now I want to emulate button presses for the machine. There is no function to press a button in the library. How would I do this via particle?
When you say you want to emulate button presses, do you want the library to think a button is pressed, or do you want the device to fake a physical press, thus ‘hitting’ the button hardware-wise?
What is the end-goal (of simulating these buttons), so we can chime in with ideas ?
id like the do the latter. i am trying to simulate a button press (hitting the button hardware wise)
below is the existing keypad. id like to make a particle keypad, but keep the same internals to the rest of the machine. potentially, id like to “man in the middle” here. so people can still use this keypad, but i can also press buttons via software. make sense?
Oh, that’s a fun one. Since this is a key matrix, a 6x3 matrix switch would be needed to “shadow” the existing keyboard. This could be done with three 8:1 analog multiplexers (CD4051) or a single 8:4 multiplexer (possibly MAX14724). Not simple but doable.
@avidan, the existing hardware is scanning that keypad with a specific response expectation. It may be possible to have a Photon/Mesh device emulate the keypad by “listening” for the scan signals and responding accordingly. Most likely doable.
If you look at the back-side of that keypad, it looks like when a button is pressed, it’s making contact between 1 of the 3 “column” traces and 1 of the 6 “row” traces. You could probably put together a few components to emulate that switching. You could put in 18 digital bus switches… I think I would use something like this Quad FET Bus Switch. You could use 6 of them, one for each “row” (ignoring 1 circuit on each IC because they don’t make Tripple FET switches). Then you need 18 GPIO pins or some sort of priority decoder IC… or you could use 3, 8-bit latching shift registers to drive the bus switches. This would take the guess work out of how the vending machine is sensing the connections because you are putting in a drop-in replacement for the buttons.
If you wanted to get fancy, you could hook the keypad up to the Photon so that you could have both manual control as well as IoT control. It would just all run through the photon. Or add some sort of cable connector to your custom PCB so that the manual control would be in conjunction with IoT control. I can imaging about 4 ways to hook all that up but it comes down to how you envision the pad working with the Photon.
ok. using the Quad FET Bus Switch feels like overkill. Is there no way to simply remove the pad entirely and plug the 9 connections to the photon and somehow emulate button presses?
Can you take some measurements before and during a button press to figure out what level the different lines sit at? Does a button press pull the lines low or high? Too many questions about how the pad is read by the vending machine to make a better suggestion. The bus FET switches would have acted just like the buttons, like a simple contact closure. There’s no way to emulate a contact closure without a transistor of some sort. Without external hardware, then you have to drive the 9 lines high or low using GPIO… but which way will take some testing. Or find a schematic or wiring diagram for the vending machine which may answer the question.
Can you plug the keypad into the vending machine and then take a multi-meter voltage reading on each of the pins between the pin and ground? This will determine which keypad pins, if any, are high before a key press. That would be where I start. If none are high, then that’s an issue… like @peekay123 said, the controller might scan the keypad instead of just doing a simple pull-up/pull-down on the lines.
I tried searching for a schematic but the vending machine manuals are so generic. I couldn’t find any good photos of the controller board to trace out the PCB regarding the keypad connections.