23
Implementation of a Digital Lock-in Amplifier on a Field Programmable Gate Array and its Remote Control in a Local Area Network Christoph Fischer Supervisor: Vlad Negnevitsky Department of Physics, ETH Zurich Zurich, February 9, 2015 Abstract Lock-in amplifiers provide an excellent technique for measuring weak signals not resolvable by conventional amplifiers. Commercial solutions, however, are often costly and inflexible. In this thesis, a low-cost and easy-to-use digital lock-in amplifier with integrated proportional-integral (PI) controller is presented, implemented on a field programmable gate array (FPGA). Furthermore, a solution for controlling multiple such FPGAs remotely in a local area network (LAN) was developed. Contents 1 Introduction 2 2 Theory 2 2.1 Lock-in Amplifier ....................................... 2 2.2 Saturated Absorption Spectroscopy ............................. 3 2.3 Z-Transform .......................................... 5 2.4 Low-Pass Filter ........................................ 5 3 Implementation 7 3.1 Low-Pass Filter ........................................ 7 3.2 Lock-in Amplifier ....................................... 8 3.3 Laser System ......................................... 9 3.4 Pre-amplifier ......................................... 10 3.5 Network Communication ................................... 13 3.5.1 Client ......................................... 13 3.5.2 Server ......................................... 14 4 Results 15 4.1 Lock-in Amplifier ....................................... 15 4.1.1 Loop-back Test .................................... 16 4.1.2 Lab Test ........................................ 17 4.2 Network Communication ................................... 18 5 Conclusions 19 A Flowcharts 20 B Installation Guide 22 1

