Multicast Time Distribution - DiVA...

91
Multicast Time Distribution Master’s Thesis performed for SP Swedish National Testing and Research Institute by EROLD PERSSON Information Networks Division Reg nr: LiTH-ISY-EX-3510-2004 Link¨ oping 2004

Transcript of Multicast Time Distribution - DiVA...

Multicast Time Distribution

Master’s Thesisperformed for

SP Swedish National Testing and Research Instituteby

EROLD PERSSON

Information Networks DivisionReg nr: LiTH-ISY-EX-3510-2004

Linkoping 2004

Multicast Time Distribution

Master’s Thesisperformed for

SP Swedish National Testing and Research Instituteby

EROLD PERSSON

Information Networks DivisionDepartment of Electrical Engineering

Linkoping UniversityReg nr: LiTH-ISY-EX-3510-2004

Supervisor: Kenneth Jaldehag, SPCarsten Rieck, SP

Examiner: Robert Forchheimer, ISY

Linkoping 19th March 2004.

Avdelning, Institution Division, Department

Institutionen för systemteknik 581 83 LINKÖPING

Datum Date 2004-03-16

Språk Language

Rapporttyp Report category

ISBN

Svenska/Swedish X Engelska/English

Licentiatavhandling X Examensarbete

ISRN LITH-ISY-EX-3510-2004

C-uppsats D-uppsats

Serietitel och serienummer Title of series, numbering

ISSN

Övrig rapport ____

URL för elektronisk version http://www.ep.liu.se/exjobb/isy/2004/3510/

Titel Title

Tidsdistribution i multicast-mod Multicast Time Distribution

Författare Author

Erold Persson

Sammanfattning Abstract The Swedish National Testing and Research Institute is maintaining the Swedish realization of the world time scale UTC, called UTC(SP). One area of research and development for The Swedish National Laboratory of Time and Frequency is time synchronization and how UTC(SP) can be distributed in Sweden. Dissemination of time information by SP is in Sweden mainly performed via Internet using the Network Time Protocol (NTP) as well as via a modem dial up service and a speaking clock (Fr¨oken Ur). In addition to these services, time information from the Global Positioning System (GPS) and from the long-wave transmitter DCF77 in Germany, is also available in Sweden. This master’s thesis considers how different available commercial communication systems could be used for multicast time distribution. DECT, Bluetooth, Mobile Telecommunication and Radio Broadcasting are di_erent techniques that are investigated. One application of Radio Broadcasting, DARC, was found to be interesting for a more detailed study. A theoretical description of how DARC could be used for national time distribution is accomplished and a practical implementation of a test system is developed to evaluate the possibilities to use DARC for multicast time distribution. The tests of DARC and the radio broadcast system showed that these could be interesting techniques to distribute time with an accuracy of a couple of milliseconds. This quality level is not obtained today but would be possible with some alterations of the system.

Nyckelord Keyword time distribution, multicast, DECT, UMTS, Bluetooth, RDS, DARC, DAB, UTC(SP), accuracy, stability

Abstract

The Swedish National Testing and Research Institute is maintaining the Swedishrealization of the world time scale UTC, called UTC(SP). One area of researchand development for The Swedish National Laboratory of Time and Frequency istime synchronization and how UTC(SP) can be distributed in Sweden. Dissemina-tion of time information by SP is in Sweden mainly performed via Internet usingthe Network Time Protocol (NTP) as well as via a modem dial up service and aspeaking clock (Froken Ur). In addition to these services, time information fromthe Global Positioning System (GPS) and from the long-wave transmitter DCF77in Germany, is also available in Sweden.

This master’s thesis considers how different available commercial communica-tion systems could be used for multicast time distribution. DECT, Bluetooth,Mobile Telecommunication and Radio Broadcasting are different techniques thatare investigated. One application of Radio Broadcasting, DARC, was found to beinteresting for a more detailed study. A theoretical description of how DARC couldbe used for national time distribution is accomplished and a practical implemen-tation of a test system is developed to evaluate the possibilities to use DARC formulticast time distribution.

The tests of DARC and the radio broadcast system showed that these could beinteresting techniques to distribute time with an accuracy of a couple of millisec-onds. This quality level is not obtained today but would be possible with somealterations of the system.

Keywords: time distribution, multicast, DECT, UMTS, Bluetooth, RDS, DARC,DAB, UTC(SP), accuracy, stability

i

Preface

This report is written as the master’s thesis for the degree in Master of Science inApplied Physics and Electrical Engineering at Linkoping University.

The work has been performed at the Swedish National Testing and ResearchInstitute, SP, in Boras.

There are a number of persons that have been valuable for this work. First,I want to express my gratitude to the supervisors at SP, Kenneth Jaldehag andCarsten Rieck, for their support of the work and their comments of the report.Second, the remainder staff at the section of Electricity and Time, deserves to bementioned for the kind reception of me that made me feel welcome at SP. Finally,Charlotte who is very important to me, has given me great mental support andlove as well as assistance with the proofreading of this report.

Linkoping, March 2004Erold Persson

iii

Abbreviations

BIMP International Bureau of Weights and Measures in FranceBIC Block Identification CodeBMCh Block Message ChannelCAP CTM Access ProfileCBS Cell Broadcast ChannelCDMA Code Division Multiple AccessCPICH Common Pilot ChannelCT Clock-Time and date informationCTM Cordless Terminal MobilityDAB Digital Audio BroadcastingDARC Data Radio ChannelDECT Digital Enhanced Cordless TelecommunicationsETSI European Telecommunications Standard InstituteFDD Frequency Division DuplexFDM Frequency Division MultiplexFDMA Frequency Division Multiple AccessFIC Fast Information ChannelGAP Generic Access ProfileGPRS General Packet Radio ServiceGPS Global Positioning SystemGPS CV GPS Common ViewGSM Global System for Mobile CommunicationsIPv4 Internet Protocol ver 4IPv6 Internet Protocol ver 6LMCh Long Message ChannelLMSK Level-controlled Minimum Shift KeyingMCI Multiplex Configuration InformationMJD Modified Julian DateMSC Main Service ChannelNITZ Network Information Time ZoneNTP Network Time ProtocolNWS NetWork ServerOFDM Orthogonal Frequency Division MultiplexPSCH Physical Synchronization Channel

v

PTB Physikalisch-Technische BundesanstaltRDS Radio Data SystemSCH Synchronization ChannelSeCh Service ChannelSI Service InformationSMCh Short Message ChannelSOS Swift Over SerialSP Swedish National Testing and Research InstituteTAF Time Accuracy FieldTAI International Atomic Time scaleTDPNT Time, Date, Position and Network name TableTDT Time and Date TableTDD Time Division DuplexTDM Time Division MultiplexTDMA Time Division Multiple AccessTM Transmission ModeTSE Transmitting Station EquipmentUSART Universal Synchronous Asynchronous Receiver TransmitterUT1 Universal TimeUTC Coordinated Universal TimeVHF Very High FrequencyWCDMA Wideband Code Division Multiple Access

vi

Contents

1 Introduction 11.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Project specification . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.3 Thesis outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

2 Time 32.1 What is time? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.2 Epoch and time interval . . . . . . . . . . . . . . . . . . . . . . . . . 32.3 Sources of time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2.3.1 Resonators . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.3.2 Q, Accuracy and Stability . . . . . . . . . . . . . . . . . . . . 5

2.4 Time scales and traceability . . . . . . . . . . . . . . . . . . . . . . . 52.4.1 International time keeping . . . . . . . . . . . . . . . . . . . . 52.4.2 National time keeping . . . . . . . . . . . . . . . . . . . . . . 6

2.5 Why accurate time? . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3 Time Distribution 73.1 Distribution techniques . . . . . . . . . . . . . . . . . . . . . . . . . 7

3.1.1 Unicast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.1.2 Anycast and manycast . . . . . . . . . . . . . . . . . . . . . . 73.1.3 Multicast and broadcast . . . . . . . . . . . . . . . . . . . . . 8

3.2 Multicast methods available today . . . . . . . . . . . . . . . . . . . 83.2.1 DCF77 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.2.2 GPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

4 Possible multicast systems 114.1 DECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

4.1.1 The DECT System . . . . . . . . . . . . . . . . . . . . . . . . 114.1.2 Time distribution via DECT . . . . . . . . . . . . . . . . . . 12

4.2 Mobile telecommunication . . . . . . . . . . . . . . . . . . . . . . . . 124.2.1 Multicast data services available . . . . . . . . . . . . . . . . 134.2.2 Broadcast synchronization channels . . . . . . . . . . . . . . 134.2.3 NITZ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

vii

viii Contents

4.3 Radio Broadcasting . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.3.1 RDS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.3.2 DARC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.3.3 DAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174.3.4 Time distribution in broadcast radio networks . . . . . . . . 18

4.4 Bluetooth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194.5 Summary of described systems . . . . . . . . . . . . . . . . . . . . . 20

4.5.1 DECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204.5.2 Mobile telecommunication . . . . . . . . . . . . . . . . . . . . 204.5.3 Radio Broadcasting . . . . . . . . . . . . . . . . . . . . . . . 204.5.4 Bluetooth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

5 A deeper review of DARC 235.1 The DARC network . . . . . . . . . . . . . . . . . . . . . . . . . . . 235.2 DARC communication layers . . . . . . . . . . . . . . . . . . . . . . 25

5.2.1 Physical layer, Layer 1 . . . . . . . . . . . . . . . . . . . . . . 255.2.2 Data link layer, Layer 2 . . . . . . . . . . . . . . . . . . . . . 255.2.3 Network Layer, Layer 3 . . . . . . . . . . . . . . . . . . . . . 265.2.4 Layer 4, Service Channel . . . . . . . . . . . . . . . . . . . . 27

5.3 DARC receiver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295.3.1 Communication with the receiver . . . . . . . . . . . . . . . . 295.3.2 Data output . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

5.4 Time source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305.5 Test implementations . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

5.5.1 Receiver settings . . . . . . . . . . . . . . . . . . . . . . . . . 315.5.2 DARC received via the serial port of a PC . . . . . . . . . . . 315.5.3 DARC received by a microcontroller . . . . . . . . . . . . . . 315.5.4 Radio stations used . . . . . . . . . . . . . . . . . . . . . . . 33

5.6 Test results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335.6.1 PC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345.6.2 Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . 35

6 Conclusions and future work 396.1 Multicast systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396.2 Investigations of DARC . . . . . . . . . . . . . . . . . . . . . . . . . 39

A Program code for Linux 43

B Program code for PIC16F874 53

C Circuit 65

D Measurement results 67

Chapter 1

Introduction

1.1 Background

Time plays in different ways an important role for everyone. For everyday use timeis for instance needed to decide meetings between people. For scientists time canbe of academic interest in the daily work. Depending of the different usage, variousquality of time is needed and expected.

The Swedish National Testing and Research Institute, SP, is responsible for thenational time scale UTC(SP). One of the commissions for the Swedish NationalLaboratory for Time and Frequency at SP is to offer and develop services for timesynchronization traceable to UTC(SP).

Time traceable to UTC(SP) is today distributed by SP via modems connectedto the telecommunication network, via Internet and via a speaking clock that canbe called up. Besides these synchronization sources maintained by SP, internationaltime sources like GPS and DCF77 are used to meet the need of time synchronizationin Sweden.

There are in principle two ways to distribute information in general, point-to-point or multicast. A point-to-point connection is established between one trans-mitter and one single receiver. The information flow is in most cases bidirectional.Multicast communication involves one transmitter and multiple receivers listeningto the same information channel.

The purpose of this master’s thesis is to investigate weather different availablecommercial communication methods can be used for time distribution in multicast.

1.2 Project specification

As a first part of the work different commercial communication methods are in-vestigated. The systems are described from the perspective of time distribution.Advantages and drawbacks of the different systems are described.

One of the systems studied is chosen for a more detailed investigation of the

1

2 Introduction

possibilities to use it for time distribution. A detailed description is given and apractical implementation is performed to evaluate how well the theoretical assump-tions correspond to the practical reality.

1.3 Thesis outline

In Chapter 2 different properties of time in general are discussed. Expressionslike accuracy, stability and time scales are explained. Chapter 3 presents generalinformation distribution methods and examples of time distribution systems usedtoday are mentioned. In Chapter 4 different possible communication methods formulticast time distribution are investigated. An overview is given and advantagesrespectively drawbacks with each system are presented. One of the systems de-scribed in Chapter 4 is selected and studied in more detail in Chapter 5. Practicalimplementations are developed and the achieved results of the test measurementsare presented. In Chapter 6 some conclusions sum up the work and recommenda-tions for future work is given.

Chapter 2

Time

2.1 What is time?

Ever since the beginning of everything time is proceeding unchangeably. The hu-man has always tried to understand or explain time and scientists like Newton andEinstein have spent years of studying this phenomenon. They, as well as scientiststoday, often ended up in a philosophical thinking where it is hard to discern rightand wrong.

Despite these difficulties of the subject, time plays an important role in thepractical life for all of us. It is from this point of view time is considered in thisreport.

