Implementation of a spread spectrum receiver with

0 downloads 0 Views 5MB Size Report
Dec 1, 1996 - Within the last ten years, a rapid expansion of mobile satellite communications has taken place. Since 1992 ...... bility Peb, the thusfar described effect has to be taken into account. If the chip rate is 64 ...... interrupt context save stack (STACKPTR) ...... BNZ. DEV RCV. Control variable used by the IF. Receiver.
Eindhoven University of Technology Faculty of Electrical Engineering Division of Telecommunication Technology and Electromagnetics

Implementation of a spread spectrum receiver with two DSPs in parallel by J.J. Boschma

Report of graduation work Performed from January 1996 to January 1997

Professor : proLdr.ir. G. Brussaard Supervisor : ir. J. Dijk

,The Faculty of Electrical Engineering of Eindhoven University of Technology disclaims all responsibility for the contents of traineeship and graduation reports.

Summary Within the last ten years, a rapid expansion of mobile satellite communications has taken place. Since 1992 the Telecommunications Division of the Eindhoven University of Technology conducts research into satellite data communication using small portable terminals. Such a portable groundstation, with an antenna diameter of several decimeters, is called a picoterminal. The project at the EUT concernes the development of a picoterminal which is capable of data rates in the order of 100 bits per second. It employs direct-sequence code division multiple access (DS-CDMA), a spread spectrum technique. For modulation, a digital scheme called binary phase shift keying (BPSK) is used. The final goal of the project is the realization of a network in which a large number of picoterminals share the same frequency band. A design was studied in which 67 picoterminals are implemented, each having a bit rate of 125.2 bit/so A second option provides the usage of 62 picoterminals, each having a bit rate of 63 bit/so In both network designs, the picoterminals should operate with a chip rate of 64 kchip/s. Currently, the EUT picoterminal project is focused on the development of an all digital implementation of a modem. This modem is equiped with two digital signal processors (DSP), the TMS320C50 of Texas Instruments. The resulting processing power should make the modem capable of functioning as a baseband transmitter or as an IF-receiver which demodulates the BPSK-signal by means of coherent subsampling. Chip rates of up to 64 kchip/s are feasable. In this report, a description is given of the software implementation on the baseband modem. The distribution of software tasks over both processors is discussed and calculations concerning critical timings in the software are given as well. For enhancing the frequency resolution of the numerically controlled oscillator on a DSP, a new software algorithm was implemented. Suggestions for improvement of the modem software are given at the end of the report. The IF-receiver was tested by performing bit error ratio measurements for different signal to noise ratios at the input of the receiver. It was measured that the modem has an implementation loss of approximately 1 dB. In order to find an explanation for the implementation loss, an analysis was made to determine the receiver's loss of performance as a result of nonideal behaviour of the control loops in the presence of noise. Furthermore, the sampling of bandlimited Gaussian noise was investigated.

List of acronyms ADC AGC AGND AR ARAU ATM AWGN BER BPF BPSK BW CDMA CODE CPU DAC DDS DFT DGND DIP DLL DPLL DS DSB DS-BPSK DS-CDMA DSP EIRP EMC EOC EPROM ESA EUT EUTELSAT FDMA FFT FIR FLBW

Analog to Digital Converter Automatic Gain Control Analog Ground Auxiliary Register Auxiliary Register Arithmetic Unit Automated Teller Machine Additive White Gaussian Noise Bit Error Rate Band Pass Filter Binary Phase Shift Keying Band Width Code Division Multiple Access Co-operative Olympus Data Project Central Processing Unit Digital to Analog Converter Direct Digital Synthesis Discrete Fourier Transform Digital Ground Dual In-line Package Delay Locked Loop Digital Phase Locked Loop Direct Sequence Dou ble Side Band Direct Sequence Binary Phase Shift Keying Direct Sequence Code Division Multiple Access Digital Signal Processor Effective Isotropic Radiated Power Electro-Magnetic Compatibility End Of Conversion Electrically Programmable Read Only Memory European Space Agency Eindhoven University of Technology European Telecommunication Satellite Organization Frequency Division Multiple Access Fast Fourier Transform Finite Impuls Response Full Linear Band Width

IV

FPBW FPLMTS FS GMDSS GND GPS GSM GSO HPA IF IFFT IIR INMARSAT INTELSAT I/O ISL lSI JTAG LEO LNA LPF LSB MEO MFLOPS MIPS MOPS J.lP NCO PAM PC PD PFD PI PLL PLU PN PSK QPSK RAM RDSS RF RMS ROM SHA SNR SPS SR

Full Power Band Width Future Public Land Mobile Telecommunication System Full Scale Global Maritime Distress and Safety System Ground Global Positioning System Group Special Mobile / Global System Mobile Geo Stationary Orbit High Power Amplifier Intermediate Frequency Inverse Fast Fourier Transform Infinite Impuls Response International Maritime Satellite Organization International Telecommunications Satellite Organization Input/Output Inter Satellite Link Inter Symbol Interference Joint Test Action Group Low Earth Orbit Low Noise Amplifier Low Pass Filter Least Significant Byte Medium Earth Orbit Mega Floating-point Operations Per Second Mega Instructions Per Second Mega Operations Per Second Micro Processor Numerically Controlled Oscillator Pulse Amplitude Modulation Personal Computer Phase Detector Phase-Frequency Detector Proportional Integral (filter) Phase Locked Loop Parallel Logic Unit Pseudo Noise Phase Shift Keying Quaternary Phase Shift Keying Random Access Memory Radio Determination Satellite Service Radio Frequency Root Mean Square Read Only Memory Sample and Hold Amplifier Signal to Noise Ratio Samples Per Second Slew Rate

List of acronyms

SSB SSBW SSMA TDMA TWTA UMTS VCO VSAT ZOH

v

Single Side Band Small Signal Band Width Spread Spectrum Multiple Access (= CDMA in this report) Time Division Multiple Access Traveling Wave Tube Amplifier Universal Mobile Telecommunication System Voltage Controlled Oscillator Very Small Aperture Terminal Zero Order Hold

List of symbols O:p, O:s

B B d , Bi BL

BN B sp B- 3dB j3

c(k) d(k) d(t), di D Dt:>. J ~

~/ls ~!IF ~/min ~/min,REA ~Tmin ~To(k)

Eb Ec

I

Ib Ie IDAC

lis Ils(k) Ils,low, Ils,high

!h Ii !IF II

In Ip

amplitude, received amplitude, transmitted amplitude filter passband and stopband attenuation bandwidth bandwidth of data signal and input signal noise equivalent PLL loop bandwidth noise equivalent bandwidth bandwidth of a spread spectrum signal half power bandwidth loop damping correction signal of frequency synthesizer correction signal of PN code generator data waveform (bits) one way Doppler shift) DLL phase detection function code phase error code phase difference of early and late correlation sample frequency adjustment IF carrier frequency offset minimum frequency step size of frequency synthesizer modified ~/min by Resolution Enhancement Algorithm min mum period step size of the NCO timer correction time energy per bit energy per chip frequency bit rate chip rate DAC samples output rate true frequency synthesizer output frequency calculated frequency synthesizer output frequency low and high raster frequency higher frequency input intermediate frequency nominal intermediate frequency lower frequency nominal basic output frequency of frequency synthesizer frequency resolution in frequency domain

VIII

fr fRFd, fRFu

fs f-3dB

F(z) i If s + f; + ~ B

(5.5) (5.6)

i,jEt'1

After rewriting and taking i=O, we obtain the subsampling constraint: 21i

+B

. 1 J +

< ff3
8.

7.2

Generating salllple pulses on the CSO-transceiver

In the G50-transceiver, the sample pulses are generated by the DSP-timer. The output frequency can be controlled by means of two registers, PRD and TDDR : MIPS ffs

= (1 + TDDR)(1 + PRD)

, where

(7.3)

MIPS = 25 0< TDDR < 15 0< PRD < 65535 Adjustments of 11s have to be made by means of register PRD, when observing that:

I

d If'

dPRD

1_- ~ fml1l. --

2

ff'

(1

+ TDDR) MIPS

(7.4)

it is clear that for best frequency resolution TDDR=O. Equations 7.3 and 7.4 now reduce to :

7.3 Controlling the DSP-timer

41

MIPS

(7.5)

Jis = (1 + PRD)

I

d ffs d PRD

1_ ~ . -

fl s MIPS

fmw -

(7.6)

vVhen the Costas loop is updated, the new sample frequency is calculated. To set the DSPtimer to this frequency, the new value of the PRD-register can be calculated as follows: PRD

= MIPS

-1

(7.7)

ff s(k)

However, this calculation cannot be performed by the TMS320C50 DSP because no divide instructions are available. Therefore, another approach was developed.

7.3

Controlling the DSP-thner

The sample frequency has a nominal value of Iis=In which is achieved by a nominal PRDregister value PRD n . Frequency adjustments are made by adding a value of ~PRD to PRD n and can be written as ~Iis=Iis - In, resulting in : _ ffs - fn

+

~

_ ffs - (1

MIPS

+ PRD + ~PRD)

(7.8)

11

vVhen assuming that the total freq uency adjustment is small, a linear expression can be derived:

~PRD = ~Jis

d PRD d Jis

(7.9)

1

PRD=PRD"

For each Costas loop upelate the correct

PRD

!J s

is set by :

dPRDI = PRD + ~PRD = PRD + ~Jis-11

11

d Ji.

(7.10) PRD=PRD"

dl

The values i RD and PRD n can be calculated with equations 7.6 and 7.7 and are provided ts by the PC during initialization of the receiver mode, while ~Ii s is calculated by the Costas loop. Setting the right lis according equation 7.10 thus requires only a multiplication and a summation. Of course, the PRD-register can be loaded with integer values only:

PRDlow

= lPRDJ

l x J, convert

or

PRDhigh

to integer below x

rxl, convert to integer above x

= rPRDl

,where

(7.11)

Generation of sample pulses

42

With parameters values fIF=128 kHz and m=3, equation 7.6 results to ~fmin=213 Hz. It's clear that a frequency resolution enhancement algorithm has to be used in order to ensure (nearly) coherent sampling.

An inlproved resolution enhancelnent algoritlun

7.4

If the Costas loop update period is again T s=Tb=875 psec and the sample frequency of 73.143 kHz is used to switch the PRD-register between values PRD!ow and PRD high , a resolution enhancement factor of N,.=Ts f18=64 is feasable. However, this would require a 64 X 64 look-up matrix which takes a great part of the available memory. On the other hand, a large N r is necessary because of the large ~fmin' Therefore, instead of using a look-up matrix as was done with the C25-transceiver, a software algorithm was implemented which determines real time if the PRD-register should be loaded with the value PRD!ow or the value PRDhigh :

{ { { { { { { {

Ouring the Costas loop update, the exact value PRO_exact} and values PRO_low and PRO_high were calculated. } Each time this procedure is called, it compares the sum } of the actual register contents ('sUffi_PRO_reg') with the} sum of the exact (desired) register contents (called } 'sum_PRO_exact'). With this information, the software } decides whether the PRO-register ('PRO_reg') should be } loaded with PRO_low or PRO_high. }

begin if (sum_PRO_reg < sum_PRO_exact) then begin PRO_reg=PRO_high; sum_PRO_reg=sum_PRO_reg+PRO_high; end else begin PRO_reg=PRO_low; sum_PRO_reg=sum_PRO_reg+PRO_low; end; sum_PRO_exact=sum_PRO_exact+PRO_exact; end

This algorithm automatically provides the maximum achievable N r because it tries to make the mean value of the PRD-register equal to the calculated exact value by ensuring that: IPRD_errorl = IsumYRD_exact - sumYRD..regl ~ (PRDJiigh - PRD_low) = 1

(7.12 )

7.4 An improved resolution enhancement algorithm

43

By defining that kREA is the k-th update of the PRD-register between two Costas loop updates, it follows that:

PRD...reg

= sum...PRD_exact -

PRD_error

k REA

= PRD_exact-

PRD_error

(7.13)

kREA

Eq uations 1.12 and 1.13 can be combined to the final result :

(

1_) ~

PRD...re g _ _ ~EA

PRD_exact

~

(PRD...re g

+

_1_) ~EA

(7.14)

from which can be seen that the approximation gets better as kREA increases.

In general the resulting frequency resolution can be written as : ~f .

-

. mm.REA -

4 Ii

Ie

MIPS N e (2m.

+ 1)

(7.15)

When substituting the parameter set (Ii, rn, fe, N e, MIPS)=(128000, 3,8000,7,25), a value of 6.fmin.RE.4.=:3.:B Hz is found.

Chapter 8

Analysis of the control loops In Chapter .5 the analysis of the Costas carrier-recovery loop and the PN-code tracking DLL as performed by [2] was given. It was assumed that the loops could be modelled as a secondorder loop, and parameters of the implemented PI-controller (K p and K i ) were calculated according those assumptions. A precise analysis of the control loops will be given in this chapter, thereby showing that the loops cannot be fit into a second-order model. This makes clear that another method for dimensioning the PI-controller is neccessary. In this chapter, also a noise analysis of the control loops is presented, this can be used to predict the detoriation of the receiver's performance in the case that noise is added to the input signal. When simulations or calculations are made in this chapter, the following receiver parameters are used: (Ii, fe, N e, m, EL, (3) = (128.10 3 ,8.10 3 ,15,3, 100, ~J2), where EL is the noise bandwidth of the loop.

8.1

Titue dOluain analysis of the phase detector

ei

As already described in Chapter 5, the phase detector of the Costas loop has inputs and eo and the output represents the sample phase error eel The output of the phase detector of the DLL gives the PN-code tracking error 6e • Because both loops employ a numerically controlled oscillator, the behaviour of ee and 6e in time with respect to the sampling and correlating properties of the phase detectors is the same. It is therefore sufficient to analyze the phase detector of the Costas loop, the obtained results are then also applicible to the phase detector of the DLL. During a correlation period, the control signal c(k) of the numerically controlled oscillator is constant, therefore the output phase eo is a linear function of sample n within that particular correlation period :

