Woz is God, or possibly the antichrist.

As I was contemplating a title for this post I realised that “Woz” is “God” backwards, or at least it’s “god” transposed onto a backwards alphabet. Check it out:

a b c d e f g h i j k l m n o p q r s t u v w x y z
      z y x w v u t s r q p o n m l k j i h g f e d c b a
      |     |               |

Take the letter “o” as the rotation point, flip the alphabet backwards and then transpose the word “god” onto the reversed alphabet, you get “woz”.

I’m talking about Steve Wozniak (co-founder of Apple Computer, you can read about Woz at Wikipedia) and although he may not be an actual god (or even the antichrist; not withstanding that whole $666.66 pricing issue…) he is quite amazing. In ’86 a friend of mine at Yarrawonga High got a “limited edition” Apple IIgs signed by Woz (Apple made at least 10,000 of these ‘limited editions’). I remember thinking, “you’d have to be pretty special to get your name on a computer”. Woz is pretty special (and probably a bit of a dork, but hey, in the 80’s being a dork could be truly cool, not just faux-cool like it is now).

The reason I mention Woz is that I’ve just been messing around with the Apple Desktop Bus, it’s a system Apple used to connect keyboards and mice to their computers. Woz developed the ADB in the mid ’80’s (it was latter replaced by the industry standard USB, however due to its simplicity it was still being used internally on Apple laptops as recently as 2005). ADB’s simplicity epitomises Woz’s approach to hardware and software design. It uses just a single data line yet it allows for up to 16 devices to be daisy-chained together on the one bus. ADB manages this by having the system assign temporary four bit address to each device on the bus. Because the system takes control of assigning addresses you can have multiple instances of the same device (i.e. a number of identical keyboards or mice) on the same bus, all functioning correctly at the same time.

ADB is also extremely simple to implement in hardware. This is the inside of an ADB mouse.

inside an Apple ADB mouse

As you can see the component count is very low, two optical encoders (the black wheels), a button, and a single IC. All communication is sent on the red wire, the blue wire is +5v (bad colour coding if you ask me), one black wire is GND and the other is the cable shield (keyboards have an additional wire they use for power-on switches, the mouse obviously doesn’t need one of these). Hardware costs are so small that they generally amount to less then the price of the connecting cable.

ADB’s ability to daisy chain devices together makes it very useful for my B&O MP3 mod. Early in the mod I decided it would be nice to use the B&O’s existing slider to control music track selection. I investigated various was of implementing this (including reading variable resistor values through the Mac serial port) but in the end decided that the simplest hardware and software approach was to mod an ADB mouse. Connecting the mouse to the PowerBook should be a simple matter of locating the internal ADB data line.

In the PowerBook G3 and G4 systems (released prior to 2005) the ADB controller is integrated into the power management IC (PMU). The PMU is on a separate board to the main processor; in the Wallstreet it’s located under the right hand side of the upper shell (for detailed Apple laptop take-apart instructions check out this great site). The track-pad is connected to the PMU via a flex cable.

PowerBook Wallstreet track-pad and PMU unit

The flex cable connects to a 10 pin socket on the PMU board. With the flex cable removed the socket looks like this.

PowerBook Wallstreet track-pad connector

Although the connector has 10 contacts, the track-pad’s flex cable indicates that only three conductors are in use (suggesting ADB communication). By testing the voltage at each of the contact points I came up with the following assumption.

PowerBook Wallstreet track-pad connector diagram

I stripped the plug from an ADB mouse and attached the power (blue), data (red), and ground (black) leads as shown below.

mouse connected to PowerBook Wallstreet internal ADB system

With this connection the mouse is automatically recognised at start-up and functions as normal. The simple ‘plug and play’ qualities of the ADB system opens it up to a wide variety of modding opportunities. One possibility that leaps to mind is the incorporation of my (now redundant) PowerBook track-pad into an external ADB keyboard (I’m currently typing on the Apple Keyboard II and the track-pad would look pretty neat in place of the numeric keyboard), but that’s a mod for another day…

Interpreting mouse movement on the Mac (whether ADB or the more common USB variety) is possible via the application programming interface (API). I’m using Objective-C with Apple’s Xcode development environment, so to detect mouse clicks I use the following handler;

- (void)mouseDown:(NSEvent *)theEvent

To check whether the left or right mouse button was pressed you can interrogate the event for a type, such as;

if [theEvent type] == NSRightMouseDown {
 -- do something responding to a right click
}

I wanted to implement the standard Macintosh approach of allowing control-clicks to register as right mouse clicks so my code looks like this;

- (void)mouseDown:(NSEvent *)theEvent
{
 if (([theEvent type] == NSRightMouseDown) || ([theEvent modifierFlags] & NSControlKeyMask)) {
  [self rightClickAction];
 } else {
  [self leftClickAction];
 }
}

This code calls the handlers rightClickAction and leftClickAction which in turn navigate the user through the MP3 players graphical user interface (GUI).

Responding to the mouse button wasn’t crucial for my project, a similar response could be achieved by checking for key presses on the PowerBooks internal keyboard, but using a mouse allowed me to track the B&O’s slider movement. I managed this with the help of a perforated metal strip I pulled from an old daisy-wheel printer.

linear optical encoder

It’s a linear encoder, just like the mouse’s encoder wheel except straight. I presume it was used by the printer to check print head movement.

optical encoder closeup

Here’s a close-up. The perforated strip alternately blocks or allows light to pass between an optical encoders send and receive modules.

circuit on encoder

Here you can see the mouse’s circuit board liberated from it’s enclosure and positioned on the strip so that left and right movement are registered by the optical encoder. Without further modification this set-up will move the on-screen mouse cursor. My program doesn’t use the standard GUI of point and click, the mouse pointer is hidden when the program launches and instead the slider is used to navigate through the menu system (in much the same way as the iPod’s click wheel).

In software the movement of the mouse can be monitored through a mouse-moved event, however before this event will register you must tell the appropriate program window to watch for it. This is done through the method;

[aWindow setAcceptsMouseMovedEvents:YES]

Mouse-moved events are turned off by default because they generally occur so often they can bog down the event queue. In the case of the B&O mod this shouldn’t be a problem (and tracking slider movement in this way is far easier than using the tracking rectangles method suggested by Apple).

Once you’ve set the program window to watch for mouse-moved events you can respond to these events through the event handler;

- (void)mouseMoved:(NSEvent *)theEvent

The event that gets passed with the message contains a range of information on the mouse’s position. I chose to get the mouse’s delta movement because unlike the mouse location the mouse delta changes even when the mouse pointer is stuck against the edge of the screen. My code looks like this;

- (void)mouseMoved:(NSEvent *)theEvent
{
 mouseDeltaY = mouseDeltaY + [theEvent deltaY];
 [self moveSelection:mouseDeltaY];	
}

The code gets the vertical distance moved by the mouse and adds this to a variable containing the distance measured so far. This allows for cumulative movement to be recorded and assists in controlling the GUI response when scrolling through menus. The cumulative movement, mouseDeltaY, is passed to the handler, moveSelection, that in turn controls the menu selection.

Although this portion of the program interface is up and running, I have yet to mount the encoder strip and circuit board inside the B&O. I’m being held up by a lack of hardware.

The B&O’s sliding control has two small wheels originally designed for fine tuning radio stations.

B&O slider

I plan to convert these wheels to buttons that will allow the user to navigate through the menu system, however I’m having trouble finding micro-switches small enough for the job. If anyone out there knows of a suitable momentary switch (around 3 mm x 4 mm, and preferably in Australia) please let me know.

Bookmark the permalink. Both comments and trackbacks are currently closed.

One Comment