Connect external switch to PC

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View


I had a need to connect a double footswitch (2 momentary switchs) to a PC. I
came up with the idea of using the circuit board from a USB keyboard. This
was the perfect solution as it was cheap, small and didn't require any
drivers to be written. When I pulled apart the keyboard and hooked up the 2
switches to page up and page down keys it didn't work. So I measured the
resistance of the flexible circuit and concluded I needed to put a 50ohm
resister in series with the switches. When I bridged the resistor across the
pins (without using the footswitch) it fired the page up or page down key as
expected. I thought the problem was solved but when I hooked up the 2
switches it stopped working. The really interesting this was though, if I
hooked up only 1 of the switches then it worked ok. This was really odd
because by disconnecting a switch that was open anyway, all I was doing was
removing a 3 metre long wire that wasn't connected to anything. So I got the
idea of hooking up a diode to this wire and that worked. So my problem is
solved but can anyone explain to me why putting a diode on a piece of wire
connected to nothing solved the problem?

Also, one I had the diodes in place i worked fine without the resistor.

I'm not much good with ascii circuits but here it is:

------
|    |
|    |--~~------------------
|    |                |    |
| KB |                \    \
|    |                |    |
|    |-->--------------    |
|    |-->-------------------
------
  |
  |
  |
  |
 USB

~~  = 50 ohm resistor
->  = diode

Thanks heaps,
Michael



Re: Connect external switch to PC


Quoted text here. Click to load it


It would be a switch matrix type arrangement in your keyboard.

These invariably have diodes inserted to prevent "phantom key presses"
from 2 keys on the same row or column being pressed together and
simulating a 3rd key being pressed.
The couple of times I tried this, I used an optocoupler to trigger the
key, for safety reasons (optical isolation), and this would have its
own internal diode (the phototransistor).

having said this, I have found keyboard hacking to prove unreliable.


In these situations I would consider using those "MAME" - video arcade
keyboard emulator modules.
They just plug in to a USB or PS2 socket and appear to windows as a
keyboard, but they have screw terminals that you simply take to ground
using any kind of switch you want to use to "press a key".

They are not just for arcade games (in fact I have never used one on
an arcade game:), they will work with any program that can accept
input from a keyboard.


http://cgi.ebay.com.au/Keyboard-Encoder-Keywiz-ST40_W0QQitemZ180428301497QQcmdZViewItemQQptZAU_Video_Game_Accessories?hash=item2a025d64b9

Re: Connect external switch to PC


news:d0f001e2-0fcc-4f05-a1ba-
Quoted text here. Click to load it

That makes sense but I can't see any components. The keyboard just consists
of a hard and soft circuit board. The flexible board doesn't have any
components unless a diode is built into the track? I would have thought if
they were going to use diodes then they would put them on the hard circuit
board.

Perhaps they are using a different method of sending out different pulses in
different lines and then look for the resulting waveform?

Quoted text here. Click to load it

I've had some in service for over 5 years. Although that was in the day when
a USB keyboard was over $20. Today's $8 keyboards might not be so reliable.
Interestingly the last time I made these I had none of these troubles.

Quoted text here. Click to load it

Thanks for that, that is an option. It is more expensive than what I sell my
module for now ($60) but it's one of those situations where cost isn't a
huge issue.

Michael



Re: Connect external switch to PC



Quoted text here. Click to load it

This may well be too expensive for your module also Michael, but here is
an OZ designed and produced alternative:
http://www.dontronics-shop.com/top16-usb-io-module.html

Cheers Don...


--
Don McKenzie

Site Map:            http://www.dontronics.com/sitemap
We've slightly trimmed the long signature. Click to see the full one.
Re: Connect external switch to PC


Quoted text here. Click to load it


The older KB's might have used different methods, the problems I had
were indeed with the newer "cheapies" for $9.95 from discount stores -
this was in early 2007..
Looking at notes I made at the time, the problems involved keys
intermittently not registering when triggered, and even "locking up"
the KB.
Certain specific keys didn't register at all when triggered - for no
reason I could find at the time.

Didnt see the point in hacking up a good quality KB as at the time,
they were not much cheaper than some of those "MAME" modules were
(about $30) and after all - "we only needed the PC  board and the
IC" ;)
Might have discovered that even the good KB used the same technology
as the cheapies and also not be easy to interface ?

I also remember that earlier on, a friend of mine made up a MAME video
game system into a home made arcade cabinet for his kids and hacked up
a PS2 keyboard to connect up the joystick and buttons.  It worked
fine, the only problems he had was having to bring 2 wires up to each
button, instead of the usual method of every button having a common
ground.  Was a mess of wires, but he was happy with it.
This also would tend to indicate that the older keyboards were less
trouble.

One option would be to go to rubbish dump sales or charity shops and
buy some old keyboards ?


The only other theory I can think of with your situation is that from
memory of working on these cheap keyboards, the "key contacts" are 2
white translucent plastic sheets that are pushed together when a key
is pressed.

These may not be a simple switch that closes and shows close to zero
ohms, they might have a substantial contact resistance, hence working
when you add the resistor.

For all I know It may also work by measuring inductance, or
capacitance.  If this is the case, then
having a length of wire hanging off the key matrix may act to increase
capacitance, or pick up mains hum or other interference causing the
problem you have with it not working when the wire is attached.

Maybe the diode happens to block interference or limit it to one side
of the matrix.




Remembering too, some of those MAME things can be in the $30-40 range
if you dont need a lot of inputs like the one shown.  The one shown
was the only one found on Ebay at the time I searched, just to give a
pic of one for you.