2.2 Epoch and time interval

When considering the concept of time there are mainly two different ways to see itdepending on the field of applications. When an event is decided to happen at aspecial point of time we are talking about the epoch or date of this special event,when something is going to take place. Another way is to consider time only as atime interval which does not care about when, but for how long something takesplace.

Often, when time is used, it is not only used by one isolated part independentof everything else. Instead time is often used as a tool to time things together. Inthis case synchronization between the different parts is very important regardlessof if we are talking about epochs or time intervals.

2.3 Sources of time

There are a large number of cycles and rhythms going on all around us, eveninside us, having the regularity that they can be used as sources of or referencesfor time. The most natural of these, and even maybe the most used historically,

3

4 Time

is the rotation of the earth, both relative to its own axis and relative to the sun.Both the variations between day and night and between different times of theyear originate from these rotations and historically this is the main source for thehuman consciousness of time. Soon one realized that it was possible to countdifferent hallmarks of these variations to know the current time. The sundial wasdeveloped.

In order to know the time also when the sun does not shine or during the nightdifferent mechanized devices to interpolate time between checks with the sun havebeen developed. These devices could be flowing water or sand adjusted to the cyclesof the sun. Later, counting swings of pendulums became a useful and importantmeasurement of time. Hereby the early resonator was developed and resonators invarious forms are the main sources of time in our days.

2.3.1 Resonators

Many different resonators are used for time keeping purposes. All of them swingwith their own resonant frequency and with various stability and accuracy. Thecheapest and most used resonator, for example in wrist-watches and electronicdevices, is the quartz crystal. It is based on the piezoelectric effect. A small pieceof the crystal vibrates when an alternating electric voltage is applied to it. Onceit is made to vibrate the crystal will continue to generate an oscillatory voltagewith its own resonate frequency. The applied voltage together with the crystalconstitute a feedback system that is regulated by the resonant frequency of thecrystal.

Another group of resonators are the atomic resonators. The atomic resonatorsuse the fact that a certain atom has so called resonant frequencies. A resonantfrequency is derived from movements of the electron between the different possi-ble energy levels an electron can occupy. When an atom is exposed to radiationof a particular frequency, of which the energy corresponds to the energy gap be-tween two energy levels of the atom, the electrons change energy level by absorbingthe radiated energy. For every atom there is at least one frequency of radiationwhich gives a peak of electrons changing their energy level and this is the resonantfrequency for that particular atom.

A few atoms are better than others to use for time keeping purposes. Todayclocks derived from rubidium, cesium and hydrogen are the most used. The rubid-ium oscillator is the cheapest one of these while the hydrogen maser is the mostadvanced and thereby the most expensive. The cesium clock is aligned in betweenand is used by national and international time keeping laboratories because of itshigh accuracy and long term stability. The definition of the SI-unit of time, onesecond, is since 1967 based on the cesium atom as well. The unperturbed resonantfrequency of a Cesium-133 atom is defined as 9 192 631 770 Hz. The duration ofone second is stated as the duration of the defined number of cycles of an elec-tromagnetic signal, of which the energy corresponds to the special energy gap ofcesium-133 [14].

2.4 Time scales and traceability 5

2.3.2 Q, Accuracy and Stability

When an ideal resonator gets an initial push, it will run forever. Of course this isnot the case in reality because of friction. The Q-factor is a measure of how manyswings a resonator makes until its energy from the initial push is consumed. Amechanical clock have a Q of about 100 whereas an atomic clock have millions inQ-value.

Two very important quality measurements in the field of time, besides Q, areaccuracy and stability. The difference between these two expressions will be ex-plained. The stability expresses the precision of something momently compared intwo different points of time, independent of each other. An ideally stable resonatorwill give us exactly the same resonant frequency now as in any later moment cho-sen randomly[14]. The accuracy means how the average frequency of the resonatoragree with the stated frequency[14]. For an accurate clock, the length of singleseconds may vary during a period of time but the average length of a second andthereby the total length of the time period agrees with the definition of time. A res-onator can be stable without being accurate if there is a constant but non-changingerror of the frequency.

There are differences between different resonators in terms of stability and ac-curacy. The cesium clock is very accurate in the long run and the definition of theatomic second is based on the cesium atom. Besides this the cesium clock is notthat stable in comparison with for example a hydrogen maser in the short term.The maser has a natural vibration of 1 420 405 752 Hz and is not very accuratewith the definition of one second, but its frequency is very stable for short timeperiods of less than a day[14].

2.4 Time scales and traceability

There are a lot of different time scales around the world maintained by nationaltime laboratories like SP in Sweden. The users of these different time scales wantto be sure of the fact that the time they are using is accurate and reliable. Toguarantee this accuracy the national time is made traceable to one internationalstandard which is the same worldwide. The national time scale of Sweden UTC(SP)is traceable to UTC and thereby an accurate time source [24].

2.4.1 International time keeping

The Coordinated Universal Time, UTC, is the international time scale for worlddistribution of time and is a combination of the International Atomic Time scale,TAI, and Universal Time, UT1.

UT1 is a dynamic time scale derived from the rotation of the Earth and is pro-portional to the angle of the rotation of the Earth. The scale is dynamic dependingon different variations of the earth’s rotation and that implies that the scale followsthe rise and the set of the sun. UT1 is maintained by IERS (International EarthRotation Service)

6 Time

TAI is an atomic time scale. It is calculated by BIPM (International Bureau ofWeights and Measures), located in France outside Paris, as a weighted average ofdata from 230 atomic clocks located in about 60 national laboratories worldwide.By definition UTC has the same metrological properties as TAI, but to follow therotation of the earth UTC is corrected with so called leap seconds. The correctionassures that the difference between UTC and UT1 is always less than 0.9 secondsand the difference between UTC and TAI is always a integer number of seconds.

UTC and TAI are virtual time scale on world basis and they are realized on anational basis, for example through UTC(SP) in Sweden maintained by SP.

2.4.2 National time keeping

The Swedish standard time is derived from UTC and realized as the national timescale UTC(SP) by SP. The base for UTC(SP) is made up by atomic clocks, cesiumclocks and hydrogen masers, continuously compared with the international timescale UTC and TAI. The comparison is established via BIPM and is obtained bymeasurements against satellites in the GPS-system (GPS Common-View see 3.2.2)and the Two-Way Satellite Time and Frequency Transfer (TWSTFT). The Swedishtime scale UTC(SP) is also one of the national time scales all over the world thatare the base for UTC.

2.5 Why accurate time?

The need for accurate time is increasing in conjunction with the general technicaldevelopment today. The different techniques available for fast communication andprecise navigation need high timing precision and they push the development for-ward by their demands at the same time as available accurate timing possibilitiespush the technical development. A result of this development is that people ingeneral expect that clocks around them give accurate time as well. The need forsynchronized and accurate public clocks introduce demands also on cheaper timedistribution methods with less accuracy than the expensive and technical advancedsystems with very high accuracy.

Chapter 3

Time Distribution

3.1 Distribution techniques

There are different techniques to distribute information in general. One major dif-ference is how the communication is established between the transmitter and thereceiver. Expressions that are used in these contexts are unicast, anycast, many-cast, multicast, broadcast and point-to-point. The meaning of these expressionswill be explained in the next sections. Unicast, anycast and multicast are defineddistribution methods in the Internet Protocols (IPv4 and IPv6) while manycast,broadcast and point-to-point are expressions used in different other communicationsituations and their meaning may vary as well.

3.1.1 Unicast

Most of the connections in traditional communication networks are unicast or point-to-point connections. A unicast connection is established between one transmitterand one receiver. The information flow may be only in one direction but in mostcases it is bidirectional. Example of unicast communication is a connection betweentwo computers on the Internet or the connection between the base station andthe mobile terminal during a call in a mobile system. An unicast system maycontain several point-to-point connections between one transmitter and a numberof receivers where the information flowing in every connection is identical. This isstill unicast communication due to the fact that the information is sent on multiplechannels.

3.1.2 Anycast and manycast

Anycast defines communication with a receiver that is the nearest in a group of sev-eral possible receivers offering the same service. In IPv6 this is used as a techniquefor chain-updating a group of routers with new routing information. A variantof anycast is manycast. In manycast, the one to communicate within a group of

7

8 Time Distribution

devices offering the same service, is chosen by a set of optional criteria. The chosenpart does not have to be the one that is the nearest in a topological point of view.

3.1.3 Multicast and broadcast

In multicast and broadcast communication identical data is distributed to sev-eral receivers without sending the data more than once. The difference betweenbroadcast and multicast is often explained differently depending on the application.One difference is how the receiver group is specified. A multicast group is definedby a given number of receivers where each receiver is addressed in the group. Abroadcast group may instead include all the members in a whole network.

Broadcast is also an expression for the transmissions of public radio and tele-vision. Here, the meaning of broadcast is that everyone with the appropriateequipment can receive the broadcasted information.

The information flow in broadcast and multicast communication is single di-rected, from transmitter to receiver. For time distribution the broadcast and mul-ticast techniques are interesting because of the possibilities to reach many receiverswith the same information with relatively simple methods. When the informationis transmitted the transmitter does not have to care about who is receiving. A sig-nificant drawback of this is that the possibilities to correct for varying transmissiondelays in the channel are very small due to the single direction communication. Thisincreases the demands on the stability of the communication channel significantly.

3.2 Multicast methods available today

The methods for time distribution are under constant development. The multicastdistribution technique is generally very interesting for time distribution. It givespossibilities to transmit time information to a large group of users with limitedresources. There are no restrictions of how many users that are allowed to receivea multicast transmission. A number of existing multicast systems offer possibilitiesfor time synchronization.

Measurements on the synchronization in the television signal was earlier a fre-quently used time source. The measurements were performed first and then cor-rections were made manually to get the time comparison.

The radio navigation system Loran C can as well be used for time synchroniza-tion purposes. The Loran C transmitters are located along the coasts. No regulartime code is transmitted but the frequency information in the system are used bymany receivers to output synchronized second pulses.

GPS and DCF77 are the most used systems in Europe for time synchronizationnowadays. Both of these systems can be regarded as broadcast systems. For timesynchronizing via Internet the Network Time Protocol (NTP) is most used. This isprimary a unicast system but has modes for manycast and multicast as well. NTPis not further treated in this report.

3.2 Multicast methods available today 9

3.2.1 DCF77

DCF77 is a time distribution system with a transmitter located in Mainflingen, 25km south-east of Frankfurt am Main, in Germany. It transmits time and frequencyinformation on a carrier frequency of 77.5 kHz.

The carrier signal is amplitude modulated with second marks. At the beginningof each second the carrier amplitude is reduced to 25 percent for a duration of either0.1 or 0.2 seconds. These different pulses correspond to binary high or low and areused to transmit a time code. The values for minute, hour, day, weekday, monthand year are BCD-coded and the whole time code is sent during a period of oneminute. The time code is based on the German national time scale UTC(PTB)provided by Physikalisch-Technische Bundesanstalt (PTB) [13].

The DCF77 is used for synchronization of real time clocks as well as frequencyreference with relatively high demands of stability. The system covers the southernpart of Sweden and can here be used as time reference with an accuracy of a coupleof microseconds with a high quality time receiver. A major drawback for Swedenis the long distance between the transmitter and the receiver. The signal might bevery weak and it is often difficult to receive it, particularly indoors.

3.2.2 GPS

The Global Positioning System (GPS) is today the globally most used for timeand frequency dissemination. The system is primary a navigation and positioningsystem but it also offers time and frequency information with high accuracy andstability. It consists of more than 24 satellites in orbits around the earth. Everysatellite is equipped with atomic clocks that are accurately monitored against UTCand the GPS time is an average time calculated of all satellite clocks and a numberof additional clocks located on the earth. The GPS-time is realized through theGPS atomic clocks and related to UTC. UTC(GPS), received with a GPS receiver,reaches an accuracy of less than 100 ns relative to UTC depending on the type ofthe receiver[24].

There are GPS receivers that are relatively cheap but the requirements of theantenna are still high. To get a high time accuracy, the position of the antenna hasto be known and the GPS always requires free sight to the satellites as well.

As an alternative to use the GPS signal directly for time synchronization, GPSCommon-View (GPS CV) can be used to compare two clocks at different locations.With this method observations of the GPS satellites are performed at the differentlocations during the same instant of time. The observations are then comparedand the time difference between the clocks is obtained[24].

10 Time Distribution

Chapter 4

Possible multicast systems

This chapter presents a couple of existing commercial communication systems thatcan possibly be used for multicast time distribution. A brief description of everysystem is made and advantages as well as disadvantages are presented.

4.1 DECT

A DECT network, used for voice communication, covers the whole of the office areaat SP. The network, together with the switchboard, is supplied by Ericsson. Whatare the possibilities to use the existing DECT network at SP for time distribution?

4.1.1 The DECT System