Implementation of a Digital Lock-in Ampli er on a Field ......This combination of lock-in detection and PI controller is used in various laser-locking schemes as shown below in the

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

  • Implementation of a Digital Lock-in Amplifier on a Field

    Programmable Gate Array and its Remote Control in a Local Area

    Network

    Christoph FischerSupervisor: Vlad Negnevitsky

    Department of Physics, ETH Zurich

    Zurich, February 9, 2015

    Abstract

    Lock-in amplifiers provide an excellent technique for measuring weak signals not resolvableby conventional amplifiers. Commercial solutions, however, are often costly and inflexible. In thisthesis, a low-cost and easy-to-use digital lock-in amplifier with integrated proportional-integral (PI)controller is presented, implemented on a field programmable gate array (FPGA). Furthermore, asolution for controlling multiple such FPGAs remotely in a local area network (LAN) was developed.

    Contents

    1 Introduction 2

    2 Theory 22.1 Lock-in Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22.2 Saturated Absorption Spectroscopy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32.3 Z-Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.4 Low-Pass Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    3 Implementation 73.1 Low-Pass Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73.2 Lock-in Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83.3 Laser System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.4 Pre-amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.5 Network Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    3.5.1 Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.5.2 Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

    4 Results 154.1 Lock-in Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    4.1.1 Loop-back Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.1.2 Lab Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

    4.2 Network Communication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

    5 Conclusions 19

    A Flowcharts 20

    B Installation Guide 22

    1

  • 1 Introduction

    In this semester project, a digital lock-in amplifier was realized on an FPGA (field programmable gatearray) as a replacement of an analogue lock-in for frequency stabilization of a laser. In a second step,a server-client type architecture was developed for remote control using a Raspberry Pi as a gatewaybetween a client on a remote computer and an FPGA.

    The project is based on the implementation of a PID lock-box on the same FPGA called EVIL(electronically variable interactive lock-box) and uses some of the existing Python code for the graph-ical interface (GUI) and the communication with the FPGA [1],[2].

    Implementing the lock-in required reprogramming of the firmware on the FPGA as well as addingnew features in the controlling program. Additionally, an improved firmware detection was addedsuch that a different interface, depending on the actual firmware on the EVIL, is loaded.

    For testing the lock-in amplifier, an existing set-up for frequency-stabilization of a laser was chosen,in which the analogue amplifier was replaced by the digital.

    Since the original GUI required an USB connection to the EVIL, the control computer must belocated nearby which, in that case, means near the experimental set-ups. Hence, a server, that isconnected to multiple EVILs and that can be controlled remotely from the already existing controlcomputers is useful. This server must be able to provide information about the connected devices andallow a client to select one for establishing a connection. When multiple users are connected at thesame time, the server must also be able to stream the data between each client and its selected FPGA.

    In the following, a short introduction into the theory behind lock-in amplifiers and their usageis given. Then the implementation of the lock-in as well as the server are investigated. Finally, theresults as well as possible improvements are being discussed.

    2 Theory

    The following section gives an explanation of the idea behind a lock-in amplifier as well as an exampleof its application in a frequency stabilization scheme for a laser. Then, a brief theoretical introductioninto the analysis of systems which are discrete in time is given. These concepts are then applied to adigital low-pass filter.

    2.1 Lock-in Amplifier

    A lock-in amplifier provides an extremely narrow band-pass filter which, at the same time does notsuffer from 1/f noise when amplifying.

    The heart of the lock-in amplifier is the phase-sensitive detector, also known as the demodulatoror mixer [3]. The detector operates by multiplying two signals together, one is a reference signal andthe other is modulated by this reference. Consider a sinusoidal modulation xr(t) = sin(ωmt) and DCsignal xs(t) = A e.g. from a photodiode we want to measure. If the DC signal is modulated by thereference modulation, i.e. xm(t) = A sin(ωmt), the multiplication (mixing) of modulated signal andreference becomes

    ymix(t) = A sin(ωmt) · sin(ωmt) =A

    2(1 + cos(2ωmt)) (2.1)

    by using the trigonometric identity

    sin2 θ =1− cos 2θ

    2. (2.2)

    Applying a low-pass filter on the mixed signal (or averaging the signal over a long period), thefrequency doubled component proportional to cos(2ωmt) can be removed and only the DC signal weare interested in remains.

    Noise components that have a different frequency ω′ from the reference will produce a signalproportional to

    sin(ω′t) · sin(ωmt) (2.3)which, in Fourier space, becomes

    F[sin(ω′t) · sin(ωmt)

    ]∝ δ(2ωm + ∆ω − ω) + δ(2ωm + ∆ω + ω)− δ(∆ω − ω)− δ(∆ω + ω) (2.4)

    2

  • where ∆ω = ω′ − ωm. Hence, only signals with a very small and fixed frequency difference ∆ω willadd to the DC signal, while all other components are blocked by the low-pass filter. This results in avery narrow filter bandwidth around the modulation frequency, much smaller than is achievable witha conventional bandpass filter [3].

    The second advantage of a lock-in is, as its name suggests, that it can be used as an amplifier.A typical noise characteristic is shown in Figure 2.1. At low frequencies, the noise of an amplifier isvery large (the so-called 1/f or flicker noise) but since the lock-in modulates the DC signal at a muchhigher frequency, it can be safely used for amplification, adding primarily white noise.

    Figure 2.1: Typical noise characteristics. At low frequencies the so-called 1/f or flicker noise dominateswhile at higher frequencies the white noise level is much smaller. The figure is from [3].

    In this semester project, the lock-in amplifier was realized on a FPGA. Additionally, it was directlycombined with a proportional-integral (PI) control. This combination of lock-in detection and PIcontroller is used in various laser-locking schemes as shown below in the example of modulationtransfer spectroscopy or also in the more commonly used Pound-Drever-Hall scheme [7].

    Combining the lock-in amplifier and the PI controller on a single, digital device has the mainadvantage that the lock-in as well as the PI-controller settings can be changed from a single computerand, as shown later in this report, it is even possible to control several EVILs via a local area network.

    Additionally, transmission of the signal from the lock-in to the PI-controller adds no noise and isinstantaneous (within one clock cycle).

    2.2 Saturated Absorption Spectroscopy

    The spectral lines of gaseous molecules or atoms are broadened due to their thermal motion (Dopplerbroadening) [4]. Laser-saturated absorption spectroscopy can overcome this limitation and is able toresolve the hyperfine spectral features [5].

    Three laser beams, called the pump, probe and reference beam, are aligned such that probe andreference beam pass the vapour cell from the opposite direction than the pump beam. Additionally,the pump beam must be much stronger that the probe beam and both must overlap at least at onepoint inside the cell. Reference and probe beam are then detected using two photodiodes. This set-upis shown in Figure 2.2a.

    If we consider molecules inside the vapour cell which have a velocity component vz > 0 in thedirection of the probe beam, the frequency of the probe is red-shifted while the pump beam is blue-shifted in the reference frame of the molecule.

    When both beams are tuned to the same frequency in the laboratory frame, only one can beresonant with an atomic transition in the group of molecules with a common velocity vz. However,if the pump beam is detuned such that is resonant with a atomic transition at the same time as theprobe beam, the transition is saturated by the strong pump and the probe beam will pass with less

    3

  • absorption [5]. This effect can be seen as a peak in the absorption spectrum and by subtracting theDoppler-broadened background, measured by the reference beam, a Doppler-free absorption spectrumcan be obtained as shown in Figure 2.2b.

    (a) Set-up for saturated absorption spectroscopy. The referenceand probe beam pass the vapour cell parallel and the pump beammust overlap with the probe.

    (b) Doppler-free transmission spectrumof Rubidium.

    Figure 2.2: Doppler-free absorption spectroscopy. Both Figures are from [5].

    Modulation Transfer Spectroscopy in Iodine Since the hyperfine transition frequencies foriodine are known with a very high precision [6], they can be used as reference for frequency stabilizationof a laser. Such a set-up is shown in Figure 2.3. Similar to the method described above, two beams,a pump and a probe beam pass a vapour cell in opposite direction. Though, as each peak in thetransmission spectrum is symmetric, they cannot be used as an error signal for locking1.

    When the pump beam is frequency- or phase modulated, the derivative of the transmitted signalcan be measured, identical to the Pound-Drever-Hall locking scheme [7]. In order to obtain an errorsignal which can be used in a control loop for stabilization of the laser, a lock-in amplifier locked tothe modulation frequency must be used.

    Figure 2.3: Locking scheme using modulation transfer spectroscopy of rubidium. Frequency modula-tion is achieved by using an acousto-optic modulator (AOM) in a double-pass configuration. Imagefrom [8]

    1A frequency drift to higher frequencies would result in an identical signal as a drift to lower frequencies

    4

  • 2.3 Z-Transform

    In the analysis of systems that are discrete in time (e.g. digitized signals), the Z-transform is a powerfultool, very similar to the Laplace transform for continuous-time systems. Instead of having differentialequations which describe the evolution in time, a discrete system can be fully characterized by an N th

    order linear difference equation [9]

    y(n) =N∑k=1

    aky(n− k) +M∑k=0

    bkx(n− k) (2.5)

    where the argument of the input and output x(n) and y(n), respectively is the number of discretizedtime steps tn since the starting time.

    The one-sided Z-transform is defined as

    Y (z) =∞∑n=0

    y(n)z−n. (2.6)

    Hence, the Z-transform of y(n− k) is

    ∞∑n=0

    y(n− k)z−n =∞∑

    n=−ky(n)z−(n+k) =

    ∞∑n=0

    y(n)z−(n+k) +

    −1∑n=−k

    y(n)z−(n+k) = z−kY (z) (2.7)

    since we can assume that y(n) vanishes for negative time steps.We can plug this result into equation (2.5) and find the transfer function in Z-space

    T (z) =Y (z)

    X(z)=

    M∑k=0

    bkz−k

    1−N∑k=1

    akz−k

    . (2.8)

    When the system has a finite impulse response (FIR), the transfer function has no poles, i.e.

    N∑k=1

    akz−k = 0 ∀z ∈ C.

    Typically however, a digital system has a feedback path, hence there are poles in the transfer functionwhich lead to an infinite impulse response (IIR).

    By using the bilinear transform [9]

    z =2 + sT

    2− sT(2.9)

    where T is the sampling time of the discrete system, one can transform between Laplace- and Z-space.This is particularly useful when analysing discrete systems which have a continuous equivalent (seeSection 2.4).

    2.4 Low-Pass Filter

    The transfer function of a first order low-pass filter is shown in Figure 2.4. Its characteristic time scale(also called cut-off frequency) is defined as the point at which the gain has decreased by 3 dB. For afirst order filter, the cut-off frequency is [10]

    f3dB =|ω0|2π

    (2.10)

    where ω0 is the pole of the transfer function.

    5

  • 100 Hz 1 kHz 10 kHz 100 kHz

    −16 dB

    −14 dB

    −12 dB

    −10 dB

    −8 dB

    −6 dB

    −4 dB

    −2 dB

    0 dB

    Frequency ν

    20 lo

    g 10

    |T(2

    π ν)

    |2

    Figure 2.4: Low-pass filter transfer function with a cut-off frequency of fc ∼ 15.9 kHz.

    The simplest implementation of an analogue low-pass filter is an RC circuit. However, since thefiltering must take place on the FPGA, a digital filter is required. A possible implementation is shownin Figure 2.5 which was already realized on the EVIL [1].

    The difference equation of this filter can be derived from

    OUT(n) = DATA(n− 1) + MULT(n− 1)MULT(n) = S · TEMP(n− 1)TEMP(n) = last IN(n− 1)−OUT(n− 1)last IN(n) = IN(n− 1)

    Note that the variable DATA has a length of 32 bit since it is the result of the multiplication of two 16bit values. In order to get the value of OUT which is again a 16 bit value, DATA must be truncated,i.e. only the 16 most significant bits (MSB) are used. This corresponds to a division of the value ofDATA by 216 and hence, the difference equation of this filter is

    OUT(n) = OUT(n− 1) + S216

    (IN(n− 4)−OUT(n− 3)

    )(2.11)

    Since the smoothing parameter S is also a 16 bit integer value that is divided by 216, the effectivesmoothing S

    216≡ α ∈ (0, 1]. After replacing IN and OUT by x and y, respectively and using (2.7), the

    Z-transform of the filter can be calculated

    Y (z) = z−1Y (z) + α(z−4X(z)− z−3Y (z)

    )(2.12)

    This yields immediately the transfer function

    T (z) =Y (z)

    X(z)=

    αz−4

    1− z−1 + αz−3(2.13)

    6

  • IN last IN TEMP MULT DATA OUTT

    S

    -

    nn - 1n - 2n - 3n - 4

    Figure 2.5: Schematics of the low-pass filter. The smoothing parameter S is a 16 bit value and in Tthe 32 bit value of DATA is truncated to 16 bits. Steps marked with the same colour are executed inthe same clock cycle.

    For small values of α, this transfer can be roughly approximated by the transfer function of a fistorder filter, i.e.

    T (z) =α

    1− (1− α)z−1(2.14)

    which has its pole at z = 1 − α. Using the bilinear transformation (2.9) as well as (2.10) yields thecut-off frequency

    fc =α

    (2− α)πT(2.15)

    As shown in Figure 2.6, the real cut-off frequency corresponds very well to the ideal below 20 kHz.However, the factor z−4 in the numerator of (2.13) indicates that the real system is lagging behindthe ideal (2.14), since each factor of z−1 delays the operation by one clock cycle.

    0 500 1000 1500 2000 2500 3000

    smoothing integer

    0

    10

    20

    30

    40

    50

    60

    70

    80

    Filt

    er

    cut-

    off

    [kH

    z]

    real filterideal first order filter

    Figure 2.6: Cut-off frequency of the real low-pass and a first order filter. The smoothing integerS ∈ (0, 65536] and corresponds to a smoothing parameter α = S · 2−16.

    3 Implementation

    In this chapter the physical implementation of the lock-in as well as the network protocol are explainedin detail.

    3.1 Low-Pass Filter

    For the calculation of the cut-off frequency of the low-pass filter, the simplified formula

    fc =α

    (2− α)πT(3.1)

    7

  • can be safely used because the cut-off frequency must be set well below 10 kHz. The sampling timeT = 1/(96 MHz) corresponds to the clock frequency of the EVIL.

    Due to an unknown bug, the actual time constant was measured to be only fc/2. The reason mightbe even on hardware level, since simulations of the low-pass confirm the calculations (i.e. finding the3 dB point in data generated by simulations of the firmware). However, the factor is constant at leastover the used frequency range and hence a correction factor is introduced such that the GUI displaysthe correct value.

    3.2 Lock-in Amplifier

    The schematics of the lock-in amplifier are shown in Figure 3.1. The analogue signal is digitized by a96 MHz, 10 bit analogue-to-digital converter (ADC). If the signal has a DC offset, it must be removed,because otherwise the signal would be proportional to

    (DC +A sin(ωt)) sin(ωt) = DC sin(ωt) +A

    2(1− cos(2ωt)) (3.2)

    which requires that the low-pass filter must also remove the component at ω. Removing the offsetbefore demodulation therefore simplifies the low-pass design.

    After the multiplication, the signal is truncated back to 16 bits, filtered by the low-pass to removethe 2ω component and finally fed into a PI controller also implemented on the EVIL as the errorsignal. The response of this controller is converted back to an analogue signal by the fast (i.e. 96MHz, 14 bit) digital-to-analogue converter (DAC).

    For modulation with the AOM, the EVIL must also output the modulation signal. This is doneusing the slower (5 MHz, 12 bit) DAC. Note that the sinusoids for modulation and demodulation musthave different phases. Otherwise the phase retardation of the modulated signal with respect to thedemodulation could not be corrected for, which might lead to an attenuation of the DC signal, i.e.

    A sin(ωt+ φ) sin(ωt) =A

    2

    (cos(φ)︸ ︷︷ ︸

    maximum for φ=kπ, k∈Z

    − cos(2ωt+ φ))

    (3.3)

    T

    ADC A

    DC Offset

    Phase Frequency

    Fast DAC

    Slow DAC

    Low pass PID Controller

    Filter Cutoff P,I,D

    Figure 3.1: Sketch of the lock-in amplifier. In and output of the EVIL are marked green and settingsset by the GUI are in red. In T, the signal is truncated from 32 to 16 bits.

    8

  • Frequency generation For generation of the reference signal, a direct digital synthesizer (DDS) isused which is shown in Figure 3.2. It consists of two parts: The lookup table (LUT) and the phaseaccumulator.

    In the LUT, all values of one period of a sine (or cosine) are stored. The accumulator thenperiodically increments the index in the LUT and the value at the index location is output. A phaseshift can be easily implemented by adding a constant offset index.

    Depending on how fast the accumulator cycles through the LUT, the frequency of the sine can bedetermined. However, if the phase accumulator would have the same bit length as the values in theLUT, the minimum frequency of the signal would be equal to the clock frequency of the processor.The easiest way to get around this problem is to use an index with a higher resolution than theLUT. Depending on the position at which the index is truncated, the minimum (and also maximum)frequency can be set.

    On the EVIL, the phase accumulator has a resolution of 22 bits and the LUT, which was generatedby the Xilinx ISE R© Design Suite, 16 bits. Together with the clock frequency of 96 MHz of the EVIL,this results in a frequency range of the DDS between 23 Hz and 1.5 MHz.

    Figure 3.2: Schematics of a DDS. The LUT consists of an array storing the amplitude of one periodof the sinusoid (right column) and the corresponding index (left column).

    3.3 Laser System

    The system that was used for testing the lock-in amplifier is a laser at 626 nm which is frequency-stabilized by modulation transfer spectroscopy similar to the set-up shown in Figure 2.3. The existingEG&G 5209 single phase analogue lock-in amplifier which was already connected to an EVIL (for PIcontrol) was completely replaced by the same EVIL to handle both demodulation and control in onedevice. Figure 3.3 shows the signal obtained by the EG&G lock-in when the laser frequency is sweptover the resonance.

    9

  • Figure 3.3: Response of the iodine set-up when ramping the laser frequency across the resonance. Thesignal is demodulated by an EG&G 5209 single phase analogue lock-in amplifier.

    The laser actually consists of two fiber lasers at 1051 nm and 1551 nm, respectively, which thencreate a beam at 626 nm by sum-frequency generation. This wavelength can be locked to a hyperfineresonance of molecular iodine. In a final step, the light is brought to 313 nm by second-harmonicgeneration for Doppler-cooling and manipulation of beryllium ions inside an ion trap [11].

    3.4 Pre-amplifier

    The resolution of the ADC determines the minimum strength of a signal that can be resolved comparedto for example noise. The EVIL has an ADC with a 10 bit resolution which implies that a signal canonly be resolved if it is at most 1024 times (60 dB) smaller than the largest accepted input. In thespecific EVIL, this is set to ∼ 190 mV which implies that the signal must have at least an amplitudeof ∼ 0.2 mV to be resolved.

    The second problem with having a weak signal is that the lock-in amplifier mixes it with thereference in a multiplication. Both input and reference are 16 bit integers which results in a mixedsignal of 32 bit length. The result is then truncated back to 16 bit by only selecting the 16 MSB whichresults in a decrease of amplitude if the input does not use the whole 16 bit range.

    Hence, two amplifiers which have their highest gain near the modulation frequency were designed:A passive LC-circuit in series with a low-pass filter and an active circuit using an operational amplifier.Since the signal that has to be amplified is modulated by the DDS, 1/f noise added by the amplifiershould not be a problem as long as the modulation frequency is high enough.

    Passive Circuit The circuit is shown in Figure 3.4a and consists of a resonant LC-circuit and asubsequent low-pass filter. As it can be seen in Figure 3.4b, the resonant circuit provides a high-passwhich, combined with the low-pass, result in a band-pass filter that also amplifies at the resonancefrequency.

    10

  • 1µF

    17 Ω

    1000µH

    100 nF

    220 nF

    vi vo

    (a) Passive circuit design consisting of a resonant LC-circuit and a low-pass filter in series. The series resis-tance of the inductor was measured to be R = 17 Ωand the calculated resonance frequency is ∼ 4.7 kHz.

    (b) Transferfunction of the passive circuit. Due tothe subsequent low-pass high-frequency componentsare damped.

    Figure 3.4: Passive amplifier circuit.

    Active Circuit The spectrum of the photodiode showed a noise component around 24 kHz, hencethe cut-off of the amplifier was set to 10 kHz in the beginning. This also means that frequency of thelock-in must be below this pick-up signal.

    A second constraint was given by the available power supply. Since there is a single channel powersupply set to 24 V near the EVIL used for the lock-in, the op amp is used in single-supply operationwhich requires that a floating ground is provided. This means that both inputs of the op amp are setto 12 V with respect to the common ground. Then a voltage of 24 V between Vcc and Vee seems like±12 V to the op amp.

    A floating ground can easily be generated by using a voltage divider with two equal resistors asshown in Figure 3.5(a). By summing up the current at the node, we find

    Vf − VR

    =Vf − 0R

    ⇒ Vf =V

    2(3.4)

    Now, we can set Vee = 0, Vcc = V and connect the floating ground to the inverting and non-invertingterminal of the op amp as shown in Figure 3.5(b).

    11

  • 100 kΩ

    100 kΩ

    + −

    24 V

    47 pF

    0 V

    Vf = 12 V

    (a) Voltage divider for creation of a floatingground. The additional capacitor is used forfiltering high-frequency noise from the powersupply.

    +

    24 V

    vo(t) + Vf

    vi(t) + Vf

    Ri

    Vf

    (b) Single-supply operation of an op amp. Both inputterminals are set to the floating ground potential.

    Figure 3.5: Elements used in the active amplifier circuit.

    Due to its low noise performance as well as highest gain-bandwidth product of the available opamps, the LF356 was chosen. The full amplifier circuit is shown in Figure 3.6. It consists of asimple inverting amplifier with a gain G = −RfRi . There is an additional low-pass filter with a cut-offfrequency of fc = 1/(2πRfCf ) and two coupling capacitors Ci and Co for changing the offset of thefloating ground on the signal. Since Ci forms a capacitive ground loop with the floating ground, itrequires a large capacitance. Otherwise the loop would act as a high pass filter with a very smallcut-off frequency damping the modulated signal vi(t) coming from the photodiode.

    +

    Vcc

    vi(t)

    Ci Ri

    +−Vf

    Rf

    Cf

    Co

    vo(t)

    Ro+−Vf

    Figure 3.6: Full active amplifier circuit. The following values were chosen: Ci = 1µF, Cf = 47 pF,Co = 220 nF, Ri = 1 kΩ, Rf ∼ 2.7 kΩ, Ro = 100 kΩ, Vf = 12 V and Vcc = 24 V.

    12

  • Figure 3.7: Bode plot of the active amplifier. The gain is set to ∼ 12 dB to match the input voltagespan of the ADC by changing the potentiometer Rf . This also changed the cut-off frequency from10 kHz to ∼ 1 Mhz.

    3.5 Network Communication

    In the following section, both, client and server are presented in detail. The network communicationprotocol is based on a server-client structure. A central computer (called server) is connected tomultiple EVILs. Remote computers in the same local area network as the server (called clients) canconnect to the server and select an EVIL. After establishing a connection, the server streams all datapackets from the client to its selected EVIL and vice versa until the client terminates the connection.

    3.5.1 Client

    The client software is based on the previous version with an additional section for LAN connections.The newly added features are shown in Figure 3.8 and include the following components

    1. List of all known servers. This list is stored in a file and loaded when the program starts.Additionally, the GUI checks all servers on that list during initialization for connected EVILs.

    2. List of all currently available EVILs on the selected server.

    3. Button for refreshing the list of available EVILs. This command sends a ping to each knownserver which then answers with a list of all its connected EVILs when available.

    4. Button for adding a new server. The IP address of the server can be entered in the panel to theleft.

    5. Button for scanning the network for available servers. If servers are found which are not alreadyon the server list, they are added. In the panels to the right, the network must be specified i.e.host IP and subnet mask.

    6. Button for opening the server control window. It allows starting (or restarting) the serversoftware remotely using a secure shell (SSH) connection.

    13

  • 1

    2

    43

    5

    6Figure 3.8: Network control section of the GUI. The numbers correspond to the numeration in thetext.

    The program flow is shown in Figure A.1 and kept similar to the original. The only difference isthat all commands, which were initially sent via a local serial port to the FPGA, must be redirectedto a server using an Ethernet connection.

    This communication consist of three processes which run simultaneously in the background:

    • The transmission (TX) worker sends commands which it receives from the GUI to a specifiedserver.

    • The receiving (RX) worker listens to a specified port on all available network interfaces and putsthe received data on the result queue.

    • The result receiver finally interprets the RX data and emits signals which then trigger GUIevents.

    As in the previous GUI version, PyQt as well as the queue objects from Python’s multiprocessinglibrary are used.

    PyQt provides a system called slots and signals which allows for the control of a program usinga GUI. Each action, e.g. a button that is clicked, can emit a signal which might even contain data.These signals are then connected to functions which process the signal. In the GUI, these signals arenot only used for triggering functions by using interface elements, but also the other way round, i.e.data that is received by the RX process triggers signals which then modify the GUI, e.g. for streamingdata to the streaming-view panel.

    The second important feature of the GUI is the inter-process communication using so-called queues.In Particular, all commands that are sent to the FPGA are put onto the operation queue. The TXworker listens to that queue and processes each incoming command. The same communication happensbetween the RX worker and the result receiver.

    3.5.2 Server

    The workflow of the server is visualized in Figure A.2. It is similar to the serial communication partof the GUI, however, for handling of multiple connections, a larger effort is required. The operationis split up in two parts: an initialization phase in which all communication processes are started anda phase in which data between all connected clients and their FPGAs is streamed.

    The initialization starts with checking all available ports for connected EVILs. Then the Ethernetcommunication process is started which handles the incoming and outgoing data. Similar to the clientside it consists of three processes2, namely

    • The (TX) worker which sends all data from an EVIL to the specified client.

    • The receiving (RX) worker listens to a specified port on all available network interfaces.2The exact information flow on the server side can be found in Figure A.3.

    14

  • • The result receiver interprets the RX data. It can either start a new connection with a clientor, if the sending client is already connected, hand the message over to the correct serial workerprocess. This ensures that multiple connections can be established simultaneously.

    Since the server can handle more than one connection between a client and an EVIL, a serialcommunication process must be started for each open connection. One single serial worker processhandles incoming commands and sends those to the EVIL. Simultaneously, it reads streaming dataand puts it back to the RX worker queue.

    When all processes are started, incoming data can be processed. In this stage the Ethernet resultreceiver interprets the data. When it receives a command used for control of the server, it is processeddirectly by the receiver, otherwise it is sent to the serial worker process associated with the client.

    For closing (and also for initializing) a connection, the server needs to stop and restart all commu-nication processes3.

    4 Results

    4.1 Lock-in Amplifier

    The lock-in amplifier was first tested in the simulation tool provided by Xilinx ISE R© Design Suite byextending the existing test benches. Afterwards, the functionality of the lock-in was tested using theloop-back setup shown in Figure 4.1a where the sinusoidal DDS output was redirected to the input ofthe lock-in. Mixing this signal resulted exactly in a DC and a frequency doubled component (Figure4.2). This test also confirmed that the phase can be adjusted correctly.

    Finally, the analogue lock-in used in the laser frequency stabilization set-up described in Section3.3 was completely replaced by one EVIL. Figure 4.3a shows the modulated input signal when notusing a band-pass filter. In Figure 4.3b, the spectrum of that input signal was calculated but at themodulation frequency of 14.969 kHz, no trace of the signal was visible.

    The situation changed when the passive amplifier described in Section 3.4 was used. Due to itscut-off, high-frequency noise (which appears in the spectrum at lower frequencies owing to aliasing) issuppressed and the signal becomes visible in the input (Figure 4.4b). The lock-in is, however, not ableto resolve the signal, most likely because it is too weak. The low frequency noise is nearly as strongas the DC signal. Moreover, the input offset (which is modulated by the lock-in to the modulationfrequency of 4.463 kHz) is dominant and cannot be further decreased (see Figure 4.4d).

    With the gain of the active amplifier set to approximately 12 dB at the modulation frequency of14.969 kHz, the amplitude of the signal matches the full bandwidth of the ADC. However, at the sametime high-frequency noise is amplified with the same gain. This resulted in the noisy signal shown inFigure 4.5a. The additional noise made it impossible to see any signal.

    3This could be improved but would not really affect the overall speed of the server.

    15

  • 4.1.1 Loop-back Test

    DDS OutputADC Input

    Error Signal Output

    (a) Configuration for the loop-back test: the DDSoutput is redirected to the input of the lock-in.

    (b) In- and Output signals in the loop-back setup.

    Figure 4.1: Loop-back set-up.

    (a) φ = 0◦. (b) φ = 90◦.

    (c) φ = 180◦. (d) φ = 270◦.

    Figure 4.2: Output of the lock-in amplifier in the loop-back setup for different phase shifts φ. Note thatthe output has double the frequency of the input signal shown in Figure 4.1b (high cut-off frequencyof the low-pass filter) and that the DC level is modulated by cosφ as derived in Equation (3.3).

    16

  • 4.1.2 Lab Test

    (a) Lock-in input signal when not using any band-pass filter or amplifier. The modulation frequencywas set to 14.969 kHz.

    DC-O

    ffset

    Picku

    p Nois

    e

    Picku

    p Nois

    e

    14.96

    9 kHz

    (b) Spectrum of the input signal. The DC-offsetcan be removed internally by the lock-in.

    Figure 4.3: Input signal without pre-filtering.

    (a) Lock-in input signal when using the pas-sive band-pass filter.

    4.463

    kHz

    8.926

    kHz

    13.38

    9 kHz

    DC-O

    ffset

    (b) Spectrum of the input signal. The modu-lation frequency was set to 4.463 kHz.

    (c) Lock-in signal of the same input. (d) Spectrum of the lock-in signal.

    Figure 4.4: Input signal and lock-in output with the passive amplifier.

    17

  • (a) Lock-in input signal when using the activeband-pass filter.

    (b) Spectrum of the lock-in output signal.The DC component is still very noisy but themixed offset at the modulation frequency is nolonger dominating.

    Figure 4.5: Input signal and lock-in output spectrum with the active amplifier.

    4.2 Network Communication

    Software Testing The software, especially the server side, was tested such that it runs stably withas little maintenance as possible. The following cases were tested on the server side

    • The server can connect a client to an EVIL and streams the data between these two. This alsoworks when more than one EVIL are connected.

    • The connection is closed correctly when either the client requests a disconnect or the connectionis not available anymore (e.g. network cable unplugged).

    • When an EVIL which is assigned to a client is disconnected from the server, the connection isclosed correctly.

    • The server can handle multiple connections simultaneously, i.e. when more than one user isconnected to an EVIL, the server sends the data from each client to the correct FPGA and viceversa.

    Also, all new GUI features were tested

    • All GUI items are updated correctly, e.g. when no serial port is selected, the connect-button isnot enabled, etc.

    • The server list can be loaded, updated and deleted properly.

    • Scanning the network for servers works and they appear in the server list correctly.

    • Controlling a server via SSH works4.

    Streaming Performance The server software was tested on both a standard laptop and the Rasp-berry Pi. On the computer streaming was possible with two FPGAs connected to two different clientswithout any restrictions. On the Raspberry Pi, by contrast, the streaming rate had to be limited to∼ 100 kS/s, otherwise the readout loop was executed not fast enough and streaming could not keepup with the desired pace.

    4This requires that the computer that runs the server also has an SSH server installed and that the client can use thePython module Paramiko.

    18

  • 5 Conclusions

    It was not possible to replace the EG&G 5209 analogue lock-in amplifier by a digital one since noerror signal could be detected. This is not surprising since even the analogue lock-in only achieves asignal-to-noise ratio (SNR) of ∼ 5. In the loop-back set-up, however, it was shown that the algorithmperforms correctly. Hence, there are three limiting factors

    • The resolution of the ADC on the EVIL board is not high enough. Commercial digital lock-inamplifiers have a resolution up to 18 bits [3] while the EVIL has only 10 bits. Using a betterADC would allow for detection of weaker signals.

    • The passive band-pass filter at the input is limited by the series resistance of the inductor. Theactive amplifier on the other hand adds too much noise. Using a better band-pass/pre-amplifierwould probably result in a better SNR.

    • The low-pass filter is approximately of first order, which implies a drop-off of 6 dB per octave.Using a higher-order low-pass would also enhance the SNR.

    The extension of the GUI to provide remote control of the EVILs was successful. The serversoftware allowed for remote control of multiple EVILs with different clients simultaneously. The onlydownside is that a Raspberry Pi is not fast enough to process the program properly at high streamingrates. Optimizing the code would require rewriting most of it in a more optimized programminglanguage like C. However, this would not guarantee a fast enough code since a speed-up of ∼ 65 timesis required to achieve the same throughput as on a standard computer.

    References

    [1] A. Hungenberg, Automatic relocking of an FPGA-based PID controller using a bandpass-filteringapproach,http://www.tiqi.ethz.ch/thesiswork/semesterthesis-alex_hungenberg.pdf [25.09.2014].

    [2] D. Nadlinger Laser Intensity Stabilization and Pulse Shaping for Trapped-Ion Experiments usingAcousto-Optic Modulatorshttp://www.tiqi.ethz.ch/thesiswork/semesterthesis-david_nadlinger.pdf [25.09.2014].

    [3] R. Burdett, Amplitude Modulated Signals: The Lock-in Amplifier in Handbook of Measuring Sys-tem Design, (John Wiley & Sons, Hoboken, 2005).

    [4] W. Demtröder, Laser Spectroscopy, (Springer, Heidelberg, 2003).

    [5] D.W. Preston, Doppler-free saturated absorption: Laser spectroscopy, Am. J. Phys. 64 11 (1996).

    [6] T.J. Quinn, Practical realization if the definition if the metre, including recommended radiationof other other optical frequency standarts (2001), Metrologia 40 103–133 (2003).

    [7] E.D. Black, An Introduction to Pound-Drever-Hall laser frequency stabilization, Am. J. Phys 6979 (2001).

    [8] V. Negnevitsky and L.D. Turner, Wideband laser locking to an atomic reference with modulationtransfer spectroscopy, Opt. Express 21, 3103-3113 (2013).

    [9] W.K. Jenkins, D.L. Jones and B.J. Hunsinger, Discrete-Time Signal Processing from ReferenceData for Engineers (Ninth Edition), (Newnes, Oxford, 2001).

    [10] Smith, J.O. Relating Pole Radius to Bandwidth, in Introduction to Digital Filters with Audio Ap-plications, http://ccrma.stanford.edu/~jos/filters/Partial_Fraction_Expansion.html,online book, 2007 edition [4.10.2014].

    [11] H.-Y. Lo et al., All-solid-state continuous-wave laser systems for ionization, cooling and quantumstate manipulation of beryllium ions, Appl. Phys. B 114:17-25 (2014).

    19

    http://www.tiqi.ethz.ch/thesiswork/semesterthesis-alex_hungenberg.pdfhttp://www.tiqi.ethz.ch/thesiswork/semesterthesis-david_nadlinger.pdfhttp://ccrma.stanford.edu/~jos/filters/Partial_Fraction_Expansion.html

  • A Flowcharts

    Sta

    rt

    Initi

    aliz

    e co

    ntro

    lcl

    ass

    Sta

    rt lo

    cal s

    eria

    lco

    mm

    unic

    atio

    n w

    orke

    rS

    tart

    eth

    erne

    tco

    mm

    unic

    atio

    n w

    orke

    r

    Con

    nect

    PyQ

    t sig

    nals

    from

    wor

    ker

    proc

    esse

    san

    d G

    UI e

    lem

    ents

    to c

    ontr

    ol c

    lass

    func

    tions

    Load

    GU

    I

    Ser

    ver

    list

    avai

    labl

    e

    Pin

    g ea

    ch s

    erve

    ran

    d sa

    ve a

    vaila

    ble

    port

    s

    Dis

    play

    por

    ts o

    f se

    lect

    ed s

    erve

    r

    Load

    str

    eam

    ing

    view

    s

    Wai

    t for

    sig

    nals

    Is c

    onne

    cted

    EV

    IL d

    ata

    Dis

    conn

    ect f

    rom

    ser

    ial,

    disa

    ble

    stre

    amin

    g

    Con

    nect

    to s

    eria

    l por

    tC

    onne

    ctio

    nbu

    tton

    Is c

    onne

    cted

    Ena

    ble

    FP

    GA

    and

    stre

    amin

    g co

    ntro

    ls

    Che

    ck F

    irmw

    are

    and

    load

    cor

    rect

    set

    tings

    tabs

    Dis

    play

    str

    eam

    dat

    a;pr

    oces

    s al

    l oth

    er c

    omm

    ands

    corr

    ectly

    Sen

    d di

    scon

    nect

    mes

    sage

    ,di

    sabl

    e st

    ream

    ing

    and

    FP

    GA

    con

    trol

    Sen

    d co

    nnec

    tion

    mes

    sage

    to s

    erve

    rS

    erve

    r an

    swer

    Load

    cor

    rect

    setti

    ngs

    tabs

    Ena

    ble

    FP

    GA

    and

    stre

    amin

    g co

    ntro

    ls

    Net

    wor

    k

    Bac

    kgro

    und

    proc

    ess

    Bac

    kgro

    und

    proc

    ess

    Yes

    No

    Yes

    No

    Loca

    lN

    o

    Yes

    Non

    e

    Firm

    war

    e

    Yes

    No

    Figure A.1: Control flow of the client software.

    20

  • Sta

    rt

    Initi

    aliz

    e et

    here

    t com

    mun

    icat

    ion

    RX

    and

    TX

    wor

    ker

    Initi

    aliz

    e se

    rial c

    omm

    unic

    atio

    nfo

    r ea

    ch p

    ort t

    hat i

    s op

    en

    Che

    ck fo

    r E

    VIL

    sA

    ppen

    d po

    rt n

    ames

    Wai

    t for

    inco

    min

    get

    hern

    et d

    ata

    Clie

    nt a

    lread

    yco

    nnec

    ted

    No

    Req

    uest

    ing

    port

    nam

    esR

    eque

    stin

    g co

    nnec

    tion

    Sen

    d er

    ror

    mes

    sage

    Est

    ablis

    h se

    rial c

    onne

    ctio

    n

    Add

    clie

    nt to

    conn

    ecte

    d us

    ers

    Yes

    Yes

    No

    Yes

    Sen

    d da

    tato

    FP

    GA

    Sto

    p al

    l com

    mun

    icat

    ion

    wor

    kers

    for

    upda

    ting

    Dis

    conn

    ect

    Put

    dat

    a to

    corr

    ect s

    eria

    lqu

    eue

    Sto

    p al

    l com

    mun

    icat

    ion

    wor

    kers

    for

    upda

    ting

    Clo

    se s

    eria

    l con

    nect

    ion

    Rem

    ove

    clie

    nt fr

    omco

    nnec

    ted

    user

    s

    Sen

    d er

    ror

    mes

    sage

    Sen

    d po

    rtna

    mes

    No

    Yes

    Yes

    No

    No

    Sen

    d da

    tato

    spe

    cifie

    dcl

    ient

    Pro

    cess

    sig

    nal

    and

    send

    it to

    the

    corr

    ect s

    eria

    lw

    orke

    r

    Eth

    erne

    t pro

    cess

    es

    Wai

    t for

    inco

    min

    gE

    ther

    net d

    ata

    Wai

    t for

    com

    mna

    dson

    the

    TX

    que

    ue

    Ser

    ial p

    roce

    ss

    Inco

    min

    gco

    mm

    and

    Sen

    d co

    mm

    and

    to th

    e E

    VIL

    If st

    ream

    ing

    is e

    nabl

    ed:

    get s

    trea

    min

    g pa

    cket

    from

    EV

    IL a

    ndpu

    t it o

    n T

    X q

    ueue

    Yes

    Tim

    eout

    Figure A.2: Control flow of the server.

    21

  • SerialControl

    EthernetControl

    TXworker

    RXworker

    ResultReceiver

    ResultReceiver

    Ethernet

    EVIL

    Server

    Serial Process

    Ethernet Processes

    Figure A.3: Information flow between different processes in the server architecture. Red arrowssymbolize signals coming from Ethernet and blue data from the EVIL.

    B Installation Guide

    Basic Python Installation On Windows, the easiest way is to use the 32 bit version of Win-python (http://sourceforge.net/p/winpython/wiki/PackageIndex_33/). Otherwise, at least thefollowing packages have to be installed:

    • Python 3.3 or 3.4 (on Ubuntu: sudo apt-get install python3.3/python3.4) as well as python3.x-dev

    • C/C++ compilers (on Ubuntu: sudo apt-get install build-essentials, on Windows:MinGW, see below)

    • Gfotran compiler (on Ubuntu: sudo apt-get install gfortran, on Windows MinGW)

    • Cython (https://pypi.python.org/pypi/Cython/)

    • Setuptools (https://pypi.python.org/pypi/setuptools/5.7)

    • Pyserial (https://pypi.python.org/pypi/pyserial/2.7)

    • Numpy (https://pypi.python.org/pypi/numpy/1.9.0)

    For the GUI, the following additional modules are required

    • SIP (http://www.riverbankcomputing.co.uk/software/sip/download)

    22

    http://sourceforge.net/p/winpython/wiki/PackageIndex_33/https://pypi.python.org/pypi/Cython/https://pypi.python.org/pypi/setuptools/5.7https://pypi.python.org/pypi/pyserial/2.7https://pypi.python.org/pypi/numpy/1.9.0http://www.riverbankcomputing.co.uk/software/sip/download

  • • PyQt4 (http://www.riverbankcomputing.co.uk/software/pyqt/download)

    • Scipy (https://pypi.python.org/pypi/scipy/0.14.0)

    • Pyudev (pyudevhttps://pypi.python.org/pypi/pyudev/0.16.1) for monitoring of the serialports (Linux only)

    Installing python modules from source is usually done with the command sudo python3.x setup.pyinstall. For SIP and PyQt5, one has to use

    1. python3.x configure.py

    2. sudo make

    3. sudo make install

    Server Control using Secure Shell In order to use SSH connections in the client software, thePython module “Paramiko” is required. It can be installed via the following steps

    • Install ecdsa (https://pypi.python.org/pypi/ecdsa)

    • On Windows: install from MinGW (http://www.mingw.org/) at least the C/C++ compilersand msys. Add ..\MinGW\bin and ..\MinGW\msys\1.0\bin to PATH (environment variables).

    • Install pycrypto (https://pypi.python.org/pypi/pycrypto) (do not use the version on Git-hub (i.e v2.7a1), it will not compile). For the installation use the following commands

    1. python3.x setup.py build

    2. python3.x setup.py install. On windows use python setup.py build -c mingw32instead.

    • Install paramiko (https://pypi.python.org/pypi/paramiko/1.14.1)

    Client and Server Installation For the GUI, clone the lockin network branch from the J-drive(J:/Git/electronics/evil gui). For the server, copy the folder server into the home folder on the Rasp-berry Pi and execute the installation script if not all Python modules are installed. The installationcan be carried out by executing the following commands in the command prompt

    • tar -xf python-setup.tar.gz

    • sh python-setup

    5(Do not use configure-ng.py for PyQt as recomended in the installation notes).

    23

    http://www.riverbankcomputing.co.uk/software/pyqt/downloadhttps://pypi.python.org/pypi/scipy/0.14.0pyudev https://pypi.python.org/pypi/pyudev/0.16.1https://pypi.python.org/pypi/ecdsahttp://www.mingw.org/https://pypi.python.org/pypi/pycryptohttps://pypi.python.org/pypi/paramiko/1.14.1

    IntroductionTheoryLock-in AmplifierSaturated Absorption SpectroscopyZ-TransformLow-Pass Filter

    ImplementationLow-Pass FilterLock-in AmplifierLaser SystemPre-amplifierNetwork CommunicationClientServer

    ResultsLock-in AmplifierLoop-back TestLab Test

    Network Communication

    ConclusionsFlowchartsInstallation Guide