Electronic – When scoping the CLK and DATA lines of a PS/2 keyboard it looks… rather odd

digital-logicoscilloscopesignal integrity

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

Best Answer

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

Related Topic