39
Kallisto Information Product Overview Software for use with the Kallisto Kallisto User’s Guide Click on any of the above hyperlinks to view the desired section. For further information about the Kallisto please email [email protected] or contact Greening Technology on phone +44-116-2796500 fax +44-116-2796501

Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

Kallisto Information• Product Overview

• Software for use with the Kallisto

• Kallisto User’s Guide

Click on any of the above hyperlinks to view the desired section.

For further information about the Kallisto please email

[email protected]

or contact Greening Technology on

phone +44-116-2796500fax +44-116-2796501

Page 2: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

Kallisto GPS CardLow Cost GPS time reference available in short ISA AT card format

Harness the precision time provided by the Global Positioning Service (GPS) satellites within yourcomputer. This low cost unit allows you to synchronise your equipment or PC system clock to microsecondaccuracy - banish those drifting clocks forever!

Key Features of the Kallisto GPS Card

· 16 bit half length AT bus card (8 data bits used but all AT IRQs available)

· Based on Rockwell 12 channel Jupiter GPS module

· Provides GPS position and time

· 1 pulse per second signal available as hardware interrupt and external output. Synchronised to secondboundary, accurate to one microsecond.

· External 1 pulse per second output qualified by software mask to allow triggering on specified secondtime mark.

· Two uncommitted TTL outputs.

· 10kHz frequency standard available as external output

· Requires only a simple external passive or active GPS antenna

· Battery back up of internal time of day clock to speed up acquisition of GPS time on power up

All specifications and accuracies subject to change.

Method of Operation

The Rockwell GPS module presents all of its output information as a series of packets over a serial data link.The data can be presented in either Rockwell binary or industry standard NMEA ASCII format. The AT cardcontains a UART to decode the serial stream and make it available to the PC bus. The UART design isfunctionally identical to a standard PC serial port so existing serial driver software can be used. Everysecond (binary mode) the GPS module generates a packet of 108 bytes. Amongst other things this packetcontains the current position and UTC time. The UTC time can be used to set the computer's operatingsystem clock.

1 of 3 01/09/97 11:46

Kallisto http://ion.le.ac.uk/kallisto/kallisto.html

Page 3: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

To obtain more precise timing information the module's 1 pulse per second (1pps) signal is used. This signalis synchronised to the second boundary and is connected to an IRQ and is also made available as an externaloutput. Clock driver software can be written to firstly obtain the initial time via the serial link and set theoperating system clock. The interrupt service routine for the 1pps signal simply increments the time by onesecond and then sets the operating system clock to the new time. Note: if this method is used the card willuse 2 IRQs - one for the serial port and one for the 1pps interrupt.

Qualified 1 pulse per second (PPS) output

A unique feature of this card is the qualified 1pps external output. the 1pps signal can be masked off with abit in a software register thus allowing external trigger signals to be generated at a specified time whilstretaining synchronisation with GPS time.

Software

The board is supplied with a Windows application to set the operating system clock. Programming is fairlysimple and full information is provided in the Rockwell manual which is supplied with the card. A DOS testprogram provided by Rockwell, together with the source code, is also available. A QNX driver is alsoavailable on request.

The Kallisto card can be used to provide a network time reference under Windows NT. TimeServ, currentlyprovided as part of the NT Resource Kit, is being enhanced to provide support for the Kallisto card.

Antennas

The antenna must have a clear unobstructed view of the sky. If the feeder length is less than about 2 metres alow cost passive antenna will be adequate. For feeders longer than 2 metres an active antenna should beused.

Suitable antennas and cabling can be supplied if required.

Applications include

· Synchronisation of equipment

· Master time reference for networked computer systems

· Accurate time stamp for data loggers and similar applications

· Positional information to 100m accuracy

For additional information and pricing contact:

Greening Technology30 Prospect RoadKibworth BeauchampLeicesterLE8 0HXUK

Tel: 0116 279 6500 Intl. +44-116 -279-6500Fax: 0116 279 6501 Intl. +44-116 -279-6501

email regarding Kallisto should be sent to: [email protected] will be forwarded to Greening Technology.

2 of 3 01/09/97 11:46

Kallisto http://ion.le.ac.uk/kallisto/kallisto.html

Page 4: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

Kallisto Software - what we do (and do not!) supply

The Kallisto is primarily a hardware product which is supplied with full programming information. Thefollowing software packages are either supplied as standard or on request. It is up to the user to determinethat they are suitable for their application.

Available Shortly

Tardis for Windows 95 and NT will soon incorporate direct support for the Kallisto receiver. Please seehttp://www.kaska.demon.co.uk for more information about Tardis.

Operating System Package

DOS Labmon47 - simple GPS receiver diagnostic and test program

Windows3.1/95 Utility to set operating system clock to within 10 milliseconds

Windows NT 4 Supported by TimeServ product

QNX 4 Task to set operating system clock to within 1 millisecond

Note: we do not supply any DOS programs to set the operating system clock

Labmon47

This program is written by Rockwell to support the Jupiter GPS receiver fitted to the Kallisto. It is capableof displaying all time, navigation and satellite information that the Jupiter is able to supply. It is suppliedwith the Kallisto in both executeable and source format. It is a DOS program and will also run in a WindowsDOS box.

Windows 3.1x/Windows95 Clock Utility

This is a 16 bit Windows application. It reads the time from the Kallisto and periodically sets the operatingsystem clock. The clock can be set to UTC (GMT) or any local offset from UTC. This program is suppliedwith the Kallisto in executeable format.

This program exploits the 1 pulse per second interrupt and sets the operating system clock within theinterrupt service routine. Overall accuracy is difficult to determine as it depends on whether another interruptpre-empts the service routine whilst the clock is being set. An accuracy of greater than 10 millisecondsshould be easily achievable.

TimeServ

This program is supplied as part of the Windows NT Server Resource Kit. The latest version, due to bereleased in mid 1997 will support the Kallisto. Prior to release, Greening Technology will supply, onrequest, a test version that supports the Kallisto. To use this software you must hold a valid licence for theNT4 Server Resource Kit. (This can be purchased at most computer bookshops)

TimeServ will set the operating system clock to an accuracy of better than the clock's resolution.(Approximately 10 milliseconds). The computer containing the Kallisto can then act as a master time serverfor other networked clients. For more information about TimeServ please click here.

1 of 2 01/09/97 11:46

Untitled http://ion.le.ac.uk/~jth/kallisto/software.htm

Page 5: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

QNX Clock Task

QNX 4 is a real time multi tasking operating system for the PC. It is ideally suited for control and datalogging applications. Because it is realtime it is possible to more fully exploit the Kallisto's high timeaccuracy. On request Greening Technology will supply, free of charge, the C source code to a task that setsthe operating system clock to an accuracy of the operating system ticksize. (0.5 milliseconds on reasonablyfast 486 and above platforms) This code can also be used as the basis for more sophisticated tasks asmessageing hooks have been included. Position and other navigation information can also be obtained usingthis program. NTP can be added to the platform to make the time available to other networked clients. (Notjust QNX, but DOS, Windows and UNIX as well). NTP for QNX can be downloaded free from QSSL.

Other Software

GPSS, Global Positioning System Software is a low cost package that shows your current position on amoving map display. Please consult the author's web page for more information.

FGT, Field Geometry Tool, will log positional data from the Kallisto. This software is primarily designed tobe be used with Greening Technology's Arcas Differential GPS surveying system, but will work with theKallisto but without differential corrections. Please contact [email protected] if you require this software.

The Kallisto card will work with most software packages that require NMEA protocol input.

What we don't support

Netware

Linux

Anyone wishing to contribute code for the above, or any other platform, is invited to [email protected]

All trademarks are acknowledged.

2 of 2 01/09/97 11:46

Untitled http://ion.le.ac.uk/~jth/kallisto/software.htm

Page 6: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

Kallisto UsersGuide

WARNINGRead this manual before connecting the antenna. Failure to

do so may damage the card.

Rev 1.00 22 December 1996

Page 7: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

1

Contents

Page

Introduction 2What is Supplied with the Kallisto 2Quick start 2

Installation 3Setting the Base Address 2Suggested UART Base Addresses 3Suggested Control register Base Address 4Setting the Hardware Interrupts 5Jumper Settings 5Fitting and Positioning the Antenna 6

Rear Panel Connectors 6

Programming 7Serial Link 7Example Code 9Register Descriptions 26Control Registers 26UART Registers 27

Installing the Windows Clock software 31

Labmon 47 32Trouble Shooting 32

Further Information about the GPS System 32

Board Layout 33

The Kallisto card is only intended for non safety critical applications. GPStiming may be lost if insufficient satellites are visible or if the antenna or itsfeeder are damaged. Strong local RF fields, particularly in the 1.5 GHz band,may affect the operation of the receiver. The user must exercise care inlocating, weatherproofing and maintaining the antenna and its feeder.

Page 8: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

2

IntroductionThe Kallisto GPS Timing Card uses the very latest Rockwell Jupiter GPS receiver module to make GPS time andposition available to the PC. The Jupiter receiver tracks up to 12 satellites to obtain a position fix and accurate UTCtime of day. This information is sent to the Kallisto board via a serial data link. The Kallisto interface circuitry faithfullyemulates a standard PC serial port thus allowing the Jupiter’s data stream to be easily collected by standard serialcommunications software routines.

In addition, the Jupiter receiver provides a 1 pusle per second (1 pps) output synchronised to the UTC second boundary.The Kallisto circuitry makes this signal available to the PC as a hardware interrupt (IRQ) allowing software routines tobe synchronised to microsecond accuracy. The 1 pps signal is also available as an external hardware output, togetherwith the 1 pps qualified by a software register. The qualified output will only track the 1 pps signal when the appropriateregister bit is set thus allowing external triggers to be generated on defined time boundaries.

When the PC is turned off the Jupiter’s real time clock and current position are maintained by a backup battery. Thisallows a position and time fix to be obtained in, typically, less than 30 seconds after power up.

