Clock Tools =========== This release consists of three small programs which together allow you to test and modify the performance of your PC/AT time functions. These programs will only work on AT class machines, they do not recognise the older XT type CMOS real time clocks. DCLOCKS.COM =========== This program is purely diagnostic in nature, it reads the date and time from the various sources in a PC and displays them. It will highlight several problems which may occur with the timekeeping functions within the PC. The display shows the time from three major sources..... 1. The time from the CMOS RTC chip, this is in Hrs:Mins:Secs 2. The time in Hrs:Mins:Secs calculated from the BIOS maintained RTC (18.2Hz). 3. The time in Hrs:Mins:Secs returned from the DOS operating system. The CMOS RTC is the most important real time clock in your PC system, this clock must maintain the time when your PC is turned off. It may consist of a chip on the motherboard with either a plug in battery or a small cell battery soldered directly to the board, or if you are lucky it will be an RTC module such as the DALLAS 1287/1287A. The chips with external batteries are usually MC146818A and use an external crystal running at 32.768Khz. The crystals used are typically unadjusted and may drift several minutes per month, drift in the +/-5 minutes per month is not unusual. The DALLAS RTC modules consist of a clock chip, adjusted crystal and battery in a solid block, pin compatible with the MC146818A. This module can be expected to drift less than +/-1 minute per month when running on it's internal battery. It will typically better this when your system is powered up. When you power up your PC the time supplied by your CMOS RTC is used to initialise the BIOS maintained clock which ticks at 18.2Hz. The clock used to provide this 18.2 per second interrupt may be derived either from the system (cpu) crystal or a crystal providing a clock for comms baud rate, speaker tones and clock. These crystals are typically not accurate enough to provide a long term stable time clock and so the 18.2Hz clock may be expected to drift significantly. When you ask DOS for the time of day, it is this 18.2Hz clock which is interrogated and used to calculate the time. It is very difficult to get to see the time maintained by the CMOS RTC, unless you write your own programs and make the required BIOS requests. How close would you expect the two clocks to be (CMOS and 18.2Hz BIOS clock)? You might be surprised to find they differ by up to 20 Seconds just after you have powered on your PC. When you initially boot your PC the point at which the CMOS time is read and the time when the BIOS clock is initialised may have several disc reads inbetween, and when booting from floppy this time can be many seconds. In most modern PCs the time may differ by only a second or two, but it is still a shock to most to find any variation at all. If you run DCLOCKS just after you have turned on your PC you will be able to see the Boot Offset for your machine. You will see that the time from the CMOS clock is shown, along with the BIOS time, ( which I calculate from the 18.2Hz clock ) and the DOS time. ( which DOS calculates from the 18.2Hz clock ) The difference between the DOS time and the BIOS time shown reflects the accuracy of the math used to get the time from the 32 bit counter of 'ticks past midnight'. To run a long term test on your clock to see the drift between the BIOS maintained and CMOS clocks there is a 'Run Time' maintained, BUT be aware that it is using the BIOS (18.2Hz) clock as its source. If your clocks vary by any significant amount you might like to bring the DOS and CMOS clocks together before running a long term test. Part of the CLKTOOLS release is a small program called CLKSYNC.COM, running this will synchronise the BIOS clock to the next second transition it senses from the CMOS RTC. (this program is explained later) DCLOCKS.COM can be loaded direct from the command line prompt and has one option switch available. If loaded without options, the program will display the time sensed synchronised with the second transitions of the CMOS clock. This option is more useful for long term testing. If the program is loaded as DCLOCKS /A then the display will not be synchronised with the second transitions in the CMOS RTC. You will notice that the lower seconds display will show each of the clocks moving from second to second as it occurs. DCLOCKS can therefore show you the initial Boot Offset error for your machine and if run for an extended period will show the drift between the clocks. You may also notice if you run for an extended period that the DOS maintained date may lose days (this was more of a problem in DOS 3.3x and 4.01 but it has been seen under DOS 5.00). The only reliable cure for this problem appears to be the utility built into Microsoft(R) Windows 3.1 which periodically corrects the date. Things to try ============= 1. Cycle the power on your PC, or use the Reset button to initiate a cold boot. Run DCLOCKS and record the clock error, it will vary from approximately 1-20 seconds depending on your PC type and speed. 2. Do a warm boot using CTL-ALT-DEL. Run DCLOCKS and record the clock error. The error will typically be in the .5-1 second range. 3. From the DOS command line prompt enter TIME, and set a new time. Run DCLOCKS and record the clock error. It will typically be 1-2 seconds. 4. If your PC is in a client/server environment, your time and date will usually be set to that of the server at boot time. DCLOCKS will allow you to see clock error imposed by this mode of operation. The results above are all affected by the system clock speed and the BIOS manufacturer. The table below shows the results for a generic 286 clone using AMI(R) BIOS. Function 8Mhz 16Mhz Cold Boot -2.60 -2.13 Warm Boot -2.36 -2.19 Set new TIME -0.62 -0.57 The results shown are averaged over 5 cycles, there is considerable variation in individual readings. While for day to day operation few users require accuracy in the DOS clock, many specialised applications can benefit from a more predictable clock. Simple process control and home control systems will be more reliable if the clock variations can be reduced. CLKSYNC.COM =========== This small program waits for the next second transition from the CMOS RTC to occur, and then uses this time value to update the BIOS maintained clock. The program may take up to one second to sync the clocks. CLKSYNC may be used within a network environment where the workstation is picking up the time from a server, which may be subject to considerable clock drift. Running the program from the Autoexec batch file AFTER the network software is loaded will bring the BIOS clock back to the locally (CMOS) set time. CLKSYNC uses BIOS functions to bring the clock into sync with the CMOS clock, and will typically set the clock within +/-55mS of the CMOS time. The program outputs a descriptive header when loaded, if this needs to be suppressed then simply re-direct it to NUL. i.e. CLKSYNC > NUL CLKSYNC will not keep the clocks in step, it does not install itself as a TSR. Use CLKSYNC to bring the clocks into sync before running a long term test using DCLOCKS. ZCLOCK.COM ========== ZCLOCK.COM is a small TSR (terminate and stay resident) program which checks the time returned from the BIOS clock with that in the CMOS clock about every 5 minutes. If the clocks vary then the BIOS clock is brought into line with the CMOS clock. The program does not synchronise with the second transitions in the CMOS clock, but simply brings the two clocks to within +/-5 ticks (18.2Hz ticks) of each other. This keeps the BIOS clock within +/-0.5 second of the CMOS clock at all times. If your CMOS clock is subject to drift, that will NOT be corrected by this program. The program outputs a descriptive header when loaded, if this needs to be suppressed then simply re-direct it to NUL. i.e. ZCLOCK > NUL The program cannot be unloaded once installed, so the PC must be re-booted to remove it. The program can be loaded high when using suitable memory manager software. Once resident, ZCLOCK will keep the BIOS time within +/-0.5 second of the CMOS clock, so the longterm accuracy is controlled by the CMOS clock. The CMOS clock will drift by an almost constant factor within the ratings of the device. If your clock drifts by +1.5 seconds per day during testing, it may be anticipated that it will maintain this within a close tolerance while the computer is on. The BIOS maintained clock, just like the CMOS clock will tend to lose or gain time by an almost constant factor, and so will tend to be corrected in the same direction each time by ZCLOCK. If the BIOS clock loses compared to CMOS time then ZCLOCK will maintain +0/-0.5 relative to the CMOS clock. While if the BIOS clock gains compared to CMOS time then ZCLOCK will maintain +0.5/-0 relative to the CMOS clock. The User Interface ================== To detect the presence of ZCLOCK.COM in it's resident state, or to access the programmable functions the user must communicate via the INT 2F (Multiplex) vector. The Multiplex vector is used by many processes and programs to communicate either with one another or with DOS. In most protocols register AX is loaded with pre-defined information and an INT 2F performed, on return to the user program the registers will usually have been changed in some manner if the information was recognised. This family of TSR programs respond on the basis of information passed in the AX, BX, CX, and DX registers and will return information in any of AX,BX,CX and ES:DI (used as an address pointer). All of these TSR's require AH=FE on entry with a pre-defined unique Product Code in BX for all bar Broadcast commands. The Product Code used for ZCLOCK.COM is 00A2(HEX). ZCLOCK.COM will respond to the following INT 2F possibilities. Installed check =============== On Entry: AX = FE00 BX = 00A2 (Product Code for ZCLOCK.COM) On Exit: ( ZCLOCK.COM is resident ) AX = FEFF BX = 00A2 ES = xxxx (ZCLOCK Segment address) DI = xxxx (ZCLOCK Database pointer) ( ZCLOCK.COM not resident ) All registers unchanged NOTE: ES:DI are used as a double word SEGMENT:OFFSET pointer to the storage area for the internal database used by ZCLOCK.COM. There is no user available data, but the SEGMENT value returned is correct. Product Broadcast ================= On Entry: AX = FEF0 BX = 0000 CX = 000F On Exit: ( If ANY of this family of TSR's present ) AX = FEFF BX = 00xx (xx=number of TSR's ) CX = 000F ( If NONE of this family of TSR's present ) All registers unchanged Integrity Checking ================== These programs include CRC checks on loading, any alteration to the program (ie. due to a Virus) will in most cases cause the program to abort the installation. ******************************************************************* If any program does advise that there has been a violation of its code, it is advised that you delete the file and reload a new copy from your backup disc. ******************************************************************* While the protection scheme built in will protect these programs from most attempts to modify the code, this works only during the installation phase. Your system should include a Virus protection scheme to provide more complete system wide coverage. WARRANTY ======== This product is supplied on an 'as is' basis and no responsibility as to its merchantability, functionality or applicability for any purpose can be accepted by the author or any associated persons or companies. No liability for any damages, either SPECIAL, DIRECT, INDIRECT, INCIDENTAL or CONSEQUENTIAL will be accepted by the author or any associated persons or companies arising out of or related to the use of this product or related documentation even if previously advised of the possibility of such damage or loss. Copyright Notice ================ (C) Copyright Jack Creasey 1992. All rights reserved. Non-Registered Shareware version. Revision Information ==================== Revision 1.00 11/91 Limited Beta test release. Revision 2.00 5/92 Integrity checking added. Shareware flags added. Revision 2.20 6/92 Use DOS division numbers for calculations by default. ZCLOCK drift limit dropped from +/-18 to +/-5 ticks.