4
\$\begingroup\$

Normally if I look at a digital signal I see a nice, relatively sharp pulse train on the screen, but when scoping the outputs of a PS/2 keyboard things get a little weird and I'm not sure what it means (though I suspect it means I've got something to learn here!)

If I don't hook the PS/2 outputs to anything other than the scope I get a rather normal looking pulse train on keypresses... it's a little odd in that it seems to slope at a small angle, but it's recognizable. However, when feeding an input line to a microcontroller (or using a 2K2 or so pull-up resistor to 5V) what you see below is what I get... (this is in AC mode for ease of display. DC mode looks similar except these oddly miniscule pulses are from 5V, though the pulses themselves are still <1 V peak-to-trough).

(Red = DATA, Yellow = CLK)

No matter what I do, the signal is surprisingly weak. Just for grins I started a normal pulse train out of the microcontroller and as expected it looked perfectly normal. I understand that PS/2 devices use an open-collector design, if that helps. So: what am I seeing here? And how do I get a relatively normal logic-level pulse train out of this signal?

Note: I tried another PS/2 device - same results.

Edit: updated pictures! All the outputs I got, normal-ish or not, are around 600mV peak-to-trough.

Edit 2: This all started because what should've been an extremely simple project (hook-up of a PS/2 keyboard to a microcontroller - with software applied to it and monitoring/driving the correct pins) didn't work... I was surprised at that first and foremost, and then started snooping at the signals (which I planned to do anyway AFTER it was supposed to be up and running, to learn more.) I keep thinking maybe it's the keyboard but I get the same effect from an old mouse as well (though it requires more handshaking to initialize it does at least send a clock burst on startup, and that burst is virtually the same in all characteristics as what I saw with the keyboard. The wiring seems sound and there really isn't much at all between the microcontroller and the DATA/CLK lines... it's virtually a straight shot to power and I/O.

And yet these patterns look vaguely familiar to me from a long time ago (different projects) and I suspect it'll be something simple.