What is Supplied with the KallistoThe Kallisto card is supplied with the following:• This manual• Rockwell’s Labmon47 DOS program that exercises the Jupiter GPS module fitted to the Kallisto• A simple Windows utility that sets the PC’s clock to within a second’s accuracy

The following are not supplied:• GPS antenna and feeder cable. This can be purchased from Greening Technology.• Software to handle the 1 pulse per second interrupt. It is almost impossible to know what the user wishes to use this

interrupt for, so it is left to the user to write suitable code.• QNX driver routines. This is available free on request from Greening Technology.• WindowsNT Timeserv. This utility sets the NT clock and makes time available on the network to other machines.

This is available free on request from Greening Technology.

All software is supplied on a sample basis only. The user is expected to determine whether or not the software meets hisrequirements and to fully test the final system. Most timing applications are specialised in nature and will usuallyinvolve some end user programming effort.

Quick StartThe following assumes that a serial port is not already fitted for COM3• Read the Installation section below, setting the UART address to 0x3E8 - COM3. Select an IRQ below 8• Turn bit 1 of SW2 off. This disables the 1 pulse per second interrupt circuitry.• Fit the Kallisto card and position the GPS antenna such that it has a clear view of the sky.• Connect the antenna and power up the computer.• Read the section about Labmon at the end of this section of the manual and the Rockwell Labmon documentation.• Run Labmon from a DOS prompt.• If the card is fitted correctly Labmon should show a display that updates once per second. If the antenna is correctly

positioned and fitted the display should indicate which satellites are visible. Note: from a cold start it can take up to20 minutes to obtain a 3D fix. This is because it takes at least 12 minutes to download a fresh almanac at 50 baud,the transmission rate from the satellites. The almanac is maintained by the back up battery, speeding up subsequentstarts considerably. At least 4 satellites need to be in track to obtain a 3D fix.

Please read this manual fully. The attached Rockwell documentation provides fullprogramming details for the Jupiter GPS module.

Page 9: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

3

InstallationThe card needs to be fitted into a standard 16 bit ISA slot. Two i/o space addresses have to be set. The first addressdetermines the base address of the UART - the serial interface device. The address can be set to any value where thereare 8 consecutive unused locations, but to retain compatibility with standard software routines only certain settings(listed below) should be used.

The second address sets the base address of the 1 pps control and interrupt registers. This base address is purposelyindependent of the UART base address to avoid conflicts with other i/o mapped devices - especially other serial ports.

There are 7 jumpers that need to be checked and adjusted if necessary, though for most users the factory defaults shouldbe fine.

After the card has been fitted the antenna needs to be correctly positioned and connected to the card.

Setting the Base AddressesIn the following discussion all base addresses are in hexadecimal. SW1 and SW2 set the base address of the controlregister and UART respectively.

A base address is a ten bit quantity that is most often expressed in fourhexadecimal digits. A hex digit can hold a value from 0 to 15 (decimal) and ismade up of four binary bits given weights of eight, four, two and one, hence themaximum value of 8+4+2+1=15.

A common serial port address is 3F8 hex. The example below shows how thehex digits are broken down into binary bits.

Binary bits 0 0 1 1 1 1 1 1 1 0 0 0

Bit weight 8 4 2 1 8 4 2 1 8 4 2 1

Sum of bits 0+0+2+1 8+4+2+1 8+0+0+0

Hex digits 3 F 8

0 0 1 1 1 1 1 1 1 0 0 0

These address bits are setby the switches, the othersare assumed to be 0

Page 10: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

4

on

off

1 2 3 4 5 6 7 8

Switch bit 1 of SW1 enables the control register, bit 1 of SW2 enables the UART. These switches should normally beON. If the switch is OFF the relevant part of the circuitry will not respond to any reads or writes and is effectively notconnected to the PC’s bus. If your application only needs to read the serial data stream from the Jupiter receiver and youhave no interest in the 1 pps signal and the associated interrupt you could turn SW1 bit 1 OFF. (This does not disablethe 1 pps signals to the rear D connector)

Switch bits 2-8 of SW1 set the base address set the base address of the control register. The same bits of SW2 set thebase address of the UART. The illustration above shows the circuitry enabled (bit 1) at base address 3E8 hex. Note theleast significant 3 bits of the address are always considered to be binary 0. (These would be switch bits 9-11).

Suggested UART Base AddressesThe UART can be set to any base address that does not conflict with other hardware, but it is advisable to set it to one ofthe four “COM” port addresses so that existing serial software can be easily used. Most PCs have two serial portsalready fitted - COM1 and COM2. COM3 and COM4 are usually free unless an internal modem card is fitted. TheKallisto board is shipped with the default setting of 3E8 - COM3.

Serial Port Base AddressCOM1 3F8COM2 2F8COM3 3E8COM4 2E8

Note: The base addresses for COM3 and COM4 are recommendations only as no official standard exists for these ports.However, most software respects these conventions.

Suggested Control Register Base AddressThe control register requires 8 consecutive free addresses. The following suggestions are guidelines only since it isimpossible to know what other hardware is already fitted to your PC.

Address Possible Conflict1801A0200 Game Port300 Prototype Adaptor, network card

3 E 8

Switch bit ON =binary 0

Switch bit OFF =binary 1

Page 11: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

5

Setting the Hardware Interrupts (IRQ)Jumper block J5 sets the 1 pps interrupt, block J6 sets the UART interrupt. Only one jumper should be fitted to eachblock. Different interrupts should be selected on each block unless interrupt sharing has been enabled (see later). Theselected interrupts must not be in use by any other hardware. The UART interrupt should be set to IRQ4 if its baseaddress has been set to COM1 or IRQ3 in the case of COM2. Note some software (especially Windows) defaults COM3to IRQ4 and COM4 to IRQ3. Do not use these interrupts if COM1 and COM2 are already fitted to your PC as they willconflict.

If the 1pps interrupt is not required by your application omit the jumper on block J5.

The above example shows a jumper fitted to IRQ 5. Note IRQs 0-2, 8 & 13 are reserved for system use. (IRQ 6 isnormally reserved for the floppy, 12 for a PS/2 mouse & 14 for the IDE disk interface)

Jumper SettingsThe following table summarises the jumper functions and their default settings.

Jumper Function when fitted Function when omitted DefaultJ1 power on defaults from ROM power on defaults from RAM omittedJ2 NMEA protocol Binary protocol omittedJ3 Jupiter reset connected to PC reset Jupiter reset not connected omittedJ4 Active antenna in use Passive antenna in use fittedJ7 Battery backup enabled Battery backup disabled fitted

J1When omitted this jumper causes the Jupiter module to read its power on defaults from onboard RAM. This minimisesthe time to the first valid fix. When fitted no reference is made to previously gathered data at power on. The Jupiter hasto gather all its information afresh. Time to the first fix can be several minutes.

J2When omitted the Jupiter uses the Rockwell binary data format over its serial link. When fitted the ASCII industrystandard NMEA protocol is used. NMEA format retains compatability with other GPS software, binary format allowsmore complex information to be obtained from the Jupiter. Note: in binary mode the serial link baud rate defaults to9600, in NMEA mode it defaults to 4800. The mode must be selected before power up. If NMEA mode is active andyou wish to switch to binary mode the Jupiter must be powered up with J2 omitted and J1 fitted. It is not sufficient toremove J2 as the communications mode is retained in onboard EEPROM which is not lost at power down. Alternativelyyou can send the appropriate NMEA message instructing a switch to binary protocol.

J3When fitted the Jupiter module is reset when the PC bus issues a reset. This will cause the module to reacquire its fix.

3456791011121415

Page 12: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

6

J4When fitted 5 volts is supplied to the centre conductor of the antenna connector. This is used to power an active antenna.

If a passive antenna is used this jumper must not be fitted. If it is theresultant short circuit will damage the RF front end of the Jupiter.

J7When fitted the card’s lithium battery maintains the Jupiter’s RAM and real time clock when the computer is powereddown. This speeds up the time to the first fix when the power is reapplied.

Fitting and Positioning the AntennaAn active antenna should normally be used with the Kallisto card. An active antenna contains an integrated pre-amplifierto boost the received signal. This allows reasonably long (several tens of metres depending on the type of cable used)feeder (feeder: the RF cable connecting the antenna to the card) lengths to be used. When J4 is fitted the Jupiterprovides 5 volts on the feeder’s centre conductor to power the antenna. Passive antennas are limited to about one metreof feeder.

If a passive antenna is used jumper J4 must be removed.Otherwise the Jupiter’s RF front end will be damaged.

The antenna should be sited such that it has a clear view of the sky with as much of the horizon visible as possible.Obstructing the antenna will restrict the number of satellites that can be acquired. At least 4 satellites are required toobtain a fix.

Rear Panel ConnectorsThe antenna connector is an SMA socket.

The following signals are available on the 9 way female D connector. All levels are standard TTL

Pin Signal1 Qualified 1 pulse per second2 1 pulse per second3 OUT04 OUT15 10 kHz6-9 Ground

Page 13: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

7

ProgrammingThe following sections give information on how to program the Kallisto card. Some utility programs are supplied withthe unit, but most applications will require some programming given the specialised nature of accurate timing. TheRockwell Jupiter programming manual is also supplied, but some concepts will be outlined here to familiarise theprogrammer with the card.

The block diagram above shows the main sections of the Kallisto card. The Jupiter receiver tracks the satellites andprovides position and time information over the serial link. The UART converts the serial data and makes it available tothe PC’s bus. The UART is fully register compatible with a standard PC serial port. Standard communicationssoftware, such as a terminal emulator, can be used to access this port. Many programming environments already supplysuitable driver code for accessing serial devices.