DECT, Digital Enhanced Cordless Telecommunications, is a standard specifiedby the European Telecommunications Standards Institute, ETSI, for cordless tele-phones. The DECT system is mostly used for indoor telecommunications as anwireless alternative to the traditional wired telephone but with the mobile advan-tages from the cellular network. The network comprises base stations and mobileterminals and the coverage varies from one private house with one base stationto large office complexes with thousands of users. Every single network is usuallyconnected to the Public Phone station.

The Physical Layer of DECT is based on both TDMA (Time Division MultipleAccess) and FDMA (Frequency Division Multiple Access). One channel consists ofa time slot and a frequency slot which are dynamically selected by the base stations.This gives a very flexible system for interference free communication. There are10 carrier frequencies between 1880 and 1900 MHz available. One frame of 10 mscontains 24 time slots and full duplex (bidirectional communication) provided byTime Division Duplex results in 12 parallel channels on each frequency. The totaldata rate is given to 1152 kbit/s at each frequency[20].

11

12 Possible multicast systems

4.1.2 Time distribution via DECT

There are roughly two different ways to use a DECT system for time distributionpurposes. One possible method could be to use some type of already implementedtime information in the system. Another way would be to use DECT as a datachannel and transmit a time code via some data interface supported by the system.

The DECT-standard released by ETSI [6, 7] does not mention anything aboutsystem time or clock time that can be used for this purpose, however differentmanufactures have made time information available via DECT for their own mobileterminals. Ericsson distributes the current system time of the switchboard to theterminal every time the terminal is powered on and connected to the system. Thetime information is not broadcasted by the base station and to get access to thistime information one must in principle connect with a device that is subscribed inthe network. This implies that there is no possibility to snap up the current timeby only listening to the DECT network.

The other possibility is to distribute time as a special payload with some kindof modem solution designed for DECT systems. The Base Stations from Ericssoncomply with two different profiles for communication in DECT, GAP (Generic Ac-cess Profile) and CAP (CTM (Cordless Terminal Mobility) Access Profile), bothspecified in the standard by ETSI. These profiles do not support any kind of plaindata communication. There are different data profiles specified in the DECT stan-dard but they can not be used without being supported by the system network.

4.2 Mobile telecommunication

Mobile telecommunication systems offer possibilities of data and voice communi-cation with high national coverage through different types of networks. The earlydigital systems, sometimes called the second generation systems, are today in prin-ciple finalized. The third generation systems are under construction and withinthese the first operational network in Sweden started offering service during 2003.What are the possibilities to use these systems for distribution of time in multicastand what are the limitations?

There are many different technical network solutions for cellular systems indifferent parts of the world. For the digital second generation systems, GSM isdominating in Europe and is partly spread in the rest of the world too. IS-95 CDMAis another second generation system. It is used in North America and is interestingin connection with time distribution. For the third generation systems there aretwo competing standards, WCDMA mostly used in Europe and CDMA2000 whichis a further development of IS-95 CDMA.

CDMA, Code Division Multiple Access, is an access method that uses differentspreading codes to distinguish the different channels from each other. It is usedinstead of FDMA and TDMA discussed in 4.1.1.

This overview concentrates on WCDMA, which is the future dominating systemin Europe, and one application of IS-95 CDMA is mentioned. The first issue to con-sider is at what level in the system the time information might be distributed. Is it

4.2 Mobile telecommunication 13

possible to send time information as a special payload on any available multicast orbroadcast data channel or is it possible to use the synchronization message broad-casted by the base station for time distribution purposes? This will be discussedin the following two sections.

4.2.1 Multicast data services available

From a general point of view, there are problems with the prerequisites for timetransmissions at higher levels. The delay of the channel may be difficult to estimateand a possible instability of this delay affects the accuracy. The most known mod-ern service for data transfer is the General Radio Packet Service, GPRS. GPRS isavailable in GSM as well as WCDMA and offers various solutions for data commu-nication. GPRS is not a multicast service though and the communication is basedon point to point connections. The quality of the service does not comply with therequirements for time transmission either because the capacity available for GPRSin the network may change dynamically. With this capacity change the delay ofthe channel may change as well.

There are different multicast/broadcast services defined for multimedia pur-poses in the specification of WCDMA but the real time properties are often notspecified. In cases where they are specified, they do not fulfill the requirementsfor the time transmission purposes. The reason is often that multimedia does notrequire these type of high qualities of the transmission channel.

There is also a low data rate broadcast channel, Cell Broadcast Channel (CBS),specified. This is aimed for SMS-like messages that can be broadcasted over a ge-ographical limited area. There is no information given about real time or delayproperties of this channel either but the parallel with SMS makes it not very in-teresting for real time applications.

4.2.2 Broadcast synchronization channels

The communication between the base station and the mobile terminal on lowerlevel is divided in different physical channels for downlink and uplink. Among thedownlink physical channels especially one group of channels are of interest, thesynchronization channels. They are used when the terminal synchronizes with thebase station. These channels are broadcasted over the entire cell from the basestation.

There are two different modes of WCDMA characterized by the duplex method,Frequency Division Duplex (FDD) and Time Division Duplex (TDD). In FDD theuplink and downlink transmissions are separated in different frequency bands andin TDD the uplink and downlink transmissions are multiplexed on the same carrier.The different duplex methods involve a different structure of the synchronizationsolution. WCDMA FDD constitutes today the generally so called third generationcellular network in Sweden and Europe.

In FDD mode the base station works asynchronous and there is no need for basestations to be synchronized between themselves. For synchronization between base

14 Possible multicast systems

station and terminal two channels are used, the Synchronization Channel (SCH)and the Common Pilot Channel (CPICH). There are a primary and a secondarySCH and they are used for slot and frame synchronization. The terminal must beable to synchronize to the cell before knowing the downlink scrambling code andtherefore the SCH is not under cell specific scrambling. After the synchronizationthe CPICH is used to determine the exact primary scrambling code for the cell.CPICH is also phase reference to other downlink channels and aid the channelestimation at the terminal for the downlink channels[15].

For TDD-CDMA, base station synchronization is desirable because of intercelland interoperator interference. The synchronization accuracy must be only onsymbol level, not chip level. It can be achieved with GPS receivers at the basestation or a common clock signal with extra cabling. The synchronization betweenterminal and base station as well as the code group of a cell for TDD-CDMA, areachieved via the Physical Synchronization Channel (PSCH)

Independent of whether the base stations are synchronized between themselvesor not, none of WCDMA-FDD or WCDMA-TDD offers any time specific informa-tion in broadcasted synchronization channels besides the chip-rate and frequencyof the channel. There are no information in the base station broadcast messagesthat can be used for time distribution without relating to something else.

IS-95 CDMA, adopted as a second generation digital cellular standard in NorthAmerica, uses GPS for synchronization and can be used for UTC time synchro-nization as well with GPS as a base. This is briefly described below.

Indirect GPS via IS-95 CDMA

In IS-95 CDMA the base stations are separated by spread-spectrum modulationand every station uses the same Pseudo-Noise code but each one with a delay of64 chips of the code, equate to 52.0833... microseconds. With this delay in thecode a maximum timing error of 10 microsecond is allowed in order to maintainan adequate separation. To obtain these timing requirements in the system theIS-95 standard defines the system time to the same time as the GPS time, whichrequires the base stations to be synchronized to GPS time within 10 microseconds.To maintain this synchronization every base station has to be equipped with a GPSreceiver.

The GPS time information is contained in the synchronization channel broad-casted from the base station to the terminal. By receiving and demodulating thissynchronization message and the pilot message broadcasted by the base station,UTC(GPS) can be received with an accuracy 10 microseconds[16]. This possibil-ity also applies to the third generation system, CDMA 2000, which uses the sametechnique for synchronization.

4.2.3 NITZ

Network Information Time Zone, NITZ, is a service message that is optional inboth GSM and WCDMA networks[9, 8]. The main purpose of the service is to

4.3 Radio Broadcasting 15

provide mobile terminals with information of current time zone during roamingbetween different networks. Some manufactures, e.g. Nokia Mobile Phones, usethis service to continuously synchronize the real time clock in the mobile terminal.Nokia also offers GSM-modules with this feature embedded. In the specificationof NITZ the accuracy of the service is given to a couple of minutes. The NITZmessage is not broadcasted but available when the terminal is connected to thebase station.

A contact was taken with Telia to discuss NITZ and its accuracy. Telia has theservice implemented in their network but they do not give any guarantees for thetime accuracy at the time of this report. They were very interested in why andhow we want to use the time and they did not sound unfamiliar to specify it for aspecial usage.

4.3 Radio Broadcasting

Today there are possibilities to send digital data via the existing infrastructure forpublic analog radio broadcasting. The information is sent via a subcarrier whichis added to the original stereo multiplex signal. There are two different channels,Radio Data System (RDS) and Data Radio Channel (DARC). Both of these couldbe possible transmission channels for time distribution.

In the near future Digital Audio Broadcasting, DAB, is probably going to breakthrough for public radio. This digital radio system will give us highly increaseddata rates for broadcasted radio and DAB also offers transmission of other digitaldata than audio.

4.3.1 RDS

RDS, specified in[12], is a low data rate channel used as an information channel bytransmitters and radio stations where different information such as program nameand program type are transmitted. The information gives the listener increasedfunctional service such that mobile receivers automatically can hold a particularradio station and change to the frequency with the strongest signal.

In Sweden nearly every radio station transmitted on the FM network supportsRDS. However the functions supported by every station can be different. TeracomAB, who is transmitting the Swedish radio stations with national coverage, P1 toP4, has also been responsible for the development of the Swedish RDS network.

The bit rate of the channel is relatively low, 1187.5 bit/s. The data stream isbased on data blocks of 26 bits where 16 bits are information bits and the remaining10 bits are for error correction. Four data blocks constitute one data group which isthe largest element of the structure. Every data group contains 104 bits and has aduration of 87.6 ms. There are different types of data groups, each type containingdifferent information. Every type of the group has a unique identity.

One service transmitted in RDS is ”Clock-Time and date information ”and themessage type is called CT. This message could be used for time distribution. A

16 Possible multicast systems

CT-group is transmitted every minute and is inserted so that the end of the groupwill occur as near the minute edge as possible depending on the group resolution.An uncertainty of half a block length, about 43 ms, is introduced here becauseof the fact that the group edge does not synchronize with the minute edge. TheRDS standard states the total accuracy to ± 100 ms. There are different possiblesources of uncertainty besides the group and minute synchronize. The path delaybetween transmitter and receiver varies depending on the geographical location, seethe discussion in 4.3.4. The source of time also has a great impact and there can bedelays in transmitter and receiver that have an effect on the accuracy. These delaysare difficult to estimate without practical tests because they may differ dependingon the type of the transmitter and the receiver.

Experience shows that the discipline of the operators to transmit the correcttime varies and there are examples of local radio stations whose time referencediffer several minutes to UTC. The most reliable time is transmitted by Teracomwho is responsible for the transmission and time reference of P1, P2, P3 and P4.Their time reference has until now been a rubidium clock synchronized to UTC viaDCF77. During this autumn however, Teracom is going to change reference andstart using NTP and their local network time instead.

RDS is already used as a time reference for synchronization of radio receivers.The time received via RDS is also used in other situations where the requirementsof the accuracy are less important. By this time it is not recommended as a reliableand quality assured time source by SP.

4.3.2 DARC

The Data Radio Channel, specified in[5], is another channel for transmitting digitaldata on the analog radio network. It is, like RDS, transmitted on a subcarrier addedto the original FM multiplex signal. The raw bit rate is 16 kbit/s and the channelcan be used for various data applications. The main usage today is disseminationof DGPS-corrections for GPS navigation and news transmissions for hand-holdcomputers.

There are three different DARC channels with national coverage transmittedvia the national radio stations P1, P2 and P3. P4 has DARC enabled in somelocal areas. P2 is exclusively used by the Swedish national defense for informationconcerning air force information. The DARC networks is managed by Teracom,who is responsible for the infrastructure as well as for the daily operation.

The data on the DARC channel is arranged in blocks were one block consistsof 288 bits which corresponds to a block duration of 18 ms. 272 blocks form oneframe, which is the largest element in the data structure.

Besides the general pay load data transmitted on a DARC channel there arevarious service information messages for the channel transmitted as well. One ofthese messages contains time and date information. The message is called Timeand Date Table, TDT, and contains information about current date and clock timein Modified Julian Day, hours, minutes and seconds. Apart from this, a TimeAccuracy Field, TAF, can be present and states in that case the number of blocks

4.3 Radio Broadcasting 17

since the beginning of the current second. With TAF enabled, the TDT can offera maximum accuracy of ± 9 ms according to how the time field is specified. Thestandard of DARC does not specify any accuracy of the time information for thefinal user but there is a bit in the TAF telling weather the time is accurate withinone second or one block.

In order to reach a higher accuracy, time information with a resolution of mil-liseconds could be transmitted with a change of the current time format or as aspecial payload.

4.3.3 DAB

During the last ten years DAB, specified in[11], has been developed and today onlyeconomical restrictions limit the changeover to digital radio for the public service.Today there are working test networks covering metropolitan areas in Sweden anda decision of an extension is close at hand. DAB is giving a total data rate of 2.432Mbits/s.