Edit 3: I asked someone I know who is more analog-oriented and they think it looks an awful lot like a signal being clamped by a diode or such (the fact it's in a 0.6V range rather than a 5V range makes more sense in that case... now I know why it looked familiar). More later when I've tested things... might be that the cable I'm using to plug into isn't so passive after all (I thought it was... but *facepalm* I'll bet it's got a diode in it for some reason. Note it's salvaged from an old CueCat FWIW, and I am wondering if it's the splitter that's not in use that's the ultimate cause... and yes, I tested the connections and they seemed normal but I could've gotten lucky and forward-biased a hidden diode without knowing it).

Scope output (with pull-ups, AC mode probes, each centered at 0V):

Output 1

Scope output (with pull-ups, DC mode probes, each centered at 5V):

Output 2

Scope output (direct read (no pull-ups), DC mode probes, each centered at 0V):

Output 3

Scope output (direct read (no pull-ups), DC mode probes, each centered at 0V) (overlay view of the signal above):

Output 4

\$\endgroup\$
  • 1
    \$\begingroup\$ What voltages do you read from the plot? Also add a plot with your scope in DC-mode. Double check probe attenuator settings on both scope and probe itself. Double check if the microcontroller isn't actively pulling down the two lines. \$\endgroup\$ – jippie Dec 20 '12 at 8:12
  • \$\begingroup\$ The DC-mode one looked similarly spikey except they were relative to 5V... they were still (as above) around 600mV peak-to-trough, relative to that. Only when an output was totally disconnected from anything (no pull-ups) did it resemble the sort of pulse train I'd expect in terms of shape (though barely different in terms of the voltage p-t). And the probes and the scope were set to 1x, and probing other digital signals gives much more normal results. Since PS/2 should look like a normal digital pulse train I am for now at a loss. \$\endgroup\$ – MartyMacGyver Dec 20 '12 at 8:19
  • 2
    \$\begingroup\$ The new pictures remind me of a bad ground connection somewhere. \$\endgroup\$ – AndrejaKo Dec 20 '12 at 9:00
  • 1
    \$\begingroup\$ I agree with AndrejaKo, could you double check that either of the probes' ground lead/clip is attached to the system's (keyboard's/microcontroller's) ground. \$\endgroup\$ – GummiV Dec 20 '12 at 9:02
  • \$\begingroup\$ Well, the probes and the keyboard are all definitely grounded (the alternate test I did - toggling another digital line on the microcontroller at around 60 KHz - showed a very normal 5V p-p pulse train as expected (unconditioned, it even showed the slight overshoot-undershoot I'd expect to see) using the same ground connection. I did tie the PS/2 shield wire to ground as well... I'd think if anything that'd enhance noise rejection though. \$\endgroup\$ – MartyMacGyver Dec 20 '12 at 9:06
4
\$\begingroup\$

Well, it wasn't a bad scope or loose wiring or a floating ground... it was the PS/2 cable I used to connect the keyboard connector to the rest of the equipment! It's a case of not knowing your salvaged equipment very well, along with some buried surprises in the cabling itself.

Thanks for all the discussion and suggestions, though it was ultimately a non-member who caught the similarity to diode behavior and made me suspect something unexpected was actually present within this cabling.

I had an old cable from a CueCat. There's some interesting teardown info here, though that's not exactly what I was trying to do (I don't even have the 'Cat anymore... just the wiring. Figured someday there'd be a website I could post to after I screwed up while using it. :-)

Thinking incorrectly that these connectors were wired in parallel, I diligently tested the bare wiring what once connected to the 'Cat against the male plug (it was handy.. had I had ANY suspicion I'd have tested the correct connector and none of this would've happened. Assumptions...)

I accounted for the correct pin numbering and got everything wired just right based on that... except neither DATA nor CLK actually feed through to the female connector (I just figured the two extra wires were unused since they didn't probe to anything). So Vcc and Gnd were fine everywhere, but the actual DATA and CLK from the keyboard were not wired to anything!

So, by rights I should've gotten nothing useful at all on the output side, since those wires weren't even connected (they were snipped short and a little staggered. However, I clearly got two non-trivial and distinct (but greatly attenuated) signals, which I diligently read and which people here tried in vain to understand. It dawned on me they might indicate a reverse-biased diode was doing the attenuation, but I'm not sure (I actually did throw a diode into the mix after it was working and it had a similar effect). I think there's some circuitry in the male connector (which has two wire bundles, one from the female PS/2 plug and one from the CueCat side). If it were simple crosstalk I'd expect the signals I saw to be even smaller, and for these signals to be jumbled together, but they were VERY distinct (had they simply been dead I would've eventually realized I needed to test the female plug and would have found my error, but the apparent presence of protection diodes in that intermediate plug threw everything off. I'll post a followup if I manage to nail that detail down - I may even cut open the connector to do it.

Edit: I just cut it open... Vcc and Gnd were indeed bonded to all three targets as expected, while DATA and CLK were run over distinct lines from the female and male connectors to the endpoint. However, NO active or passive components were present, debunking that theory! It must've been just enough cross-talk. Given how they were crammed into the connector it's possible they were juuuuust close enough to their respective wires to bleed only their signals, though it's weird that I was getting attenuated though distinct clock and data signals despite the fact their wires were terminating on unused ping and their wires weren't even routed to the keyboard (that part of the cord didn't even have these two wires I was reading!) Bizarre...

I posted this thinking it was a very simple cable... clearly it was not and I used the wrong lines but this is a good example of what can happen when there are active components hidden in an apparently innocuous connector or cable (if anyone remembers APC's serial cables, they had hidden surprises in the form of special resistors to keep you from just using any old serial cable for communicating with your UPS... and the old iPod cables did that as well. Proprietary Cabling 101!) That's why the signals I saw rang a bell. Hopefully this helps others who are troubleshooting weird results with an apparently normal cable assembly.

tl;dr - Always keep the possibility of hidden components in mind when using salvaged connectors (especially if you get bizarre but strangely repeatable and well-isolated signals), and test the pins you'll actually be using, not just the ones you think are wired through!

Here's the output I got in the end. It was identical whether the keyboard was plugged into the microcontroller, with or without pull-up resistors, or even without anything at all (just straight into the scope). It should be a nice 5V p-p signal straight out... I was wrong about these open-collector outputs having any bearing on the signal strength or shape. They were just red herrings thanks to whatever is in that splitter jack...

Final test

\$\endgroup\$

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.