The receiver also generates a 1 pulse per second (1pps) signal, whose rising edge is synchronised to the secondboundary. The control logic turns this signal into a hardware interrupt generated every second. The 1 pps signal is alsobuffered to two hardware outputs - as a raw signal, and qualified with a software register within the control logic. Thequalified signal is only active when the appropriate control bit is set.

There are three other hardware outputs: two uncommitted signals whose state is determined by two bits of the controlregister and a 10kHz signal locked to GPS time. (There are exactly 10,000 pulses per GPS defined second)

Serial LinkThe Jupiter receiver can provide quite complex information about position, time, speed, satellite location etc and fulldetails are given in the accompanying Rockwell Jupiter programming manual. Obtaining the time, however, is quitesimple.

The serial link can be set to either provide data in Rockwell binary format or ASCII NMEA format. (See Jumpersettings in the installation guide) NMEA mode sets the link to 4800 baud, binary mode sets it 9600 baud. NMEA is aGPS industry standard and is useful if you have existing GPS software. It can also be useful as part of a simple boardconfidence test by using a terminal emulator program to read the data stream. A set of ASCII parameters, all startingwith a $ symbol, should be printed every second. Binary mode provides more information from the receiver and isprobably easier to program since string handling is avoided. The following discussion assumes binary mode.

Note: there is no provision for either hardware or software flow control over the serial link. Your application must beable to receive the data at the rate it is transmitted.

The modem control lines DCD, DSR and DTR are physically connected to each other, as are CTS and RTS.

Unless the receiver is otherwise programmed, it generates a 55 word (110 bytes) packet every second. This packet,called message 1000, is one of 13 output messages. Message 1002 is also sent once per second but after message 1000.Message 1003 is sent after message 1002 but only every 30 seconds. (This may change for subsequent revisions of theJupiter firmware) These messages may be ignored, except that the application’s receive buffer should be large enough to

UART Jupiter Receiver

ControlLogic

AT Bus

SerialLink

1 pulse persecond signal

HardwareOutputs

Antenna

Page 14: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

8

cope with the total length of messages 1000, 1002 & 1003. The remaining messages are only transmitted upon request(except for message 1011 which is sent once at power up/reset). To determine UTC time and position simply set yourserial software to capture message 1000 into a buffer and then decode the contents of the buffer. The Rockwell manualfully describes the contents of the message. Your software should check that the Number of MeasurementsUsed in Solution field returns a value of 4 or more and that the Solution Invalid field returns 0 before thetime and position are assumed to be accurate.

If your application only requires time resolution to one second you only need to decode the message packet. If, however,you require greater accuracy you should activate the 1 pps hardware interrupt. The interrupt will occur within onemicrosecond of the UTC second boundary. Your 1 pps interrupt service routine will then perform its task at a preciselydetermined time (within the constraints of other system interrupts/tasks). To timestamp the interrupt it is necessary toread message 1108 as well as message 1000. This is because message 1000 is poorly syncronised with respect to the 1pps interrupt and may be emitted before or after the pulse. In order to resolve this ambiguity message 1108 is provided.This message is always sent a fixed time before the pulse. It indicates the number of UTC seconds since the start of theweek (midnight Sunday). Obviously, this message does not provide enough information to fully construct the date andtime. To do this:• Ensure that message 1108 is turned on.• Read message 1000. Repeat until number of satellites used in calculation is >3. Fix is then valid.• Calculate the time of the start of the current week (usually in seconds past 1/1/1970 in most operating systems) from

message 1000 UTC time information.• Turn off message 1000 so as not to disturb the timing of message 1108• Flush serial buffers and wait for next message 1108• Read seconds into week, add time of start of week already determined. Use this value to initialise a count variable.• Turn on message 1000.• Wait for interrupt, set operating system clock from count variable, and increment count variable.• Repeat above step for as long as the fix is indicated as valid by reading message 1000.• If fix becomes invalid go to the first step.

Messages are turned on or off by sending a header only message to the Jupiter. See section 1.2 of the Zodiac Serial DataInterface section of the Rockwell Programming Manual. The next section gives programming examples.

Most multitasking and or real time operating systems already provide interrupt driven drivers to read serial ports, soreading the serial data stream is simply a question of making calls to the correct driver. Windows 3.1 and Windows 95also provide serial drivers whose parameters are set up in the appropriate control panel. The relevant Windowsprogramming documentation should be consulted for further information. MS-DOS programmers have a harder task inso far as they have to provide their own software to read the serial port. If your application is reasonably simple BIOScalls can be made to read the port. (Usually called _bios_serialcom() by most C compilers) More demandingapplications will need an interrupt driven driver. The book “C Programmer’s Guide to Serial Communications” by JoeCampbell, published by SAMS, ISBN0-672-22584-0, gives a useful introduction to the subject. The source codeprovided with Rockwell’s Labmon software also give an example of how to communicate with the UART.

Page 15: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

9

Example CodeThe following code examples are from a QNX program to set the operating system clock. It can be easily adapted tosuit other environments.

GPSCLOCK.C//gpsclock.c////Reads GPS time from the Kallisto card and sets the qnx operating system//clock.////The Kallisto card mimics a standard serial port. The UART base address and//IRQ of the card should be set up so as not to clash with other hardware.//Dev.ser should then be set up so as to recognise the Kallisto card as a serial//port, with the baud rate set to 9600 baud, 8 bits, 1 stop bit, no parity.////The CONTROL base address and IRQ of the Kallisto card should also be set//so as not to clash with any other hardware. These values should also be//different to the UART values. Please see the user’s guide for more//information.////This task must be compiled and run as root////Note: This software only tested under 32 bit QNX (Proc32)#ifdef __USAGEgpsclock -d <serial port> -p <control base address> -i <control IRQ> -o offset

where <serial port> is the name of the serial port allocated to the Kallisto card by Dev.ser. eg /dev/ser3 <control base address> is the base address of the Kallisto control register in HEXADECIMAL eg 300 <control IRQ> is the IRQ setting for the Kallisto control register eg 11 <offset> is the desired offset in hours between operating system time and UTC time. eg 1.5 will set the os clock 90 mins ahead of UTC.

example: gpsclock -d /dev/ser3 -p 300 -i 11 -o 1

All arguments, except -o, must be specified - there are no defaults-o defaults to zero#endif

/*How this Program Works======================

It is assumed that the Kallisto board is jumpered for Rockwell Binary format.

Messages from the Jupiter’s serial port are read in by a dev_read() intoa buffer. For timing purposes two messages are of interest: msg 1000 andmsg 1108. msg 1000 is sent by the Jupiter every second and, amongst otherthings, tells us:

How many satellites are being used. (At least 4 are required) UTC date and time

msg 1000 is poorly syncronised to the 1 pulse per second hardware signal thatgenerates an interrupt that is serviced by this program. This means that theUTC time can be inaccurate by +- 1 second. This is resolved by reading msg 1108which gives:

UTC seconds since the start of the current week

msg 1108 is synchronized to the 1 pps pulse and is emitted at a constant offsetto the pulse.

So to construct the current time we need to:

1 Read msg 1000 one or more times until at least 4 satellites are used2 Find out the time of the start of the current week from msg 10003 Turn off msg 1000 so as not to disturb the timing of msg 11084 Add the seconds from start of week obtained from msg 1108 to the already calculated time of the start of week.5 Use this value to initialise a counter that is incremented every time the 1 pps interrupt occurs.6 Turn on msg 10007 Keep checking that at least 4 satellites are in view, ie a valid fix.

Provided that the fix is valid the time counter is used to set the operatingsystem clock every interrupt. If the fix becomes invalid the os clock is notset and we go back to step 1 above.

Page 16: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

10

Leap Seconds============

From time to time UTC timeis corrected by a second to account for changes inthe Earth’s rotational speed. The GPS satellites use GPS time, which was thesame as UTC when the system was first turned on but has had no leap secondsadded. The satellites also broadcast the current offset between GPS time andUTC. (11 seconds on 12 September 1996). msg 1000 gives both GPS and UTC timevalues. The program detects any change in the difference between the two. Ifa difference occurs the fix is considered invalid and the time is recalculatedfrom step 1 above. Note: this part of the code has not been tested as a leapsecond has not occurred since the code was written.

Monitoring msg 1000===================

Other tasks can request the decoded contents of msg 1000 by Send() ing amessage of type struct req_msg. This task will reply with struct msg_1000after the next 1 pps interrupt. The Send() ing task can use this informationto record the fix status in a log etc.

*/#include <math.h>#include <i86.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <unistd.h>#include <errno.h>#include <fcntl.h>#include <conio.h>#include <termios.h>#include <sys/kernel.h>#include <sys/sched.h>#include <sys/types.h>#include <sys/stat.h>#include <sys/dev.h>#include <sys/name.h>#include <sys/irqinfo.h>#include "kallisto.h"#include "jupiter_utils.h"#include "msg_1000.h"#include "msg_1108.h"#include "msg_1221.h"

#define DEBUG /* turn debug printing to console on or off */

pid_t proxy; //process id of the proxy. This proxy is triggered by the //1pps interrupt service routine.volatile int counter; //incremented by interrupt service routinevolatile time_t time_count; //UTC time kept here

//interrupt handler//the pragmas are important!#pragma off( check_stack );pid_t far handler(){ clr_irq(); //clear the interrupt counter++; //if this get to be >1 then missed processing an irq time_count++; return(proxy); //this triggers the proxy }#pragma on( check_stack);