The DAB data channel is divided into two main channels, the Main ServiceChannel (MSC) and the Fast Information Channel (FIC), which for time distri-bution have very different properties. The MSC is time interleaved to obtain aneffective error correction but at the price of a very long delay in the channel, 360ms. The FIC, on the other hand, uses high protection and frequent repetition ofthe data and is available without the delay caused by the error correction.

The FIC is primary used to transmit the multiplex configuration of the DABtransmission but there are also possibilities to send Service Information (SI) viathis channel. One of these SI messages is Date and Time which allow an operatorto send time information at a millisecond level. The service information is optionalfor the operator but the data format is specified in the DAB standard.

Data modulation and structure

DAB uses a multi-carrier modulation method called OFDM (Orthogonal FrequencyDivision Multiplex). The idea behind multi-carrier modulation is to split up thehigh rate data stream into a number of (K) parallel data streams of low datarate and modulate each of them separately on its own carrier. This leads to anincreased symbol time with preserved data rate and makes the system less sensitiveto intersymbol interference. There are four different Transmission Modes (TM),each with different OFDM parameters to suit various physical situations.

Mode K Ts Frame length FIBs per FrameTM I 1536 1246 µs 96 ms 12TM II 384 312 µs 24 ms 4TM III 192 156 µs 24 ms 3TM IV 768 623 µs 48 ms 6

Table 4.1. Different modes of DAB

18 Possible multicast systems

The data in DAB is structured in frames with a length of 24 ms, 48 ms or96 ms depending on which TM it is operating in. Every frame consists of twosynchronization symbols and a number FIC and MSC symbols. The number ofsymbols and the symbol time, Ts, depends on the operating mode. For TM IIthere are three FIC symbols and 72 MSC symbols. The gross bit rate for MSC isalways 2.304 Mbits/s whereas the gross bit rate for the FIC is 96 kbits/s for everymode except TM III which has 128 kbits/s.

The FIC consists of a number of Fast Information Blocks (FIB) which carrythe information. For the FIC a error coding rate of 1/3 is used and by that a netbit rate of 32 kbit/s is obtained for TM I,II,IV and for TM III the net bit rate isincreased by a factor 4/3. Every FIB comprises 32 bytes of data, of which 2 bytesare used for error detection (CRC) and the remaining bytes are used for MultiplexConfiguration Information (MCI) and SI. The number of FIBs varies depending onthe Transmission Mode and is adjusted to get the appropriate data rate.

SI - Time and Date

The Service Information, which is optional to transmit, may contain Time and Dateinformation and this could with advantage be used for time distribution purposes.The information includes Modified Julian Day and the time in UTC. The time canbe given in two formats, a short-form with only hours and minutes and a long-formformat with seconds and milliseconds as well. There is also a confidence indicator,a bit that tells weather the time is within the agreed tolerance.

There is no information about the accuracy of the time in the standard besidesthe fact that the time can be made available in millisecond resolution. The factthat the data rate of DAB is high and the symbol time is relatively short wouldgive opportunities to distribute time at millisecond level. Considerations may benecessary when choosing the time source and designing the receiver, and maybeeven the transmitter, to reach this accuracy.

4.3.4 Time distribution in broadcast radio networks

Most broadcast radio transmitters are active in the VHF-band (30 - 300 MHz) andhave limited coverage areas. To obtain a national coverage several transmitters haveto be used. This may be a problem for the purposes of time distribution. For hightiming capabilities it is be desirable that all transmitters are synchronized. Theoptimal situation would be to have a cesium clock as time source, located at everytransmitting station. This is however a very expensive solution and practicallyimpossible to carry out.

A more practicable solution would be to have one accurate time source locatedat a central position such as Kaknastornet. It is located in Stockholm and from herethe transmissions of the national radio stations are distributed to the local trans-mitters. How would the delays be affected depending of the different geographicallocations of the local transmitters according to Kaknastornet? The maximum dis-tance between the source and the transmitter would be about 1400 km. If the

4.4 Bluetooth 19

speed of light is regarded as the signal propagation velocity the maximum delaywould be about 5 ms. In fact, the delay would be higher because the communica-tion lines to the transmitting stations does not support light speed communication.The real delays are difficult to predict at a theoretical level because of the lack ofavailable written system information from Teracom. Presumably these delays arenot even known by Teracom because they do not have these real time demands inthe network today. A very rough assumption would be that the delays are in theregion of 20 ms.

In DARC, the position of the transmitter may be included in the time message.If there is a considerable delay, proportional to the distance between Kaknastornetand the transmitter, it could be corrected by using this position.

The transmitted signal in the VHF-band is not reflected in the ionosphere.Only the ground wave will reach the receiver and thereby the limited coverage areaof one transmitter. The advantage of having no ionospheric reflection is that thereception is never disturbed by the sky wave and the propagation time does notvary from day to day depending on different ionospheric conditions.

4.4 Bluetooth

Bluetooth is a wireless communication method developed for cheap, simple andsecure communication with relatively short range, for example flexible connectionsbetween mobile phones and accessories such as headsets and laptops. It operatesat 2.4 GHz, which is a globally available license-free frequency band reserved forindustrial, scientific and medical applications which is called the ISM-band. Themodulation is very modern and uses both Time Division Multiplex (TDM) andFrequency Division Multiplex (FDM). During transmission a frequency hoppingtechnique is used and in principle the channel frequency can change for each timeslot, every 625 microseconds. The maximum bit rate for Bluetooth is 723.2 kbit/sin downlink and 57.6 kbit/s in uplink or 433.9 kbit/s symmetric[4].

There are two types of network topologies for a Bluetooth network. One masterand up to seven slaves can form a piconet and several piconets can be connected toeach other to form a scatternet. In the scatternet every master has the capabilityto act as both master and slave in different time slots and by that connect thetwo piconets. The scatternet forms a so called ad hoc network. There are differentclasses of output power and these give a master slave connection a range of between10 and 100 meters.

Bluetooth is primarily developed for point-to-point communication although anetwork may include several nodes. However there is a broadcast function whereone can send one packet to every active slave in one moment. This is a one waycommunication channel without possibility to check whether the slaves received thetransmitted package or not. It is possible to use the multiplexing service supportedby Bluetooth to send different data types on the same channel.

There is no time information embedded in Bluetooth as system. The possibilityto use Bluetooth as time distribution system is to transfer a special payload with

20 Possible multicast systems

time information. This distribution system would however cover a very local area.Another issue might be that there are several layers between the physical channeland the common development interface, providing many functions that are not veryuseful for time distribution. The risk is that these functions will create transmissiondelays that are difficult to estimate. The data rate of Bluetooth is also unnecessarilyhigh. For time distribution only, a simpler communication solution might fulfill therequirements.

4.5 Summary of described systems

4.5.1 DECT

DECT is today mostly used for voice communication and is not an interestingalternative for a new establishment of a time distribution network. One possibilitywould be to use an existing DECT network and receive the time stated by theswitchboard which already may be available in the mobile terminals. It is difficultto evaluate the quality of the switchboard as time source though and to make itreliable would presumably require a large work.

4.5.2 Mobile telecommunication

The mobile telecommunication systems dominating in Sweden are today GSM andin the future WCDMA. There is no obvious way to use GSM or UMTS for multicasttime distribution with high accuracy. The possible multicast channels availableare designed for multimedia and do not comply with the demands of a real timechannel for time distribution. There is no time information in the broadcastedsynchronization message that can be used either. The complexity of these systemsis very high. Changes in order to allow accurate time distribution would be avery large project and has to be done in close co-operation with mobile systemdevelopers.

4.5.3 Radio Broadcasting

The opportunities to send digital data via the public broadcasting network arevery interesting for multicast time distribution. The three systems RDS, DARCand DAB are reviewed. All of the three systems contain time information that canbe used for multicast time distribution.

RDS

RDS offers time with an accuracy of 100 ms according to the RDS-standard. Therelatively low data rate and long symbol time does not make this system interestingfor a further development to obtain a higher accuracy.

4.5 Summary of described systems 21

DARC

DARC has a higher data rate than RDS. With a receiver designed for time receptionand a reliable time source, the accuracy could be at least 18 ms. The limitationis that the time is stated with a resolution of one block and the block length is 18ms. With changes of the time format so that the time is stated with millisecondresolution the accuracy could possibly reach a couple of milliseconds.

DAB

DAB is the latest broadcasting technology and is completely digital. The timeformat available may contain a resolution of milliseconds. If the receiver and thetransmitter (encoder) are designed properly and an accurate source is used, thetime accuracy would probably be at least a couple milliseconds thanks to the highdata rate and short symbol time.

4.5.4 Bluetooth

For short-range communication of up to 10 and maybe 100 meters Bluetooth shouldbe a cheap and robust wireless technology. For time distribution Bluetooth maybe interesting for short distances. One possible drawback is the protocol structurethat is rather complicated and it includes many functions not needed for timedistribution. This may result in delays difficult to estimate.

22 Possible multicast systems

Chapter 5

A deeper review of DARC

The are a number of conditions that make the public broadcasting networks inter-esting for time distribution with national coverage.

• The transmitter network is already established.

• The limited complexity of the technical solution makes it suitable for realtime communication.

• There are often time information already available in the systems that canbe used. Modifications may however be necessary to increase the accuracy.

• The systems are constructed for multicast/broadcast communication.

In order to investigate possibilities and restrictions of time transmission viathe public broadcasting networks DARC was selected for a detailed study. In theDARC transmission, time information is included and this information is usedfor the investigation. Two experimental receiver systems were constructed witha commercial receiver connected to a PC respectively a microprocessor. Differentmeasurements were then performed to evaluate the accuracy and stability of thetransmitted time.

5.1 The DARC network

The DARC signal is transmitted as a subcarrier on the FM multiplex signal usedfor public broadcasted analogous radio. The advantage of transmitting via theFM signal is that the existing infrastructure is used for the transmission. Thetransmitters are already available with an almost complete national coverage andthe communication out to the transmitters is established as well.

In Sweden there are three parallel networks corresponding to the three nationalradio stations P1, P2 and P3. There is also a fourth network covering metropolitan

23

24 A deeper review of DARC

areas via the P4 station. All networks are operated by Teracom but there aredifferent service providers for each of them.

The DARC transmitted via P1 is used by Sectra AB which primarily sendsfinancial information for their CitySurfer, a hand-hold DARC receiver with dis-play. Via P2 the Swedish Military is using DARC for LuLIS, a tactical broadcastinformation system that provides air situational awareness to all military units inreal time. Finally the DARC via P3 is used by Teracom AB where smaller serviceproviders are allowed to rent more or less capacity. The local P4 network is usedfor transmitting Differential GPS-corrections (DGPS) to final users.

The two main components that are specific for DARC in the network infras-tructure are the NetWork Server (NWS) and the Transmitting Station Equipment(TSE). There is one NWS for every network and for the Swedish networks operatedby Teracom AB the NWS is located at Kaknastornet in Stockholm. The NWS isresponsible for controlling the transmission, the direction and the quantity of theinformation which is sent to the TSE. The TSE is located at the FM transmittersite and consequently there is a TSE, one for each network, at every transmitter.The data stream is received by the TSE from the NWS and the TSE is the DARCencoder that generates the DARC compliant 76 kHz subcarrier.

Figure 5.1. Example of system outline of DARC

5.2 DARC communication layers 25

5.2 DARC communication layers

The communication between two DARC devices, a transmitter and a receiver, isstructured according to the Open System Interconnection reference model (OSI ref-erence model). The OSI reference model is nowadays the most used for structuringcommunication between different devices.

As a main principle of structuring, the model subdivides the functionality in 7functional layers. Layer 1 - 4 include functions needed for transferring data betweendevices and Layer 5 - 7 include functions needed to facilitate the interaction betweenusers at application level. For our requirements concerning time distribution themain interests are Layer 1 - 4. The other layers offer a large number of additionalfunctions but these are not needed or even not necessary for the time distributionpurpose. DARC is specified in [5].

5.2.1 Physical layer, Layer 1

The transmitter side is responsible for modulating the subcarrier with the datareceived from Layer 2 and for adding the modulated subcarrier to the FM multiplexsignal. The subcarrier frequency is 76 kHz ± 7.6 Hz and it is modulated withLevel-controlled Minimum Shift Keying (LMSK). LMSK is a type of MSK wherethe amplitude of the modulated subcarrier is controlled by the level of L-R (leftminus right) signal.

The receiver side is responsible for extracting the subcarrier from the FM mul-tiplex signal and demodulation of the subcarrier. The data from the demodulatedsubcarrier is sent to Layer 2.

The channel has a continuous gross bit rate of 16 kbit/s ± 1.6 bit/s.

5.2.2 Data link layer, Layer 2

The Layer 2 includes logical functions related to the data transmission such asblock and frame synchronization, data formatting, error protection and scramblingfor energy dispersal.

