
                             MouseClock Project
                                 Rev.  2.1f
                           26-Feb-95 / 18-Feb-00
                  Copyright (C) 1993-95  Adriano De Minicis


WARNING - WARNING - WARNING:
============================

THIS IS AN OLD PROJECT, I DON'T KNOW IF IT STILL WORKS WITH NEW 
AMIGAS/ACCELERATORS/OS. I DO NOT SUPPORT ANYMORE THIS PROJECT, SO
I HAVE RELEASED ALL DOCS HERE. BUILD AT YOUR OWN RISK.



WHAT IS IT?
===========

MouseClock is a hardware/software project of a low cost, very small external
battery backed up clock calendar for all Amigas (especially for A1200, A500,
A600).  It is connected to the mouse port #2.



REQUIREMENTS 
============

It works on all Amigas with OS1.2 or greater (tested on A1200, A2000, A500).
Some practice is required to build MouseClock.  If you have never built an
electronic circuit it's better to ask a friend for help.



CONTENTS
========

 1. Description
 2. Freeware notice
 3. Distribution
 4. Disclaimer
 5. Usage of MouseClock (hardware)
 6. Usage of SetMClock (software)
 7. Error messages and suggestions
 8. Hardware description
 9. Construction
10. Calibration
11. Thanks
12. Changes from v1.22 to 2.0


1. DESCRIPTION
==============

MouseClock, as stated before, is a very small external clock connected to
the mouse port #2 (GamePort).

There are two versions of MouseClock:

- The base version is very small, but you can't connect a joystick unless
  you remove the clock.

- The pass-through version has an auxiliary connector for the joystick and
  a switch to select between MouseClock and the joystick. The circuit
  consists of the base version plus few parts. The only drawback is that
  it's a little bigger (about 5 x 5.5 cm instead of 5 x 3.5 cm)

The advantages of an external clock are:

- Installing it does not void warranty.

- It is compatible with all Amigas: if, for example, you have an A500 and
  you plan to buy an A1200 you can move MouseClock from one computer to
  the other in a few seconds.

- It may be used as an emergency replacement for a damaged internal clock.

Someone may suppose that external is cumbersome and/or occupies the
joystick port:

- It's very small (the dimensions of my prototype on veroboard are: 
  44 x 35 x 16 millimeters).

- Adding a few parts you can build a "pass through" joystick version.
  With a switch you select MouseClock or the joystick.

- If you own an A1200 you can install MouseClock internally without
  opening your Amiga. How? Simply put it inside the rear opening under
  the disk drive (see the picture file "DemoPic1" for more infos)

How much it costs?

- Much less than an internal clock: components cost about 15$




2. FREEWARE NOTICE
==================

MouseClock is now FREEWARE.

I sold my Amiga two years ago, and since than I forgot this project...
Now I've received a request for the registration, but since I cannot
support anymore this project, I decided to release the schematics and
mounting plans, and all the source code, so all this is now FREEWARE.

The last change is in the software v1.23 (1998) due to someone
reporting me timeout problems with an accelerated A4000.

I DO NOT KNOW IF THE SOFTWARE STILL WORKS WITH THE NEW MODELS OF
AMIGA/ACCELERATORS/OS, AND I DO NOT SUPPORT THIS PROJECT ANYMORE.
SO THERE IS NO WARRANTY. BUILD AT YOUR OWN RISK.


3. DISTRIBUTION
===============

The files in this archive may be copied and distributed freely (also on
networks and CD-ROMs) as long as all the files remain unmodified and intact,
and as long as there is no charge for them except a reasonable copying and
media fee.

You are not allowed to sell MouseClock in commercial way (contact me for
agreements).

Adriano De Minicis
Via Latisana 37
33054 Lignano Sabbiadoro UD
Italy
email: adriadm@netanday.it



4. DISCLAIMER
=============

SetMClock sets as outputs some lines of the mouse port #2 (GamePort).
Remove any peripheral from that connector before running SetMClock, to avoid
damages to the peripheral and/or the Amiga.  Note: when SetMClock ends, the
mouse port returns to the standard configuration.