void main(int argc, char *argv[]){ static short msg_buff[2048]; //messages from the serial link received here static struct msg_1000 m1000; //decoded message 1000 put here static struct msg_1108 m1108; //decoded message 1108 put here struct timespec tv; //time used to first set OS clock put here time_t start_of_week; //time of start of UTC week int status; unsigned stat; int cbase=0; //control register base address int irq=0; //control IRQ char device[80]; //serial port device name int id; //return fro qnx_hint_attach; int fd; //file descriptor of serial port extern cntrl_base_address; //global used in utils.c pid_t tpid; //pid of task that just sent a message int first_irq=YES; //flag for first interrupt int msg_count; //size of serial packet received int set_clock_flag=NO; //set to yes when valid time_count valid

Page 17: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

11

int valid_fix=NO; //set to yes when valid fix obtained int msg1108_on_flag=NO; //set to YES when msg 1108 on & msg 1000 off float offset=0; //local time offset to UT

#ifdef DEBUG printf("GPSCLOCK loaded\n");#endif

//initialise variables device[0]=’\0’; //empty string m1000.packet_status=(-5); //see msg_1000.h for more details

//check the arguments while((status=getopt(argc,argv,"d:p:i:o:")) !=(-1)){ switch(status){ case ’d’: //device sscanf(optarg,"%s",device); break; case ’p’: //port sscanf(optarg,"%x",&cbase); cntrl_base_address=cbase; break; case ’i’: //irq sscanf(optarg,"%d",&irq); break; case ’o’: //offset sscanf(optarg,"%g",&offset); break; case ’?’: //error printhelp(); break; default: //should never get here! fprintf(stderr,"getopt - bad switch!\n"); exit(-1); } }//did we get all the arguments? if(irq==0||cbase==0||device[0]==’\0’)printhelp();//do a bit of sanity checking if(cbase<0x100||cbase>0x3ff){ fprintf(stderr,"Control base address out of valid range 0x100-0x3ff\n"); printhelp(); } if(irq<3||irq>15||irq==8||irq==13){ fprintf(stderr,"Control IRQ setting %d invalid\n",irq); printhelp(); }//check task is running as root if(geteuid()!=0){ fprintf(stderr,"gpsclock must run as root\n"); exit(-1); }

//register name with the operating system if((qnx_name_attach(0,GPSCLOCK_NAME))==(-1)){ perror("Unable to register task’s name, qnx_name_attach():"); exit(-1); }

//set task’s priority if((setprio(0,GPSCLOCK_PRIORITY))==(-1)){ perror("Unable to set task’s priority, setprio():"); exit(-1); }#ifdef DEBUG printf("GPSCLOCK registered with OS and priority set\n");#endif

//open the serial port fd=open(device,O_RDWR|O_NOCTTY); if(fd==(-1)){ fprintf(stderr,"Could not open serial port %s\n",device); perror("open():"); exit(-1); }

//set the port to raw mode stat=dev_mode(fd,0,_DEV_MODES); if(stat==(-1)){ perror("Could not set raw mode, dev_mode():"); exit(-1); }#ifdef DEBUG printf("GPSCLOCK serial port opened and set to raw mode\n");#endif

Page 18: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

12

//attach the proxy proxy=qnx_proxy_attach(0,0,0,-1); if(proxy==(-1)){ perror("Unable to attach a proxy. qnx_proxy_attach():"); exit(-1); }#ifdef DEBUG printf("GPSCLOCK proxy attached\n");#endif

//initialise the board disable_irq(); clr_irq();

//attach interrupt if((id=qnx_hint_attach(irq,&handler,FP_SEG(&counter)))== -1){ perror("Unable to attach interrupt,qnx_hint_attach():"); exit(-1); }#ifdef DEBUG printf("GPSCLOCK interrupt attached\n");#endif

//empty the input serial stream status=tcflush(fd,TCIFLUSH); if(status!=0){ perror("tcflush failed"); exit(-1); }#ifdef DEBUG printf("GPSCLOCK serial stream flushed\n");#endif

//turn off messages that are not required status=set_message(fd,1002,OFF,NONE,NO_CHANGE,0,0,0); status+=set_message(fd,1003,OFF,NONE,NO_CHANGE,0,0,0); status+=set_message(fd,1135,OFF,NONE,NO_CHANGE,0,0,0); if(status!=0){ printf("A call to set_message failed\n"); exit(-1); }

//ensure message 1000 is on status+=set_message(fd,1000,ON,NONE,LOG,ONTIME,1,0); if(status!=0){ printf("A call to set_message failed\n"); exit(-1); }#ifdef DEBUG printf("GPSCLOCK messages set\n");#endif

//make sure that position pinning and ground track smoothing are off//as this affects the accuracy of the 1pps pulse status=send_msg1221(fd,GTSD|PPD,NONE); if(status!=0){ printf("send_msg1221 failed\n"); exit(-1); }

#ifdef DEBUG printf("Waiting for first 1 pps IRQ....\n");#endif enable_irq(); //turn on the interrupts status=tcflush(fd,TCIFLUSH); tpid=Receive(proxy,NULL,0); //wait for the irq from the 1pps signal status=tcflush(fd,TCIFLUSH);

#ifdef DEBUG printf("received\n");#endif

//done all the setting up so time for the main loop for(;;){ status=tcflush(fd,TCIFLUSH); //read the packet from the serial stream msg_count=get_packet(fd,msg_buff); if(msg_count==40&&msg1108_on_flag==NO){ //picked up 1108 by mistake msg_count=get_packet(fd,msg_buff); //look for 1000 again }#ifdef DEBUG printf("\nmsg_count=%d\n",msg_count);#endif if(msg_count!=0){ //check the packet contents

Page 19: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

13

if(msg1108_on_flag==NO){ //must be looking at msg 1000#ifdef DEBUG printf("msg 1000 processing\n");#endif status=decode_msg1000(msg_buff,&m1000,msg_count); if(status==0){ //valid packet#ifdef DEBUG printf("Valid msg 1000 packet\n");#endif

//get start of week start_of_week=calc_start_of_week(&m1000); if(start_of_week!=0){ //enough satellites in view valid_fix=YES; //switch over to looking at msg 1108 //check for leap seconds status=check_for_leapsecond(start_of_week,&m1000); if(status==1){ //found a leapsecond valid_fix=NO; set_clock_flag=NO; } if(set_clock_flag==NO&&valid_fix==YES){ //time_count currently invalid //got start of week time so turn off msg 1000 status=set_message(fd,1000,OFF,NONE,NO_CHANGE,0,0,0);

if(status!=0){ printf("A call to set_message failed\n"); exit(-1); } msg1108_on_flag=YES; } } else{ valid_fix=NO; //not enough satellites in view set_clock_flag=NO; } } else{ //invalid packet - ensure we are receiving msg 1000 status=set_message(fd,1000,ON,NONE,NO_CHANGE,0,0,0); if(status!=0){ printf("A call to set_message failed\n"); exit(-1); } //flush the input buffer status=tcflush(fd,TCIFLUSH); if(status!=0){ perror("tcflush failed"); exit(-1); } msg1108_on_flag=NO; valid_fix=NO; //deem it a bad fix set_clock_flag=NO; } } //end of 1000 mode else{ //must be decoding message 1108#ifdef DEBUG printf("msg 1108 processing\n");#endif status=decode_msg1108(msg_buff,&m1108); if(status==0){ //valid packet time_count=calc_time_now(&m1108,start_of_week);#ifdef DEBUG printf("Valid msg 1108 packet\n"); disp_secs(m1108.UTC_sec_week); printf(ctime(&time_count));#endif if(time_count!=0){ //valid time obtained time_count--; //timecount incremented by isr set_clock_flag=YES; } }

//got a good time_count value so turn on 1000 status=set_message(fd,1000,ON,NONE,NO_CHANGE,0,0,0); if(status!=0){ printf("A call to set_message failed\n"); exit(-1); } msg1108_on_flag=NO; } //end of 1108 mode } enable_irq(); //turn on the interrupts

tpid=Receive(proxy,NULL,0); //wait for the irq from the 1pps signal if(msg1108_on_flag==YES){ status=tcflush(fd,TCIFLUSH); }

Page 20: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

14

//at this point the 1 pps interrupt has just happened#ifdef DEBUG printf("(proxy receive) Message received from %d\n",(int)tpid); ptime ("After proxy receive");#endif //if no data, first irq or missed irq or bad fix don’t set os clock if(first_irq==YES||counter>1||msg_count==0||valid_fix==NO||set_clock_flag==NO){#ifdef DEBUG printf("***Chucked irq: counter=%d msg_count=%d set_clock_flag=%d valid_fix=%d\n",counter,msg_count,set_clock_flag,valid_fix);#endif counter=0; //reset the isr counter first_irq=NO; //and do nothing } else{ //packet and irq valid so set clock assuming gps fix valid counter=0; if(set_clock_flag==YES&&valid_fix==YES){ set_os_clock(time_count+(time_t)(offset*3600)); } m1000.UTC_tod=time_count; //saved for use by monitoring tasks }

check_message(&m1000); //see if any other task wants message 1000 }//end of main loop }//end of main

//*****************************************************************************

//prints help message saying what the command line arguments should be//and then exitsvoid printhelp(){ fprintf(stderr,"\n\nInvalid or missing command line arguments\n"); fprintf(stderr,"The correct form is:\n"); fprintf(stderr,"gpsclock -d <serial port> -p <control base address> -i <control IRQ> -o <offset>\n\n"); fprintf(stderr,"Type \"use gpsclock\" for more information\n"); exit(-1); }

//receives a packet from the GPS card via the serial port//returns the number of bytes readint get_packet(int fdes,short msg_buff[]){ int status;

status=dev_read(fdes,msg_buff,BUFF_SIZE,BUFF_SIZE,GAP,0,0,0); if(status==(-1)){ perror("Failed to get data from serial port, dev_read():"); exit(-1); }

return(status); //return no of bytes read }

//returns time in seconds past 1/1/1970 to the start of the current week//using the contents of msg_1000. A later read from msg_1108 gives the//number of seconds into the current week. The exact time cannot be//calculated from msg_1000 because msg_1000 emerges from the Jupiter at//an ill defined moment.////returns: time of start of week or 0 if the satellite fix is invalidtime_t calc_start_of_week(struct msg_1000 *st){ struct tm t,*ttt; time_t tt; int status;

if(st->soln_invalid!=0)return(0); //not a valid solution if(st->no_meas<4)return(0); //not enough satellites

//extract the current(ish) time from msg_1000 t.tm_year=st->utc_year-1900; t.tm_mon=st->utc_month-1; t.tm_mday=st->utc_day; t.tm_hour=st->utc_hrs; t.tm_min=st->utc_mins; t.tm_sec=st->utc_secs; t.tm_isdst=0;

tt=mktime(&t); //converts to secs past 1 Jan 1970

ttt=gmtime(&tt); //back to a structure! - but this time we know //tm_wday ie how far into the week it is

Page 21: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

15

//go back to the start of the week ttt->tm_mday=ttt->tm_mday-ttt->tm_wday; ttt->tm_wday=0; ttt->tm_hour=0; ttt->tm_min=0; ttt->tm_sec=0; ttt->tm_isdst=0;

tt=mktime(ttt); //now at seconds to start of week

if(tt==((time_t)(-1))){ printf("calc_start_of_week: mktime failed\n"); exit(-1); }

return(tt); }