The largest element in the data structure is the frame which consists of 78336 bits divided in 272 blocks with 288 bits each. There are two types of blocks,information blocks and parity blocks. Every block is beginning with a Block Iden-tification Code (BIC) of 16 bits. The information block comprises 176 informationbits and 96 bits for error correction besides the BIC and the parity block is exclu-sively used for error correction.

Figure 5.2. A Layer 2 information block

26 A deeper review of DARC

The error correction is performed both horizontal for one block and verticalover the entire frame.

There are three different frame types specified, each one with different allocationand layout of the parity bits. The frame A comprises 190 information blocks and82 parity blocks in one sequence. In frame B the parity blocks are spread almostuniformly over the frame in order to obtain an information transmission as uniformas possible. Frame C only consists of information blocks and no delay is caused byparity blocks. There is also a variant of frame A, frame A1, with real time blocksinserted between the parity blocks to suspend the delay caused by the parity blocks.The total number of blocks in that case is 272 + 12.

Figure 5.3. A DARC Layer 2 frame of type A

The BIC that starts every block is used to distinguish parity blocks from in-formation blocks and to retrieve frame and block synchronization. There are fourtypes of the 2 bytes long BIC and they are designed to have poor cross-correlationwith each other, while their auto-correlation make them suitable for synchroniza-tion. Layer 2 also scrambles the data to avoid restrictions on incoming data andto spread the modulation spectrum.

The transmitter side is responsible for sending Layer 2 frames once it is filledwith data by Layer 3. The receiver side is responsible for interpretation of theincoming continuous bit stream as well as delivering received data blocks to Layer3 with a quality check parameter included.

5.2.3 Network Layer, Layer 3

Layer 3 is responsible for providing data ready for Layer 2. The data is organizedin Layer 3 blocks of 22 bytes or 176 bits each, corresponding to the length of theinformation part in the information blocks of Layer 2. One Layer 3 block consistsof a Layer 3 header and a remaining data part. In Layer 3 there are four logical

5.2 DARC communication layers 27

channels defined, each one with different functionality depending on the type ofthe transmitted data. The channels are presented below.

• The Service Channel (SeCh), handling Layer 4 service messages, is used fortransmitting network and service information to the receivers.

• The Short Message Channel (SMCh), handling Layer 4 short messages, isused for transmitting data with real time capabilities.

• The Long Message Channel (LMCh), handling Layer 4 long messages, is usedfor transmitting data files.

• The Block Message Channel (BMCh), is used for transmitting blocks of data.

The different channels are identified in the first four bits of the Layer 3 headerand the rest of the Layer 3 header is then different depending on the channel type.The SeCh is of most interest for time application because there are special servicemessages containing time information in this channel.

Figure 5.4. Service massage divided in Layer 3 blocks

SeCh Layer 3 header

The Layer 3 header of the Service Channel is 3 bytes long and contains informationabout the service message in general, the type of the message, the length of it andthe first bits indicate the service channel.

There are eight types of different service messages where two are time informa-tion messages, Time, Date, Position and Network name Table (TDPNT) and Timeand Date Table (TDT). The other service messages contain frequency informationof nearby transmitting stations and multiplex information concerning services onthe other message channels.

5.2.4 Layer 4, Service Channel

In the next layer, Layer 4, the different service messages as well as the messagesof the other logical channels are implemented. The service messages comprise a

28 A deeper review of DARC

Layer 4 header and the special service message. The header occupies three bytesand the message can occupy up to 301 bytes. The maximum total length of aservice message is 304 bytes and in that case it will occupy 16 Layer 3 blocks.

Two of the service message types are TDPNT and TDT. The reason why thereare two types of service messages for time information is that TDT replaces theearlier TDPNT. Both TDT and TDPNT contain current Modified Julian Day andUTC time in hours, minutes and seconds. The main difference is that it is possibleto obtain higher accuracy with TDT. There is a Time Accuracy Field (TAF) inTDT that states the number of blocks since the beginning of the current second.With the block length of 18 ms it is possible to receive time information with amaximum accuracy of ± 9 ms without changing the time format. Today TDTshould be used instead of the old TDPNT.

In both these message types network name and position of the transmitter canbe included as well. This is optional for TDT but shall be included in TDPNT.

Figure 5.5. The format of the TDT Time and Date Table

Figure 5.6. The Time Field of TDT

5.3 DARC receiver 29

5.3 DARC receiver

The receiver used for the time transmission investigations of the DARC system isSectra DRB-3000. This is a stand alone receiver equipped with a RS-232 connectorto connect the receiver to a computer or microprocessor. The receiver is compliantwith DARC according to the standard by ETSI [5].

There is no internal antenna on the receiver. An external antenna have to beconnected via the SMB coaxial RF jack. A small table antenna was included ondelivery which has been used with success and besides this a fixed antenna locatedon the roof of the office building was used.

The DARC receiver is not very complicated and is therefore relatively cheap.The price of the Sectra DRB-3000 is about 5000 SEK but only the DARC chip isprobably essentially cheaper.

5.3.1 Communication with the receiver

It is possible to communicate with the receiver via two different protocols, the ter-minal interface or the SOS-protocol. The communication with the receiver via bothof these protocols takes place through standard RS-232 communication connectedto the 9-pole DSUB RS-232 connector of the receiver [21, 22, 23].

Terminal interface

To communicate with the receiver via the terminal interface connection is estab-lished with a terminal program and the receiver has to be set up in terminal mode.There is a special set of commands available to control the receiver and they aretransmitted via the common terminal interface and sent to the receiver in ASCII-format. The terminal protocol is primarily intended for test purpose.

SOS-protocol

The SOS-protocol is a special protocol developed for communication between theDARC receiver and the equipment communicating with it. Everything sent to orfrom the receiver via SOS is embedded in a frame. The frame is delimited with areserved byte which marks the start and stop of the frame. For different type ofmessages logical channels are defined. One message comprises a start and a stopbyte, channel, channel specific message and CRC for error detection. To preventthe start and stop byte from occurring somewhere else in a message byte-stuffingis performed. If a reserved byte is included anywhere else in a message this willbe replaced with two other bytes. Byte-stuffing and calculation of CRC is madeaccording to instructions in the SOS-protocol reference [22].

5.3.2 Data output

The decoded data from DARC is available from the receiver via both the terminalinterface and the SOS-protocol. The data can be made available at different layers

30 A deeper review of DARC

depending on the data mode configuration of the receiver. Via the terminal inter-face DARC data is decoded and transmitted without any additional informationcompared with the data transmitted on the channel. In SOS-mode the transmit-ted data are supplemented with the SOS frame structure. Information about thecurrent status of the receiver and data quality, interesting for the user, is alsoobtained.

Data mode 2 contains DARC Layer 2 blocks after BIC synchronization butbefore error correction. Both information and parity bits are sent but the BICis excluded. The block length of a Layer 2 block is 34 bytes. The informationincluded by the SOS-protocol is 9 bytes long. The total length of the Layer 2 blockis 43 bytes plus eventual extra bytes in case of byte-stuffing.

Data mode 3 contains DARC Layer 3 blocks after horizontal error correction.If vertical error correction is performed the block is put out a second time. TheLayer 3 block consists of 22 bytes plus SOS protocol information of 9 bytes whichresults in a block length of 31 bytes excluding byte-stuffing bytes.

There are a number of modes for data of higher layers but these functionalitiesare not needed for the purpose and are left without further explanation. Accordingto the documentation also a raw data mode should be available but this mode is notaccessible in the particular receiver according to Sectra. This mode, if accessible,could offer the possibility to access the data at an even lower level and avoid delaysin the receiver.

5.4 Time source

The DARC system is not primarily designed for time distribution. The informationavailable about the organization of the time system of DARC is therefore limited.Contacts have been taken with Teracom and they have given an overview but nota detailed description.

The time in the TDT or TDPNT messages can be stated by either the NWSor TSE. In both cases the time is obtained via the Network Time Protocol. TheNWS is synchronized via the local network at Kaknastornet and the TSE obtainthe NTP-time from the default gateway at the transmitting station. According toTeracom the NTP source in their local area network is hierarchically built with 5- 10 NTP servers at Internet in the top and GPS-clocks at different locations asbackup.

The NWS states the time in the TDT messages for P1 and the TSE for P3.How often the NWSs and the TSEs are synchronized with the NTP sources isunknown. The orgin of the time source is not perfectly known for the moment andthis should be considered when the following test results are studied.

5.5 Test implementations

In order to obtain a measure of the possible accuracy and stability that can beachieved by receiving the DARC TDT message two different test solutions were

5.5 Test implementations 31

implemented. Both are based on the Sectra DRB-3000 DARC receiver.

5.5.1 Receiver settings

The SOS-protocol was used to receive the data and the receiver was configured tosend data in mode 2 or 3. Data mode 2 was preferred for the tests in order tominimize the delays due to error correction. Different baud rates of the receiverwere used, 19200, 38400 and 57600 kbit/s, all with the modem parameters 8N1 (8data bits, none parity and one stop bit).

Other parameters of the receiver that have to be controlled are tuning fre-quency and receiver search mode, auto or manual. Manual mode was used and thefrequency was set depending on the desired station.

5.5.2 DARC received via the serial port of a PC

The first attempt was to connect the Sectra DRB-3000 to a PC and simply comparethe received time with the real time clock of the PC. The receiver was connectedto the serial port on the PC. For the serial port programming of the PC, Linuxwas found to be the easiest operating system to use and C/C++ was chosen as theprogramming language.

The serial port was accessed via the standard Linux library termios.h. Theprogram continuously reading the serial port uses a simple technique where theread command, polling the serial port, can be controlled by two parameters.

a) A byte timer that returns from listening to the port after a given time period(ms) or when one byte is received.

b) One parameter that defines a minimum number of bytes to receive untilreturn.

The program waits for a TDT message and when it is received, the time is extractedand compared with the clock of the PC. The PC clock is synchronized with the NTPstratum 1 servers located at SP. The program code is attached in the Appendix A.

In order to investigate the continuity of the data stream output from the re-ceiver, measurements were also performed of the timing at block and byte levelby measuring the time between every block or byte. Irregular delays in the datastream may affect the arrival time of the TDT messages and thereby the stabilityof the received time.

5.5.3 DARC received by a microcontroller

In a second test system a microcontroller was connected to the Sectra DRB-3000.With the DARC TDT messages as reference a pps (pulse-per-second) signal iscreated by the microcontroller which is compared with the pps signal available fromUTC(SP) at the time laboratory at SP. The comparison is performed with a timeinterval counter using the 10 MHz time base from UTC(SP). The counter measures

32 A deeper review of DARC

the time between the two pulses with negligible noise and the measurements arelogged with a PC.

Figure 5.7. System and measurement outline for the microcontroller solution

The microcontroller

The microcontroller used is a flash-based Microchip PIC16F874 with a maximumclock frequency of 20 MHz. [17] This is an 8 bit RISC CPU with only 35 single wordinstructions and a FLASH program memory of 4 K (14-bit words). It is equippedwith a USART (Universal Synchronous Asynchronous Receiver Transmitter) whichcan easily be configured for communication with the receiver via its RS-232 port.

In order to shorten the instruction time as much as possible the clock frequencywas chosen to 20 MHz and generated with a 20 MHz Crystal as source. Theinstruction time is 200 ns with this clock frequency.

Three different timers are available for various timing issues. Timer1 was chosenfor generating the pps signal using interrupts. This is a 16 bit counter that canbe clocked with another clock source compared with the main clock frequency. Tominimize the timing error originated from the timer it is clocked with 100 kHzobtained from a function generator with the 10 MHz UTC(SP) as reference. Thesinusoidal signal from the function generator is connected to the microcontrollervia a Schmitt trigger forming a square signal. To fit the 16 bit timer the signal isprescaled 1:2 in the timer. 50000 increments of the Timer1 will now correspond tothe duration of 1 second. The maximum value of the 16 bit timer is 65535. For aninterrupt after one second or 50000 ticks Timer1 is initialized with the value 15536.

Microcontroller system design

The PIC16F874 is the central device in the microcontroller implementation. Inorder to get a functional test system some peripheral components are needed.The layout of the circuit is shown in Appendix B. The RS232 communicationis established via a MAX202 circuit which convert the TLL/CMOS levels of thePIC to RS-232 signal levels. A 74HC14 was chosen to create the timer clock signalfrom the 100 kHz sinusoidal signal. The pps signal with an amplitude of 5 V was

5.6 Test results 33

created by a EL7202C MOSFET driver connected to one of the output ports ofthe microprocessor. A 7805 voltage regulator was used as power supply. 6 LEDswere also connected to ports of the PIC to be used as output indications of theprocessor.

Programming the microcontroller

The programming of the PIC16F874 was performed in assembler. [26, 18] The codewas written and compiled in MPLAB provided by Microchip and the microcon-troller was programmed via In-Circuit Serial Programming with MultiProgrammer3.5 provided by AD-Teknik AB.

