Is PC USB power subject to dips and spikes?

I've built myself an arduino-based PS2 keyboard -> USB keyboard converter (that also switches some keys around). I'm ironing out the last few kinks. I've got a SparkFun Pro-Micro (ATmega 32U4@5v+16MHz) wired directly to the PS2's Data&Clock pins with the sole source of power being the host computer (attached via USB).

Very occasionally, usually after I've left the computer completely alone for a while, when I wake the computer up (e.g. with the mouse), I see an event that I'm pretty sure is the PS2 clock pin flip-flopping just once (or maybe twice; not quite sure). In any event, the PS2 interrupt fires, but it's not followed-up by the rest of the protocol, it's just a glitch.

It happens so rarely I can't claim to have solid data. Sometimes I know the host computer was asleep and the phantom blip happened right as the host machine woke up. This has happened on two different workstation class computers with quality power supplies. The keyboard didn't lose any settings, so it wasn't a full loss of power. There have been times when it's happened when I don't think the host was actually asleep, but the monitors were black, so I think a power issue could still be in play here as the video card would have suddenly sprung back into gear.

My questions are these:

  1. Do you agree with me that the likely cause is a power-dip on the USB 5v line as the computer comes back from sleep?
  2. It seems to me like slapping a capacitor across power/ground might help. Are there guidelines about how to craft such a circuit to best effect?

Or am I completely off-base here? Is there something in the USB protocol that could be the cause of this? Something on the Arduino (I've got a SparkFun Pro Micro, ATmega 32U4 5v 16MHz).

Thanks!

That's unlikely...

Computer power supplies* are noisy, but it's the kind of noise that can cause problems with analog audio. It's very rare to get a glitch/error in the digital data. If you were powering a small motor off the USB, that could potentially cause a glitch.

  • The noise probably isn't coming from the power supply... It's all of the digital switching on the motherboard and other digital electronics.

If you can get a scope on it and make it trigger on the glitch, the output of that would I think be useful for figuring this out - but that might be hard to do.

Without that - I'd try as you suggested putting a cap between power and ground, and seeing if that helped... (nothing special here, just like... 10~100uF probably? The exact value is probably not critical). If you're able to see the glitch on the scope, you could of course see what impact the cap had and assess if you needed a larger one, or whether it wasn't helping.

I found this article:

Per what both of you said, it's overkill because it has caps for filtering high frequency noise as well. He does have some good guidance in there about 10uF being the recommended max. (That said, if a 47uF one pops out of my pile of caps first, it's happening.)

Hooking a scope up isn't practical, the event happens way too rarely. But I suppose my coworkers would be impressed having my ridonculous 1960's era scope whirring by my desk all day :slight_smile: Who cares about practicality.

From what you're saying and what I'm reading, there's no harm in hooking up a cap, and it might be sufficient, then again, maybe not. Right now the best way to find out is just to try it.