It is possible to connect a joystick to an auxiliary connector if you'll
build the pass-through version of MouseClock (only few additional parts
required).

WARNING
-------
NEVER insert or remove MouseClock when the Amiga is on, especially if you
haven't removed the metallic shield of the DB9 connector of MouseClock.  
In fact, pin 7 and 8 (+5V, GND) of the mouse port may be shorted by the
metallic shield of the other connector, shorting the Amiga!.  I STRONGLY
SUGGEST to cut the metallic shield from the DB9 female connector of
MouseClock (not Amiga!).  If you'll do this, there is no risk to short the
Amiga, however is always better not to insert/remove MouseClock when the
Amiga is on.
         
If you use an alkaline or lithium battery instead of the NiCd accumulator
(only from Rev.2.0) be sure to modify the circuit as stated in the
drawings. Alkaline and especially lithium batteries may EXPLODE if charged!


I CANNOT BE HELD RESPONSIBLE FOR ANY KIND OF DAMAGE CAUSED BY THIS PROJECT.
                 BUILD AND USE IT AT YOUR OWN RISK..ETC...



5. USAGE OF MouseClock (hardware)
=================================

Using MouseClock is simple: connect it to the mouse port #2 (gameport)
when the Amiga is off (read the warning notes above!).

Base version of MouseClock
--------------------------
Simply use SetMClock to access the clock (see below).