The data stream from the DARC receiver is received in blocks of one byte.When a TDT-block is detected the TAF is extracted and the number of blockssince the last second provides a base for the calculations of the time period untilthe next second switch. The Timer1 will be initialized with a value calculated bymultiplying the value of TAF with 900, which is equivalent with the number ofticks of the timer during one block, and then add 15536 for the offset. A pulseis then generated via an interrupt when Timer1 overflows from FFFFh to 0000h.After the 10 microsecond pulse is generated, the timer is initialized to 15536 again.One second will pass until the next interrupt if no correction with information formanother TDT-block is made.

Initialization of the timer is performed immediately after the TAF field is re-ceived and there is a constant number of instructions between the reception of thisfield and the initialization. Often there are several TDT messages sent during onesecond. Only one message per second can be used and a simple selection was touse the first message every second. In order to avoid incorrect messages caused bya bug discussed in 5.6.1, only time messages that arrived during the first 350 mswere accepted as well. The program code is included in Appendix C.

To analyze the variations of the data stream a variant of the program waswritten to send out a pulse of 10 microseconds after every byte or every blockreceived. The time between two pulses was achieved by measuring the period timebetween every rising edge with the time interval counter.

5.5.4 Radio stations used

For the tests radio signals from the transmitter located in Boras were used. BothP1 and P3 use the newer format of the time message TDT while P2 uses the olderTDPNT. P1 and P3 have thereby become the most interesting sources for thiswork. The tests were performed under very good receiving conditions which gavea high quality of the data. Various data quality has not been studied in this work.

5.6 Test results

In the tests the stability of the time, in short and long term, has primarily beenstudied. The accuracy has been of less interest in most cases because it can easily

34 A deeper review of DARC

be corrected for in the time receiving software or in the receiver if the time isstable. The accuracy will be of more interest if time from different transmitters iscompared, according to the discussion in 4.3.4.

5.6.1 PC

The tests with the DARC receiver connected to the PC was only presented onthe monitor to get a rough apprehension about the accuracy and stability of TDTmessage. The primary task was to check the short term stability and to gain knowl-edge about the data format and how to extract the TDT-message. By studyingthe accuracy of the received time messages on the monitor they were found to varyin a maximum range of about 40 ms during approximately 20 messages received.This variation was larger than expected from the theoretical studies of DARC, see5.2.4. The sources of these variations will be discussed later in this report.

Bug in TDT

In conjunction with these tests a bug was discovered in the update of the transmit-ted Time Accuracy Field. The TAF should state the number of blocks since thelast change of second. The maximum value would be 55 and the TAF is therebyrepresented by 6 bits in the TDT-massage. In fact, the most significant bit isnever updated and instead of a switch between 31 and 32 the counter restarts atzero. When an incorrect TAF is received this will cause an error of 550 ms. Thebug is probably located somewhere in the time coding at the transmitter Teracom.Contacts have been taken with responsible staff at Teracom regarding this. Theyconfirm the bug, which was not known before this remark, but their intention isnot to correct it immediately. The encoders coding DARC are manufactured by athird part, Sectra, which makes the situation even more complicated.

The bug can be corrected, by the software processing the data stream, withhigh reliability in most of the cases except one. When the first time message of asecond includes an incorrect TAF, it is difficult to detect this. The case was nothandled in this implementation but an attempt was carried out in the software forthe microcontroller, see 5.6.2.

Limitation of Linux

To find possible sources of the relatively large variations of the received time in theshort term, the data output of the receiver was analyzed. By timing the arrival ofevery block or byte, it is possible to check the continuity of the data stream. Ifthere are irregular delays in the stream, these will probably affect the stability ofthe time reception.

By doing this experiment a limitation of Linux on a ix86 system became obvious.The resolution of the timing ability of a PC with Linux is limited to 10 ms. This isbecause of the scheduling timing-limit of processes in Linux. The limited resolutionresults in random and unpredictable time differences of 10 ms. No further effortswere made to solve the timing-limit the problem for this implementation. Instead

5.6 Test results 35

the microcontroller solution was implemented and measurements to explain the 40ms variation were made in this test system.

5.6.2 Microcontroller

With the microcontroller, tests of both accuracy and stability of the received timeand the data stream continuity of the receiver have been performed.

Time stability

The investigation of the time stability has been performed according to the mea-suring method described above. Measurements have been performed during shortperiods, of two hours, with measurements every second and during longer periods,of a couple of days, with measurements every minute.

The above described bug makes the measurements and the microprocessor soft-ware unnecessarily complicated. One solution to prevent the incorrect messageswas to accept only time messages received during the first 350 ms of a second.The check was implemented in a simple manner but it turned out that this simplesolution was not enough. In some cases the receiver still synchronizes to the incor-rect messages. These cases are rather few and because of that this bug is going tobe corrected in the DARC system, no more time was spent on the problem. Theoutliers of the collected data may be filtered manually, but was not.

Measurements have been done on both P1 and P3 and the results differ a lot.Diagrams of the results are presented in Appendix D. For a period of two hoursmeasured on P1, with measurements every second, the variations in the short termare distinct.The time varies in a range of about 30 ms, see D.1. The main reasonsfor this variation probably are the limited block resolution of the time and thevariations in the data stream of the receiver, which are discussed below. In theshort term the stability of the transmitted time via P3 is similar to the results forP1 because there are no differences in how the data is transmitted.

The long term time stability has been measured for one day or more. Un-fortunately the bug in the TAF disturbs the result to some extent but the maincharacteristics are distinguishable. Two results are presented in Appendix D. InD.2 measurements have been performed every 15:th second during 24 hours with-out disturbance of the bug. The variation here is in a range of about 60 ms. In D.3the time was measured every 60:th second during 67 hours. Here the deviations forsome periods are outside the diagram due to the bug. If we ignore these deviationsthe stability is in the range of 80 ms.

The time quality of P3 is worse, see D.4. The first thing to notice is that theavailability of the TAF is limited. During periods of several hours TAF is nottransmitted and only the current second is available. The reason for this behavioris unknown. Furthermore the time is drifting very much. During two hours thetime drift is about 100 ms.

The differences between the channels depend on the different sources of time.As described before the time is stated by TSE for P3 and by NWS for P1. The

36 A deeper review of DARC

conclusion is that the time supplied by NWS is much more stable in the long termthan the time supplied by the TSE. The long term stability is limited by the timesource. There is nothing that indicates that these variations would depend on thereceiver or the transmission in DARC.

Time accuracy

The time accuracy has not primarily been studied at this moment but can be readin the result diagrams as well. For P1 the time is delayed about 60 - 100 ms asshown in D.1, D.2 and D.3. The accuracy of P3 is not interesting because of thebad stability.

Generally the accuracy is affected by the time source and the delay in the chan-nel. None of these issues are enough investigated by Teracom for time distribution.The time source is discussed in 5.4. The delay of the channel is in the primary casedependable on the transmitter equipment and also on the receiver. The possibledelay in the receiver is easy to correct for in the design of the receiver. A delayoriginating from the transmitter can also be corrected for in the receiver if it isconstant. How different locations may affect the accuracy is discussed in 4.3.4.

The data stream of receiver

The data stream of the receiver was analyzed to investigate if the variation of thetime stability in the short term might depend on possible irregularities of the datastream. Measurements were made on both block level and byte level with differentbit rates of the receiver. The analyzed bit rates are 19200, 38400, 57600 and 115200kbit/s.

At block level approximately the same results are obtained independent of thebit rate chosen. The receiver does not put out every block with the same blockduration. The measurements show that about five blocks are output with a blockduration of about 15 ms followed of a delay of about 15 ms and then the next fiveblocks are output. This should be compared with the block length in the Layer1 of exactly 18 ms. The delay between every fifth block can at worst cause thearrival time of the TDT message to vary with 15 ms. The diagrams D.5 and D.6in Appendix D show the block time for different bit rates.

At byte level these irregularities are obvious too. Depending on the bit ratewe have different byte times. Most of the bytes have the same byte time at onesingle bit rate with exception of the last byte in every block of which the durationis significantly longer. A delay is introduced and it varies depending on bit rateso that the block duration looks like described above. In Appendix D diagrams inD.7, D.8 and D.9 illustrate the byte time for different bit rates.

These irregularities really influence the time stability. As noted above the arrivalof the time messages will vary in 15 ms as worst and this results in considerableeffects on the time stability in the short term. The diagram of the block time at38400 bits/s, D.5, also shows that the delay in some situations can be even larger.The reason of the behavior is unknown.

5.6 Test results 37

The various delays are effects originating from the design of the receiver. Ifthe delay between every block was constant, it would not disturb the arrival of thetime message. The effect is probably impossible to avoid with this receiver. Theresult is the same for the data of both Layer 2 and Layer 3. In the documentationof the receiver a raw data format is mentioned but this format does not work. Thisformat may give another result but it could not be tested this time. Contacts havebeen taken with Sectra about the data formats and they say that the raw formatis only for their development and not available on receivers for sale.

38 A deeper review of DARC

Chapter 6

Conclusions and future work

6.1 Multicast systems

Among the described multicast systems the radio broadcasting systems are veryinteresting for time distribution. A national time distribution network coveringSweden could with advantage be developed by using digital data channels that areoffered via DARC or DAB. DARC is currently available and in the future DAB isthe technology that can be used. The accuracy of DARC is discussed below andthe expected maximum accuracy of DAB is on millisecond level.

Today accurate synchronization is not needed in the mobile systems in Europeand therefore time information with high accuracy originating from the systemsynchronization is not available either. The multicast channels available for datadistribution are intended for multimedia transmissions and do not correspond tothe requirements needed for time distribution. There is no doubt that accuratetiming can become possible via the mobile systems if considerations of that istaken when designing the networks.

For local time distribution DECT and Bluetooth were studied. Bluetooth is amodern data communication method that can probably be used for time distribu-tion. The problem might be that the technology and protocol structure are rathercomplicated. There are many possible sources of delays that are difficult to esti-mate. Those may have an effect on the stability if not considered when designingthe hardware. Today DECT is limited to wireless voice communication and is notsuitable for time distribution.

6.2 Investigations of DARC

The short term stability of the time transmitted via DARC is limited by the receiverand by the resolution of the stated time. The received time varies in a range of30 ms in the short term. In the long term the received time varies in a maximumrange of 80 ms and these variations probably originates from the source of time.

39

40 Conclusions and future work

To achieve a better short term stability in addition to a more stable time source,a receiver with a regular data flow has to be used. At the market of DARC-receiversthe receiver form Sectra is very common and there is no aparent substitute. TheDARC-receiver and the microcontroller would probably have to be substituted withone device that receives the DARC signal, reads the time and outputs it in a desiredformat. By this, the communication stage at a high level like RS-232 between thereceiver and the microcontroller, can be avoided.

With a receiver designed for time reception, the short term accuracy is limitedto 18 ms by the block resolution of stated time. If time information with higherresolution is transmitted or the current time is complemented with a correction theshort term stability would have possibilities to reach a couple of milliseconds.

The long term stability depends on how the TSE and NWS are synchronizedwith the source and on how stable and accurate the source is. To investigatethis, collaboration has to be established with Teracom, which today does not haveenough knowledge to answer these questions. With the current equipment it isprobably limited by NTP and the accuracy and stability it will provide togetherwith how the TSE end NWS are designed. With a more accurate and stable sourcethe conditions for the long term accuracy and stability would probably be better.It would also be interesting to investigate how the NWS and TSE synchronize tothe source.

Bibliography

[1] 3GPP TS 23.107 3rd Generation Partnership Project; Technical SpecificationGroup Services and System Aspects; Quality of Service (QoS) concept andarchitecture. 3rd Generation Partnership Project, 2003.

[2] 3GPP TS 23.246 3rd Generation Partnership Project; Technical SpecificationGroup Services and System Aspects; Multimedia Broadcast/Multicast Service(MBMS); Architecture and Functional Description. 3rd Generation Partner-ship Project, 2003.

[3] L. Ahlin and J. Zander. Principles of Wireless Communications. Studentlit-teratur, Lund, Sweden, 1998.

[4] J. Bray and C. F. Sturman. Bluetooth: Connect Without Cables. Prentice Hall,2001

[5] ETSI EN 300751. Radio broadcasting systems; DAta Radio Channel (DARC);System for wireless infotainment forwarding and teledistribution. EuropeanTelecommunications Standards Institute, 2003.

[6] ETSI EN 300444 Digital Enhanced Cordless Telecommunications (DECT);Generic Access Profile (GAP). European Telecommunications Standards In-stitute, 2003

[7] ETSI EN 300824 Digital Enhanced Cordless Telecommunications (DECT);Cordless Terminal Mobility (CTM); CTM Access Profile (CAP). EuropeanTelecommunications Standards Institute, 2003.

[8] ETSI TS 101626. Digital cellular telecommunications system (Phase 2+); Net-work Identity and Time Zone (NITZ); Service description, Stage 1. (GSM02.42 version 7.0.0 Release 1998) European Telecommunications StandardsInstitute, 1999.