//calculates time of next 1 pps pulse and puts it into tvv structure//m: previously decoded contents of msg 1108//sow: previously decode time of start of week in seconds////returns: 0 if invalid fix// else time now in seconds past 1/1/1970time_t calc_time_now(struct msg_1108 *m,time_t sow){ if(m->TM_valid==0){ //time not valid return(0); } if(m->UTC_sec_week<3||m->UTC_sec_week>604797){ return(0); //near start of week so information obtained from msg 1000 //might refer to the wrong week, so best ignored } return((time_t)(sow+m->UTC_sec_week)); }

//sets the operating system clockvoid set_os_clock(time_t tc){ int status; struct timespec tvv;

tvv.tv_sec=tc; tvv.tv_nsec=0;

status=clock_settime(CLOCK_REALTIME,&tvv); if(status!=0){ perror("Failed to set os clock,clock_settime():"); exit(-1); }#ifdef DEBUG printf(ctime(&tc)); ptime("os clock set");#endif }

//looks to see if any other task has requested the contents of message 1000void check_message(struct msg_1000 *m){ pid_t tpid; int status;time_t t;

struct req_msg rmsg;

while((tpid=Creceive(0,&rmsg,sizeof(rmsg)))!=(-1)){

if(tpid==proxy){ //should never get a messge from the proxy printf("Proxy sent a message at the wrong point!!\n"); exit(-1); }

if(rmsg.type!=’R’||rmsg.msg_type!=1000)return; //wrong sort of message

status=Reply(tpid,m,sizeof(struct msg_1000)); //reply with msg_1000 if(status==(-1)){ perror("Reply failed"); exit(-1); } } return; }

//Checks to see if a leap second has occurred by looking at the difference//between gps and utc time.//

Page 22: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

16

//sow: previously calculated seconds from 1/1/1970 to start of current week//m: pointer to previously obtained msg 1000 contents////returns: 0 if no leapsecond// 1 if leapsecond detectedint check_for_leapsecond(time_t sow,struct msg_1000 *m){ static time_t current_diff; //GPS-UTC seconds time_t old_current_diff; time_t UTC_secs_from_sow; //UTC seconds into current week time_t t; struct tm tt;

old_current_diff=current_diff;

//calculate UTC seconds from 1/1/1970 from msg1000 information tt.tm_sec=m->utc_secs; tt.tm_min=m->utc_mins; tt.tm_hour=m->utc_hrs; tt.tm_mday=m->utc_day; tt.tm_mon=m->utc_month-1; tt.tm_year=m->utc_year-1900; tt.tm_isdst=0;

t=mktime(&tt);

//find UTC seconds from start of week UTC_secs_from_sow=t-sow;

//find current leapseconds current_diff=(time_t)m->gps_sec-UTC_secs_from_sow;

if(old_current_diff==current_diff)return(0); else return(1); }

//for debugging onlyvoid ptime(char *str){ struct timespec tt; struct tm *ttt;

clock_gettime(CLOCK_REALTIME,&tt); ttt=gmtime(&tt.tv_sec); printf("============%s %d %d %09d\n",str,ttt->tm_min,ttt->tm_sec,tt.tv_nsec); }

void disp_secs(long secs_week){ int day=0; int hour=0; int min=0; int sec=0; int tmp1,tmp2,tmp3;

day=secs_week/86400; tmp1=(secs_week-(day*86400)); hour=tmp1/3600; tmp2=(tmp1-(hour*3600)); min=tmp2/60; sec=tmp2-(min*60); printf(" %1d %2d:%2d:%2d\n",day,hour,min,sec); }

UTILS.C//utils.c////Low level utility routines for use with the Kallisto GPS board

#include <conio.h>#include <stdio.h>#include "kallisto.h"#include "msg_1000.h"

int control; //A record of what we write to the control registerint cntrl_base_address; //base address of the control register. This must be //set before any of the routines below are used.

//writes to the control registervoid write_control(int contents){ outp(cntrl_base_address+CTRL_REG,contents); }

//reads the status registerint read_stat(){ return((int)(inp(cntrl_base_address+STAT_REG)&0x01)); }

Page 23: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

17

//enables 1pps IRQvoid enable_irq(){ control=control|0x01; write_control(control); }

//disables 1pps IRQvoid disable_irq(){ control=control&0xfe; write_control(control); }

//enable qualified 1pps outputvoid enable_q1pps(){ control=control|0x02; write_control(control); }

//disable qualified 1pps outputvoid disable_q1pps(){ control=control&0xfd; write_control(control); }

//sets OUT0void set_out0(){ control=control|0x10; write_control(control); }

//resets OUT0void reset_out0(){ control=control&0xef; write_control(control); }

//sets OUT1void set_out1(){ control=control|0x20; write_control(control); }

//resets OUT1void reset_out1(){ control=control&0xdf; write_control(control); }

//clears 1pps interruptvoid clr_irq(){ outp(cntrl_base_address+IRQ_CLR,0); }

JUPITER_UTILS.C.//jupiter_utils.c////routines to control binary messages to/from Jupiter#include <math.h>#include <i86.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <unistd.h>#include <errno.h>#include <fcntl.h>#include <conio.h>#include <sys/kernel.h>#include <sys/sched.h>#include <sys/types.h>#include <sys/stat.h>#include <sys/dev.h>#include <sys/name.h>#include <sys/irqinfo.h>

#include "jupiter_utils.h"

//Enables/disables a message//If enabled the message is output at its default rate////fd: file descriptor of serial port assigned to Kallisto//message: message id eg 1000//state: message turned ON or OFF

Page 24: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

18

//acknowledge:// Setting this to NONE causes no response from the Jupiter to this packet// ACK causes the Jupiter to respond with a 1221 header only// packet if this message is sent with no errors// NAK causes the Jupiter to respond with a 1221 header only// packet if this message is sent with errors// ACKNAK causes a response with a 1221 header only packet// if this message is sent with or without errors////lq:// Setting to NO_CHANGE does not alter the output timing parameters of the// packet.// LOG changes the output timing to once every <interval> seconds// with an initial output starting <offset> seconds from now.// QUERY causes the packet to be transmitted once//////trigger: when set to ONTIME and lq==LOG packet will be transmitted every// <interval> seconds with an initial <offset> seconds delay.// when set to UPDATE the packet will only be transmitted when its// contents have changed.////interval: only relevant if lq==LOG and trigger==ONTIME. Determines the ouput// rate in seconds of the packet.////offset: only relevant if lq==LOG and trigger ==ONTIME. First packet is// transmitted <offset> seconds from now. If offset==60 the first packet is transmitted 0// seconds from the next minute boundary.int set_message(int fd,int message,int state,int acknowledge,int lq,int trigger, unsigned short interval,unsigned short offset){ unsigned short buf[14]; ssize_t status;

//set up message to be sent to Jupiter buf[0]=0x81FF; //sync word buf[1]=(unsigned short)message; //message id buf[2]=0; //header word only message if(state==ON)buf[3]=0x4000; else buf[3]=0x8000; switch(acknowledge){ //define response from Jupiter case NONE: buf[3]=buf[3]+0; break;

case ACK: buf[3]=buf[3]+0x0600; break;

case NAK: buf[3]=buf[3]+0x0500; break;

case ACKNAK: buf[3]=buf[3]+0x0700; break;

default: printf("set_msg:Bad value supplied for acknowledge argument\n"); return(-1); }

//check lq; switch(lq){ case(NO_CHANGE): break; //nothing else to add to the packet

case(QUERY): buf[3]=buf[3]|0x0800; //set query bit break;

case(LOG): buf[3]=buf[3]|0x2000; //set log bit buf[2]=3; //data portion of length 3 to follow buf[5]=trigger; //ONTIME or UPDATE if(trigger==UPDATE){ buf[6]=buf[7]=0; } else{ buf[6]=interval; buf[7]=offset; } buf[8]=calculate_data_checksum(buf,9); break;

default:

Page 25: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

19

printf("set_msg:Bad value supplied for lq argument\n"); return(-1); } buf[4]=calc_header_checksum(buf);

//send it to the Jupiter if(lq==NO_CHANGE) status=write(fd,buf,10); else status=write(fd,buf,18); if(status==-1){ perror("set_message/write:"); return(-1); } if(lq==NO_CHANGE){ if(status!=10){ printf("set_message/write: only wrote %d bytes, not 10\n",(int)status); return(-1); } } else{ if(status!=18){ printf("set_message/write: only wrote %d bytes, not 18\n",(int)status); return(-1); } } return(0); }

//calculates header checksumunsigned short calc_header_checksum(unsigned short buffer[]){ unsigned short cs=0; int i;

for(i=0;i!=4;i++){ cs=cs+buffer[i]; } if(cs!=0x8000){ cs=~cs; cs=cs+1; } return(cs); }

//checks if data checksum is correct//returns 0 if checksum ok else -1//length is the length of the packet including the headerint check_checksum(unsigned short buffer[],int length){ unsigned short cs=0; int i;