Re: Connect external switch to PC
news:fd27aca1-ba13-42d2-b305-
Quoted text here. Click to load it

I think I agree with you there. I get a brand new keyboard and throw 95% of
the mass of it straight in the bin.

Quoted text here. Click to load it

Quite possibly.


That would be an issue for me as I have a lot of double footswitches in the
field with only 3 wires. :-)

Quoted text here. Click to load it

Bugger that!! :-))

Quoted text here. Click to load it

That is true.

Quoted text here. Click to load it

This is correct except it is the tracks that have the resistance. From 70ohm
to about 30 from a quick test I did (some keys obviously have longer
tracks).

Quoted text here. Click to load it

When I measured the voltage across the switch (when open) I get -2.5V. When
I switched the contacts over I still got -2.5V so something odd is going on
there. I thought maybe they send down different frequency pulses so they can
detect multiple keypresses.

Quoted text here. Click to load it

I will have a look into this and most likely switch to one of these
controllers in the future. This is actually what I was looking for but
didn't realise existed. Just from a wastage point of view I prefer not to
throw out brand new keyboards. Thanks for the tip!

Cheers,
Michael



Re: Connect external switch to PC
Quoted text here. Click to load it

I just realised it's not quite what I'm after. I really need 3 wires for my
2 switches, it looks like I would have to use 4 wires. Also I don't want to
install any software on the PC and I definately can't use PS2 as this is
usually already in use. Bugger, looks like i'm back to hacking appart
keyboards.

Michael



Re: Connect external switch to PC
Quoted text here. Click to load it



The MAME boards that I have seen will work with 3 wires as you
require.  (All will IIRC)

Each of the switch positions you just take to ground to activate the
switch, so you on need one wire for common and one wire for each
needed switch.


The other alternative - if you are happy to use a microcontroller, is
to make up one of the many PS2 keyboard emulator circuits that are
published on the internet (usually using PIC). If you are going to be
making a lot of these, this is probably the cheapest and most hassle
free way to go.

IF you can't use PS2 into your computer, then you can include a PS2 -
USB adaptor, even though it is yet another expense.

Finally, IIRC, some (not all) of the MAME PS2 boards will go in line
with an existing PS2 device
allowing both to be used.

Re: Connect external switch to PC


news:5fe9bc4e-765e-46c8-863d-
Quoted text here. Click to load it

Ok, my misunderstanding again :-) When it said "no matrix, every switch wire
independently" I presumed both wires. Of course it wouldn't make much sense
for them to have 40 pins for 20 keys. To have a common ground is actually a
better solution for me because when I pull appart a keyboard I'm just lucky
that page up and page down keys share a common wire on the matrix, it's
quite possible I could find a keyboard that this is not the case.

Quoted text here. Click to load it

I'm really keen on a USB solution. From a quick search I just did there are
USB options available. I'm in 2 minds, pulling apart a keyboard does work,
it's cheap, simple and the board is very small. On the other hand there
could be issues for example if someone extends the length of cable to the
footswitch. I'll do some research and see if I can find a good USB mame
board.

Thanks for all the information.

Cheers,
Michaek



Re: Connect external switch to PC


Quoted text here. Click to load it


You can try using a simple opto coupler to isolate the matrix
completely from any long leads to the switches.

if using an optocoupler,
pin 1 (A +)  and 2 (K -)  are the LED, (simply switch +5v to this via
a 330 ohm series resistor)

on a 4 pin opto,
pin 3 & 4 are the transistor - pin 3 is the emitter and pin 4 is the
Collector,  wire this directly across the keyboard key you want to
trigger.  (positive to the collector, though this might be hard to
determine on the keyboard matrix, you probably wont damage the opto by
experimenting with it in both directions.)


on a 6 pin opto such as 4N26. '
pin 4 & 5 are the transistor - pin 4 is the emitter and pin 5 is the
Collector,

There is no guarantee that this will work (it should, if you could get
the key to trigger by putting a diode across the pins) , but it only
costs a couple of bucks worth of parts to try if it doesn't.







Re: Connect external switch to PC



Quoted text here. Click to load it

Would it be less messy to use the handshake lines on a COM port, assuming
that one will be available? A small amount of software may be required, but
the hardware side would be a heap neater.



Re: Connect external switch to PC


Quoted text here. Click to load it

We used to use serial but the whole idea behind using a USB keyboard was to
eliminate the serial port. The serial port had the problem of some false
triggering with clients who had some noisy equipment. I could have possibly
solved that but some modern PCs don't have serial ports. I could use a USB
to serial converter but it might just be easier to make it USB. We also gain
the advantage that users don't need to specify which port they are using.
Selecting COM1: vs COM2: seems a little old fashioned to me. :_)

Michael



Re: Connect external switch to PC



Quoted text here. Click to load it

Those keyboard switches are in a matrix and you don't know the matrix
layout. Guess wenn you connect both switches separately (so no common wire)
your problem may be solved.

petrus bitbyter



Re: Connect external switch to PC


news:4af81970$0$4591
Quoted text here. Click to load it

I do know that matrix layout because I followed the tracks on the flexible
board. AFAIK, I had the wiring hooked up correctly. I checked multiple times
for extra circuits that I might have missed but could find nothing. I
thought there might be a complete loop on the flexible board all the way
back to a different pin on the solid board but there was nothing I could
see.

Michael



Re: Connect external switch to PC



Quoted text here. Click to load it

You could check out devices called 'keyboard wedges'. Such as
made by Unique Micro Design in Melb.

Site Timeline