[9] ETSI TS 122042. Digital cellular telecommunications system (Phase 2+); Uni-versal Mobile Telecommunication system (UMTS); Network Identity and TimeZone (NITZ) service description; Stage 1. (3GPP TS 22.042 version 5.1.0 Re-lease 5) European Telecommunications Standards Institute, 2003.

41

42 Conclusions and future work

[10] G. Frerking. Serial Programming HOWTO. Linux Documentation Project,2001.

[11] W. Hoeg and T. Lauterbach. Digital Audio Broadcasting: Principles and Ap-plications. John Wiley & Sons, UK, 2001.

[12] IEC 62106:1999. The new RDS IEC 62106:199 standard. RDS Forum, Switzer-land, 1999.

[13] K. Jaldehag. Sparbarhet for tid och frekvens med hjalp av GPS och andra radio-baserade system? Den 19. nordiske konferanse Maleteknikk & Kalibrering,Danmark 23-26 November, 1997.

[14] J. Jespersen and J. Friz-Randolph. From Sundials To Atomic Clocks. US De-partment of Commerce, NITS, USA, 1999.

[15] T. Ojanpera and R. Prasad. WCDMA: Towards IP Mobility and Mobile In-ternet. Artech House, London, UK, 2001.

[16] B.M. Penrod. A New Class of Precision UTC and Frequency Reference UsingIS-95 CDMA Base Station Transmission EndRun Technologies, USA, 2001.

[17] PIC16F87X Data Sheet. Microchip Technology Inc., 2001.

[18] M. Predko. Programming and customizing PICmicro MCU microcontrollers.McGraw-Hill, 2002.

[19] M. R. Sweet. Serial Programming Guide for POSIX Operating Systems. GNUFree Documentation License, 2003.

[20] B. H. Walke. Mobile Radio Networks, Networking and Protocols. Chapter 9,DECT. John Wiley & Sons, UK, 1999.

[21] Programmers Guide - DARC Receiver. Sectra Wireless Technologies AB, Swe-den, 2002.

[22] Protocol Reference - SOS. Sectra Wireless Technologies AB, Sweden, 2002.

[23] Terminal Command Reference - DARC Receiver. Sectra Wireless TechnologiesAB, Sweden, 2002.

[24] www.sp.se/metrology/timefreq/eng/tochf.htm

[25] www.ntp.org

[26] www.piclist.com

Appendix A

Program code for Linux

#include <sys/types.h>#include <sys/stat.h>#include <sys/time.h>#include <fcntl.h>#include <termios.h>#include <cstdio>#include <unistd.h>#include <iostream>#include <cstring>

using namespace std;

/* baudrate settings are defined in <asm/termbits.h>,which is included by <termios.h> */#define BAUDRATE B57600

/* change this definition for the correct port */#define MODEMDEVICE "/dev/ttyS0"#define _POSIX_SOURCE 1 /* POSIX compliant source */

#define FALSE 0#define TRUE 1

volatile int STOP=FALSE;

void print_hex(char ch){

for (int i=2*sizeof(char) - 1; i>=0; i--) {cout << "0123456789ABCDEF"[((ch >> i*4) & 0xF)];

}

43

44 Program code for Linux

}

void print_bin(char ch){

for (int i=7; i>=0; i--) {int bit = ((ch >> i) & 1);cout << bit;

}}

bool* char_to_bin(char ch){

bool *bin = new bool[8];for (int i=7; i>=0; i--){

bin[7-i] = ((ch >> i) & 1);}return bin;

}

void print_bin2(bool *b){for(int i=0; i<8; i++){

cout << b[i];}cout << endl;

}

int n_cube(int x, int y){

if (x==0)return 0;

else{

int res = 1;for (int i=0; i<y; i++){

res *= x;}return res;

}}

unsigned short swap(signed short in_value){unsigned short most_byte = (unsigned char)(in_value >> 8);return ((in_value << 8) | most_byte);

}

45

unsigned short eval_crc(unsigned char* expression, int exp_length){

unsigned short usCrc = 0xFFFF;

for(int i = 0; i < exp_length; i++ , expression++){

usCrc = swap(usCrc) ^ (unsigned short)(*expression & 0xFF);usCrc ^= ((usCrc & 0x00FF) >> 4);usCrc ^= (swap(usCrc & 0x00FF) << 4) ^ ((usCrc & 0x00FF)<< 5);

}return usCrc ^ 0xFFFF;

}

unsigned char* byte_stuff(unsigned char* command, int &length){

int temp_length = length;int byte_to_stuff = 0;for(int i = 0; i < temp_length; i++){

if (command[i] == 0xC0 || command[i] == 0xDB){

byte_to_stuff++;}

}cout << "bytestuff " << byte_to_stuff << endl;if (byte_to_stuff > 0){

length += byte_to_stuff;

unsigned char *new_command = new unsigned char[length];int new_pos = 0;for(int i = 0; i < temp_length; (i++, new_pos++)){

switch (command[i]){

case 0xC0 :new_command[new_pos] = 0xDB;new_command[new_pos+1] = 0xDC;new_pos++;break;

case 0xDB :new_command[new_pos] = 0xDB;new_command[new_pos+1] = 0xDD;new_pos++;break;

default :cout << "default " << command[i] << endl;

46 Program code for Linux

new_command[new_pos] = command[i];}

}delete [] command;return new_command;

}else {

return command;}

}

unsigned char* build_command(unsigned char* command,int &length,unsigned char channel)

{unsigned char* command_temp = new unsigned char[length+3];command_temp[0] = channel;cout << "channel ";for (int i=2*sizeof(char) - 1; i>=0; i--) {

cout << "0123456789ABCDEF"[((command_temp[0] >> i*4) & 0xF)];}cout << endl;for(int i = 0; i < length; i++){

command_temp[i+1] = command[i];cout << command_temp[i+1];

}length += 1;delete [] command;

unsigned short crc = eval_crc(command_temp, length);cout << "crc ";

for (int i=2*sizeof(short) - 1; i>=0; i--) {cout << "0123456789ABCDEF"[((crc >> i*4) & 0xF)];

}

cout << endl;

command_temp[length] = (unsigned char)(crc >> 8);command_temp[length+1] = (unsigned char)(crc);length += 2;command_temp = byte_stuff(command_temp,length);command = new unsigned char[length+2];command[0] = 0xC0;for(int i=0; i<length; i++){

47

command[i+1] = command_temp[i];}command[length+1] = 0xC0;length += 2;delete [] command_temp;return command;

}

int send_text_command(char command[], int fd){

command[strlen(command)] = 13;int i = write(fd, command, strlen(command) + 1);return i;

}

main(){

int fd;struct termios oldtio,newtio;

/*Open modem device for reading and writing and not ascontrolling tty because we don’t want to get killedif linenoise sends CTRL-C.

*/fd = open(MODEMDEVICE, O_RDWR | O_NOCTTY );if (fd < 0) {

perror(MODEMDEVICE);exit(-1);

}/* save current serial port settings */tcgetattr(fd,&oldtio);/* clear struct for new port settings */bzero(&newtio, sizeof(newtio));

/*BAUDRATE: Set bps rate. You could also use

cfsetispeed and cfsetospeed.CRTSCTS : output hardware flow control (only used

if the cable has all necessary lines.See sect. 7 of Serial-HOWTO)

CS8 : 8n1 (8bit,no parity,1 stopbit)CLOCAL : local connection, no modem contolCREAD : enable receiving characters

*/

48 Program code for Linux

newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;

/*IGNPAR : ignore bytes with parity errorsICRNL : map CR to NL (otherwise a CR input on the othercomputer will not terminate input)otherwise make device raw (no other input processing)

*/newtio.c_iflag = IGNPAR | ICRNL;

newtio.c_oflag = 0; //raw output

newtio.c_lflag = 0; //non-canonical output, no echo

/* inter-character timer unused */newtio.c_cc[VTIME] = 0;/* blocking read until 5 chars received */newtio.c_cc[VMIN] = 1;

//************main program start*************//variable declaration

int blocklength = 0;unsigned char byte[1];unsigned char blockbuf[255];

int hour, minute, second, block;

bool b,last_b = 0, b_32 = 0, change_second = 0;int last_second;struct timeval tv;

//clean the modem buffer ant activate new settings

tcflush(fd, TCIFLUSH);tcsetattr(fd,TCSANOW,&newtio);

//build and send commmand to the receiver

/* int length = 4;unsigned char *command = new unsigned char[length];

command[0] = 0x06;

49

command[1] = 0x3E;command[2] = 0x00;command[3] = 0x02;

command = build_command(command,length,0x03); //build command

write(fd,command,length); //send command*/

//read loop startwhile (0 > -1) { // loop for input

read(fd,byte,1); //repeate until new blockif (*byte != 0xC0){

blockbuf[blocklength] = *byte; //save byteblocklength++; //blocklength increase

}else //block recived{

gettimeofday(&tv,NULL);switch (blockbuf[0]){ //check channel

case 0x06: //Indication channelif ((((unsigned char)(blockbuf[5] << 4)) >> 4) == 0x8 &&

(blockbuf[6] >> 4) == 0x05) { //check if TDT

hour = minute = second = block = 0;

/* b = ((blockbuf[11] >> 6) & 1); //extract hourhour += b*16;b = ((blockbuf[11] >> 5) & 1);hour += b*8;b = ((blockbuf[11] >> 4) & 1);hour += b*4;b = ((blockbuf[11] >> 3) & 1);hour += b*2;b = ((blockbuf[11] >> 2) & 1);hour += b*1;// cout << hour << ":";

b = ((blockbuf[11] >> 1) & 1); //extract minminute += b*32;b = (blockbuf[11] & 1);minute += b*16;b = ((blockbuf[12] >> 7) & 1);minute += b*8;b = ((blockbuf[12] >> 6) & 1);

50 Program code for Linux

minute += b*4;b = ((blockbuf[12] >> 5) & 1);minute += b*2;b = ((blockbuf[12] >> 4) & 1);minute += b*1;// cout << minute << ":";*/b = ((blockbuf[12] >> 3) & 1); //extract secondsecond += b*32;b = ((blockbuf[12] >> 2) & 1);second += b*16;b = ((blockbuf[12] >> 1) & 1);second += b*8;b = (blockbuf[12] & 1);second += b*4;b = ((blockbuf[13] >> 7) & 1);second += b*2;b = ((blockbuf[13] >> 6) & 1);second += b*1;

if (second != last_second) //correct bugchange_second = 1;

b = ((blockbuf[14] >> 4) & 1);block += b*16;

if (last_b == 1 && b == 0)b_32 = 1;

if (change_second){b_32 = 0;change_second = 0;

}block += b_32*32;last_b = b;

b = ((blockbuf[14] >> 3) & 1); //extract TAFblock += b*8;b = ((blockbuf[14] >> 2) & 1);block += b*4;b = ((blockbuf[14] >> 1) & 1);block += b*2;b = (blockbuf[14] & 1);block += b*1;

if (last_second != second){ //compare time

51

cout << block << " "; //and presentcout << second << ":"; //diffcout << block*18 << " ";cout << tv.tv_sec%60 << ":" << tv.tv_usec

<< " ";int diff = tv.tv_usec/1000 - (block*18);if (diff < 0)

diff += 1000;cout << diff << endl;

}last_second = second;

}break;

case 0x03: //Command Channelfor(int i=0;i<blocklength;i++){ //present answer

print_hex(blockbuf[i]); //on command channelcout << " ";

}break;

}

blocklength = 0; //new blockread(fd,byte,1);if (*byte != 0xC0){

cout << "fel sync" << endl;cout << endl;

}}

}tcsetattr(fd,TCSANOW,&oldtio); //restore old portsettings

}

52 Program code for Linux

Appendix B

Program code for PIC16F874

Title "Your Program";

list P = 16F874;

include "P16f874.inc";; ------------------; CONFIGURATION FUSE; ------------------;

__CONFIG _CP_OFF & _WRT_ENABLE_ON & _HS_OSC__CONFIG _WDT_OFF & _PWRTE_OFF & _BODEN_ON__CONFIG _LVP_OFF & _CPD_OFF & _DEBUG_OFF;; CRYSTAL SPEED = 20000000Hz;

CBLOCK 0x20dataL_w_status_pclathbyteMultiplierMultiplicandProduct:2Tempmultiplicand:2FullTim:2secondlast_secondblock

53

54 Program code for PIC16F874

last_blockTimDelay0TimDelay1TimDelay2TimDelay3TEMP0TEMP1TEMP2TEMP3p_statTempTMR1HoffsetDelay

ENDC

org 0x0000 ; start address = 0000hgoto main

org 0x0004

;INTERUPT HANDLERmovwf _w ;save w, STATUS and PCLATHmovf STATUS,wbcf STATUS, RP0bcf STATUS, RP1movwf _statusmovf PCLATH, wmovwf _pclath

bsf PORTD,2call TogRB0

bcf T1CON, TMR1ON ;stop timermovlw 0xB0movwf TMR1Lmovlw 0x3Cmovwf TMR1Hbsf T1CON, TMR1ON ;start timer

