A vintage keyboard, a mysterious battery, and some questionable 1990s engineering choices...
Keyboard
For five years this classic keyboard has sat in my cupboard:
This is an Apple Extended Keyboard II, released 1990. This model is praised by keyboard nerds for its "clicky" mechanical ALPS switches and sturdy design.
This particular keyboard has a hand-written asset sticker from the Federal Department of Administrative Affairs (1987-1993):
I think either my Dad or I bought this at an ex-government auction in the late 1990s, together with a Macintosh IIsi that was briefly our dial-up modem router at home. Later, the Macintosh and its keyboard spent around twenty years in my Dad's shed.
When my parents downsized five years ago, the Mac and its magnificent Portrait Display were sold. I kept the keyboard.
Recently I saw it sitting in the cupboard, once again forgotten. Time to actually use this thing!
Birthday
The keyboard was a bit sad and unsanitary, with a thick layer of 1990s grime. So I gave it a birthday!1
Specifically I stripped it down, washed all the plastic parts, and put it back together.
iFixit's teardown is very helpful. The vintage plastics on this particular keyboard seem to be in good condition, despite my clumsiness nothing snapped off.
It's never going to be pristine, but it's now a lot nicer to look at and use.
No Yak Shaving
Being from 1990, this keyboard connects using Apple Desktop Bus (ADB):
A converter is required to connect it over USB.
For an embedded developer prone to distraction, this creates a risky situation... the task is simple enough, and countless DIY versions already exist, so it's tempting to "just knock something together". One could build on the classic TMK firmware, leverage the USB device support I've been implementing for MicroPython, or pick a real challenge like bit-banging low speed USB in Rust on a dirt cheap RISC-V micro.
NO! BAD GUS! TOO MANY PROJECTS!
I reminded myself that I have too many projects already, including a whole electric car conversion to do. Best not to chase more squirrels or shave more yaks.
In hindsight, I should have ordered a pre-built TMK ADB-USB adapter at this point. However, overseas shipping is slow. Someone on eBay Australia had listed a "Griffin Technology iMate Universal ADB to USB Adapter". Confirmed working, reasonable price, and even in the original packaging:
Griffin Technology
These days Griffin Technology seem to mostly sell phone cases, but in the 1990s they specialised in Macintosh accessories. When the iMac was released in 1998, Apple switched from ADB to USB. So in 1999 Griffin released the iMate to adapt ADB devices to "iMacs, Macs with USB, and PCs with USB". Pretty cutting edge stuff!
Griffin seem to have sold the iMate from late 1998 through to late 2008. Not a bad run!
iMate No Good
Sadly, my laptop didn't work with the iMate and the Apple Extended Keyboard II. The iMate briefly enumerates over USB but goes immediately into a permanent USB reset loop before giving up. The Linux kernel log tells the sad tale:
17:34:38 usb 3-4: new low-speed USB device number 6 using xhci_hcd
17:34:38 usb 3-4: New USB device found, idVendor=077d, idProduct=0405, bcdDevice= 3.70
17:34:38 usb 3-4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
17:34:38 usb 3-4: Product: iMate, USB To ADB Adaptor
17:34:38 usb 3-4: Manufacturer: Griffin Technology, Inc.
17:34:38 input: Griffin Technology, Inc. iMate, USB To ADB Adaptor as /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.0/0003:077D:04>
17:34:38 hid-generic 0003:077D:0405.000C: input,hidraw6: USB HID v1.00 Keyboard [Griffin Technology, Inc. iMate, USB To ADB Adaptor]>
17:34:38 input: Griffin Technology, Inc. iMate, USB To ADB Adaptor as /devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.1/0003:077D:04>
17:34:38 hid-generic 0003:077D:0405.000D: input,hidraw7: USB HID v1.00 Mouse [Griffin Technology, Inc. iMate, USB To ADB Adaptor] on>
17:34:40 usb 3-4: reset low-speed USB device number 6 using xhci_hcd
17:34:42 usb 3-4: reset low-speed USB device number 6 using xhci_hcd
17:34:43 usb 3-4: reset low-speed USB device number 6 using xhci_hcd
17:34:45 usb 3-4: reset low-speed USB device number 6 using xhci_hcd
17:34:45 usb 3-4: reset low-speed USB device number 6 using xhci_hcd
17:34:47 usb 3-4: reset low-speed USB device number 6 using xhci_hcd
17:34:48 usb 3-4: reset low-speed USB device number 6 using xhci_hcd
17:34:50 usb 3-4: reset low-speed USB device number 6 using xhci_hcd
17:34:50 usb 3-4: reset low-speed USB device number 6 using xhci_hcd
17:34:52 usb 3-4: reset low-speed USB device number 6 using xhci_hcd
17:34:54 usb 3-4: reset low-speed USB device number 6 using xhci_hcd
17:34:55 usb 3-4: reset low-speed USB device number 6 using xhci_hcd
17:34:56 usb 3-4: reset low-speed USB device number 6 using xhci_hcd
17:34:57 usb 3-4: reset low-speed USB device number 6 using xhci_hcd
17:34:57 usb 3-4: USB disconnect, device number 6
It worked once or twice for a moment, but never consistently. It felt a lot like an electrical noise issue...
I messaged the eBay seller, who confirmed the iMate had been working fine plugged into a newer "AppleDesign" ADB keyboard. I figured maybe it was the keyboard. After all, this one had been left in a country shed for twenty years...
Capacitors
"Oh, I know! Vintage computer people are always excited about replacing old capacitors!"
The keyboard had three identical 1uF electrolytic capacitors visible on the board.
I keenly desoldered one. Out of circuit it measured 1.1uF, 110% of the rated capacitance! Solid effort for a 30+ year old capacitor.
Uh, maybe it's not the capacitors. I soldered that one back on.
Mystery Battery
Until now I hadn't done any reading about the iMate. Reading its page on Deskthority, I got a surprise:
The iMate contains an undocumented button cell battery, of type CR1225. The purpose of this battery is not confirmed, as Griffin have never formally acknowledged its existence. The consensus is that it provides the power required to switch on certain Macintosh models via the keyboard, from keyboards with a power button.
The battery is not required (the iMate will operate without it, but without the power-on feature), but when the battery becomes depleted, the iMate may fail to function
(Emphasis mine.)
WTAF! Why does a permanently connected USB device have a secret battery in it?
Taking the iMate apart,3 sure enough there's a coin cell battery in there:
It was totally flat. However, even with the battery removed the USB issue stayed exactly the same.
Replacement battery
My local $2 shop didn't have a CR1225 cell, but they did have a CR1220 cell which is the same thickness and voltage. $4 later and... the iMate worked flawlessly!2
Very weird. Now I am totally Nerd Sniped: What does this mystery battery do? Why is it needed for this keyboard, but maybe not for other keyboards?
When I raised the issue on Mastodon I received two theories: "totally an NSA keylogger", and "purely for planned obsolescence". I guess both are possible...
Research
The 2000s were a long time ago in Internet Years. The blessed Internet Archive has captured a lot from this era, but the sources linked from Deskthority seem to be lost. There's some good info on the TMK wiki, including Wayback Machine links for Griffin's original iMate Support pages. Indeed, Griffin never mentioned it has a battery.
Time to look closely at the PCB:
The largest component is a Cypress CY7C63413-PVC. This is long discontinued, but it still has a product page on Digikey complete with datasheet PDF (published 1997, revised 1998).
The chip is a One Time Programmable "8-bit RISC" microcontroller with an integrated USB Low Speed interface. Operating voltage is 4.0V to 5.5V and there's no low power features, so it seems unlikely that the 3V battery is used directly with this micro.
There's also a lot of discrete parts on the PCB, and a worrying number of very high impedance 2.2 Megaohm resistors. When it comes to noise susceptibility, very high impedance terminations are a red flag.
In the end, I traced the whole circuit:
You can get the KiCad files on GitHub.
Identifying the diodes and transistors from their marking was tricky, for example Q1 on my board is marked "KF" and I'm not sure what that is. However, between Deskthority and flickr user ninjabong (lol), there are images of two other iMate PCBs with the same layout but slightly different parts. Perhaps different production runs?
To understand the schematic, I first had to learn about two features of vintage Apple computers...
ADB PSW Signal
ADB is a single wire low speed serial bus, so the four pins on the Mini-DIN connector are 5V Power, Ground, the ADB data signal, and Power Switch (PSW).
In the Apple Extended Keyboard, the power switch is connected to the "power" key in the corner and switches the PSW signal to ground through a diode:
In a Macintosh, the other end of this signal pin has a zener diode for protection and a 100K pullup. The signal then feeds into the "MCU" which can switch on the rest of the Mac:
(Part of a glorious Macintosh IIsi schematic, as created by a company called Bomarc Services and preserved by the Internet Archive. Highlighting mine.)
Note that when the Mac is powered off no power flows to the 5V power pin on the ADB connector, the only powered pin is PSW which is pulled up to "always on" power inside the Macintosh.
Normal USB Wakeup
Modern USB devices do not have a dedicated "power switch" pin on their plugs.
Ever since USB 1.0 in 1996, there is a "remote wake-up" option where a USB device can stay powered in a suspended state until it wakes the host. This is what happens on most USB keyboards where pressing any key wakes the computer from sleep, or (depending on the hardware) powers on the computer.
Unlike the ADB power switch signal, the USB device has to stay powered for "remote wake-up" to work.
Cursed Apple USB Power Button
It seems Apple made an "interesting" choice in 1998 when they switched from ADB to USB. I can't find a decent technical source for this, only tidbits like this uncited quote from Wikipedia:
The power key was replaced with a more conventional power button on early USB keyboards, thanks to a proprietary pin wired to the Macintosh's power supply in Apple's early USB implementations, subsequently eliminated on the Pro Keyboard along with the special power supply pin.
This Instructable, linked from the TMK wiki, describes building a custom "Power Macintosh G3 power button" by connecting a USB cable's USB D- signal and Ground pin through a momentary pushbutton.
Seems like rather than implementing USB "remote auto-wakeup" to power on, Apple kept the spirit of the ADB PSW pin. They wired the keyboard's power button to the USB D- signal. Pressing the button shorts this signal to ground. This way the rest of the keyboard can stay unpowered, apart from the D- pin.
For about $50AU I could get a "model M2452" Apple keyboard and confirm this sketch is accurate, but I've already gone way too deep on this...
All the FETs
Looking at the iMate again, I think the extra circuitry exists to translate ADB's Power Switch signal into the "Cursed Apple USB Power Button" signal. Here's the relevant part of the schematic:
I think it works like this:
- PSW is normally pulled up to the battery voltage by pull-up resistor R3, so Q1 (P-channel FET) is normally turned off.
- When the power key is pressed, PSW drives low and turns on Q1.
- Q2 is another P-channel FET, whose purpose is to stop the power key from messing up USB signalling if USB is powered. If Q1 turns on then Q2's Source pin sees 3V from the battery.
- If USB is powered then Q2's Gate pin sees 5V, meaning Vgs remains positive and Q2 stays turned off.
- If USB is not powered then the voltage at Q2's Gate pin is 0V, Vgs is negative, and Q2 will turn on.
- If Q2 turns on then the voltage from the 3V battery next appears at the Gate pin of Q3 (an N-channel FET).
- This turns on Q3, which pulls down the USB D- pin.
- If the iMate is connected to an old USB Mac, this signal will turn the Mac on!
This pretty much works as designed as long as the battery holds charge. Yay!
There are some things about the schematic that I still don't understand, such as why Q1 and Q2 are different P-channel FETs with similar specifications and in compatible packages. I assume there's a key difference between them, but I don't know what.
Confirming the fault
If the fault is in this part of the circuit then we should be able to see it by capturing the USB data signals with a logic analyzer.
Here is a working iMate with a fresh battery, talking 1.5Mbps Low Speed USB:
Here are the USB signals from a faulty iMate with no battery, stuck in a USB reset loop:
The traces are similar, but on the faulty iMate the USB D- line randomly glitches to a low level (near the right of the image). The Sigrok USB decoder has interpreted these as "bus reset" signals, but a compliant USB Bus Reset needs to last 10ms or longer to be valid. These pulses are much shorter, they are nothing but noise!
Nevertheless, the USB host is correctly interpreting them as an error and triggers a proper Bus Reset a short time later. Communication restarts until the next time the USB D- signal glitches low...
So much noise
The issue appears either when the battery is removed, or if the battery has completely discharged meaning its internal resistance is very high.4 At this point the entire part of the circuit connected to "BATT+" is effectively floating, as is the PSW pin:
Looking at the PSW pin on an oscilloscope, it's incredibly noisy:
The ADB data signal is clearly visible, coupled into the floating PSW signal:
(Ch1 is PSW pin and Ch2 is ADB pin.)
Without any low impedance path to decouple or discharge, the noise is left bouncing around the circuit!
I think that the noise-induced voltage at Q2's Source pin sometimes exceeds 5V. When it reaches a high enough voltage, Q2's Vgs becomes negative enough that Q2 turns on despite USB being powered and active:
(Recall that Q2 was intended to prevent the power switch from triggering while USB was active...)
Q2 only has to very slightly turn on in order to pass enough current to turn on Q3 and short out the USB D- signal. This is because Q3's Gate pull-down resistor R5 is a massive 2.2Mohm, and the typical Gate cut-off voltage for Q3 is 1.2V. Even 550nA of current passing through Q2 may be enough to turn on Q3.5
I wasn't able to see this on the oscilloscope, the highest PSW voltage I saw was around 5V. However, probing the circuit changes its behaviour! My cheap 10X scope probe adds approximately 17pF of capacitance, and this resolves the issue: while the oscilloscope probe was attached the iMate worked perfectly!
Quick Fix
To validate this theory I soldered a 100nF capacitor between the BATT+ voltage and Ground. This should act as a decoupling path for the electrical noise.
A pretty good place to solder a surface mount capacitor is between pin 3 of D3 and one of the battery holder pins:
I used an 0603 sized capacitor, but an 0805 would fit better. Not the greatest soldering, but the electrons won't notice.
Sure enough, the iMate works fine now. The PSW signal looks much the same on the oscilloscope, but Q1 no longer turns on. I believe that any time a voltage develops between Q1 and Q2, it now discharges through Q1's body diode into the capacitor.
Adding more decoupling capacitors to the actual PSW line (rather than BATT+), or decreasing the value of some of the Gate resistors, would likely reduce the noise further. For now it seems to fine, though. My only doubt is how much RF noise is radiating from the ADB cable's PSW wire, but I guess I'll find out about that!6
I haven't reinstalled a battery, as I don't need the Apple Cursed USB Power Button functionality. However if someone installs a battery later on then it should all keep working fine, as well.
Why this keyboard?
Why did other ADB keyboards apparently work OK with a flat-battery iMate, while this one was faulty?
My best guess is that different ADB keyboards have different PSW circuits in them. For example, other keyboard models might have a decoupling capacitor, a pullup resistor, or better common mode noise filtering on the PSK signal. This is just a theory.
Does it really need a battery?
I've been trying to think of a way Griffin could have implemented "Apple Cursed USB Power Button" functionality without a battery. I haven't thought of a way, yet.
If you were designing the iMate in 2023 then you could probably use a supercapacitor instead of a coin cell battery, and have it charged when USB was powered. Unfortunately consumer grade supercapacitors were probably quite hard to source in 1998...
Connecting the PSW pin directly to D- would be tempting, as the two circuits are so similar. However, then the USB D- signal would be connected into the ADB cable's PSW wire whenever USB was active, and would become an even worse antenna!6 Once you start thinking of ways to block the signal when USB is enabled, and unblock it when the keyboard is unpowered, then it's hard not to wish you had access to an independent voltage source like a battery...
Griffin's engineers(s) seemingly ignored what happens in the circuit when the battery goes away. Some would suggest this wasn't an accident (i.e. planned obsolescence), but I think it probably was an accident. That said, not mentioning the battery at all in their support material is harder to explain.
Conclusion
So, uh, "don't start a new project" resulted in a lot more yak shaving than I'd counted on...
Worse, I'm already kind of dissatisfied with the iMate - it doesn't distinguish left and right for Alt/Shift/etc. Also, because I'm not a Mac user it'd be nice to have a firmware that could swap Command and Alt keys instead of needing to configure that in software. So, if I keep this keyboard then I might end up buying a different adapter for it anyway. Sigh.
Oh well, at least I probably learned something.
-
I don't know if this is Australian slang or not? "Giving something a birthday" means sprucing up something that's been shabby and neglected. I often hear mechanics say it about cars or tools. ↩
-
A moment of temporary awe: This is an unmodified device designed around 1998, probably based on the USB 1.0 specification. It uses 1.5Mbps USB signalling to communicate. Yet it can work connected to a modern laptop's USB4 port that supports 10Gbps signalling. USB catches a lot of flak, but maintaining that kind of backwards compatibility after 25 years and a 6000x performance increase is pretty impressive. ↩
-
As Deskthority also notes, the iMate plastic casing clips together. With a plastic spudger it's easy to pop the two halves apart. Be warned, the plastic on mine has somehow become both soft and brittle. The plastic spudger dented the case, and during disassembly and reassembly I also snapped off two of the four locator pins inside. It still holds together fine, though. ↩
-
Electrically I think these are basically equivalent states. ↩
-
This hand-wavey estimate disregards gate capacitance, other properties of the FET, and that we actually care about Charge not Current. However, 2SK1399 input capacitance is tiny - 8pF - so the gate is going to charge pretty easily in this circuit. Hand-wavey wannabe electrical engineering FTW! ↩
-
I noticed Griffin Technology has FCC reports on file for some contemporary products like the iMic, but not the iMate. In their defence, it'd be hard to compliance test a product that can potentially be connected to an infinite array of different ADB devices. ↩↩
Thoughts on “Mysteries of the Griffin iMate”