(8.1)

If it is assumed that the input phase such that we may state that:

ei can be considered constant during a correlation period,

Analysis of the control loops

46

Bi (k)

"':J

Bi (k

+ 21~)

"':J

Bi (k

+ 1)

(8.2)

then it is found that the error phase Be

= Bi -

Bo is given by : (8.3)

\Vhen ommitting the influence of the data-stream and the PN-code and also ignoring the fact that the subsampling principle implies that each successive sample changes sign, it is easily found that the output of the correlators can be written as :

(8.4)

(8.5)

As done earlier, we assume that Be is small during a correlation period and we thus find that cos(Be ) :::::; 1 and sin(B e ) :::::; Be. This leads to the following equation for the output of the phase detector:

Ve,COSTAS(k+l)=VIC ( k+ 2N2N

1) VQC (k+

2N

2N) 2N

=A

2

I:

N

n=2 n=even

Be (k

+ 2~)

(8.6)

vVith equation 8.:3 this can be written as : 2N

Ve,COSTAS(k

+ 1) = A 2 N

I:

(Be(k)

+ 21~ (Be(k + 1) -

Be(k)))

(8.7)

n=2

n=even

Because of the the following: 2N

~

LJ

n=2 n=even

n

1

-2N = -N

N 1 ~n= -(N+1)

LJ

n=l

2

(8.8)

equation 8.7 can be modified into:

(8.9)

So, the ouput of the phase detector at the end of correlation period k represents the phaseerror approximatly halfway that period. Because the increase (or decrease) of the phase error

8.2 Frequency domain analysis of the control loops

47