length--;

for(i=5;i!=length;i++){ cs=cs+buffer[i]; } if(cs!=0x8000){ cs=~cs; cs=cs+1; }

if(cs==buffer[length])return(0); else return(-1); }

//calculates data checksum//returns 0 if checksum ok else -1//length is the length of the packet including the headerunsigned short calculate_data_checksum(unsigned short buffer[],int length){ unsigned short cs=0; int i; length--;

for(i=5;i!=length;i++){ cs=cs+buffer[i]; } if(cs!=0x8000){ cs=~cs; cs=cs+1; }

return(cs); }

Page 26: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

20

MSG_1000.C//routines to decode binary message 1000

#include <math.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <unistd.h>#include <errno.h>

#include "kallisto.h"#include "msg_1000.h"#include "jupiter_utils.h"

#define DEBUG

//decodes the message found in buf into the structure st//returns 0 if operation successful, -n if contents//of buf found to be corrupt////buf contains message but not necessarily at the start//*st decoded message put here//len number of characters waiting in buf to be processedint decode_msg1000(short buf[],struct msg_1000 *st,int len){// unsigned int *lptr=(unsigned int *)buf;// unsigned int *loptr=(unsigned int *)(buf+1); unsigned int *lptr; unsigned int *loptr; int i;

//first look for msg 1000 for(i=0;i!=len;i++){ if((buf[i]==(short)0x81ff)&&(buf[i+1]==(short)1000))break; } if(i==len){ st->packet_status=-2; return(-2); //not message 1000 }

#ifdef DEBUG printf("msg 1000 found %d bytes into buffer\n",i*2);#endif

//point to start of msg 1000 buf=buf+i; lptr=(unsigned int *)buf; loptr=(unsigned int *)(buf+1);

if(buf[0]!=(short)0x81ff){ st->packet_status=-1; return(-1); //header corrupt } if(buf[1]!=(short)1000){ st->packet_status=-2; return(-2); //not message 1000 } if(buf[2]!=(short)MSG1000_LEN-6){ st->packet_status=-3; return(-3); //wrong length of data portion } if((check_checksum((unsigned short *)buf,MSG1000_LEN))!=0){ st->packet_status=-4; return(-4); //bad checksum }

st->packet_status=0; //good packet - so parse it into the structure

st->set_time=*(loptr+2); st->seq_no=buf[7]; st->sat_seq_no=buf[8]; st->soln_invalid=buf[9]; st->soln_invalid_A=buf[9]&0x01; st->soln_invalid_D=(buf[9]>>1)&0x01; st->soln_invalid_E=(buf[9]>>2)&0x01; st->soln_invalid_H=(buf[9]>>3)&0x01; st->soln_invalid_V=(buf[9]>>4)&0x01; st->soln_type=buf[10]; st->soln_type_P=buf[10]&0x01; st->soln_type_A=(buf[10]>>1)&0x01; st->soln_type_D=(buf[10]>>2)&0x01; st->no_meas=buf[11]; st->polar_nav=buf[12]; st->gps_week_no=buf[13]; st->gps_sec=*(lptr+7);

Page 27: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

21

st->gps_nsec=*(lptr+8); st->utc_day=buf[18]; st->utc_month=buf[19]; st->utc_year=buf[20]; st->utc_hrs=buf[21]; st->utc_mins=buf[22]; st->utc_secs=buf[23]; st->utc_nsec=*(lptr+12); st->lat=*(lptr+13); st->lng=*(lptr+14); st->height=*(lptr+15); st->geoid_sep=buf[32]; st->gspeed=*(loptr+16); st->tcourse=buf[35]; st->mvar=buf[36]; st->crate=buf[37]; st->datum=buf[38]; st->ehpe=*(loptr+19); st->evpe=*(loptr+20); st->ete=*(loptr+21); st->ehve=buf[45]; st->cbias=*(lptr+23); st->cbias_sd=*(lptr+24); st->cdrift=*(lptr+25); st->cdrift_sd=*(lptr+26);;

return(0); }

MSG_1108.C//routines to decode binary message 1108

#include <math.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <unistd.h>#include <errno.h>

#include "kallisto.h"#include "msg_1108.h"#include "jupiter_utils.h"

//decodes the message found in buf into the structure st//returns 0 if operation successful, -n if contents//of buf found to be corruptint decode_msg1108(short buf[],struct msg_1108 *st){ unsigned int *lptr=(unsigned int *)buf; unsigned int *loptr=(unsigned int *)(buf+1);

if(buf[0]!=(short)0x81ff){

st->packet_status=-1; return(-1); //header corrupt } if(buf[1]!=(short)1108){ st->packet_status=-2; return(-2); //not message 1108 } if(buf[2]!=(short)MSG1108_LEN-6){ st->packet_status=-3; return(-3); //wrong length of data portion } if((check_checksum((unsigned short *)buf,MSG1108_LEN))!=0){ st->packet_status=-4; return(-4); //bad checksum }

st->set_time=*(loptr+2); st->seq_number=buf[7]; st->UTC_sec_week=*(loptr+6); st->GPS2UTCIOS=buf[15]; st->GPS2UTCFOS=*(lptr+8); st->TM_valid=buf[18]&0x01;

return(0); }

MSG_1221.C//sends message 1221: Nav configuration message

Page 28: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

22

#include <math.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <unistd.h>#include <errno.h>

#include "kallisto.h"#include "msg_1221.h"#include "jupiter_utils.h"

//fd: file descriptor of serial port assigned to Kallisto//config_word: This is word 7 and sets the following options;// Held altitude disable// Ground track smoothing disable *// Position pinning disable *// Measurement filtering disable//// * These should be disabled if accurate 1 pps output is required//// The above options will be set to enabled by default. OR-ing the following// into config_word will disable the appropriate function://// HAD Held altitude disable// GTSD Ground track smoothing disable// PPD Position pinning disable// MFD Measurement filtering disable// config_word should be 0 or the OR of any of the above////acknowledge:// Setting this to NONE causes no response from the Jupiter to this packet// ACK causes the Jupiter to respond with a 1221 header only// packet if this message is sent with no errors// NAK causes the Jupiter to respond with a 1221 header only// packet if this message is sent with errors// ACKNAK causes a response with a 1221 header only packet// if this message is sent with or without errors////returns: 0 if ok// -1 if failed to send message to serial port correctly

int send_msg1221(int fd,int config_word,int acknowledge){ static unsigned short buf[15]; ssize_t status; int i;

//set up message to be sent to Jupiter buf[0]=0x81FF; //sync word buf[1]=(unsigned short)1221; //message id buf[2]=9; //length of data part of packet switch(acknowledge){ //define response from Jupiter case NONE: buf[3]=0; break;

case ACK: buf[3]=0x0600; break;

case NAK: buf[3]=0x0500; break;

case ACKNAK: buf[3]=0x7000; break;

default: printf("send_msg1221:Bad value supplied for acknowledge argument\n"); return(-1); } buf[4]=calc_header_checksum(buf); buf[5]=0; //reserved buf[6]=config_word; //word 7 for(i=7;i!=14;i++)buf[i]=0; //set reserved fields buf[14]=calculate_data_checksum(buf,15);

//send it to the Jupiter status=write(fd,(void *)buf,30); if(status==-1){ perror("set_message/write:");

Page 29: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

23

return(-1); } if(status!=30){ printf("set_message/write: only wrote %d bytes, not 30\n",(int)status); return(-1); } return(0); }

KALLISTO.H//kallisto.h////defines and function prototypes for the kallisto gps board

#define GPSCLOCK_NAME "/kallisto/gpsclock"#define GPSCLOCK_PRIORITY 29

#define GPSCLOCK_MONITOR_NAME "/kallisto/gpsmoni"#define GPSCLOCK_MONITOR_PRIORITY 11

#define GPSREADER_NAME "/kallisto/gpsclock"#define GPSREADER_PRIORITY 9

#define YES 1#define NO 0

#define PI 3.141592654

#define BUFF_SIZE 2048 /* size of packet receive buffer */#define GAP 1 /* serial receive time out in 1/100ths sec */

#define CTRL_REG 0x00 /*write only control register */#define STAT_REG 0x00 /*read only status register */#define IRQ_CLR 0x01 /*write only IRQ clear */

/****************************************************************//* CONTROL REGISTER - CTRL_REG (write only) *//* *//* Bit 0 1=1pps IRQ enabled, 0=disabled *//* Bit 1 1=enable 1pps to qualified 1pps output, 0=disable *//* Bit 2 not used *//* Bit 3 not used *//* Bit 4 external output OUT0 follows this bit *//* Bit 5 external output OUT1 follows this bit *//* Bit 6 not used *//* Bit 7 not used *//* *//* *//* STATUS REGISTER - STAT_REG (read only) *//* *//* Bit 0 1=1pps IRQ set, 0 = not set *//* Bits 1-7 not used *//* *//* *//* INTERRUPT CLEAR REGISTER - IRQ_CLR (write only) *//* Writing any value to this register clears the 1pps interrupt *//* *//****************************************************************/

//this message is sent to gpsclock by any task requesting the contents//of message 1000. The structure msg_1000 is sent in reply (see msg_1000.h)struct req_msg{ char type; //only valid type at the moment is ’R’ int msg_type; //only valid type is 1000 };

//prototypes for gpsclock.cvoid printhelp(void);int get_packet(int,short buf[]);void serial_flush(int,short buf[]);time_t calc_start_of_week(struct msg_1000 *);time_t calc_time_now(struct msg_1108 *,time_t);void set_os_clock(time_t);int check_for_leapsecond(time_t, struct msg_1000 *);

//prototypes for utils.cvoid write_control(int);int read_stat();void enable_irq();void disable_irq();void enable_q1pps();void disable_q1pps();void set_out0();void reset_out0();

Page 30: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

24

