0
\$\begingroup\$

I am trying to emulate the PS/2 keyboard protocol with a custom piece of hardware, without using a microcontroller. The said piece of hardware will consist of 13 momentary push buttons.

http://pcbheaven.com/wikipages/The_PS2_protocol/

The keys will be hard mapped to specific ASCII values. My idea is (with intricate trace design), on button press, to fill a shift register with the correct ASCII value + PS/2 bits and shift the bits out as the PS/2 data. I was hoping to control the shift register with a decade counter, opening the the latch and inhibiting the clock to the shift register for one cycle, then waiting for 11 cycles to shift the data out of the shift register.

Is there an simpler more obvious solution or should continue to refine my design? I'm testing the concept with 8 stage shift reg + counter, but will expand later to accommodate the necessary 11 bits if the concept works. Also, no formal training in electrical engineering, I apologize if my question is not appropriate.

\$\endgroup\$
  • 1
    \$\begingroup\$ Is there a specific reason to avoid the microcontroller? \$\endgroup\$ – Anindo Ghosh Nov 12 '12 at 20:39
  • 3
    \$\begingroup\$ If it's just a hatred of microcontrollers you could use an FPGA instead =P \$\endgroup\$ – NickHalden Nov 12 '12 at 20:42
  • \$\begingroup\$ cost and I would like to avoid programming a microcontroller for each piece of hardware, and general interest in how efficient I can be \$\endgroup\$ – chris.antonellis Nov 12 '12 at 20:43
7
\$\begingroup\$

You need to be careful: the PS/2 protocol is bidirectional, so you can't just transmit. Once in a while the computer will pull the CLK line low and then drive the DATA signal for a few clocks, and then you need to acknowledge it. Furthermore, your understanding of a keyboard protocol appears to be a bit incomplete. They do not send ASCII values, they send key codes, including separate key-down and key-up events. Also, you need open-drain outputs.

It would be far easier to do this with a microcontroller. Regarding your specific arguments against them in your comments:

  • Cost: there are lots of microcontrollers with enough I/O to read the key matrix and speak PS/2 that are less than $0.50, like the PIC16F54. You will be hard pressed to get all of your discrete parts for less.

  • Programming: You can order chips pre-programmed with whatever firmware you provide from a distributor like Digikey, or directly from the manufacturer.

  • Efficiency (space): A single microcontroller will be much smaller than several discrete chips and usually includes an internal clock, pull-ups, open-drain buffer, etc. (Note that open-drain can be achieved by switching a pin between two states: output 0, or input with pullup enabled.)

  • Efficiency (power): Microcontrollers have lots of sleep modes available and can be almost completely powered off while no keys are being pressed, or in between scans of the keyboard.

  • Efficiency (your time): You will likely run into lots of problems besides the protocol issues, like needing to debounce keys, etc. Firmware fixes are going to be a lot faster than having to respin a PCB or order some new chips.

\$\endgroup\$
  • \$\begingroup\$ Using the internal pull up to emulate the open drain is a bad idea (at least with ATtiny/AVR). I have experimented with this in the past and the signal doesn't even look like a digital one. Solution, don't enable the internal pull up, use a physical one. \$\endgroup\$ – jippie Nov 13 '12 at 8:07
  • \$\begingroup\$ Another +: Before I started experimenting microcontrollers, I was convinced they need a crystal and stuff to supply it with a proper oscillator. But todays microcontrollers mostly have internal oscillators, they don't need any external components (other than the decoupling cap). \$\endgroup\$ – jippie Nov 13 '12 at 8:09
  • \$\begingroup\$ Another +: When I was a young boy ... it took massively expensive equipment to program a PROM or a microcontroller. Today I use a 20€ Arduino and freely available software to do all my programming. \$\endgroup\$ – jippie Nov 13 '12 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.