within a correlation period is a linear function of time, one could also conclude that the correlator outputs the mean value of the phase error during the last correlation period. By this result, it can be seen that the phase detector of both control loops have to be modelled by a gain !{d and a delay time Td of half a correlation period:

J{d=A

2

N2

(8.10)

1

(8.11)

Td = "2Ts

The behaviour of the Costas loop was simulated by a Matlab script-file. From figure 8.1 can be seen that an overshoot of .54 % occurs if the Costas loop is modelled as a second-order loop and a damping factor of f3 = ~12 is used. For a true second-order loop, in that case an overshoot of only 4.3 % is expected.

0.16r-----r-----r-----r------,r------,

0.14

0.12 ...............

'0 0.1

~

lI-

Ql f/l

l-

~ 0.08

I-

0.

I

:;

./

i

0. ::J

J

00.06

I I I

0.04

-

../.

modem loop implementation

I

--- true second-order loop

I I

0.02 ... IJ .. I

°O"-J'-----'-----'--'-----'--'--------''-----'--

0.01

0.02

0.03

0.04

0.05

Time[s]

Figure 8.1: R.esponse of the Costas loop to an input step of 0.1 [rad]

8.2

Frequency dOlllain analysis of the control loops

The open-loop gain of a control loop is given by :

HO(s)

= I": e-s~T,

(1- s~Ts) (sri + 1) s s

(8.12)

Analysis of the control loops

48

in which:

K = I\dK;I\o

(8.13)

I\p

(8.14 )

T: - 1 -

K;

The terms of equation 8.12 respectively represent the total proportional gain, the delay of the phase detector, the numerically controlled oscillator preceeded by a zero-order hold (expression obtained via bilinear transformation [20]) and the PI-controller. \Vhen rewriting equation 8.12. equations for magnitude and phase as a function of the radial frequency can be obtained:

V(U/1TP IHO(w)1 = K

+ 1)(w2~~." + 1)

(8.15)

0 w~

1 1 rPHo(W) = arctan(wT;) - arctan(w"2Ts) -w"2T., - IT

(8.16)

In figure 8.2 the Bode-plot of these equations is presented. It can be seen that a phase margin of only 34 degrees exists at a frequency of 46 Hz, thus expecting a closed-loop gain much higher than 1 for that frequency. \Vith equations 8.15 and 8.16 the closed-loop gain can be written as :

(8.17)

In figure 8.3 the closed-loop gain of the control loop and a true second-order loop is given. It can be seen that the gain and bandwidth of the loops as implemented in the spread spectrum receiver is much higher than expected (compare the curve of the second-order loop). From the analysis in this section, it is clear that the parameters of the PI-controller cannot be calculated under the assumption that the loops can be seen as a true second order loop. This is largely due to the fact that the loop update frequency is rather low compared to the loop bandwidth, for a stable behaviour of sampled loop it is usualy demanded that the loop update frequency is more than ten times the loop bandwidth. In the simulated case, the ratio between loop update frequency and loop bandwidth is only: T L ~ 5.3. 8

k

It is not expected that the Costas loop or DLL will become really unstable, but the large gain and bandwidth will have a negative effect on the noise performance. This will be analyzed in the next section.

8.3 Noise analysis of the control loops

49

60

m

:£ 40 c:

"ctj Cl

0. 20

0

.2

C Q) 0. 0

0

. . . ..

.

-20 0

.

20

.

.

40

60

80

100

120

140

160

180

200

Frequency [Hz]

l

,4O

l-160 . •

••



••••

0.-180 .. 0.

0 0

t

Q)

0.

-200

0

-220 0

20

40

60

80

100

120

140

160

180

200

Frequency [flz]

FigUl"e 8.2: Open-loop Bode-plot for both the Costas loop and DLL

8.3

Noise analysis of the control loops

It is expected that the input signal is corrupted by white Gaussian noise. Due to this noise, the output of the phase detectors will also have a noise component. ·When the phase detector output noise is (mathematically) transfered to its reference input, the loop output noise can be calculated when the sampling frequency and the closed loop gain are known. The noise at the output of the loops (i.e. the output signals of the numerically controlled oscillators in the Costas loop and DLL) will lead to a less higher signal output of the correlators and is therefore the cause of a virtual lower signal to noise ratio at the input of the receiver.

8.3.1

Description and notation of noise processes

A white Gaussian noise signal will be denoted as nG(t). Statistically, the noise process can be characterized by mean {l and variance (72. '-IVe thus can say that Gaussian noise is a normal distributed statistic process: (8.18)

The noise at the reference input of the Costas loop phase detector will be characterized by the parameters {lei and (75i while the other phase detector input (the loop output) of the Costas loop uses {leo and (75 According these parameters, the DLL noise processes are given by {loi' ,

0

50

Analysis of the control loops

5,----.--=-==---.---,----.----,,----.---,----.------,

o

\

m ~-10

,

, .

c:

"iii

Ol

',',.

.

,,

g--15 .2

,.. , ' :,

-0 Q)

,

l/l

.........,

.2 -20

()

-25

-

"

modem loop implementation

••- true second-order loop '-...

-30

........

"":'-"

.....

·35'------'----...L-------l--....L---'---------'----...L-----'--....L---

o

~

~

M

00

100

1~

1~

1M

1M

~

Frequency [Hz]

Figure 8.3: Closed-loop gain of the control loops and true second-order loop

2 2 ,' POo an d a oo ao '

Because the signal input noise is zero mean, it is characterized by

8.3.2

a; only.

Input-output relations for noise in control loops

In the equations of this section, parameters for characterizing noise in the Costas carrierrecovery loop will be used. However, the analytical results are valid for all control loops. As described before, the noise process at the input of the loop can be characterized by a mean value (po.) and a value representing the variance (aJ). The mean of the process can be interpreted as a DC-value which simply leads to the following relation:

(8.19)

The variance a5 actually represents the power of the noise process. Due to the sampling of the control loop~, we find that the spectral power density of the input phase noise is 2Tsa5. because the input noise power is spread out uniformly over a band which is half the sampling frequency and duplicated at all harmonics of that sampling frequency. The variance of the output phase noise is therefore given by :

8.3 Noise analysis of the control loops

51

(8.20)

8.3.3

Noise behaviour of the Costas loop phase detector

If noise is applied to the input signal, and both Costas loop and DLL are in lock, the central correlator output values for 1- and Q-stream are given by the following equations:

VIC (

,,~+

2N

2N

1) =

n

:'N-1

AN

+ '""' nC I (k + - ) ~'2N

(8.21)

n=1 n=odd

VQe (k+ 2N) = 2N

~ nCQ (k+~) ~, 2N

(8.22)

n=2 n=even

Knowing that all samples of the noise process are independend, one can derive that:

VIC ( k

+

VQe (k+

2N 2N

1) =

AN

+ NI(O, NoD

(8.23)

~~) =NQ(O,No-;)

(8.24)

Finally, the phase detector output is given by :

Ve,eosTAs(k

+ 1) = VIC

(k

-1)

+ 2N2N

vQe ( k

+ 2N2N-

1) =

,r

JV

2

2

')

(0, N O"i (A- N

2 + O"i))

(8.25 )

which can be rewritten to :

Ve,eOSTAs(k

+ 1) = [\d N(O,

2N

~NRi

( 1 + 2N

~NR))

(8.26)

in which the input signal to noise ratio is written as :

(8.27)

and the number of samples per correlation period for each stream is given by : N=

2N f·

CI

Ic(2m

+ 1)

(8.28)

By this result, it can be concluded that the input phase OJ is corrupted by a zero-mean Gaussian noise process. In most practical cases the assumption that 2N SNRj ~ 1 holds, we thus

52

Analysis of the control loops

find the characterizing parameters to be : /lB,

=0

~

(r B, -

8.3.4

(8.29) 1

(8.30)

..,....,..."....",.,....=-

2N SNRi

Noise behaviour of the DLL phase detector

When analyzing the noise behaviour of the DLL phase detector, it is assumed that the Costas loop and the DLL are both in lock. The expression for the DLL phase detector output shows which correlator output have to be analyzed:

~ (

v e ,DLL(k+1)=vh

~ vQL

k+

1)

2N 2N

(k + 2N) 2N -

~

-vIE

~ vQE

(

k+

2N 2N

1)

+ (8.31)

(k + 2N) 2N

In the following, the data-signal and optional ±-signs are ommited because they are not important for analyzing the noise behaviour. The late and early correlator outputs of the 1- and Q-phase can be written as (see also Chapter 5 for the notation of the PN-codes PI and Pe) :

vn ( k+

2N 2N

1) =

ANRc

( -

.6. ) 2 Tc

+

?;

2N-l

(

Hc,!

n) (

n)

k+ 2N PI k+ 2N

n=odd

(8.32)

(8.33) (8.34) n=even

VQE

(k+

~~) =

f

nC,Q

n=2 n=even

Squaring these expressions gives:

(k+

21~)pe (k+ 21~)

(8.35 )

53

8.3 Noise analysis of the control loops

V~~ IE

(

~ (~ k+ 2N2N- 1) =AN-R -T + 2 2

2

)

c

c

~

2ANRc

( 2 Tc

)

2N-l

~

(k+

llG,I

2~)Pe (k+ 2~) + (8.37)

n=odd 2N-l 2N-l

L L

llG,I

(k + 2~ ) Pe (k + 21~ )

llG,I

(k + 2:' ) Pe (k + 2:' )

n=l m=l n=odd m=odd

2N

2

vQL

(

k

+

2N

L

2N) 2N

L

llG,Q

(k

n=2 m=2 n=even nt=even

21'-/

21'1

L

L

(k

llG,Q

n=2 m=2 n=even n1.=even

+ 2~ )

Pi (k

+ 2~ ) Pe

+ 21~ )

(k +

llG,Q (

+ 2:' )

k

PI (k

+ 2:' ), (8.38)

2~ )

llG,Q (

k

+ 2:' ) Pe

(k

+ ;~ ),

(8.39)

Because the autocorrelation function R c is an even function, the following holds:

(8.40)

After some rearranging, we thus find for the DLL phase detector output:

Ve,DLdk

+ 1)

=2AN R c (

~Tc) 2~1

llG,I

(k

+ 2~)

(PI (k

+ 2~ )

- Pe (k

+ 2~ )) +

n=odd 21V-]

2J.V-l

'"""

'"""

~

~

llG I

n=l m=l n=odd m=odd

(PI

,

(k + ~) 2N

llG I

'

(k + ~) 2N .

(k + 21~ ) PI (k + ;~ ) - Pe (k + 2~ ) Pe (k + 2:' ) ) +

2N

2N

L L

llG,Q

(k + 21~ )

llC,Q

(k + 2:' ) .

- Pe (k

+ 21~ ) Pe

(8.41)

n=2 m=2 n=even m=even

(PI (k

+ 21~ ) Pi

(k

+ 2:' )

(k

+ 2:' ))

Evaluating this expression is done by the following argumentation: • The first term of equation 8.41 contributes a noise sample for each n where (PI - Pe) equals ±2. Therefore, the samples n have to be in the LlTc-wide region round a central chip transition (so that PI and Pe have opposite signs). Because the PN-code contains approximatly !Nc transitions (this can be concluded from the autocorrelation function), only !LlN samples out of N contribute to the output of the phase detector. • The other terms contain an expression with PI and Pe which is far more difficult to analyze. However, these terms are the multiplication of two noise samples which lead

Analysis of the control loops

54

to negligible contributions to the total noise output (as was seen when analyzing the Costas phase detector noise behaviour). For that reason, a worst case approximation for these terms is employed, assuming that all noise samples contribute to Ve,DLL. Later on, we'll see that the resulting expression can be neglected. Using statistic notations for the noise samples, we find that:

(8.42)

For .6. :::; 2 the following holds:

He

2l.) = 1 -2l.( -T L 2

(8.43)

e

The phase detector output can now be rewritten as :

(8.44)

According the results of Chapter 5, the DLL phase detector gain for large values of N c can be written as : (8.45)

The noise output of the phase detector can now be rewritten to :

l'e,DLL(k

_ + 1) = I\.d/V(O,

~

4NSNRi

(

2

1 + ~(2 _ ~)2NSNRi

)

)

(8.46)

from which can be concluded that the PN-code phase 6i is corrupted by a zero-mean Gaussian noise process, which for sufficient large values of .6.(2 - .6.)2 N SNRi is given by :

°

?

O"j,

8.3.5

(8.47)

= ~ = 4N SNRi

Po,

(8.48)

Detoriation of receiver performance

According to the results as obtained earlier in this chapter, the central correlator I-phase signal-output (from which the data-signal is extracted) is given by :

VIC

2N ( k+ 2N-l)

= ±ANcos ( Be

( k+ ~ N+l)) R e (J e( k+ ~ N+l) T e ) d(k)

(8.49)

55

8.3 Noise analysis of the control loops

To investigate the loss in signal to noise ratio, due to noise in the Costas carrier-recovery loop and the PN-code tracking DLL, the following simplifications are made: • The data-signal d(k) and the optional ±-sign are of no importance for the analysis and for that reason removed from the expression. • For small values of (}e, the cos-term can be approximated by the first two terms of its series-expansion : cos( (}e) :::::: 1 - ~();. Because the input-phase of the detector can be interpreted as a constant parameter which is always zero at the sampling instants, we also can state that (}e = -(}o. • The autocorrelation function can be denoted by a linear function for small values of 8e , so R c (8 e T c ) = 1 - 18e l. As with the Costas loop, for the OLL holds that 8e = -8 0 , This leads to the following expression :

VIC

(k

+ 2N2N-

1) = (1 ., ( + ---w + 1)) ( Ib. ( + ---w + 1) I) AN

1- 2(J~

k

N

1-

o

k

N

(8.50)

From this result we can see that the mean signal-output of the correlator can be written as :

(8.51)

Because both (}o and 80 are zero mean normal distributed with variances of respectively and simple integral mathematics show that:

at,

at

(8.52) (8.53)

This finally leads to the result that :

(8.54)

From equation 8..54 can directly be calculated what detoriation of input signal to noise ratio is to be expected, simulation results are presented in figure 8.4. To be able comparing the simulation with the measurement results of the next chapter, BL is 10 Hz for the DLL and 30 Hz for the Costas loop.

Analysis of the control loops

56

0.4~--~---,-----.----.-----.---....,....-----r---,

0.38

m

~0.36

~ ~

c

0.34

'"

E (; 0.32

't: Cll

a.

al

0.3

L>

::> "0

g 0.28

.S;

jO.26

ec 0.24 o

l)

0.22 0.2 L -_ _. L -_ _-'---_ _- - ' -_ _-'----_ _- - ' -_ _--'---_ _---'-_ _- ' -12 -11.5 -11 -10.5 -10 -9.5 -9 -8.5 -8 Input SNR [dB]

Figure 8.4: Det.oriat.ion of receiver performance due to noise in the control loops

at

01,

Because both and will be much less than 1, equation 8..54 also reveals that the DLL has a much greater influence on the receiver's performance than the Costas loop.

Cl~apter

9

Performance measurements Several measurements were made to determine the actual performance of the all digital implementation of the G50-transceiver. In this chapter, the theoretical limit for the performance of the spread spectrum receiver is derived first, after that results of real time measurements are presented. Also, additional measurements were set up to determine the causes of performance loss of the receiver. Appendix C contains tables with the measurements results and information about the used equipement and procedures.

9.1

Theoretical lilnit of performance for a single user

\\Then deriving an expression for the theoretical expected performance of the receiver, it is assumed that the control loops are not influenced by any noise on the input signal. Under this assumption (all control loops free of noise and thus free of tracking errors) the following can be stated (see also Chapter 8) :

VIC

(k

+

2N

2;;

1) =

AN

+

2N-1

L

nG,I

(k

+ 2~)

(9.1 )

n=l n=odd

in which

TIc,!

is the input noise with variance

(1[.

Knowing that all samples of the noise process are independend, one can derive that:

VIC

(k

+ 2N2N-

1) =

AN

+ N(O, Na.;)

(9.2)

Under the assum ption that a 0 databit is transmitted with the same probability as a 1 databit, the receiver puts the decision-level just between the signal-levels of those bits. Because the signal-levels are ±AN, the decision-level is at zero. The bit error probability can be written as follows: Peb

= P(O send) . P(l detected 10 send) + P(l send) . P(O detected 11 send)

(9.3)

58

Performance measurements

Under the assumption that P(O send)=P(1 send)=%, this can be rewritten into: Peb

= 2"1 P(l detected 10 send) + 2"1 P(O detected 11 send)

(9.4)

From figure 9.1 (representing the probability density function of the I-phase correlator output) can be seen that the probability of deciding to the wrong bit is equal for both databits and fully determined by the signal- and noise-level.

i

-AN

o

pdf

+AN

--

amplitude

FiguI'e 9.1: Correlator output probability density function

We thus see that a bit error occures if the noise component in the correlator overcompensates the signal-level (shaded areas in the figure). With Gaussian noise, the bit error probability can be rewritten to :

Peb =

1

00

AN

1 ( - AN e -~ 2 N~; dy = Q __ ) J2rrN~1 JN~l

(9.5)

With the following expressions for the input signal to noise ratio and the number of samples for each correlator per correlator period

(9.6) (9.7)

we can finally write that:

SNRi)

N c Ii fc(2m

+ 1)

(9.8)

The following section will present actual measurement results and compare them with the results of this section.

9.2 Real time measurements

9.2

59

Real time lueasureillents

As can be seen from equation 9.8, enlarging the subsampling factor m can lower the bit error probability. This was also verified by measurements with the following set of parameters : N c=7, fc=8 kHz, fi=128 kHz and SNRi=-9 dB. The bandwidth B L of the control loops was 10 Hz for the DLL and 30 Hz for the Costas loop. Measurement results for a few different values of m :

Itn=2 = 2.25 . 10- 3 3 Peb I m=3 = 4.10.102 Peb I m=4 = 1.26· 10-

Peb

The effect can be explained straightforward: a lower value of Tn gives a higher sampling frequency If s and thus more sam pies per cOlTelator period. It can be concluded that for the best receiver performance, the subsampling factor should be chosen as low as the modern can handle. Another measurement gives a better insight in the performance of the receiver, this time the subsampling factor m was held constant and bit error probabilities were measured for several values of the input signal to noise ratio. The following parameters were used: N c =15, fc=8 kHz, fi=128 kHz and m=:3. Control loop bandwidth BL was again 10 Hz for the DLL and 30 Hz for the Costas loop. Figure 9.2 shows the results, it also contains a curve which was fitted through the measurement points according the 'least squared error' method and a curve which represents the theoretical expected performance (as given by equation 9.8) .

,-

•-- measurement -

thecretic performance

,'-''l'

....................

,

.... :

"

10-5,

10" L - _ . - L_ _-'--_ _L--_---'-_ _-..L.._ _L . - _ - - ' - _ - - ' -12 -11.5 ·11 -10,5 ·10 -9.5 -9 -8.5 ·8 Input signal to noise ratio [dB]

Figure 9.2: Performance as a function of input signal to noise ratio

When for a certain signal to noise ratio the theoretic

Peb

is calculated, then figure 9.2 shows

60

Performance measurements

what increase of SNRi is necessary for the modem to achieve the same bit error probability. That increase is called the modem implementation loss and given by figure 9.3.

1.05,------,---.....,.---,-----r----.---,------.--....,

co

0.95

~

1:l 0.9

.2 o

"

~0.85

C Ql E

~

0.8

£;

~ 0.75

"0

o

::; 0.7 0.65 L

0·'~':-2--.---:1-'-1.5=--.-:'-11,-----.---:10 .5,-----.1-'-0--.-:'-9.=-5--.9 2B

(B.5)

By this, it can be concluded that for a minumum bandwidth of B=Ic the following constraint must hold: ffs

> 2fc

(B.6)

where the sample frequency is given by (Chapter .5)

4/i

ffs

(B.7)

= (2m + 1)

We thus see that by the constraint as given by B.G, the constraint of relation B.! is always satisfied too. With the current Ii of 128 kHz, table B.! shows the values of fIs for several values of the subsampling factor m.

~ 4

3 2 1 0

[kHz] I .5G.889 73.143 102.400 170.GG7 .512.000

ffs

Table a.l: Sample frequency

hs

when ]i=128 kHz

It can be concluded that only m=l can be used, higer values of m result to values of lis which do not satisfy relation B.6 (with Ic=64 kHz) while for m=O the sample frequency of .512 kHz cannot be handled by the modem. Because the performance of the receiver is improved if several samples instead of one are taken of each chip of the PN-code, it is recommended to use a higher sample frequency than the one resulting from Ii=128 kHz and m=1. The sample frequency 1]8 can be chosen in such way that nearly all processing power of the receiver is utilized, say 1]8=200 kHz for example. [n that case, both 1- and Q-phase take an average of 1..56 samples per chip of the PN-code while the bandwidth of the input bandpass filter can be approximately one and a half times the chip rate. The resulting values for Ii are given in table B.2.

77

~ fj [kHz] 6 650.000 550.000 5 4 450.000 3 350.000 2 2.50.000 1 150.000 50.000 0 Table B.2: Input frequency

For choosing a value of

Ii,

Ii

I

when 1/.=200 kHz

the following items should be considered also:

• The bandwidth of the input filter should be in the range B= Ie to B=2Ic. A low value of Ii offers the possibility of sharp filter curves but on the other hand, the low it-ratio may lead to complex filter designs in order to obtain a flat frequency response in the passband. • The Costas loop employs a numerically controlled oscillator (the digital timer on the DSP). Therefore, the sample pulses are corrupted with extra phase-jitter of which the probability density function is a uniform distribution between - ~its and +~its' It thus can be concluded that a higher input frequency Ii also leads to more phase-jitter in the Costas loop and therefore results to an extra detoriation of receiver performance. To give an idea of the properties, with the values of table B.2 and MIPS=2.5 :

Ii = 50

kHz

Ii = 650

271"50.10 3 : 201og(cos( 25.10 6 ))

kHz : 201og(cos(

271" 650· 10 3 25.10 6

= -0.001 dB

))

= -0.12 dB

Expected perfornlance Thusfar, only measurements were carried out at a chip rate of 8 kHz. Two possible sources of an increase of Peb can be thought of when the spread spectrum receiver is operated at a chip rate of 64 kHz: • Just like the Costas loop, the DLL employs a NCO which is responsible for extra phase-jitter. Because the chip rate is low compared to the clockspeed of the NCO, the detoriation of receiver performance is negligible: _ 64.10 3 20 log(l - 25. 10 6 ) = -0.02 dB

• Because nearly all processing power of the modem is utilized, it is expected that calculation of new update values for both the Costas loop and the DLL are interrupted

78

The modem at 64 kHz chip rate

by sample- or PN-code generator-interrupts. Therefore, some extra delay is introduced in the control loops. Because it is expected that this delay is small compared to the loop update period, this phenomenon will also not contribute signifficantly to the performance detoriation of the receiver.

By the previous items, it is concluded that receiver performance at a chip rate of 64 kHz will be almost equal to the receiver performance at an 8 kHz chip rate.

Appen.dix C

Measurements The spread spectrU111 link 111eaSUre111el1t setup For measurements according the setup of figure C.1, the following equipment was used: • A C2S-transceiver print, configured as a baseband transmitter with device-address

o.

• A C50-trc.nsceiver print, configured as a baseband receiver with device-address 1. • BPSK mod ulator board as described in [3]. • PCl. CONEX-system 80486. This PC is equiped with the GSO-emulator (communicating via the .JTAG-interface) and all CSO-transceiver program development and debugging software. • PC2, Tulip 80286, running the PC BER-measurements program. Communicates with C50-transceiver via the parallel printer port. • HP 3326A two channel synthesizer, for generating the IF-carrier (128 kHz sine). • Random-Noise generator, General Radio Company 1390-B. Maximum of2 V signal level in 500 kHz bandwidth [18]. • HP 3400A nns-voltmeter. Used for measuring the signal- and noise-power at the input of the ADC. • HP 5381A frequency counter, for measuring the sample frequency

hs.

• Tektronix 2225 50 MHz oscilloscope, for various purposes

The C25- and GSO-transceivers, the BPSK modulator board and various power supplies were integrated in a 19 inch rack.

80

Meas Urelnents

PC

parallel interiace

BER-measurement software

C25-transceiver

C50-transceiver

JTAG

input

output

PC development software

d(I)·p(l)

IF-carrier generator

noise generator

A,cos(o',I)

,------>

I--n(l)

BPSK modulator

A'COS(lO,I)'d(I)'p(l) + n(l)

true-rms voltmeter

Figure C.l: Measurements setup

Procedure for setting the input signal to noise ratio During all measurements, the noise level at the input of the ADC was held at 1 V rms' To obtain a specific input signal to noise ratio. the signal level for that SNR; has to be calculated first. Thereafter, the following procedure must be followed:

• Connect the HP signal generator and GRC noise generator to the BPSK modulator board, connect the output of the modulator to the GSO-transceiver input and the HP rms-voltmeter. • Set the signal level to 0 V rms and set the noise level to 1 V rms' Then attenuate the noise by a. factor 10000 with the switch at the noise generator. • Set the input signal to the desired level and put the noise attenuator-switch back to its original position. The HP 3400A rIlls-voltmeter has a full scale accuracy of ± 1 % for frequencies up to 1 MHz [19]. Because the signal to noise ratio is determined by two readings (signal- and noise-level), the total measurement accuracy is ± 2 %. This is equivalent to an accuracy of ± 0.17 dB.

81

Measurelnent results

Paran1eter measurement 1 measurement 2 measurement 3 measurement 4 mean value mean number of errors measurements time [s]

Peb

Subsampling factor m=2 2.28·10 3 2.39.10- 3 1.93.10- 3 2.42.10- 3

m=3 4.46· 10 3 4.08.10- 3 4.12.10- 3 3.73.10- 3

m=4 1.38· 10 2 1.04.10- 2 1.34 . 10- 2 1.29 . 10- 2

2.25.10- 3

4.10.10- 3

1.26.10- 2

64 25

117 25

360 25

Table C.l: Feb for Nc=i, 1c=8 kHz, 1i=128 kHz, SNR,=-9 dB and O"i=1 V rms

Parameter measurement 1 llleasurement 2 Peb measurement 3 mean value mean number of errors measurements time [s]

SNRi [dB]

11

~----'-1-::-2---'---------:-1----:1--1

5.23.10- 3 05.23 . 10- 3 5.38.10- 3 5.28.10- 3 70 25

1.46· 10- 3 1.46. 10- 3 1.95. 10- 3 1.62.10- 3 86 100

-10

3.80.10- 4 3.71 .10- 4 4.04.10- 4 3.85.10- 4 82 400

\---9----,..-------8- 7.12.10- 5 5.44.10- 5 5.06.10- 5 5.87.10- 5 31 1000

6.56.10- 6 1.17.10- 5 2.38.10- 6 6.88.10- 6 15 4000

Table C.2: Bit. error probability Feb for N c =15, 1c=8 kHz, m=3, 1i=128 kHz and noise O"i=1 V rms

Param.eter measurement 1 measurement 2 Peb measurement 3 mean value mean number of errors measurements time [s]

virtual SNRi [dB]

-----,-11,.-----1 -10 1--''----9:::---12 -8 4 5 3 4 5.23.101.79 . 106.19·10 5.89· 10 6 2.24·10 4 7.47.10- 4 5.81.10- 5 7.34.10- 6 2.69.10- 3 3.36.102.47.10- 3 1.31.10- 4 4.88.10- 5 7.17.10- 6 5.98.10- 4 5 3 4 4 5.63.106.80.10- 6 2.32.106.23.102.30.1030 15 31 33 49 1000 4000 2.5 400 100

Table C.3: Feb for N c =15. 1c=8 kHz, m=3, 1i=128 kHz, noise O"i=1 V rms and simulated input signal

Appen.dix D

Script files for Matlab Matlab offers the possibility of writing little programs, called script-files. Three script-files were used: • control.m is a script file which perfroms all simulations concerning the control loops (step response, frequency response, expected detoriation of receiver performance). • noise.m performs the simulation of sampling bandlimited noise. • measure.In generates plots of the measurement data.

control.ul %*************************************************************************** % First part of the listing, user may alter these values %***************************************************************************

% PICO-terminal parameters fi

128000;

m

3;

fc

8000;

Nc BL

15;

100; 0.707;

beta

% input frequency % subsampling factor % chip rate % chips per databit % loop bandwidth % loop damping factor

% Ki and Kp calculated as with second order. but multiplied with factors Kp_factor Ki_factor

= =

1.000; 1.000;

% factor for Kp % factor for Ki

% Signal parameters 0.447; le-8;

A

sigma2_i

% amplitude of input signal

% variance of input Gaussian noise

% Simulation parameters step

=

0.10;

% input step, for response simulation

Script files for Matlab

84

t t f f

s e s e

0.00; 0.05; l' 200;

% start of simulation time % end of simulation time % start of simulation frequency % end of simulation frequency

.

% Plot control variables (0 plot_theta_o plot_sigma2_o plot_theta_e plot_sigma2_e plot_H_f plot_bode plot_polar plot_perf

no plot, 1 : plot)

0; 0; 0;

O', 0; 0; 0; 1;

% output phase % variance of output phase % error phase % variance of error phase % plot of closed-loop IH(f) I % bode-plot of open loop % polar-plot of open loop % noise performance degradation

%*************************************************************************** % Second part of the listing, not to be altered by the user %*************************************************************************** % Calculate other variables ffs Ts N

Kd Ko wn Kp Ki points Kp Ki SNR_i

4*fi/(2*m+1); Nc/fc; Ts*ffs/2; (A*N) -2; (2*pi)*(2*N)*fi/ffs-2; 2*BL/(beta+1/(4*beta)); 2*beta*wn*Ts/(Ko*Kd); (Ts*wn)-2/(Ko*Kd); (t_e-t_s)/Ts; Kp*Kp_factor; Ki*Ki_factor; 10*log10(0.5*A"2/sigma2_i);

% sampling frequency % loop update time % I- or Q-samples per correlator period % phase detector gain % frequency synthesizer gain % natural loop frequency % proportional gain PI-controller % integrator gain PI-controller % number of simulation points % adjust Kp % adjust Ki % input signal to noise ratio in dB

% Simulation of the loop, time domain c

theta e sigma2_e theta_o sigma2_o

zeros(l,points); zeros(l,points) ; zeros(l,points) ; zeros(l,points) ; zeros(l,points);

% control signal frequency synthesizer % measured phase error by detector % variance of theta_e % true phase error % variance of theta_o

int=O; % do simulation itself errors=O; for p=2:(points-1) v_I=A*N*cos(theta_e(p))+sqrt(N*sigma2_i)*randn; 7. I-phase v_Q=A*N*sin(theta_e(p))+sqrt(N*sigma2_i)*randn; % Q-phase v_e=v_I*v_Q; % error signal theta_e(p)=v_e/Kd; % true measured v_e=v_e-Kd*step; c(p)=Kp*v_e+int; % control signal int=int+Ki*v_e; % integrator theta_o(p+1)=theta_o(p)-Ko*c(p); % true output phase theta_e(p+1)=(theta_o(p)+theta_o(p+1))/2; % virtual output phase if (v_I Initial situation in Data_Ll0: - interrupts enabled - TCOL:=O, so the drawn * 's have column index (TPERIOD-l) - PRD:=TNCOL, to cover the first 3 timer periods ------> TINTlb => NEWVALs - Code phase step in Mainla during code acquisition will over rule the chip time interval marked with # $. In case the part ACQUIS is not reached before the next TINT2 occurs, then only $ becomes over ruled. During code tracking => FDLLER => TROW. It is good to let TCOL just run through, because then TPERIOD can even be larger than Nc. Chip_Tint

*** TINTlab

SPM LDP LAC XORK SACL BGZ

1 #0 SWIT 1 SWIT EARLAT

Process the central code LAC TIME SACL PRD LDP LAC ADD ANDK SACL SUB BGEZ

#6 CODEPH PHSSTP 3FFFh CODEPH PHSSTP NOCORE

LAC ADD SACL

CODEPH PHSSTP CODEPH

LDP ZALH SACH ZALH SACH ZALH SACH ZALH SACH ZALH

#GMEM_DP ICORCH_ IVAL QCORCH_ QVAk ICORLH_ IVALL_ ICOREH_ IVALE QCORLH_

Restore PM mode (KPM=2, see Appendix II) Determine if early/late or central local Spreading code must be updated Increase early and late codes

Pass the new calculated period to The timer period register

CODEPH:=(CODEPH+PHSSTP) mod 4000h

If (CODEPH-PHSSTP) fc) and a FIR filter look-up table. - DAC_Int4a: With DACVoidR and DACVoid this routine makes it possible to generate chip rates lower than the lowest on board transmit clock frequency of 8 kHz (power of 2). - DAC Int4b For chip rate >= 8 kHz (power of 2). - DAC Int4c For pulse shaped chips, so SampPerChip(=K) >= 2, and a DAC output rate that has to be >= 8 kHz (power of 2). AD568 DAC output values: 0 = 5.12 V, 800h = 0 V, OFFFh = -5.12 V Definitions (see also Chapter 3)·: SampPerChip = K, the value provided by the PC has to be given as the power of 2, because it is also used to set the internal transmit clock rate. ChipPerpulse = N, N=T div K; if (T mod K»O then N:=N+1. T, is the number of filter taps so (N-1)K < T FIRaddr + 0

II AR4 -> DiPjaddr +

I

I 1 1

I 2 2

II

I

K-1 0 3 4

II 0 \---DiPjbeg

I 1 5

2 6

1 II I I K-1 0 1 7 8 9

II

..

I

II

10 10 II 1 2 K-1 T-1 NK-1 FIRend---j K-1 0

II

I I dummy I I

N-1 DiPjend---j

The ShpFilter loops calculate the FIR filter output only for every K-th tap (by means of ARO), from a start tap (indicated by FIRoff), because pg(t)=O for all other taps. The offset FIRoff is increased at every output sample. When it will become K then the bit-chip values in DiPjaddr are shifted one place to right (by means of the LTD instruction). After that a new bit-chip value is calculated (in a similar as DAC_Int4a,b) and inserted at DiPjbeg and FIRoff :=0. The filter tap outputs are calculated backwards (N-1 .. 0), because the DMoV in LTD goes from mem to mem+1 (hence there is a dummy location). The followin pseudo pascal program shows the build up of DAC Int4c. FIRoff:=FIRoff+1 if FIRoff=K then

131

begin FIRoff:=O Load new bit-chip value at DiPjbeg end if FIRoff=K-l then Filter with DKOV of bit-chip values (so use LTD) else Filter normally, i.e. without DMOV (so use LTA) Initializations (see Data_Ll): FIRoff:=K-l (equivalent to FIRoff:=O. but avoids SXM problems) DiPjbeg:=DiPjaddr DiPjend:=DiPjaddr + N-l AR1:=(FIRend+FIRoff=)FIRend AR4:=DiPjend

.

';'-1 '

",

On entry. for a.b and c: - AR5 is chip counter (and ARP) - AR2 points to chip in SSGodeOwn - AR6 is bit counter - AR3 points to bit in SendData Only for c: - ARO used for stepping through FIR coeff with step K. and for GMPR - ARl points to the FIR coefficients in FIRaddr - AR4 points to the bit-chip values in DiPjaddr Speed of DAG_Int4c: The pulse shaping routine takes the most cycles when FIRoff=K and a new bitchip value of the message has to be loaded -) K*fc=fDAG 5 V (and -1 => -5 V) Add DAC offset of 800h DAC output value

with DMOV of bit-chip values 0 ARP=AR4, ACC=O, P:=O ARO,SampPerChip Use LTD instruction for DMOV *- ,AR1 *O-,AR4 ARO,DiPjbeg 1 N bit-chips done? ShpFilter2 Add last filter product Bit-chip=l ==> 5 V (and -1 => -5 V) 1000h,15 Add DAC offset of 800h OutData_7 DAC output value AR7 OutData_7 SarnpRate OutData_7 OutData_7,DAC_PORT *+

*+ *+ *+

ARP=AR7

134

Receiver software source listings

LSTi EINT RET

;******************************************************************************* PARALLEL COMMUNICATIONS PORT ROUTINES - Transmit - PARCommand

;******************************************************************************* -------------------- Transmit routine ------------------------This procedure starts a packet transmission from the device to the PC by sending the first character SOH (a nibble). After that the whole rest of the parallel port communication is interrupt driven and taken care of by the interrupt service routines PAR_Int2 and PAR_Tint. First however Transmit fills the packet array PAR_TrmOata with an answer string. Auxilary registers: - ARO points to the to be transmitted answer string of which the first word contains the length in bytes, see for examples the section "Strings". - ARi points to the packet storage area PAR TrmData. - AR2 counts the number of bytes in the string. Labels: - TRH_Li and TRH L2 from a loop that stores the high byte, respectively the low byte of the words in the string as nibbles (two nibbles per byte) in the packet. TRH_L3 at the end the SOH is put to port ih with LptWrtC and PAR_Status=3, PAR_Retry=O, PAR_TrmLen=length of packet, and PAR_TrmCnt=l. It is not necessary to initialize ARiVAR, because this will be done in PAR_Li0. Remark: When a packet transmission doe not complete successfully a retry can be performed in the following cases: - When another nibble then AACK was received from the PC on SOH, then two additional retries can be done by immediately retransmitting the SOH in PAR_Lii. For even more retries the program branches to PAR_RetryTrm. - The part PAR_RetryTrm restarts a packet transmission allover again by making PAR_TrmCnt:=l, reseting ARl and sending the SOH. This can happen up to two times, otherwise PAR_Status:=O and the transmission is aborted. The PAR_RetryTrm part can be branched to from: PAR_Li0, when no correct AACK was received on SOH. PAR_L12. when no correct DACK was received on LEN2-0, 01h .. Dlen-4h. PAR_L13, when no correct EOT was received on Dlen-41. - Just as PAR_RetryTrm the part TI_RetryTrm in the PAR_Tint interrupt service routine restarts a packet transmission allover again when a time-out of TMOUTL = 5.2 msec (at 25 MIPS) occurs. This indicates that no data was received from the PC.

Transmit

LACK SACL ZAC SACL

PAR_Retry

LARP

ARi

3 PAR_Status

135

LRLK SACL

AR1,PAR_TrmData *+,ARO

LAR MAR LAC ADDK SACL LAC SACH ANDK SACH LAC ANDK SACL

AR2,*,AR2 *-,ARO *+,1,AR1 4 PAR_TrmLen PAR_TrmLen,8 *+ OFOOOh *+,4 PAR_TrmLen OFh *+,ARO

LAC SACH ANDK SACH BANZ B

*,4,AR1 *+ OFOOOh *+,4,AR2 TRM_L2,*-,ARO TRM_L3

LAC ANDK SACH ANDK SACH BANZ

*+,12,AR1 OFFOOh,4 *+ OFOOOh H,4,AR2 TRM_Li,*-,ARO

LACK 1 SACL PAR_TrmCnt DINT RelocIntVec TINT,07980h,PAR_Tint LptWrtC SOH EINT RET

;******************************************************************************* -------------------- PARCommand routine ------------------------Is called from MAINLOOP when PAR_Status=2 indicating that a command has been received from the PC. This routine then finds out which command and jumps to the corresponding command service program part as defined in the PAR_Answer area (see also the section "Strings" and Beg_L1). Auxilary registers: - ARO points to PAR_RecData buffer with the received command from the PC, after a command has been found it points to the first word of other data (if any) send along with the command word. - AR1 counts the number of characters in a command word - AR2 goes through a command information string in PAR Answer - AR3 successively contains the command information addresses - AR4 counts the number of possible commands Variables: Temp2 contains the address of a command service program - Temp1 contains a character of a stored command word to be compared with the received command in PAR RecData

136

PARCommand

Receiver software source listings

LARP LRLK LAR MAR LRLK

AR4 AR4.CmdCnt AR4.* *-.AR3 AR3.CmdCnt+l

; *** PC_Ll to PC_L4 loops through the possible commands PC_Ll LAR AR2.*+.AR2 LAC *+ SACL Temp2 LAR AR1,*+.ARl MAR *-.AR2 LRLK ARO.PAR_RecData

*** PC_L2 and PC_L3 loop through respectively the high and the low bytes *** of a command word PC_L2 LAC *,8,ARO SACH Templ LAC *+.ARl SUB Templ PC_L4 BNZ BANZ PC_L3.*-.AR2 LARP ARO LAC Temp2 BACC Command found (odd number of Characters in command word) ; ;

PC_L3

PC_L4

LAC ANDK SUB BNZ BANZ LARP LAC BACC

*+.ARO OFFh *+,ARl PC_L4 PC_L2,*-,AR2 ARO Temp2

LARP BANZ

AR4 PC_Ll,*-,AR3

Command found (even)

*** All possible commands have been search through but no match with the *** command received from the PC was found. LRLK ARO,UnknwCmdStr CALL Transmit B MAINLOOP

;******************************************************************************* ROUTINES THAT ARE USED FOR THE MEASUREMENTS - PNCodeGen - MakeBitMessage

;******************************************************************************* -------------------- PNCodeGen ------------------------; Fills SSCodeOwn area in (data) RAM with the own spread spectrum code of

137

length SRLen. This procedure uses the following registers (AR1, AR6 and AR7 are not used): - ARO=SRLen and AR5=O count the number of chips of the PN code in the loop PN_LONG - AR2=Taps counts the number of feedbacktaps to process in the loop PN_SHORT - AR3 points to the proper code definition info in the PNData area - AR4 points to SSCodeOwn where the chip values are stored And the following variables: - SRLen (must be specified before entry) - Taps, Tap, Tapx (local) - Seq, NewSeq (local) Finally the spreading code is copied again at the back in SSCodeOwn area and scaled for DAC output, by means of AR5, AR2, AR4 and the variable Helpl.

PNCodeGen

LRLK LARP LAC SUB BZ LAC SACL RPT MAR B

AR3,PNData AR3 *+ SRLen PN_l *+ Taps Taps *+ PN_O

Make AR3 point to code definition Info corresponding to SRLen

PN 1

LAR SAR LARK LAC SACL LAR SACL SFL SACL LRLK

AR2,*+ AR2,Taps AR5,O *+,AR5 Code Len ARO,CodeLen Seq

Initialise the other variables and Pointers

PN LONG

PN SHORT

RTC CMPR BBNZ LAR LAC SACL LACK SUB SACL LAC RPT SFL ANDK SACH LAC XOR SACL MAR BANZ RPT

NewSeq AR4,SSCodeOwn

0 PN_END1, *+, AR3 AR2,Taps *+,AR2 Tap 14 Tap Tap Seq Tap 8000h Tapx,l NewSeq Tapx NewSeq *PN_SHORT,*,AR3 Taps

PN_LONG loop is done CodeLen times To fill the SSCodeOwn array with The PN code PN_SHORT loop is done Taps times XORs all feedback values to Determine NewSeq

Set AR3 back to begin of tap

Receiver software source listings

138

PN_2

MAR MAR LAC RPT SFR BNZ SUBK SACL LAC AND SACL SFL SACL B

**+,AR4 NewSeq,l SRLen

Positions info in PNData Put chip value (+1 or SSCodeOwn

-1)

in

PN_2 1 *+,AR5 NewSeq CodeLen Seq NewSeq PN_LONG

; *** Miscelleaneous actions: Apply proper scaling necessary for both ; *** transmitter and IF receiver. PN_END1 LAC Device BNZ PN_END2 Transmitter ; *** Device Scale the code to for DAC output AR4,SSCodeOwn LRLK Where 7DO corresponds to 5 V LAC CodeLen SUBK 1 SACL Help1 LAR AR2,Help1 LALK 7DOh Help1 SACL Help1 LT LARP AR4 MPY * SPL *+,AR2 PN_SCALE1,*-,AR4 BANZ

RET ; *** Device PN END2

IF Receiver LRLK LAC SUBK SACL LAR LT LARP MPY SPL BANZ LRLK LARP LAC SACL

AR4,SSCodeOwn CodeLen

Scale the code according to KM, See Appendix II.

1

Help1 AR2,Help1 KM AR4

*

*+,AR2 PN_SCALE2,*-,AR4 AR2,SSCodeOwn AR2 *,AR4

Copy first chip to end of code, This is necessary for CHIPE

*

RET ;******************************************************************************* -------------------- MakeBitMessage ------------------------; Get the message which is to be transmitted as the spread spectrum signal and

139

store the bits (value +1 or -1) of it in SendData area. AROVAR should point to the message length field plus message string. This procedure uses the following registers (AR1, AR5, AR6 and AR7 are not used): - ARO points to the message received from the PC, which contains the characters of the message to be transmitted - AR4 points to the SendData area where the message bits are stored (1 bit per word) AR2 counts the number of characters in the message - AR3 bit counter And the following variables: SendLen, contains the number of bits in the message - Helpl local variable Temp2 variable must be or 1 before this routine is called and determines whether the bit values will be +1,-1 or +1,0

°

MakeBitMessage

LAR LARP LAC SACL LAR RPTK SFL SACL LARK LRLK

ARO,AROVAR ARO .+,AR2 SendLen AR2,SendLen 2

BANZ B BANZ MAR LARK B LAC SFL SAR RPT SFR ANDK BNZ SUB

M_BIT,.-,AR3 MB END MBit_O,.-,ARO .+ AR3,8 M_BYTE,AR2 .,AR4

MBit_l

SACL B

.+,AR3 M_BIT

MB_END

RET

M_BYTE M_BIT

MBit_O

SendLen AR3,8 AR4,SendData Loop that processes the bytes (characters) of the message Loop that processes the bits of A byte

AR3,Helpl Helpl 1 MB i t_1 Temp2

Temp2=1 Temp2=0

e.g. 1,1,1,-1,1,-1,-1 e.g. 1,1,1, 0,1, 0,

°

.

;

ROUTINES THAT EXECUTE/SERVICE THE COMMAND THAT WAS RECEIVED FROM THE PC - Reset - Data

;

-------------------- Reset ------------------------; Reset command has been received, send Ok and restart program.

.

Receiver software source listings

140

Reset Reset_O

LRLK CALL LAC BNZ Wait

ARO,OkStr Transmit PAR_Status Reset_O

B

Begin

;******************************************************************************* -------------------- Data ------------------------Data is received from the PC and the data to send is stored in the sendbuffer

Data

SAR

ARO,AROVAR

LAC BNZ

Device Data_L8

;******************************************************************************* The CSO-transceiver is configured as transmitter and has received a data command *** Reply answer to PC LRLK CALL Data_Ll LAC BNZ Wait

ARO,DataTrmStr Transmit PAR_Status Data_Ll

DINT *** Get parameter values from PAR RecData buffer LAR ARO,AROVAR LARP ARO #7 DP:=7 LDP LAC SACL SRLen 7 LAC *+ ADD *+,8 SACL Phase LAC *+ K as power of 2 SACL SampPerChip LAC *+ Fc as power of 2 SACL ChipRate LAC *+ Pulse length in chip times SACL ChipPerPulse LAC *+ ADD *+,8 DAC output amplitude for positive chips SACL PCHIPV LAC *+ ADD *+,8 DAC output amplitude for negative chips SACL MCHIPV #6 LDP DP:=6 So AROVAR points to the fields with the SAR ARO,AROVAR

141

Message length end the message IN *** Wait a random time provided by the PC before starting to transmit. Since *** Phase is maximally 32767 the maximum delay is approximately (4+x-l)*Phase *** /10 MIPS = 23 msec for x=4. LDP #7 LAC Phase RNDl SUBK 1 RPTK 3 X=4 NOP BGZ RNDl *** Fill SSCodeOwn area in (data) RAM with the own spread spectrum code of *** length SRLen LDP #7 Copy SRLen also to datapage 6 SRLen_7 LAC #6 LDP DP:=6 SACL SRLen CALL PNCodeGen LAC Code Len Copy Code Len also to datapage 7 #7 LDP DP:=7 SACL CodeLen_7 In PNCodeGen the chip values are set for 7DOh=5 V, but need to be adjusted according to PCHIPV and MCHIPV for DAC output chip amplitudes VerifyNr -> go tracking!

Acquistion, called Mainlab ACQUIS

; *** Threshold testing

* * *

LAC LOP SUB LOP BZ

TDUTACQ #GMEM_OP TimeHL #6 AcqTooHigh

Code acquistion time-out testing

LAC SUB BGZ

CCDR THRESH ABVTHR

Threshold testing

Increase

codephase

OINT LAC LOP SACL

TIMES #0 PRO

Jump if above threshold (looks like acquistion)

Increase code phase Oatapage: =0

153

ABVTHR

EINT LDP

#6

LACK SACL

ACORTR

Reset acquisiton or tracking variable No acquisition; ACORTR:=O

B

MAINLOOP

Wait for next event

LAC BNZ LAC ADDK SACL LAC ADDK SACL SUB DINT BGZ EINT B

ACORTR VER_l Verifications

Increment verification mode counter

0

1

Verif ications ACORTR 1

ACORTR VerifyNr

If ACORTR > VerifyNr then go tracking Prepare for Tacq

TRACK_l MAINLOOP

Not Tacq yet Otherwise wait for next correlation Results }1)C>C)\


P-reg

LT MPYA

DLLKp DLLERR

Copy proportional constant in P-register ACC:ACC + P-reg, DLLKp*DLLERR -> P-reg

SACL

DLLFL

Store result in loop filter register

154

Receiver software source listings

SACH APAC SACH LT LACT

DLLFH FDLLER KS1 FDLLER

Calculate loop error signal LACT implements KS1, see Appendix II

Store loop error signal with SACH will Implement KH4

*

Calculate newtimerperiodsTNCoL,TNCoH,andtheresolutionTRoW

* *

ADDH SACH LT LACT SACL LDP SACH ADDH SACH LDP LT MPYU LALK \ (

* * *

INIPRD Temp1 TSHIFT Temp1 Temp2 #0 TNCoL ONE TNCoH

New NCO period with TSHIFT (PC) resolution bits

Save the resolution part New NCO period

#6

Temp2 TPERIoD 4000h,2

APAC SFR SACH LT MPY PAC SFR ADD SACL

TRESA TROW

Go

carriertracking

Temp2 Temp2 TPERIOD

Add round off term of 0.5 with shifts left To account for PM=1 and SXM=1 TSHIFT assumes PM=O so compensate for PM=1 New resolution row index O.. TPERIoD

Compensate for PM=1 New resolution row address

***********************************************************

* * *

Carrier

tracking (calledMain2b)

***********************************************************

*

CARR

* *

*

Calculate

phasedetectorerrorsignal

LDP LT MPY LDP PAC NoP

#GMEM_DP IVAL QVAL

SACH

VERRoR,1

Calculate error signal By mutiplying IVAL with QVAL

#6

Move P-register to accumulator

Store result in VERRoR, this implements KH5

155

(see Appendix II)

* * *

Calculate

loopfilter

ZALH ADDS

LFREGH LFREGL

Copy loop filter register into accu

LT MPY

Ki VERROR

Copy integration constant in T-register Ki*VERROR -) P-reg

LT MPYA

Kp VERROR

Copy proportional constant in P-register ACC:=ACC + P-reg, Kp*VERROR -) P-reg

SACL SACH APAC SACH LT LACT SACH

LFREGL LFREGH

Store result in loop filter register

LERROR KS2 LERROR LERROR

Calculate loop error signal LACT implements KS2, see Appendix II

Store scaled loop filter result in LERROR, this Implements KH6 (see Appendix II)

;*** Pass LERROR to CPU_1 via Global Memory, rest of calculations by CPU_1 LDP SACH SetGMIF

#GMEM DP LError 6,NEW_FREQ]LAG

Pass LERROR Signal to CPU_1

;******************************************************************************* Process the bits and characters of the received spread spectrum message. This part of the IF receiver program is called Main3 and can be devided into three parts: Main3a: Search for the prefix in the message determine whether the 1- or the Q-branch samples on the tops of the vi signal, uses cyclic buffers of length 7 because the used prefix contains 7 successive 1's or -1's depending on the bit polarity determine the polarity of the bits initialize for Main3b or Main3c when the proper prefix and branch have been found - Main3b: and extract the message characters Main3c: or perform BER measurements

LAC SEARCH BHZ MSG_RCV ;******************************************************************************* --------------- Main3a -------------------*** Search for the prefix in the received spread spectrum message First check for prefix not found time-out LACC TOUTPFX Prefix should be found with a few sec. LDP #GMEM_DP SUBS TimeHi LDP #6 BZ PfxTooHigh

156

Receiver software source listings

--- Take care of cyclic buffer loop around (uses AnswerStr area) On entry ARP=AR2 BANZ MSG_Sl,*-,AR3 Decrement 7-bits cyclic buffer counter AR2 LARK AR2,6 LRLK Flap back to begin of cyclic buffers AR3,AnswerStr LRLK AR5,AnswerStr+7 ; --- Update IBYTE based on the I-branch with new bit #GMEM_DP MSG_Sl LDP IVAL_ LAC ; ARP=AR3 LDP #6 MSG_S2 BLZ SACL *+,AR5 Store absolute value in cyclic I-buffer IBYTE,l LAC ADDK 1 MSG_S3 B ABS SACL Idem *+,AR5 LAC IBYTE,l ANDK OFFh SACL IBYTE ; --- Update QBYTE based on the Q-branch with new bit #GMEM_DP LDP QVAL_ ARP=AR5 LAC LDP #6 MSG_S4 BLZ Store absolute value in cyclic Q-buffer SACL LAC QBYTE,l ADDK 1 MSG_S5 B ABS SACL Idem LAC QBYTE,l ANDK OFFh SACL QBYTE ; --- Check I -branch for prefix and inverse prefix in IBYTE LAC IBYTE ; ARP=AR5 SUBK PREFIX MSG_S7 BZ LAC IBYTE SUBK PREFIXI MSG_S6 BZ IQPFX=2, no prefix found in I-branch yet, B MSG S8 Go check on Q-branch The prefix was found in the I-branch LACK OFFh IXORORN:=OOh or OFFh for bit polarity SACL IXORORN LARP ARl ARP:=ARl Sum last 7 IIVALls that are in cyclic LRLK AR1,AnswerStr End use Tempi as temporary store LAC *+,13 ADD *+,13 ADD *+,13 ADD *+,13 ADD *+,13 ADD *+,13 ADD *+,13 SACH Tempi IQPFX LAC

157

SUBK SACL

1

IQPFX

; IQPFX:=l ; Go check the Q-branch ; --- Check Q-branch for prefix and inverse prefix in QBYTE MSG_S8 LAC QBYTE ; ARP=AR5 or ARl SUBK PREFIX MSG_Sl0 BZ LAC QBYTE SUBK PREFIXI BZ MSG_S9 LAC No prefix in found Q-branch IQPFX SUBK 1 LARP AR2 ARP:=AR2 IQPFX=2, no prefix found yet in the 1BNZ MAINLOOP Nor Q-branch yet, so wait for next bit IQPFX=l, so both branches have been B MSG SI Checked, but only the I-branch seams to Contain the prefix The prefix was found in the Q-branch LACK OFFh QXORORN:=OOh or OFFh for bit polarity SACL QXORORN LARP ARP:=ARl ARl Sum last 7 IQVALls that are in cyclic LRLK AR1,AnsllerStr+7 End use Temp2 as temporary store LAC *+,13 ADD *+,13 ADD *+,13 ADD *+,13 ADD *+,13 ADD *+,13 ADD *+,13 SACH Temp2 LAC IQPFX SUBK 1 BNZ IQPFX=l, so both branches have been MSG_SQ Checked, but only the Q-branch seams to Contain the prefix B IQPFX=O, so both branches contain the * Prefix --- Decide on 1- or Q-branch and save decision and polarity mask MSG_SIQ LAC Tempi ; Sum IIVALI - Sum IQVALI SUB Temp2 BLZ MSG_Sll LAC IXORORN SACL XORORN XORORN:=IXORORN LACK 0 IORQVAL:=O for IVAL B MSG_SEnd LAC QXORORN XORORN:=QXORORN SACL XORORN LACK 1 IORQVAL:=l for QVAL MSG_SEnd B , Decide whether the I-branch contains the proper prefix and save decision , and polarity mask if so MSG_SI ARP=AR2 LARP ARP:=ARl ARl LRLK AR1,AnswerStr+7 Determine IQVAL!s sum LAC *+,13 ADD *+,13 ADD *+,13

158

Receiver software source listings

ADD ADD ADD ADD SUB BLZ LACK SACL B

*+,13 *+,13 *+,13 *+,13,AR2 Temp1,13 MSG S12 2

IQPFX MAINLOOP

ARP:=AR2 Sum IQVAL! - Sum IIVALI Prefix found in I-branch is ok The IVALs were apparantly taken near the Zero-crossings and the (rare) occassion Has occured that they form the prefix While the QVALs do not --> Resume search

MSG_S12

LAC IXORORN SACL XORORN XORORN:=IXORORN LACK 0 IORQVAL:=O for IVAL B MSG_SEnd ; --- Decide whether the Q-branch contains the proper prefix and save decision ; --- and polarity mask if so MSG_SQ ARP=AR1 LRLK AR1,AnswerStr Determine IIVALls sum LAC *+,13 ADD *+,13 ADD *+,13 ADD *+,13 ADD *+,13 ADD *+,13 ADD ARP:=AR2 *+,13,AR2 SUB Sum IIVALI - Sum IQVALI Temp2,13 BLZ MSG_S13 Prefix found in Q-branch ok The QVALs were apparantly taken near the LACK 2 SACL IQPFX Zero-crossings and the (rare) occassion Has occured that they form the prefix B MAINLOOP While the IVALs do not --> Resume search LAC QXORORN SACL XORORN XORORN:=QXORORN LACK 1 IORQVAL:=l for QVAL ; --- Prefix was found, end the search MSG_SEnd SACL IORQVAL ARP=AR2 or AR1 SetGMIF 6,RESET_TIME_FLAG LACK 1 SACL SEARCH LAC RORBER BNZ MSG_S14 *** Initialize for receiving the spread spectrum message characters in Main3b LARP ARO ARP :=ARO LAR ARO,AROVAR LAC H,AR3 ARP:=AR3 SUBK 1 Get message length in bytes, minus 1 since The prefix has already been received, and BZ MSG S13x Again minus 1 because AR5 will count from SUBK 1 SendLen-1 to 0 (if there is no character SACL SendLen After the prefix, the program will except The next prefix as a character) AR2 points to the area where the message LRLK AR2,SendData Bytes will be stored LARK AR3 counts the bits in a byte AR3,7 AR5 counts the bytes of the message LAR AR5,SendLen B MAINLOOP

159

; *** Initialize for bit error rate (BER) measurements in Main3c MSG S14 LARP ARO ARP:=ARO LAR ARO,AROVAR LAC *+,3,AR2 ARP:=AR2 SUBK 1 SACL SendLen AR5 viII count the bits dovn to 0 AR2,SendData+8 LRLK AR2 points to the expected message bits SUBK 8 Initialize AR5 and AR2 and compensate for BGZ MSG_S14x The 8 prefix bits that vere already Received this first time LRLK The message consists only of the prefix AR2,SendData ADDK 8 Equivalent to LACK 7 MSG_S14x SACL Templ AR5,Templ LAR LAC XORORN Make XOR mask for one bit ANDK 000lh SACL XORORN LARP AR2 B MAINLOOP SUBK 2 If SEARCH=2 then no measurements BZ MAINLOOP LAC Else RCV or BER measurement RORBER MSG_BER BNZ ;******************************************************************************* --------------- Main3b -------------------*** Receive the characters of the spread spectrum message Load IVAL

MSG_Rl MSG_R2

MSG_R3 MSG_R4

or QVAL_ LAC LDP BNZ LAC B LAC LDP

IORQVAL #GMEM_DP MSG_Rl IVAL MSG_R2 QVAL_ #6

BLZ LAC ADDK B LAC ANDK SACL BANZ LARP XOR SACL

MSG_R3 BYTE,1 1 MSG_R4 BYTE,l OFFh BYTE MAINLOOP,*AR2 XORORN *+,AR5

LARK BANZ B

AR3,7 MAINLOOP,*-,AR3 RDespreadEnd

ARP=AR3

Decrement bit counter AR3 ARP:=AR2 Character received, mask for correct Bit polarity save in SendData ARP:=AR5 Reset bit counter AR3 Decrement byte counter AR5, ARP:=AR3

;******************************************************************************* ; --------------- Main3c --------------------

160

Receiver software source listings

; *** Perform bit error rate BER measurements MSG_BER LAC IoRQVAL MSG_B3 BNZ ; --- Use the I-branch #GMEM_DP LDP IVAL_ LAC #6 LDP MSG_B1 BLZ LACK 1 MSG_B2 B MSG_B1 LACK 0 MSG_B2 XoR XoRoRN SUB *+,AR5

BNZ SACL B ; --- or use the Q-branch MSG_B3 LDP LAC LDP BLZ LACK B MSG_B4 LACK MSG B5 XoR SUB BNZ SACL B ; --- The bit was wrong MSG_B6 LAC ADDK SACL LAC ADDK SACL SUB BNZ B ; --- Correct bit, do nothing MSG B7 LAC LDP SUB LDP BZ BANZ LRLK LAR B

MSG_B6 BITEB MSG_B7

ARP=AR2

Correct for bit polarity Compare with expected bit value ARP:=AR5 Correct bit, reset burst count

#GMEM_DP QVAL_ #6 MSG_B4 1 MSG_B5 0

XoRoRN *+,AR5 MSG_B6 BITEB MSG_B7 BITERR 1 BITERR BITEB 1 BITEB BITEBM MSG B7 BERTooHigh ToUTBER #GMEM_DP TimeHi_ #6 BDespreadEnd MAINLooP,*-,AR2 AR2,SendData AR5,SendLen MAIN LOOP

Correct for bit polarity Compare with expected bit value ARP:=AR5 Correct bit, reset burst count

Max. successive bit errors, then stop Else wait for next correlation/bit

Test elapsed BER measurement time

Decrement bit counter AR5, ARP:=AR2 AR2 points to start of expected Message bits AR5 counts the bits of the message

;******************************************************************************* The measurements have completed, report the result(s) to the PC

161

- RDespreadEnd

- BDespreadEnd - AcqTooHigh - PfxTooHigh - BERTooHigh

Receive message measuerement went ok, report the RDespreadEndStr, TACQH, TACQL, Verifications and the received message characters. BER measurement went ok, report the BDespreadEndStr, TACQH, TACQL, Verications, TBERH, TBERL and BITERR. no code acquisition within TOUTACQ, report the AcqTooHighStr and Verifications. no prefix was found after code acquisition, report the PfxTooHighStr, TACQH, TACQL and Verifications. BER measurement stopped because two error bits occurred in a row, report BERTooHighStr, TACQH, TACQL, Verifications, TEERH, TBERL and BITERR.

;******************************************************************************* -------------------- RDespreadEnd ------------------------This routine reports message that was received during Main3b to the PC

RDespreadEnd DINT ; *** Reallocate and mask the interrupts to prepare for communication with PC GetRdyForPAR *** Put reply message for PC in AnswerStr with format as used by Transmit Copy the characters of the RDespreadEndStr into the answer string, Temp2 will contain the answer length. CopyStrToAnswer RDespreadEndStr

--- Append the measurement result variables to the answer string SAR ARO,Help1 ARP=ARO LAC TACQH Code acquistion time SACL *+ LAC TACQL SAeL *+ Number of verification mode entries LAC Verifications SACL *+ SAR ARO,Help2 LAC Help2 SUB Help1 SFL ADD Temp2 SACL Temp2 Temp2 contains string length sofar --- Put the characters of the depreaded message into the answer string LARP AR2 ARP:=AR2 LRLK AR2,SendData LAC SendLen is zero means one character, SendLen See Main3a initialization for MSG_RCV SFR SACL Two characters per word Help1 AR3,Help1 LAR LAC *+,8 ADDS *+,ARO SACL *+,AR3 BANZ RDespr_1,*-,AR2 LARP ARO Adjust in case of odd string length LAC SendLen ANDK 0001h BNZ RDespr_2

162

Receiver software source listings

MAR SBRK LAC SACL

*-.AR2 2 *,8,ARO *+

LAC ADD ADDK LRLK SACL EINT CALL LAC BNZ Wait

Temp2 SendLen

B

Fill length field

1

ARO,AnswerStr *

Go transmit to PC

Transmit PAR_Status RDespr_3

MAINLOOP

;******************************************************************************* -------------------- BDespreadEnd ------------------------This routine reports the BER measurement results, that have been obtained in Main3c, to the PC

BDespreadEnd DINT ; *** Reallocate and mask the interrupts to prepare for communication with PC GetRdyForPAR *** Save the elapsed BER measurement time LDP #GMEM_DP ZALH TimeHi ADDS TimeLo LDP #6 SACH TBERH SACL TBERL *** Put reply message for PC in AnswerStr with format as used by Transmit CopyStrToAnswer BDespreadEndStr --- Append the measurement result variables to the answer string SAR ARO,Helpl ARP=ARO Code acquistion time LAC TACQH SACL *+ LAC TACQL SACL *+ Number of verification mode entries LAC Verifications SACL *+ Elapsed BER measurement time LAC TBERH SACL *+ LAC TBERL SACL *+ LAC BITERR Number of bit errors SACL *+ SAR ARO,Help2 LAC Help2 Helpl SUB

163

SFL ADD

BDespr_1

LRLK SACL EINT CALL LAC BNZ Wait B

Temp2

String length calculated

ARO,AnswerStr

Go transmit to PC Store length field

* Transmi t PAR_Status BDespr_1

MAINLOOP

;******************************************************************************* -------------------- AcqTooHigh -------------------------

AcqTooHigh DINT ; *** Reallocate and mask the interrupts to prepare for communication with PC GetRdyForPAR *** Put reply message for PC in AnswerStr with format as used by Transmit CopyStrToAnswer AcqTooHighStr

--- Put the measurement result variables in the answer string SAR ARO,Help1 ARP=ARO Number of verification mode entries LAC Verifications SACL *+ SAR ARO,Help2 LAC Help2 SUB Help1 SFL ADD String length calculated Temp2

AcqTH_1

LRLK SACL EINT CALL LAC BNZ Wait B

ARO,AnswerStr

*

Go transmit to PC Store length field

Transmit PAR_Status AcqTH_1

MAINLOOP

;******************************************************************************* -------------------- PfxTooHigh -------------------------

PfxTooHigh DINT ; *** Reallocate and mask the interrupts to prepare for communication with PC GetRdyForPAR *** Put reply message for PC in AnswerStr with format as used by Transmit CopyStrToAnswer PfxTooHighStr

164

Receiver software source listings

--- Put the measurement result variables in the answer string SAR ARO,Helpl ARP=ARO LAC TACQH Code acquistion time SACL *+ LAC TACQL SACL *+ LAC Verifications Number of verification mode entries SACL *+ SAR ARO,Help2 LAC Help2 SUB Helpl SFL ADD Temp2 String length calculated

PhTH_l

LRLK SACL EINT CALL LAC BNZ Wait B

ARO,AnswerStr

*

Go transmit to PC Store length field

Transmit PAR_Status PfxTH_l

MAINLOOP

;******************************************************************************* -------------------- BERTooHigh -------------------------

BERTooHigh DINT ; *** Reallocate and mask the interrupts to prepare for communication with PC GetRdyForPAR

*** Save the elapsed BER measurement time LDP ZALH ADDS LDP SACH SACL

#GMEM_DP TimeHi_ TimeLo #6 TBERH TBERL

*** Put reply message for PC in AnswerStr with format as used by Transmit CopyStrToAnswer

BERTooHighStr

--- Put the measurement result variables in the answer string ARP=ARO SAR ARO,Helpl Code acquistion time LAC TACQH SACL *+ LAC TACQL SACL *+ Number of verification mode entries LAC Verifications SACL *+ Elapsed BER measurement time LAC TBERH SACL *+ LAC TBERL SACL *+ BITERR LAC Number of bit errors

165

SACL SAR LAC SUB SFL ADD

BERTH_1

*+

ARO,Help2 Help2 Help1 Temp2

String length calculated

LRLK SACL EINT CALL LAC BNZ Wait

ARO,AnsllerStr

Go transmit to PC Store length field

B

MAINLOOP

*

Transmit PAR_Status BERTH_1

abs_end

;******************************************************************************* -------------------- ADC interrupt service routine (INT1) --------------------------------------- Clear ADC D-flip-flop procedure ------------------------.sect . label

"ProgBO" PrgBgBlkO

;******************************************************************************* -------------------- ADC interrupt service routine (INT1) -------------------uses AR6

QBRAN

LARP

AR6

LDP IN

#GMEM DP QSAMPLE_,ADC_PORT

SPM LAC NEG SACL LT MPY PAC SACL

o

SPM

1

Receiver

pulseshapingfilterHR(z) (ornot)

MULTPQ_ MULTPQ_ QSAMPLE_ MULTPQ_ QSAMPLE_ Restore PM mode to have KPM1=2, see Appendix II

FILTQ

*

* *

LAC RcvFIRnr BZ CORRQ --- Perform the receiver pulse shape filtering HR(z) for the Q branch LAC QSAMPLE_ ; Put Q sample into the S_DELAY line

Receiver software source listings

166

LAR SACL LAR ZAP RPT MACD APAC SACH

AR6,S_DELbeg_ • AR6,S_DELend_ ; Make ACC and P register zero RcvFIRT RCOEFBO+OFDOOh,.-; PM=l QSAMPLE_

; Save matched filtered sample

CORRQ

• • •

remove

spreadingcode/acquisit ionandDLL

ZALH ADDS LT MPY APAC SACL SACH

QCORCH_ QCORCL_ QSAMPLE_ CHI PC_

ZALH ADDS LT MPY APAC SACL SACH

QCOREH_ QCOREL_ QSAMPLE_ CHIPE

ZALH ADDS LT MPY APAC SACL SACH

QCORLH_ QCORLL_ QSAMPLE_ CHIPL

ENDQ

RETE

PrgLenBlkO

. label .set

; Perform central correlation

Central chip; also used for scaling

QCORCL_ QCORCH_ Perform early correlation

Early chip; also used for scaling

QCOREL_ QCOREH_ Perform late correlation

Late chip;also used for scaling

QCORLL_ QCORLH_ RET with EINT and context restore PrgEndBlkO PrgEndBlkO-PrgBgBlkO-l

. .

;

; Program end ;

. end

c50_gnlelll.aSlll

.

;

SPREAD SPECTRUM IF LINK MEASUREMENTS PROGRAM

167

By Jeroen Boschma

1 december 1996

This is the assembler part for C50-1 and C50-2. It contains constants and configuration of the global memory area and a DSP initialisation-macro as well. ;******************************************************************************* TEST 64K_CHIPRATE

.set

1

o means

RAMBO RAMB1 RAMB2

.set .set .set

00100h 00300h 00060h

Begin add. of block BO data memory Begin address of block B1 Begin address of block B2

S DELAY

.set

380h

RCOEFBO

.set

iAOh

Start address of samples delay line Values in block B1 for the receiver Start addr. of FIR filter coefficients In block BO for the receiver

no testing

;******************************************************************************* ; Data pages and flag addresses in global memory ;*******************************************************************************

GMEM GMEM_DP GMEM_FDP GMEM FAD1 GMEM FAD2

.set .set .set .set .set

OFCOOh 001F8h 001FFh 0007Fh 0007Eh

Begin address of global memory First data page of global memory Data page of flag address in GMEM Write here causes INT3 at C50-2 Write here causes INT3 at C50-1

;******************************************************************************* ; Values of flags ;*******************************************************************************

INIT]REQ]LAG NEW_FREQ]LAG RESET_TIME_FLAG INIT_RCV_FIR_FLAG STARLRCV_FLAG

.set .set .set .set .set

OOh 01h 02h 03h 04h

;******************************************************************************* ; Variables in global memory ;*******************************************************************************

Help_ IniPRD dPRD_dFfs IniFreq_ FPeriod_ LError TimeLo TimeHi

.usect .usect .usect .usect .usect .usect .usect .usect

"GMEM",1 "GMEM",1 "GMEM",1 "GMEM",1 "GMEM",1 "GMEM",1 "GMEM".1 "GMEM".1

ISAMPLE QSAMPLE_ MULTPL MULTPQ_

.usect .usect .usect .usect

"GMEM".1 "GMEM".1 "GMEM".1 "GMEM".1

Temporary register to store a I-sample Idem for a Q-sample Multiply with 1 or -1 in I branch Multiply with 1 or -1 in Q branch

168

Receiver software source listings

;******************************************************************************* ; Chip variables ;*******************************************************************************

CHIPC CHIPE CHIPL

.usect .usect .usect

IGMEM",1 IGMEM",1 "GMEM",1

Current central chip value Current early chip value Current late chip value

;******************************************************************************* ; Correlation variables ;*******************************************************************************

ICORCH ICORCL ICOREH_ ICOREL ICORLH ICORLL QCORCH_ QCORCL QCOREH_ QCOREL_ QCORLH_ QCORLL_

.usect .usect .usect .usect .usect .usect .usect .usect .usect .usect .usect .usect

IGMEM",1 IGMEM",1 IGMEM".1 IGMEM",1 IGMEM",1 "GMEM",1 "GMEM".1 "GMEM",1 "GMEM",1 IGMEM",1 IGMEM",1 IGMEM".1

I-branch I-branch I-branch I-branch I-brnach I-branch Q-branch Q-branch Q-branch Q-branch Q-branch Q-branch

CORrelation CORrelation CORrelation CORrelation CORrelation CORrelation CORrelation CORrelation CORrelation CORrelation CORrelation CORrelation

IVAL IVALE IVALL QVAL_ QVALE_ QVALL_

.usect .usect .usect .usect .usect .usect

"GMEM" , 1 "GMEM",1 "GMEM",1 "GMEM".1 "GMEM",1 "GMEM",1

Value Value Value Value Value Value

the the the the the the

of of of of of of

Central High Central Low Early High Early Low Late High Late Low Central High Central Low Early High Early Low Late High Late Low

I-branch I-branch I-branch Q-branch Q-branch Q-branch

early late early late

;******************************************************************************* Variables related to the spread spectrum message to be received

Receiver FIR filter variables ;******************************************************************************* RcvFIRnr_ RcvFIRT_ FIR_Offs S_DELbeg_ S DELend_

.usect .usect .usect .usect .usect

"GMEM",1 "GMEM",1 "GMEM",1 "GMEM",1 "GMEM",1

Number of the FIR filter lookup table Length of the FIR filter (taps) Offset address FIR-coefficients Start address of samples delay line Last address of samples delay line

;******************************************************************************* FIR filter coefficent look-up tables for several transmit and receive square root raised cosine pulse shaping filters, with several possible choices for K and N. see Chapter 3. The tap coefficients are normalized Q15 numbers and yield a maximal DAC output of 5 V (= 7DOh, see PNCodeGen and Data_L1). The coefficients in the FIR filter tables for the receiver have been scaled by a factor 0.5, because in ADC_Int1 PM=1 yielding a factor 2. The receiver FIR coefficients have to be stored in reversed order, because they are used with the MACD instruction. ;*******************************************************************************

169

.sect

"LookUp"

FIRShapeXmt FIR pulse shaping filter with K=2 and N=16. (T=32 taps, and as shown in the ; the program rc_fir.m KshpT=0.72381206, sumT=0.70726629, sumTa=0.97714079) .word 2,16,35 .word -23, -71, 140, -91 71, 40, -140, 40, 390, -390, 367, 367, -3719, 3719, 23107 · word -91, .word 23107, 3719, -3719, 367, 367, 390, -91 -390, 140, 71, -23 -140, 40, 40, -71, · word -91, FIR pulse shaping filter with K=4 and N=8 (T=32 taps, KshpT=0.74341428 , sumT=0.50198009, sumTa=0.67523600) .word 4,8,35 .word -212, 383, 82, 290 .word -186, -479, -56, 795 .word 922, -591, -3021, -3770 .word -36, 8668, 19266, 26556 .word 26556, 19266, 8668, -36 .word -3770, -3021, -591, 922 .word 795, -56, -186 -479, 383, -212 82, · word 290, FIR pulse shaping filter with K=4 and N=16 (T=64 taps, KshpT=0.72559377, sumT=0.50027953, sumTa=0.68947606) .word 4,16,67 -51, -14, 87 .word 15, 73, 47, -39, -80, .word 26, -194 91, -30, -140, -95, 74, 160, 779 .word -207, 80, -55, 376, 284, -182, -469, .word 903, -579, -2959, -3692, -35, 8489, 18868, 26008 .word -579, 903 26008, 18868, 8489, -35, -3692, -2959, .word -207 779, -55, 376, -182, -469, 284, 80, .word -194, 26, 74, -140, -30, 91 160, -95, -14, -51 .word 87, -80, -39, 47, 73, 15, FIR pulse shaping filter with K=8 and sumT=0.35525471, sumTa=0.50412877) .word 8,8,67 .word -229, -155, -10, .word -54, -290, -439, .word 975, 670, -58, .word -1398, 1644, 5814, .word 25873, 23975, 20460, .word -3158, -3709, -3309, .word 899, 567, 144, .word 182, 343, 388,

N=16 (T=64 taps, KshpT=0.70469040,

166, -426, -1127, 10731, 15832, -2320, -221, 317,

317, -221, -2320, 15832, 10731, -1127, -426, 166,

388, 144, -3309, 20460, 5814, -58, -439, -10,

343, 567, -3709, 23975, 1644, 670, -290, -155,

182 899 -3158 25873 -1398 975 -54 -229

FIR RAISED cosine pulse shaping filter with K=4 and M=128 calculated with pr(t). These coefficients can be used for testpurposes, to show on the oscilloscope the zero lSI at the mid chip instants. (KshpT=0.66689587 , sumT=1.0001085, sumTa=1.4996471) .word 4,12,-204 2 . word 0, 1, 2, 1, 1, 1, 0, -2 .word 0, -2, -1, -3, -2, -1, 0, 4 . word 0, 3, 3, 2, 4, 1, 0, -8 .word 0, -5, -6, -8, -3, 0, -2, .word 0, 10, 18, 19 12, 6, 5, 0,

170

Receiver software source listings

.word .word .word .word .word .word .word .word .word .word .word

-25, 0, 0, 93, 0, -1259, 21850, 19386, 0, 497, 0, -63, 0, 19, 0, -8, 0, 4, 0, -2, 0, 2,

-31, 125, -2623, 13114, 375, -57, 18, -8, 4, -3, 2,

-13, 61, -2677 , 5736, 104, -18, 6, -3, 2, -1, 1,

0, -18, -57, -63 0, 104, 375, 497 0, 5736, 13114, 19386 0, -2677 , -2623, -1259 0, 61, 125, 93 0, -31, -13, -25 0, 5, 12, 10 -5 0, -2, -6, 0, 1, 3, 3 0, -1, -2, -2 0, 1, 1, 1

FIRShapeRcv Receiver FIR pulse shaping filter with K=4.5714286 and T=18 taps, KshpR=0.74639877, sumR=2.1085095, sumRa=2.8249102 . . word 1,18,21 .word 263, -135, -778, -1171 .word -699, 977, 3596, 6304, 8026 . word 8026, 6304, 3596, 977, -699 .word -1171, -778, -135, 263 Receiver FIR pulse shaping filter with K=4.5714286 and T=16 taps, KshpR= sumR= sumRa= .word 2,16,-21

.text

;******************************************************************************* Wait This macro is used after an answer has been transmitted to the PC to wait for the last Timer interrupt to occur. The macro takes about 0.2 msec on a 25 MIPS TMS320C50 DSP and the timer interrupt will occur within it because WAITLEN is set for 0.15 msec. Because the RPT instruction is uninterruptable 10 RPTK loops are used to establish the wait time.

;******************************************************************************* Wait

$MACRO RPT NOP NOP $ENDM

#5100

;******************************************************************************* ; Macro which converts 16 bit 2's complement in ACC to 12 bit offset binary ; format of the DAC.

;******************************************************************************* $MACRO NEG SACB AND XOR EXAR AND

#08000h #08000h #07FFFh

171

ORB RPT SFR AND $ENDM

#3

#OFFFh

;******************************************************************************* ; Macro to initialise the DSP

;******************************************************************************* InitDSP

$MACRo DINT RXF CNFD RoVM RSXM SPM

0

oPL

#02800h,PMST

LACC SAMM LACC SAMM LACC SAMM

#OOOOlh CWSR #04F4Fh PDWSR #00082h IOWSR

LACC SAMM

#OFCh GREG

LDP

#6

ZAC LARP LRLK RPT SACL LRLK RPT SACL LRLK RPT SACL LRLK RPT SACL

ISR vector-table at 02800h

Program and data wait-states I/O wait-states

Global memory OFCOOh-OFFFFh (lk)

Init blocks BO to B2 and GMEM ARl ARl,RAMBO #OlFFh

*+ ARl,RAMBl #OlFFh

*+ ARl,RAMB2 #OOlFh

*+ ARl,GMEM #OlFFh

*+

Choose copy or no-copy of program B End_Copy Copy the program from EPROM to RAM copy _start LALK SACL Helpl LALK abs_code SACL Help2 LALK abs_end-abs_code

172

KoPIE

Receiver software source listings

SAGL

Temp1

LAG TBLR ADDK SAGL

Help1 Temp2 1 Help1

LAG TBLW ADDK SAGL

Help2 Temp2 1 Help2

LAG SUBK SAGL BGZ

Temp1 1 Temp1 KoPIE

Apparantly the TBLW instruction Gan also be used for addresses Higher than Offfh (12 bits) [31] .

; Gopy program into block BO, which will be used as program memory LRLK RPTK BLKP GNfP

AR1,RAMBO PrgLenBlkO PrgBgBlkO,H

Be sure other GSO finished init-procedure RPT NoP InitDSP

#65535

$ENDM

;******************************************************************************* ; End of file ;*******************************************************************************

measure. pas program GSO_If_measurements; {This program performs a series of measurements for an If communication link } {between two GSO-transceiver prints. One board is configured as transmitter, } {the other as If receiver. The program uses the parallel port communications} {interface routines from Diederen [2], to control the GSO-transceiver prints.} {August 1996, this program has been expanded by J. Boschma with functions } {to change various parameters by means of a menu. Also the possibility to } {write results to a log file was implemented. }

uses dos,crt; {Note: interrupt procedures that handle hardware-generated interrupts } { should not use any of Turbo Pascal's input and output or dynamic memory} { allocation routines, because they are not reentrant. Likewise no DOS } } { functions can be used because DOS is not reentrant.

173

canst {--- Constants related to the parallel port communications interface: Iptnr=l ; {parallel port number timeoutlen=2; {time length = n*1/18 sec en>l) timeoutlenansw=10; {time length = n*1/18 sec en>l) timeint=$08; {the clock tick interrupt Iptlint=$OF; {the parallel port 1 interrupt Ipt2int=$OD; {the parallel port 2 interrupt aack=$OC; {attention acknowledge 1100 dack=$OA; {data acknowledge 1010 eot=$06; {end of transmission 0110 nack=$03; {not acknowledge 0011 soh=$OO; {start of header 0000 xmt=O; {address of the CSO-transmitter print rcv=l ; {address of the C50-receiver print {--- Other constants: MIPS=2S000000; {speed of the DSP PREFIX=$7F; {prefix of the transmitted IF message

} } } }

} } } } } } } } } } } } }

type bytearray=array[0 .. 25SJ of byte; wordarray=array[0 .. 25SJ of word; commdata=record status: integer; {O=inactive, l=transmit, 2=receive, {3=answer, 4=error retry: integer; {number of retries made transmlen:integer; {length of transmit message transmcount:integer; {counter for characters to xmt transmdata:bytearray; {characters to transmit receivlen:integer; {length of received message receivcount:integer; {counter for characters received receivdata:bytearray; {characters received end; {record commdata}

var {--- Variables related to the parallel port communications interface: nr:integer; {exitcode packet:commdata; data: byte; {databyte read from parallel port lpt: integer; {address of parallel port tocount: integer; {t imeout counter transmitarray:bytearray; {array to be transmitted messagearray: bytearray; {array to be printed to screen oldtimerint,oldlptint:pointer; {pointers to standard interrupts commnr:integer; {device number, as set by dip-sws outdataO,outdatal:byte; {bytes for device selection and {interrupt generation writevalue:byte; {byte to be send to parallel port q: integer: {position on screen len:byte; {length of character string to send str,rcvstr:string; {string to send, or received c:integer; {--- Baseband transmitter and IF receiver parameters SRLen:byte; {shift register length

} } } } } } } } }

} } } } } } } } } } } } } } }

} }

174

Receiver software source listings

Nc:integer; Phase:word; SampPerChip:byte; ChipRate:integer; ChipPerPulse:byte; fc:longint; PCHIPV,MCHIPV:integer; RcvFIRnr,RcvFIRT:byte; CSRatio:double; TIMES,INIPRD:word; TSHIFT:integer; A:double; fIF:longint; m: integer; Ini_PRD:word; Ini_Freq:double; dPRD_dFfs:word; THfactor:double; THRESH:longint; VerifyNr:integer; DLLKp,DLLKi,Kp,Ki:double; DLLXi,Xi.DLLBL,BL:double; KBo:double; Rangefc,RangefIF:integer; KM,KS1,KS2:integer;

{code length in chips } {random init. code phase transmitter,} {must be in range of 0 .. Nc-1 } {number of samples/chip (power of 2) } {chip rate in kHz (power of 2) } {number of chips/pulse shape } {chip rate in chip/s } {DAC chip amplitude factors } {Select receiver pulse shaping filter} {code phase step as fraction of Tc } {NCO periods } {NCO resolution enhancement term } {amplitude of the IF carrier in V } {IF frequency in Hz } {undersampling factor }

{amount of maximum acq. THRESHold, is} {also called Rthr in this report } {code acquisition THRESHold } {number of times code acq. > THRESH, } {after the first time } {DLL and Costas loop loop-filter } {loop damping and Noise band width } {full scale back off factor } {tracking range for fc and fIF in Hz } {scaling constants }

} {--- Variables related to the C50-tranceiver measurements: } ToUTACQ,ToUTPFX,ToUTBER:word; {measurement time-out times SEARCH,RoRBER:integer; {do Receive-, BER-measurements or not} } BITEBM:integer; {max. bit error burst length message:string; {user message, transmitted on IF link} } Perror:double; {Bit error probability {---

Variables that contain measurement Verifications:word; TACQ:longint; TBER:longint; BITERR: word; rcvmes:string; Seconds1,Seconds2:real;

results } {number of verifcation mode entries } {code acquisition time in 0.1 msec } {BER measurement duration in 0.1 msec} } {Number of BIT ERRors {received IF user message } } {measurement timing

{--- Measurements title and variables for the logfile and editor Title:string; LogFileName:string; WriteLog:string; Y_Editor:integer; procedure restorelptint; { This procedure restores the standard begin if (lpt=$3BC) or (lpt=$378) then begin port[$21]:=port[$21] or $80; setintvec(lpt1int,oldlptint);

}

hardware printer interrupt vector.

}

{printer port is LPT1

}

{disable interrupt via interrupt mask} {reset the interrupt vector }

175

end else begin if lpt=$278 then begin port[$21] :=port[$21] or $20; setintvec(lpt2int,oldlptint); end; end; port[lpt+2]:=4; end; {restorelptint}

{printer port is LPT2

}

{disable interrupt via interrupt mask} {reset the interrupt vector }

{reset port

procedure restoretimerint; { This procedure restores the standard clock-tick interrupt vector. begin setintvec(timeint,oldtimerint); end; {restoretimerint}

}

}

procedure quit(nr:integer); { Exits the program with exit code: 0 if communication ended, 1 if lpt? was} } { not found. begin restorelptint; restoretimerint; halt (nr) ; end; {quit}

procedure lptwrite(writevalue:byte); { This procedure writes a value (writevalue) to the printer port and } } { generates an interrupt on the device by making a high pulse via resp. { outdatal ,0, 1. } begin {--- First write the value that is sent to screen, this is mainly done for} {--- debugging purposes. The first three lines on the screen display the } {--- transmited bytes (q=3* 80 characters/line *2 =480). } if writevalue480 then q:=O; {maximum of 3 lines of values sent, are } {written to screen } {--- Now put data byte and interrupt pulse to the communications port port [lpt] :=writevalue; {write data to printer port } port[lpt+2]:=outdatal; {select device and make IRQ on device low}

}

Receiver software source listings

176

tocount:=timeoutlen; port[lpt+2J:=outdataO; port[lpt+2J:=outdatal; end; {lptwrite}

{make IRQ on device high {make IRQ on device low

procedure incretry_t; { Another attempt to transmit is made. begin packet.retry:=packet.retry+l; if packet.retry=3 then packet.status:=4

else begin packet.transmcount:=l; packet.transmdata[OJ:=$Ol; lptwrite(soh) ;

} }

}

{count the number of retries {if number of retries equals 3 {then fatal error, communication {aborted

} } } }

{reset to O. because it is used as} {a counter in lptint } {send start of header (SOH) } {again and initialise parameters }

end; end; {incretry_t}

procedure incretry_r; { Another attempt to receive is made. begin packet.retry:=packet.retry+l; if packet.retry=3 then packet.status:=4

else begin lptwrite(nack) ; packet.receivcount:=O; end; end; {incretry_r}

}

{count the number of retries } {if number of retries equals 3 } {then fatal error, communication } {aborted }

{else send not acknowledge (NACK) } {and initialise parameters }

procedure maketextarray(charstring:string; var text:bytearray); { This procedure makes a textarray of a string to be send. The textarray { contains the ordinal numbers of the string characters var counter: integer; ch:byte; letter:char; longintvar:longint; str:string; code: integer; begin len:=length(charstring); for counter:=l to len do begin letter:=charstring[counterJ;

} }

177

ch:=ord(letter); text[counter-1]:=ch; end; text[len]:=13; end; {maketextarray}

{terminate textarray with value 13

procedure lptmsg(var message:bytearray); { This procedure sends a message to the bottom of the screen and scrolls the} { old messages upwards. The message is not written by means of the 'write' } { command, because within a hardware-interrupt routine it is not allowed to } } { use DOS commands. The message is directly written to the video memory. { $BOOO is the base address of the Hercules video memory, $BOOO of the VGA } { video memory. } var a: integer; teller: integer; begin for a:=1840 to 1919 do begin memw[$BOOO:a shl 1]:=memw[$BOOO:(a shl 1)+160]; {scroll old message up } memw[$BOOO: (a shl 1)+1] :=$02; end; a:=1920; teller:=O; while message[teller]13 do {message is terminated with value 13 } begin memw[$BOOO:a shl 1] :=message[teller]+$OEOO; {write char. to video memory} {determine the char. color } memw[$BOOO:(a shl 1)+1]:=$02; a:=a+1; teller:=teller+1; end; while a$09 then begin maketextarrayC'Error: AACK not received on ATTENTION',messagearray); lptmsg(messagearray); incretry_t; end else lptwrite(soh); end else {--- AACK received, send LEN byte } begin lptwriteCpacket.transmdata[packet.transmcount]); packet.transmcount:=packet.transmcount+l; end; end else begin if packet.transmcount= 1 because LACT is used in TMS320C50) } { (idem ) KS2 } { DLLKp } { DLLKi } { Kp } { Ki } { Remarks: } { 1) The influence of Dfmin on Kp and Ki of the Costas loop is cancelled { through the scaling, this is caused by the fact that LERROR has to be } { calculated in 1 [Hz], independent of the actual resolution that ffs } { will have. The reason for this is that LERROR has to be calculated with}

}

188

{ { { { { { { { { { { { { { { { { { { { {

Receiver software source listings

1 [Hz] resolution is that INIFREQ (=fn) is also given in [Hz]. } 2) Kp and Ki for the DLL and the Costas loop are calculated for a signal } vi with amplitude A in [V]. However, the scaling by the factor scale } (which is also given in Table Al) cancels the influence of A, so in } Kp and Ki are provided to the IF receiver board with A=5 [V]. This is } possible, because by means of KM the IF receiver scales the samples } such that to the rest of the receiver functions it is as if the signal} amplitude of vi is indeed 5 [V]. } 3) The KBD (back off) scaling factor can be used in situations of high } noise levels and low signal amplitudes to prevent potential overflow } caused by the large KM factor. Furthermore, KBD can be used to make } representation of the DSP value for Ki, Kp, DLLKp and DLLKi a bit } larger in case one of them is small « 10). } 4) Take also care that the Kp and Ki values of the loops do not become } larger than 32768, if so then adjust the values of Rangefc, RangefIF } and or KBD. } 5) Besides the scaling of Kp and Ki of the loops to A=5 [V] the factor } helpKM also accomplishes that the code acquistion THRESHold in the IF } rerceiver can be represented as a part of the 32678. } 6) The minimum signal amplitude that can be handled is determined by the } maximum value of KM which is 32768, so A > 5 / (N KBD). }

var { General Nd:integer; N,Ts,fn:double; DTmin:double; { DLL DLLWn:double; DLLKd,DLLKo:double; DLLdemandl,DLLdemand2,DLLdemand3:double; Dfmin:double; { Costas loop Wn:double; Kd,Ko:double; Demandl,Demand2,Demand3:double; { Scaling KPM1,KPM,KH1,KH2,KH3,KH4,KH5,KH6:longint; Ka,helpKM,helpKS1,helpKS2,help,scale:double; begin { General parameters Nd:=Nc; Ts:=Nd/fc; fn:=4*fIF/(2*m+l); N: =Ts*fn/2; { Parameters for the DLL code tracking loop DTmin:=l/MIPS; DLLWn:=2*DLLBL/(DLLXi+l/(4*DLLXi»; DLLKd:=sqr(A*N)*2*(1-1/sqr(Nc»; DLLKo:=Nd*DTmin*fc; DLLdemandl:=1/(50*Nd*fc); DLLKp:=2*DLLXi*DLLWn*Ts/(DLLKo*DLLKd); DLLdemand2:=0.1/Ts; DLLdemand3:=0.5*DLLBL/sqr(fc); DLLKi:=sqr(DLLWn*Ts)/(DLLKo*DLLKd); { Parameters for the Costas carrier tracking loop Dfmin:=Ini_Freq*fc/(MIPS*Nc); Wn:=2*BL/(Xi+l/(4*Xi»;

}

}

}

}

}

}

}

189

Kd:=sqr(A*N); Ko:=2*Pi*fIF*2*N*Dfmin/sqr(fn); Demandl:=0.02/Ts; Kp:=2*Xi*Wn*Ts/(Ko*Kd); Demand2:=0.1/Ts; Demand3:=0.5*BL; Ki:=sqr(Wn*Ts)/(Ko*Kd); { Scaling the parameters } Ka:=32768/5; KPM1:=2; KPM:=2; KH1:=65536; KH2:=65536; KH3:=65536; KH4:=65536; KH6:=65536; KH5:=32768; KS1:=round(ln(32767/(1 shl TSHIFT)/ (int(0.5*MIPS/(fc-Rangefc)+1.0)-int(0.5*MIPS/fc»)/ln(2.0)-0.5); KS2:=round(ln(32767*(2.0*m+l.0)/(4.0*RangefIF»/ln(2.0)-0.5); if KS1