Pass-through version of MouseClock
----------------------------------
This version allows you to connect a joystick (not an analog joystick or
paddle) to the auxiliary DB9 connector.
Set the switch to the 'Clock' position before calling SetMClock (otherwise
SetMClock doesn't see the clock!). No damage occurs if you use a joystick
when the switch is in the 'Clock' position or vice versa.



6. USAGE OF SetMClock (software)
================================

SetMClock is the software to set the system time from MouseClock or vice
versa.  It's the replacement of SetClock.  Being written 100% in assembler,
it is quite compact (about 3K).

SetMClock requires the file "MClock.upd" (4 bytes) in the directory "S:" to
work properly.  This file is created the first time with the option 'save'.
It is necessary because the clock chip I've used doesn't save the year,
which must be saved on disk.  The year is automatically updated comparing
the current date with the date stored in the file (day, month any year of
the last 'save').  If the current date (read from MouseClock) precedes the
date stored in the file, then the year must be increased.  The only
situation that can cheat MouseClock is when the computer remains off from
the beginning of the new year to the month and day stored in the file.  For
example, if "MClock.upd" contains '15 Jan 1993' and MouseClock reads '10
Jan', then year is 1994; but if MouseClock reads '15 Jan' or later the year
is 1993, with the exception above mentioned.  To avoid this situation,
update the clock for example at the end of January, so that SetMClock has an
entire month to notice that the year is changed.

If you don't have a hard-disk, it's better to copy the file "S:MClock.upd"
in all the boot disks that make use of SetMClock.

WARNING: Do not run SetMClock if a peripheral other than MouseClock is
         connected to the mouse port #2. See the Disclaimer chapter.

NOTE: Do not run multiple copies of SetMClock since they interfere, giving
      wrong results (but there is no damage).


CLI/Shell Usage
---------------
SetMClock load     Set system time/date from MouseClock. Requires file 
                   "S:MClock.upd".
                   If you want to set system time every time you boot
                   the Amiga, include this command in the startup-sequence
                   (or user-startup).

SetMClock save     Store system time/date into MouseClock and into the file
                   "S:MClock.upd" (creating it if it doesn't exist).
                   Use the AmigaDOS command 'date' or the 'Time' prefs
                   (WB 2.0 or higher) to set the system time. Example:

                     date 1-jun-93 12:34
                     setmclock save

                   Note: when saving, seconds are reset. To reduce the
                   error, wait for seconds being near zero before running
                   SetMClock (or use the 'zero' option to correct seconds).

SetMClock zero     Reset seconds of MouseClock. If the seconds counter was
                   at position 30..59, time is advanced by one minute
                   (seconds are always reset).

SetMClock          Shows some help.


WorkBench Usage
---------------
Use a project icon which default tool is "SetMClock" (with path) and which
tooltypes are:

MODE=load  \
MODE=save   } Use ONLY ONE of this (equivalent to CLI option)
MODE=zero  /

The default tooltype is 'load'.

You can use the three icons I've supplied as examples. Attention: if you
move SetMClock to another directory (for example C:) you must modify the
default tool of those icons, including the complete path to SetMClock.

It's useful to start SetMClock from WB if you have booted the Amiga
from a disk that doesn't call SetMClock in the startup-sequence.



7. ERROR MESSAGES AND SUGGESTIONS
=================================

Can't find battery backed up clock
----------------------------------
MouseClock is not connected to the mouse port #2, or it doesn't work.
If you have the joystick version of MouseClock probably the switch is
not set to the 'clk' position.

Battery backed up clock not set
-------------------------------
MouseClock is found, but date and time are not set. This happens every time
the battery power fails, and thus also the first time.
If this error occurs every time you switch off the Amiga, then the battery
may be low or not connected. Check it (battery voltage must be greater than
2.2V).

Can't open S:MClock.upd
-----------------------
File "S:MClock.upd" does not exist or can't be opened.

Can't save S:MClock.upd
-----------------------
Probably the system disk is write protected.

Bad data in S:MClock.upd
------------------------
Garbage found in "S:MClock.upd". Restore with SetMClock save.



8. HARDWARE DESCRIPTION
=======================

To reduce the number of I/O lines (so that MouseClock can be connected to the
mouse port instead of the parallel port) I've used a clock chip with the I²C
bus (IC1, M 8716 produced by SGS-Thomson).  The other chip (IC2) interfaces
the Amiga and the I²C bus.  Diodes D1 and D2, connected to the I²C feedback
lines, avoid an excessive current flow from the battery to the Amiga when the
Amiga is off.  If the diodes are shorted, the current drawn from the battery
would be much higher than the current consumption of IC1, descharging the
battery too quickly.

From rev. 2.0 you can also use a cheaper alkaline (2 x 1.5V) or lithium
battery instead of the NiCd accumulator. In those case there is a slight
modification of the circuit, using two low drop schottky or germanium
diodes (you may try with normal silicon diodes like 1N4148, but the circuit
may not work (no damage)).


9. CONSTRUCTION
===============

This section refers to drawings that you'll receive with registration.
From rev. 2.0 there is a PCB (printed circuit board) layout for both
versions of MouseClock: if you want to build the pass-through version
use the entire part of the PCB, otherwise simply strip the unneeded
part (see drawings). Track layout is printed in three different modes:

   1:1 direct reading (view from the copper side) for those of you
       using transfer symbols.
       
   1:1 and 2:1 mirrored (view from the components side) for those of
       you using photoresist boards.

If you don't want to make a PCB, there is still the mounting plan for
veroboard (in this case only for the base version, since the modifications
required to add "joystick extension" are very simple and can be made with
flying wires). I suggest to use a thin wire-wrap wire (for example AWG 28)
to make the connections.

Once you've decided which version you want to build, you must decide the
battery type:

   a) Rechargeable 2.4V NiCd or NiMH (default, the type I suggest)
   
   b) Not rechargeable 3V: they must be changed when discharged.
      The energy absorbed by MouseClock is about 50 mAh/year (for example
      a battery of 200 mAh will last 4 years)
      Modify the circuit as shown (replace R1,R2 and T1 by D3 and D4)

      b1) Alkaline: cheap and easy to find (2 x 1.5V) but very big compared
          to the circuit.

      b2) Lithium: cheaper than NiCd but must be treated with great care

      b3) Normal carbon-zinc (2 x 1.5V): the cheapest and easier to find,
          but big and having high self leakage, so will probably last only
          one year. If you plan to use MouseClock for a limited period
          (waiting to buy a memory-turbo-board with clock) it's the
          cheapest solution.

If you use a NiCd, NiMH or lithium battery you must ensure that it fits
on the PCB, otherwise you've to modify the track layout. The maximum
diameter is about 20 mm. I've used a NiCd cell of about 15 mm diameter,
7 mm height. You can use the mounting plan drawing as a reference when
buying, since it has 1:1 scale.