movlw 0x10movwf Delaydecfsz Delay,fgoto $ - 1bcf PORTD,2

55

reset bcf PIR1,TMR1IF ;reset interupt

movf _pclath, w ;Write PCLATH, w and STATUSmovwf PCLATHmovf _status, wmovwf STATUSswapf _w,fswapf _w,wretfie

;; -------------------------; SETUP PORTS; -------------------------;

main movlw 0x00 ; setup portsmovwf PORTAmovlw b’00111111’movwf PORTBmovlw 0x00movwf PORTCmovlw 0x00movwf PORTDmovlw 0x00movwf PORTEbsf STATUS,RP0 ; RAM Page 1movlw 0x00movwf TRISAmovlw 0x00movwf TRISBmovlw 0x80movwf TRISCmovlw 0x00movwf TRISDmovlw 0x00movwf TRISE

;; -------------------------; SET ANALOG/DIGITAL INPUTS; -------------------------;

56 Program code for PIC16F874

movlw 0x06 ; all digitalmovwf ADCON1

;; ------------------------------------; SET BAUD RATE TO COMMUNICATE WITH PC; ------------------------------------; Boot Baud Rate = 57600, No Parity, 1 Stop Bit

movlw 0x14 ; 57600 baudmovwf SPBRGmovlw b’00100100’ ; brgh = high (2)movwf TXSTA ; enable Async Trans, set brghbcf STATUS,RP0 ; RAM Page 0movlw b’10010000’ ; enable Async Receptionmovwf RCSTA

bsf RCSTA, CREN ;enable continues recive

;; ------------------------------------; PROVIDE A SETTLING TIME FOR START UP; ------------------------------------;

clrf dataLsettle decfsz dataL,F

goto settle

movf RCREG,Wmovf RCREG,Wmovf RCREG,W ;flush receive buffer

;----------------------------------------------------------;INITIALISE TIMER1 OSC = 100000 Hz;-------------------------------------------------------

bsf STATUS,RP0 ;RAM page 1bsf TRISC, 0 ;Set RC0/T1CLK inputbcf STATUS,RP0 ;RAM page 0bsf T1CON, TMR1CS ;enable counter modebcf T1CON, T1OSCEN ;enable clock input RC0bcf T1CON, T1SYNC ;enable sync clockbsf T1CON, T1CKPS0 ;prescale 8bcf T1CON, T1CKPS1 ; "

;----------------------------------------------------------

57

;INITIALISE INTERUPTS;-------------------------------------------------------

bsf STATUS,RP0 ;RAM Page 1movlw b’00000001’;enable TMR1IEmovwf PIE1bcf STATUS,RP0 ;RAM page 0movlw b’11000000’;enable PEIE and GIEmovwf INTCON;

movlw 0xB0 ;Initialize timer with 15536movwf TMR1L ;Gives interupt after one seocndmovlw 0x3Cmovwf TMR1Hbsf T1CON, TMR1ON ;start timer

; ---------; MAIN LOOP; ---------;

bcf p_stat,0 ;Mark first cycle

loop clrf TimDelay0clrf TimDelay1clrf TimDelay2clrf TimDelay3clrf TEMP0clrf TEMP1clrf TEMP2clrf TEMP3

call receive ; wait for a charmovwf byte

sublw 0xC0 ;check C0btfss STATUS, Zgoto loop ;falsenext call receive ;true, check nextmovwf bytesublw 0xC0btfss STATUS, Zgoto loop ;falsenew_block call receive ;true, Byte 1 0sublw 0xDB ;Check byte-stuffingbtfsc STATUS,Z

58 Program code for PIC16F874

goto loopcall receive ;Byte 2 1sublw 0xDB ;Check byte-stuffingbtfsc STATUS,Zgoto loopcall receive ;Byte 3 2movwf bytesublw 0xDB ;Check byte-stuffingbtfsc STATUS,Zgoto loopmovf byte,w ;Check CRCbtfsc byte,6 ;Skip if cleargoto loop ;Set -> CRC faultcall receive ;Byte 4sublw 0xDB ;Check byte-stuffingbtfsc STATUS,Zgoto loopcall receive ;Byte 5sublw 0xDB ;Check byte-stuffingbtfsc STATUS,Zgoto loopcall receive ;Byte 6movwf bytesublw 0xDB ;Check byte-stuffingbtfsc STATUS,Zgoto loopmovf byte,wmovlw b’00001111’;extract logical channelandwf byte, wsublw b’00001000’;SeCh?btfss STATUS, Zgoto loop ;falsecheck_TDT call receive ;true, check TDT, Byte 7movwf bytesublw 0xDB ;Check byte-stuffingbtfsc STATUS,Zgoto loopmovf byte,wrrf byte, f ;extract TYPErrf byte, frrf byte, frrf byte, wandlw b’00001111’sublw b’00000101’;TDT?btfss STATUS, Z

59

goto loop ;falseget_time call receive ;true, get time, Byte 8sublw 0xDB ;Check byte-stuffingbtfsc STATUS,Zgoto loopcall receive ;Byte 9sublw 0xDB ;Check byte-stuffingbtfsc STATUS,Zgoto loopcall receive ;Byte 10sublw 0xDB ;Check byte-stuffingbtfsc STATUS,Zgoto loopcall receive ;Byte 11sublw 0xDB ;Check byte-stuffingbtfsc STATUS,Zgoto loopcall receive ;Byte 12sublw 0xDB ;Check byte-stuffingbtfsc STATUS,Zgoto loopcall receive ;Byte 13movwf byte ;Secondsublw 0xDB ;Check byte-stuffingbtfsc STATUS,Zgoto loopmovf second,w ;Save last secondmovwf last_secondrlf byte,f ;Extract currant secondrlf byte,wandlw b’00111100’movwf secondcall receive ;Byte 14movwf bytesublw 0xDB ;Check byte-stuffingbtfsc STATUS,Zgoto looprrf byte,frrf byte,frrf byte,frrf byte,frrf byte,frrf byte,wandlw b’00000011’iorwf second,f

60 Program code for PIC16F874

movf second,w ;check last_second == secondsubwf last_second,wbtfsc STATUS,Zgoto loop ;true, not new secondcall receive ;new_second, Byte 15 14movwf byte ;Blocksublw 0xDB ;Check byte-stuffingbtfsc STATUS,Zgoto loopmovf byte,wandlw b’00111111’movwf TimDelay0

; TimDelay = TimDelay * 900; Temp = TEMP; TimDelay size = 16 bits; Error = 0 %; Bytes order = little endian; Round = no

; ALGORITHM:; Clear accumulator; Add input * 1024 to accumulator; Substract input * 128 from accumulator; Add input * 4 to accumulator; Move accumulator to result;; Approximated constant: 900, Error: 0 %

; Input: TimDelay0 .. TimDelay1, 16 bits; Output: TimDelay0 .. TimDelay3, 26 bits; Code size: 69 instructions

;shift accumulator left 2 timesclrcrlf TimDelay0, frlf TimDelay1, fclrf TimDelay2rlf TimDelay2, frlf TimDelay0, frlf TimDelay1, frlf TimDelay2, f

;copy accumulator to temporarymovf TimDelay2, w

61

movwf TEMP2movf TimDelay1, wmovwf TEMP1movf TimDelay0, wmovwf TEMP0

;shift temporary left 5 timesswapf TEMP2, fswapf TEMP1, fmovf TEMP1, wandlw 0x0Fxorwf TEMP1, fiorwf TEMP2, fswapf TEMP0, fmovf TEMP0, wandlw 0x0Fxorwf TEMP0, fiorwf TEMP1, fclrcrlf TEMP0, frlf TEMP1, frlf TEMP2, f

;substract temporary from accumulatormovf TEMP0, wsubwf TimDelay0, fmovf TEMP1, wskpcincfsz TEMP1, wsubwf TimDelay1, fmovf TEMP2, wskpcincfsz TEMP2, wsubwf TimDelay2, f

;shift temporary left 3 timesclrcrlf TEMP0, frlf TEMP1, frlf TEMP2, frlf TEMP0, frlf TEMP1, frlf TEMP2, fclrf TEMP3

62 Program code for PIC16F874

rlf TEMP3, frlf TEMP0, frlf TEMP1, frlf TEMP2, frlf TEMP3, f

;add temporary to accumulatorclrf TimDelay3btfsc TimDelay2, 7comf TimDelay3, fmovf TEMP0, waddwf TimDelay0, fmovf TEMP1, wskpncincfsz TEMP1, waddwf TimDelay1, fmovf TEMP2, wskpncincfsz TEMP2, waddwf TimDelay2, fmovf TEMP3, wskpncincfsz TEMP3, waddwf TimDelay3, f

btfss p_stat,0 ;check if first_cyclegoto set_time ;first_cycle

movlw b’01111111’;check if time is validmovwf offset ;32512 - TMR1, valid if positivemovf TMR1H,w ;read TMR1Hmovwf TempTMR1H ;check pos or neg resultsubwf offset,w ;subtractbtfss STATUS,C ;check if negativegoto loop ;negative

set_time movf TimDelay1,w ;Add 15536 to TimDelayaddlw 0x3Cmovwf TimDelay1movf TimDelay0,waddlw 0xB0movwf TimDelay0btfsc STATUS, Cincf TimDelay1,f

63

bcf T1CON, TMR1ON ;Timer offmovf TimDelay1, w ;Set timer with TimDelaymovwf TMR1Hmovf TimDelay0, wmovwf TMR1Lbsf T1CON, TMR1ON ;Timer oncall TogRB5bsf p_stat,0 ;Reset first cyclegoto loop

;; -------------------------------------------; RECEIVE CHARACTER FROM RS232 AND STORE IN W; -------------------------------------------; This routine does not return until a character is received.;receive btfss PIR1,RCIF ; (5) check for received datagoto receivemovf RCREG,W ; save received data in Wreturn

;; -------------------------------------------------------------; SEND CHARACTER IN W VIA RS232 AND WAIT UNTIL FINISHED SENDING; -------------------------------------------------------------;send movwf TXREG ; send data in W

TransWt bsf STATUS,RP0 ; RAM PAGE 1WtHere btfss TXSTA,TRMT ; trans is complete if hi

goto WtHere

bcf STATUS,RP0 ; RAM PAGE 0return

;-------------------------------------------; TOGGLE PORT 1;------------------------------------------

TogRB5 btfsc PORTB,5goto ClearB5bsf PORTB,5 ;set RB5returnClearB5 bcf PORTB,5 ;clear RB5return

64 Program code for PIC16F874

TogRB0 btfsc PORTB,0goto ClearB0bsf PORTB,0 ;set RB0returnClearB0 bcf PORTB,0 ;clear RB0return

end

Appendix C

Circuit

65

66 Circuit

Appendix D

Measurement results

67

68 Measurement results

Figure D.1. Measurements during about 2 hours

69

Figure D.2. Measurements during about 24 hours

70 Measurement results

Figure D.3. Measurements during about 67 hours

71

Figure D.4. Measurements during about 24 hours

72 Measurement results

Figure D.5.

73

Figure D.6.

74 Measurement results

Figure D.7.

75

Figure D.8.

76 Measurement results

Figure D.9.

På svenska Detta dokument hålls tillgängligt på Internet – eller dess framtida ersättare – under en längre tid från publiceringsdatum under förutsättning att inga extra-ordinära omständigheter uppstår.

Tillgång till dokumentet innebär tillstånd för var och en att läsa, ladda ner, skriva ut enstaka kopior för enskilt bruk och att använda det oförändrat för ickekommersiell forskning och för undervisning. Överföring av upphovsrätten vid en senare tidpunkt kan inte upphäva detta tillstånd. All annan användning av dokumentet kräver upphovsmannens medgivande. För att garantera äktheten, säkerheten och tillgängligheten finns det lösningar av teknisk och administrativ art.

Upphovsmannens ideella rätt innefattar rätt att bli nämnd som upphovsman i den omfattning som god sed kräver vid användning av dokumentet på ovan beskrivna sätt samt skydd mot att dokumentet ändras eller presenteras i sådan form eller i sådant sammanhang som är kränkande för upphovsmannens litterära eller konstnärliga anseende eller egenart.

För ytterligare information om Linköping University Electronic Press se förlagets hemsida http://www.ep.liu.se/ In English The publishers will keep this document online on the Internet - or its possible replacement - for a considerable time from the date of publication barring exceptional circumstances.

The online availability of the document implies a permanent permission for anyone to read, to download, to print out single copies for your own use and to use it unchanged for any non-commercial research and educational purpose. Subsequent transfers of copyright cannot revoke this permission. All other uses of the document are conditional on the consent of the copyright owner. The publisher has taken technical and administrative measures to assure authenticity, security and accessibility.

According to intellectual property law the author has the right to be mentioned when his/her work is accessed as described above and to be protected against infringement.

For additional information about the Linköping University Electronic Press and its procedures for publication and for assurance of document integrity, please refer to its WWW home page: http://www.ep.liu.se/ © [Erold Persson]