void set_out1();void reset_out1();void clr_irq();

//prototypes for gps_monitor.cvoid init_menu(void);void display_results(struct msg_1000 *);void conv_dms(double,int *,int *, double *);void check_1pps(struct msg_1000 *);

//additional prototypes for route_rec.cvoid record_results(FILE *,struct msg_1000 *m);

MSG_1000.H//msg_1000.h//Binary message type 1000 decoded into this structure//See Rockwell programming manual for more information

#define MSG1000_LEN 55 /* length of message 1000 in short ints */#define UL unsigned long

struct msg_1000{

int packet_status; //status of last packet received from Kallisto card //0=ok //-1 = corrupt header //-2 = not message 1000 //-3 = wrong data portion length //-4 = bad checksum //-5 = no valid message 1000 ever received //if this field between -1 and -4 the remaining fields //will contain the values of the last valid packet and //are thus likely to be out of date time_t UTC_tod;// UTC seconds past 1/1/1970. This is not strictly part // of msg_1000, but is calculated by gpsclock from // msg_1000 & msg_1108 UL set_time; //(words 6-7) int seq_no; //(word 8) int sat_seq_no; //range 0 to 32767 (word 9) int soln_invalid; //solution invalid - 0=valid non-zero=invalid (word 10) //for solution invalid below (word 10.x) 1 = invalid int soln_invalid_A; //solution invalid - altitude used (word 10 bit 0) int soln_invalid_D; //solution invalid - no differential GPS (word 10 bit 1) int soln_invalid_E; //solution invalid - not enough satellites (word 10 bit 2) int soln_invalid_H; //solution invalid - Exceeded max EHPE (word 10 bit 3) int soln_invalid_V; //solution invalid - Exceeded max EVPE (word 10 bit 4)

int soln_type; //solution type (word 11) //for soln_type_X below 1 = true int soln_type_P; //solution type - propagated solution (word 11 bit 0) int soln_type_A; //solution type - altitude used (word 11 bit 1) int soln_type_D; //solution type - differential (word 11 bit 2)

int no_meas; //number of measurements used in solution (word 12) int polar_nav; //1 = true (word 13) int gps_week_no; //GPS week number 0 - 32767 (word 14) UL gps_sec; //GPS seconds from epoch (words 15-16) UL gps_nsec; //GPS nano seconds from epoch (words 17-18) int utc_day; //UTC day 1 to 31 (word 19) int utc_month; //UTC month 1 to 12 (word 20) int utc_year; //UTC year 1980 to 2079 (word 21) int utc_hrs; //UTC hours 0 to 23 (word 22) int utc_mins; //UTC minutes 0 to 59 (word 23) int utc_secs; //UTC seconds 0 to 59 (word 24) UL utc_nsec; //UTC nano seconds from epoch (words 25-26) long lat; //latitude in radians *10**8 (words 27-28) long lng; //longitude in radians *10**8 (words 29-30) long height; //height in metres *10**2 (words 31-32) int geoid_sep; //geoidal separation in metres *10**2 (word 33) UL gspeed; //ground speed in metres/sec *10**2 (words 34-35) int tcourse; //true course in radians *10**3 (word 36) int mvar; //magnetic variation in radians *10**4 (word 37) int crate; //climb rate in metres/sec *10**2 (word 38) int datum; //0 to 188 & 300 to 304 UL ehpe; //expected horizontal position error (words 40-41) UL evpe; //expected vertical position error (words 42-43) UL ete; //expected time error (words 44-45) int ehve; //expected horizontal velocity error (word 46) long cbias; //clock bias (words 47-48) long cbias_sd; //clock bias std deviation (words 49-50) long cdrift; //clock drift (words 51-52) long cdrift_sd; //clock drift std deviation (words 53-54) };

Page 31: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

25

//function prototypes for msg_1000.cint decode_msg1000(short buf[],struct msg_1000 *,int);

MSG_1108.H//msg_1108.h//Binary message type 1108 decoded into this structure//See Rockwell programming manual for more information

#define MSG1108_LEN 20 /* length of message 1108 in short ints */#define UL unsigned long

struct msg_1108{ int packet_status; //status of buffer decode (not part of message) UL set_time; //words 6-7 short seq_number; //word 8 UL UTC_sec_week; //words 14-15 UTC seconds into week unsigned short GPS2UTCIOS; //word 16 GPS to UTC offset integer part UL GPS2UTCFOS; //words 17-18 GPS to UTC offset fractional part (nsec) short TM_valid; //word 19 bit 0 time mark validity };

//function prototypes for msg_1000.cint decode_msg1108(short buf[],struct msg_1108 *);

MSG_1221.H//msg_1221.h

#define HAD 0x01#define GTSD 0x02#define PPD 0x04#define MFD 0x08

int send_msg1221(int,int,int);

Page 32: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

26

Register DescriptionsThe board’s registers divide into two main groups - those contained within the UART, and the control registers. Thebase address of the UART registers is set by SW2 and the control registers’ base address is determined by SW1.

Note: The UART registers are directly compatible with those found in a standard PC serial port. Standard serialcommunications software should function without modification.

Control RegistersThree registers comprise the Control Register Set:

Register Name Offset fromBase Address

Read/Write

CONTROL 0 WRITESTATUS 0 READINTERRUPT CLEAR 1 WRITE

Each register is either read only or write only and are accessed with byte wide port i/o transfers.

Four bits of the CONTROL register are used:

Bit Function0 (lsb) 1 = 1 pps interrupt enabled, 0 = disabled1 1 = enable qualified 1 pps hardware output, 0 = disable2 not used3 not used4 hardware output OUT0 follows this bit5 hardware output OUT1 follows this bit6 not used7 not used

All bits default to 0 at power up / reset.

One bit of the STATUS register is used:

Bit Function0 (lsb) 1 = 1 pps interrupt set, 0 = not set1-7 not used

Bit 0 is set when the 1 pps interrupt goes active and is cleared by writing to the INTERRUPT CLEAR register. Writingany value to the INTERRUPT CLEAR register clears the 1 pps interrupt. Resetting bit 0 of the CONTROL REGISTERto 0 will not clear the interrupt, it will only prevent further interrupts from being generated.

Page 33: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

27

UART RegistersThe UART uses the 16550 chip with an onboard FIFO buffer. This is an improved but functionally equivalent version ofthe 8250 used on the original PC design. There are 10 registers:

Offset from Base Address Register Read /Write0* Receive buffer Read only0* Transmit holding register Write only1* Interrupt enable Read/Write2 Interrupt identification Read only2 FIFO control Write only3 Line control Read/Write4 Modem control Read/Write5 Line Status Read/Write6 Modem Status Read/Write7 Scratch Read/Write0** Divisor latch (LSB) Read/Write1** Divisor latch (MSB) Read/Write

* These registers are only accessible when the DLAB bit of the Line Control register is 0** These registers are only accessible when the DLAB bit of the Line Control register is 1

Interrupt Enable Register (Base address + 0)

Bit Name Function7 not used6 not used5 not used4 not used3 EDSSI When 1 enables interrupt on clear to send, data set ready, ring indicator and data carrier detect2 ELSI When 1 enables interrupt on overrun, parity & framing errors and break indication1 ETBEI When 1 enables interrupt on transmitter register empty0 ERBFI When 1 enables interrupt on received data available or FIFO trigger level

FIFO Control Register (Base address + 2)

Bit Name Function7 RXT1 Receiver FIFO trigger level - see below6 RXT0 Receiver FIFO trigger level - see below5 reserved4 reserved3 DMAM DMA mode select, not supported, leave at 02 XRST When 1 all bytes in the transmitter FIFO are cleared and the counter is reset. The shift register

is not cleared. XRST is self clearing.1 RRST When 1 all bytes in the receiver FIFO are cleared and the counter is reset. The shift register is

not cleared. RRST is self clearing.0 FE When 1 the transmitter and receiver FIFOs are enabled. When 0 all bytes in both FIFOs are

cleared. This bit must be set when other bits in the FIFO control register are written to or thebits will be ignored.

RXT1 RXT0 Receiver FIFO trigger level (bytes)0 0 10 1 41 0 81 1 14

Page 34: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

28

Interrupt Identification Register (Base address +2)

Bit Name Function7 FFE When logic 1 indicates FIFO mode enabled6 FFE When logic 1 indicates FIFO mode enabled5 not used4 not used3 IID2 Interrupt identification - see below2 IID1 Interrupt identification - see below1 IID0 Interrupt identification - see below0 IP When 0 indicates that an interrupt is pending

IID2 IID1 IID0 IP Priority Interrupt Typex x x 1 None0 1 1 0 Highest Receiver Line Status0 1 0 0 Second Received Data Ready1 1 0 0 Second Character Timeout0 0 1 0 Third Transmitter Holding Register Empty0 0 0 0 Fourth Modem Status

Receiver Line Status: Indicates overrun, parity, framing errors or break interrupts.The interrupt is cleared by reading theline status register.

Received Data Ready: Indicates receive data available. The interrupt is cleared by reading the receive buffer. In FIFOmode indicates the receiver FIFO trigger level has been reached. The interrupt is reset when the FIFO drops below thetrigger level.

Character Timeout: FIFO mode only, Indicates that no characters have been removed from, or input to, the receiverFIFO for the last four character times and there is at least one character in the receiver FIFO. The interrupt is cleared byreading the receiver FIFO.

Transmitter Holding Register Empty: Indicates that the transmitter holding register is empty. The interrupt is cleared byreading the interrupt identification register or writing to the transmitter holding register.

Modem Status: Indicates clear to send, data set ready, ring indicator, or data carrier detect have changed state. Theinterrupt is cleared by reading the Modem Status register.

Modem Control Register (Base address + 4)

Bit Name Function7 06 05 04 LOOP Loopback enable3 OUT2 When 1 enables interrupt circuitry on the Kallisto card2 OUT1 not used1 RTS RTS output follows inverse logic of this bit0 DTR DTR output follows inverse logic of this bit

Loopback enable: When 1 the transmitter shift register is internally connected to the receiver shift register, the modemcontrol inputs are internally connected to the modem control outputs and the outputs are forced to the inactive state.transmit and receive interrupts function normally but modem control interrupts are now controlled through the modemcontrol register.

Page 35: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

29

Line Control Register (Base address + 3)

Bit Name Function7 DLAB Set to 1 to access the baud rate divisor latches. Set to 0 to access the receiver buffer, transmitter

holding register and interrupt enable register.6 BKCN When 1 the serial output is forced to the spacing state, logic 0.5 STKP Forces parity to logic 1 or 0 if parity is enabled. See EPS & PEN.4 EPS See below3 PEN See below2 STB Sets number of stop bits per character. See below1 WLS1 See below0 WLS0 See Below

STKP EPS PEN Parityx x 0 None0 0 1 Odd0 1 1 Even1 0 1 Logic 11 1 1 Logic 0

STB WLS1 WLS0 Word Length Stop bits0 0 0 5 bits 10 0 1 6 bits 10 1 0 7 bits 10 1 1 8 bits 11 0 0 5 bits 1.51 0 1 6 bits 21 1 0 7 bits 21 1 1 8 bits 2

Line Status Register (Base address + 5)

Bit Name Function7 FFRX 0 in character mode.In FIFO mode indicates one or more parity errors, framing errors or break

indications in the receiver FIFO. FFRX is reset by reading the line status register.6 TEMT Indicates that the transmitter holding register and the transmitter shift register are empty and are

ready to receive new data. TEMT is reset by writing a character to the transmitter holdingregister.

5 THRE Indicates that the transmitter holding register is empty and is ready to receive new data. THRE isreset by writing a character to the transmitter holding register.

4 BI Break interrupt: indicates that the receive data input has been at logic 0 for longer than one fullword transmission time. In FIFO mode only one zero character is loaded into the FIFO andtransfers are disabled until the input goes to logic 1 and a valid start bit is received.

3 FE Framing error: indicates the received character had an invalid stop bit. The stop bit following thelast data or parity bit was a 0 bit.

2 PE Parity error: the received character does not have the correct parity.1 OE Overrun error: Indicates that the receive buffer was not read before the next character was

received and the character is destroyed. In FIFO mode indicates that the FIFO is full and thecharacter is destroyed.

0 DR Data ready: data is present in the receive buffer or FIFO. DR is reset by reading the receivebuffer or FIFO.

Page 36: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

30

Bits BI, FE, PE and OE are the sources of receiver line status interrupts. These bits are reset by reading the line statusregister. In FIFO mode these bits are associated with a specific character in the FIFO and the exception is revealed onlywhen the character reaches the top of the FIFO.

Modem Status Register (Base address + 6)

Bit Name Function7 DCD Complement of the DCD input6 RI Complement of the RI input5 DSR Complement of the DSR input4 CTS Complement of the CTS input3 DDCD Indicates DCD has changed state2 TERI Indicates RI has changed from low to high state1 DDSR Indicates DSR has changed state0 DCTS Indicates CTS has changed state

Bits DDCD, TERI, DDSR and DCTS are the sources of Modem status interrupts. These bits are reset when the modemstatus register is read.

On the Kallisto board the modem control lines DCD, DSR and DTR are physically connected to each other, as are CTSand RTS.

Scratchpad Register (Base address + 7)

This register is not used by the UART and can be used by the programmer for data storage.

Baud Rate Selection (Base address + 0, Base address + 1)

For 4800 baud set the divisor latch to 24.For 9600 baud set the divisor latch to 12.

FIFO Mode Interrupt OperationThe receive data interrupt is issued when the FIFO reaches the trigger level. The interrupt is cleared as soon as the FIFOfalls below the trigger level.

The interrupt identification register’s receive data available indicator is set and cleared along with the receive datainterrupt.

The data ready indicator is set as soon as a character is transferred into the receiver FIFO and is cleared when the FIFOis empty.

Page 37: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

31

Installing the Windows Clock SoftwareA simple utility to set the operating system clock is supplied with the Kallisto card. This utility will run under Windows3.1, Windows 3.11 and Windows 95. It will not run under Windows NT. The operating system clock is set to the nearestsecond, the 1pps interrupt is not used by this application. The operating system clock can be set to UTC or to any localtime offset from UTC.

InstallationThe Kallisto card must be configured to use Rockwell Binary data format. See page 4, Jumper Settings.The UART base address should be set to one of the standard values as outlined in Suggested UART Base Addresses onpage 3. Please read and fully understand the installation instructions at the beginning of this manual before attempting touse this software.

Windows needs to be configured correctly to communicate with the Kallisto’s COM port. The baud rate, UART address& IRQ are all set up via the Windows control panel - not in the clock program.

Windows 3.1 & 3.11In the main program group double click on Control PanelDouble click on PortsDouble click on the COM port that you have allocated to the Kallisto board (usually COM3)Set the Baud Rate to 9600, Data Bits to 8, Parity None, Stop Bits 1, Flow Control NoneClick on Advanced...Set Base I/O Port Address to match the Kallisto’s UART address (3E8 for COM3)Set Interrupt Request Line (IRQ) to match the Kallisto’s UART IRQClose all dialogue boxes and restart Windows.

Windows 95

From the Start button select Settings Ð Control PanelDouble click on SystemSelect Device Manager tabDouble click on Ports (COM & LPT)Double click on Communications Port (COMn) where n is the COM port number that you have allocated to theKallisto board. (Windows should have auto detected the presence of the Kallisto’s UART at boot time)Click on the Port Setting tab.Set the Baud Rate to 9600, Data Bits to 8, Parity None, Stop Bits 1, Flow Control NoneClick on the Resources tabChange Settings based on to Basic configuration 5Highlight Interrupt Request and click on Change SettingSet the IRQ to match the Kallisto’s UART IRQ.Close all dialogue boxes by clicking on OKRestart Windows if requested

At this point it is a good idea to repeat the above process but check that the entered values are correct and as intended.

Setup ProgramInsert the installation floppy and from Windows RUN menu type a:\setupThe setup program will install two main pieces of software; the gps clock program and the LabWindows runtime engine.The latter provides all the code to run the user interface. When installation is complete double click on the gpsclock icon(or launch it from the Windows 95 start menu)

The program needs configuring the first time it is run. Subsequently the configuration is read from a file stored in thesame directory as the executable. Click on the arrow under the Serial Port heading. Select the Kallisto’s COMport. If the program can communicate correctly with the Kallisto card the indicator next to System clock under

Page 38: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

32

GPS Control will turn from red to yellow. When valid fixes are received the indicator will turn to green. When theindicator is green the operating system clock is set approximately every minute. The Local Time Offset controlcan be used to set the difference between local time and UT. The operating system clock is always set to the local timevalue. Once configured the program can be run minimised in the background. To do this by default select the programicon and then either press alt-enter (Windows 3.1) or right click and select properties (Windows 95). Check RunMinimised (Windows 3.1) or change the Run setting to Minimised (Windows 95). If the Icon (or a shortcut to it inWindows 95) is placed in the Startup group the program will be launched at Windows boot time.

Labmon47Labmon47.exe is a DOS diagnostic program written by Rockwell. The Labmon disk supplied with the Kallisto cardcontains both the executable and source code. The source code contains routines for communicating with the UART andis a useful starting point for anyone wishing to write their own DOS program. The attached Labmon documentationassumes that the Jupiter module is attached to one of the PC’s external serial ports. By virtue of the Kallisto’s inbuiltUART the Jupiter is already attached to a serial port. As long as the Kallisto’s UART is configured to one of thestandard COM port addresses and its UART IRQ is 7 or less (Labmon can’t handle the extended AT bus IRQs) theprogram will work.

TroubleshootingUse Labmon47 to troubleshoot an installation. If Labmon47 does not show a display that updates once per second therecould be two possible faults:• The UART address switches or IRQ are incorrectly set or conflict with another device.• The jupiter module is no longer sending any messages to the UART. This can happen if a program instructs the

Jupiter to turn off messages by mistake. To rectify this force a cold start (see below).

If Labmon47 does show an updating display but never shows any satellites in track then the antenna installation needsinvestigation. If an passive antenna is being used check that the feeder length does not exceed 10 feet. Also check that J4is not fitted. If it is it is possible that the Jupiter’s RF front end has been destroyed. If an active antenna is being usedcheck that J4 is present. Check that the antenna can be powered from +5v on the feeder centre conductor. Check that thefeeder attenuation does not exceed the gain of the antenna. Check the integrity of the feeder and RF connectors. Ifpossible, disconnect the feeder from the antenna and check that +5v can be measured on the centre conductor relative tothe outer shield. Check that the antenna has a clear view of the sky and is not excessively shadowed by buildings etc.

Forcing a Cold StartA cold start brings the Jupiter up from a known healthy state. All stored almanac, ephemeris, time and communicationsettings data will be lost. It will take up to 20 minutes to obtain a 3D fix again. To force a cold start power the computerdown and fit jumper J1. Restart the computer and remove J1.

Further Information about the GPS SystemGreening Technology can only support the Kallisto board in its intended role as a simple time standard. A basic GPStutorial is included in the attached Rockwell manual. More in depth information can be found in The Guide to GPSPositioning ISBN 0-920-114-73-3 available from:

Canadian Institute of Surveying and MappingBox 5378Postal Station FOttawa, OntarioK2C 3J1CanadaTel 613-224-9851

Price C$35 + shipping

A set of Web links can be found at http://ion.le.ac.uk/kallisto

Page 39: Kallisto Information - rabel.org · Kallisto Information • Product Overview • Software for use with the Kallisto • Kallisto User’s Guide Click on any of the above hyperlinks

GREENING TECHNOLOGY Kallisto GPS Timing Card

33

Board Layout