Also important is the dimension of the compensator C2 to fit on the PCB.
You may also replace it with a fixed capacitor between 15 and 27 pF.
In this case you can't calibrate the clock (but it is quite precise: I've
used the compensator, but never calibrated it!)

And now let's go!

I suggest to use sockets for the two ICs, and to cut with a hack-saw the
metallic shield of the DB9 female connector.

Start by fitting the sockets, wire links, the two pins for the jumper, all
resistors and capacitors, the quartz, and the transistor (if required).
Next fit the diodes and the DB9 connector. Do not mount the battery. 

If you're building the pass-through version prepare the 8 conductors cable,
and solder the DB9 female at one of the ends (see drawings). Solder the other
end of the cable at the corresponding points of the PCB, being sure not to
swap wires (swapping 7 and 8 destroy MouseClock and can damage the Amiga,
so check twice!). Then solder the switch (S1) (PCB or panel type).

Make a first check of all connections, making sure that there are no short
circuits, expecially between the 5V line and ground (pins 7 and 8 of the
DB9 connector). A short circuit between these lines can damage your Amiga.
Be careful!. Don't be in a hurry to test the clock!

When you are sure that it's all ok, mount the battery (with the jumper not
inserted).  Make sure not to short the battery (use a insulated cable to
connect the negative pin of the battery, and don't lean the circuit on
metallic objects:  NiCd batteries don't like to be shorted!).  Make a second
check of all connections.  If there are no errors, insert the two integrated
circuits in their sockets, making sure they have the correct orientation and
they are not swapped.

WARNING: The clock chip (IC1) is a CMOS type, sensitive to electrostatic
         charges, so handle with care. Be sure to discharge your body
         (touch a ground plane) before handling the chip.

Another check, and then insert the jumper (that supplies the circuits).  If
you have built the joystick version set the switch to the 'clock' position.
Switch off the Amiga, connect MouseClock to the mouse port #2, and switch on
the Amiga.  From the WB, double click on the ClkLoad icon: if appears the
requester "Can't find battery backed up clock" you have done some error in
the circuit.  Switch off the Amiga, and check the circuit (may be the switch
is not in the 'clk' position).  If the circuit works properly you should see
the requester "Battery backed up clock not set" or "Can't open
S:MClock.upd".  Try to double click on the ClkSave icon: there shouldn't be
any message.  Retry with ClkLoad: if no message appears it's all O.K.,
congratulations!.  To see how to use SetMClock or for an explanation of the
error messages see the respective sections of this doc.

If the circuit doesn't work and you can't find the error, check if there is
a 1Hz square wave between pin 5 of IC1 and ground. If there isn't then
the quartz oscillator doesn't work: try adjusting the compensator.

NOTE: The NiCd battery is probably discharged when you build MouseClock.
      To recharge the battery leave the computer on for some hours (the
      charge time is usually 14 hrs, but it isn't necessary to leave the
      Amiga on for all that time, if you often use the Amiga).
      If you have a NiCd battery charger you can recharge the battery
      with it before soldering the battery to the circuit.

Have a good work!  :-)



10. CALIBRATION
===============

The calibration of the circuit can be omitted, since the clock is quite 
precise. For this reason you may replace the compensator with a fixed
capacitor.

If you have a frequency meter with good resolution at low frequencies (must
display fractions of Hertz), adjust the compensator until you read exactly
128 Hz on pin 8 of IC1.

If you don't have a frequency meter, the procedure is longer: if you notice
that the clock is too fast or slow after a week, turn the compensator a
little in one direction.  After another week check the error: if it is
decreased, the direction of the rotation is correct, otherwise, turn the
compensator in the opposite direction.  Many adjustments are needed to
reduce the error.



11. THANKS
==========

I wish to thank Roberto Borri for his suggestions and debugging,
all the registered users, Fred Fish for his great PD-collection, 
and the Commodore-Amiga for this wonderful computer.


12. CHANGES FROM v2.0 TO 2.1f
=============================

Added: new version of the clock program (SetMClock v1.23, see README
       for info), all the schematics and mounting plans.

NO MORE SUPPORT

