I was looking at this schematic for an old (pre USB) mouse:

enter image description here

when I noticed it had a crystal on it (Y1). I was curious why a mouse would need a timer? Wouldn't it be able to use the clock from the computer? Also if it has its own crystal couldn't it get out of sync​ with the CPU clock?

  • 1
    Where did you get that schematic from? There are some errors: e.g. the polarity of the photodiodes is reversed. – Curd May 22 '17 at 14:38
  • 1
    @curd the schematic came from here: commodore.ca/manuals/funet/cbm/schematics/misc/index.html – Tyler H May 22 '17 at 14:49
  • 7
    Maybe the "crystal" is in reality just a ceramic resonator. BTW: Why do you expect that there is no clock generation inside a mouse? It is even likely that there are several subcircuits inside the computer, maybe even on the motherboard, that have their own clock generation (crystal oscillators). – Curd May 22 '17 at 14:49
  • 4
    As @OlinLathrop answer says, the mouse MCU isn't trying to be in sync' with the Host system's microprocessor (MCU). The mouse MCU just wants to be in sync' with the communications port, be it USB, RS232C or anything else. – TonyM May 22 '17 at 14:52
  • 5
    From your link, it appears this mouse was intended to spoof a joystick. If the joystick interface wasn't designed to have a clock signal, then there's no clock signal available for the mouse to use. – The Photon May 22 '17 at 16:05
up vote 25 down vote accepted

That MOS 5717 thing is most likely a microcontroller or some part that executes code. It needs a clock to run.

However, just a clock for a micro doesn't need crystal accuracy. That is probably for communication. USB requires a fairly high-accuracy clock.

A mouse doesn't need to track real time, and there is no reason for it to be in sync with the CPU clock. Its USB clock must only be close enough to the host's USB clock for communication to work. Timing about how fast mouse events are occurring or time between mouse events is handled in the host. The mouse just sends info about what it senses happening.

Added

The above was written in response to the original question, which made no mention of this mouse not being USB. Since pretty much all new mice have been USB for a decade or more, it was reasonable to answer in that context. When you ask about something unusual, it's your responsibility to make that clear.

Despite not having USB, this mouse still had a processor that needed to be clocked. It also apparently used timing to measure the positions of pots connected to a joystick, something else the OP failed to mention. It seems now that a comment by supercat is most relevant, so I am copying it into the answer:

The Commodore 64 has potentiometer inputs that measure the time required to charge fixed capacitors through variable resistances. Software expects that a mouse will read as a resistance value in the range 0-255, and that it will wrap cleanly 254, 255, 0, 1, etc. which means the mouse has to accurately time its output pulses to within less than 0.4%
  • 1
    @user2417339 Because the CPU clock isn't accurate enough. The crystal provide this lacking accuracy to the system – M.Ferru May 22 '17 at 14:53
  • 9
    The point is that for USB, both ends must have a reasonably accurate clock. So the mouse needs a crystal to make USB work. Why not use the clock from the host PC? The short answer is USB doesn't give the device a copy of the host clock. Why not is kind of complicated - lots of different things were being traded off against each other when USB spec was written, and that lost out. – Jack B May 22 '17 at 15:28
  • 2
    Downvoter, please explain what you think is wrong. – Olin Lathrop May 22 '17 at 15:30
  • 3
    @OlinLathrop: The Commodore 64 has potentiometer inputs that measure the time required to charge fixed capacitors through variable resistances. Software expects that a mouse will read as a resistance value in the range 0-255, and that it will wrap cleanly 254, 255, 0, 1, etc. which means the mouse has to accurately time its output pulses to within less than 0.4%. – supercat May 22 '17 at 16:15
  • 2
    @Jerry: Most of them are just wires with the only information being the color of the insulation. I figured two of them would be the USB D+ and D- lines, with others going to mouse buttons, maybe LED indicators, or whatever else fancy stuff this mouse might be doing beyond being just a mouse. – Olin Lathrop May 23 '17 at 13:51

The MOS 5717 has quite a bit of independent work to do on its own to create the mouse functionality from a set of optical encoders.

The description from the datasheet states it the best as,

The 5717 is a custom CMOS mouse controller for the Commodore 64. It will be housed in the body of a two button mouse, enabling it to be plugged into the 64 joystick port and provide mouse control of GEOS software,etc. It achieves the mouse function by grounding the SID chip's POTX and POTY lines at various times in the SID 512uS cycle to provide the 64 with positional information.

Before ADCs were free to add to just about any IC, the SID interface used the charge/discharge time created with potentiometer and an input integration capacitor to estimate the 'pot' value. The 5717 emulates a potentiometer with digital outputs by controlling the signal timing on the POT lines.

You can see such oscillator in many electronic device nowadays. A microcontroler execute operation at each tick. To control and understand what the µC is doing, you need an accurate clock. Most µC has a build in clock but it is not very accurate.

As said @Olin Lathrop, this accurate clock is needed eventually for the USB protocol or, for doing some measurement periodically...

Other answers have covered what the micro inside the mouse needs a clock for. However they haven't covered the most important parts of the question:-

Wouldn't it be able to use the clock from the computer?

The first thing to note is that the computer isn't giving it a clock. If there isn't one to use, you can't use it. Unless you want to set up a custom connector, of course - but then you need to persuade all your potential customers to hand-modify their computers. Unless your customers are all extremely hardcore electronics experts, this isn't going to be a successful business strategy!

More importantly though is the question of why the computer isn't giving it a clock. In order for the clock to be fast enough to run the micro in the mouse, it needs to be pretty fast - a few hundred kHz is the absolute minimum, and more normally you're up into MHz for even very old micros. The 5717 apparently expected a 4MHz clock. The problem here is that unless you're very careful about the cable construction, signal sourcing and sinking, and all the associated interesting aspects of fast digital comms, what you create when you put 4MHz down a cable is a radio transmitter. It absolutely is possible to do this well without broadcasting to the world - USB, DVI and HDMI manage to send digital data at high rates - but it's by no means straightforward. So people generally don't send clocks down long cables unless they've got a good reason to do so.

Also if it has it's own crystal couldn't it get out of sync​ with the CPU clock?

You're absolutely right that if the mouse produces data which the CPU has to read clock-synchronously, then the mouse will need the CPU clock. (Actually you can get by with a slower synchronous clock and multiply up at the other end, but let's forget that for the moment, for simplicity.) So, does it?

Again, looking at the system, the answer is clearly "no". The 5717 changes its resistance as the user moves the mouse. The user isn't going to move the mouse that fast, and the user can move the mouse whenever they like, so there's no requirement for it to be clock-synchronous. Worst case, the resistance changes partway through the CPU reading it, and the CPU either gets the lower value or the higher value. The next time around, the resistance stays steady and the CPU gets the final value. Since the mouse is only moving at the speed of the user's hand, no-one much cares about one sample more or less to get to the final value.

So, to answer your questions in reverse order:

  • It doesn't matter if it's out of sync with the CPU clock.
  • There are good technical reasons for not sending the CPU clock down a wire unless it's absolutely necessary, and in this case it isn't so they haven't.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.