# Lab 8

The questions below are due on Friday March 20, 2020; 05:15:00 PM.

You are not logged in.

Note that this link will take you to an external site (https://shimmer.csail.mit.edu) to authenticate, and then you will be redirected back to this page.

Music for this Lab

Goals: In Lab 8 we're going to do two things. One is to build a 5 V to 30 V boost converter, so we can get rid of the 30 V power supply. The second is to build the final part of the Doppler ultrasound system, namely a comparator.

Before starting this lab check that your function generator is in High-Z mode by pressing Shift, Enter, the right arrow three times, down arrow twice. If it shows 50 Ohm, use the left or right arrows and Enter to switch to High-Z.

## 1) Preliminaries

• Make sure you have completed the prelab prior to starting the lab.

• Make sure you have completed and gotten checked-off for Lab 5, Lab 8, and Lab 9, before you attempt this lab, since we're altering the Teensy in a way that won't allow it to be used on a breadboard anymore!

## 2) Recap

First, let's recall again what we're trying to do with the Doppler ultrasound system, and what we've done so far. Our overall system block diagram looks like:
• We create ultrasound using the transmit stage. In this stage, we first use the Teensy to create a square wave, and then we use an amplifier to amplify the voltage.

• That ultrasound bounces off an object. If the object is moving, it changes the ultrasound wave frequency by a little bit. We are trying to discern that frequency change.

• To do that, we first amplify the received signal approximately 10\times using our receive amp.

• Then we want to turn the signal into a square wave to make it easier to manipulate. The comparator does this. Remember, we can do this because the information we care about is the frequency of the signal, which remains unchanged when we turn it into a square wave.

• Then we want to measure the frequency of that digitized signal. Rather than measuring the frequency of the digitized signal directly, we first multiply the received signal with the original transmit square wave using an XNOR gate.

• You'll recall from Lab 7 that this created a signal with two main frequency components, one at \delta f, the doppler shift frequency, and one at ~ 80 kHz. In Lab 10 we designed a 1 kHz Sallen-Key low-pass filter to remove the 80 kHz signal.

• Now we just need to measure the frequency of the remaining signal at \delta f. However, we will first turn that signal back into a nice square wave using a comparator before sending to the Teensy.

• The other task we want is to get rid of the two different power supplies. Since we have 5 V coming in to power the Teensy, we would like to create a 30 V supply voltage from that 5 V supply. We will do this with a boost converter.

We'll do the Boost Converter first, and then move on to the comparator!

## 3) Switching Boost Power Supply

Our goal here is to build a switching boost power supply that produces an output of +30 V from a 4-6 V input, such as the USB input to the Teensy (5 V). A schematic of the power supply, and an explanation of its input and output connectors, is in the [full system schematic](COURSE/ultrasound/Ultrasonic Velocity Sensor Schematic V1_4_NV.pdf).

The input VIN is 5 V from the USB that goes to V+ (pin 2). The output is VOUT, which is nominally 30 V. The majority of the power supply is concerned with producing the (adjustable) 30-V VOUT from VIN. To begin, capacitors C11 and C12 store charge that is delivered as a current to the load at VOUT. As the charge is delivered, thereby depleting the capacitor charge, the voltage at VOUT falls.

Resistors R15 and R16 form a voltage divider that measures VOUT, presenting an attenuated version of VOUT to the Maxim MAX771 integrated circuit. When the voltage falls too low, the MAX771 turns on transistor Q1, which in turn pulls its drain terminal (where the inductor L1 and the diode D1 are connected) nearly to ground. At this time, the current through L1 begins to ramp up as it is excited by the voltage difference between VIN and ground. The inductor current passes through Q1 and resistor R14. The voltage drop across R14 allows the MAX771 to measure the current. When the current is adequately high, the MAX771 turns off Q1. Since the inductor current must go somewhere, L1 raises the voltage at Q1's drain terminal so as to turn on D1, thereby allowing the current to flow through D1 into C11 and C12. This replenishes the capacitor charge that was delivered to the load.

This process repeats itself as the MAX771 attempts to maintain the voltage at its pin 3 at 1.5 V, which is the fraction of VOUT determined by the voltage divider comprising R15 and R16; as a result, the voltage divider determines the voltage at VOUT.

Note that the power supply runs in discontinuous mode, meaning that the inductor current discharges to zero during each cycle so that all its energy is transferred to the capacitors at VOUT. The figure below shows several voltage waveforms over the course of one cycle of operation for VIN = 5V and VOUT = 30 V.

The green waveform is the voltage across R14, and is a measure of the inductor current as it ramps up. It reaches a peak of 100 mV which corresponds to a peak current of 1 A in about 6.6 µs. (Does this make sense given the inductance of L1?) The blue waveform is VOUT measured with AC coupling. Thus, the blue waveform shows the voltage ripple on VOUT. Its peak-to-peak ripple is on the order of 50 mV. Finally, the yellow waveform is the voltage at the drain of Q1, between L1 and D1. Note that during the time that the diode discharges into the capacitors at VOUT, this voltage is approximately VOUT. From the waveform, VOUT is almost 30 V. Once the current through L1 drops to zero, D1 turns off, and the 360-pF output (drain-to-source) capacitance of Q1 discharges through L1. This causes the yellow waveform to ring around the input voltage VIN, which is 5V. (Can you explain the period of the ringing based on the inductance of L1 and the output capacitance of the MOSFET?)

## 4) Populate and Solder

Obtain a MAX771 and place it in the appropriate socket. Take a look at the [full system schematic](COURSE/ultrasound/Ultrasonic Velocity Sensor Schematic V1_4_NV.pdf) to see where it fits in. Now obtain the rest of the components for the boost converter (at the front!!!):

• Transistor Q1, IRLD024BPF
• Diode D1, STPS3L60Q
• Inductor L1, 100 uH
• Capacitors: 1 - 10 \muF, 2 - 1 \muF, and 3 - 0.1 \muF
• Resistors: R14 (1 ohm), R15 (191 k), and R16 (10 k)

Solder them to their appropriate locations on the PCB. Some notes on orientation:

• The inductor L1 should go in a particular orientation, with the text aligned to the long axis of the board.

• The transistor Q1 should also be oriented a particular way. The two pins with the tab should go toward the outside of the board.

• The diode D1 also has an orientation. The line denotes the negative terminal, and should go toward the inside of the board.

All orientations are shown in the image below:

Next, we will solder up some final parts for the Teensy.

Please make sure you have completed and gotten checked-off for Lab 5, Lab 8, and Lab 9, before you attempt the next step, since we're altering the Teensy in a way that won't allow it to be used on a breadboard anymore!

Obtain one 5-pin male header. We will use this for the Teensy. Take the male header and solder it to the Teensy in the same orientation as the two already-soldered header strips. We will use pins from this headerto create an output voltage from the Teensy and send that output voltage to the PCB.

## 5) Boost converter testing

Do not connect the 30 V supply anymore to your board. It will destroy your boost converter.

Connect 5 V and ground to your US PCB. Use the oscilloscope to measure the DC voltage at TP9, and make sure it is around 30 V. Then AC couple the signal to look at the ripple, make sure it is around 50 mV, as in the measurements above.

Checkoff 1:
Demonstrate your working boost converter to the staff.

## 6) One Last Comparator for the Road

We used a comparator way back in Lab 7 and in ex05. Take a look at that lab and exercise problem as refresher.

The role of this second comparator is to clean up the signal coming out of the S-K LPF. We want the signal coming out of that filter (which is somewhere in-between a sinusoid and a square wave) to be a nice square wave so that it can be easily put into the digital input pins on the Teensy, where we'll then measure its frequency.

For this second comparator, since the signal coming in is already pretty square, alot of hysteresis is fine. In fact, let's just go for 2.5 V of hysteresis.

Choose R12 and R13 such that there is 2.5 V of hysteresis in this comparator stage. As before, choose resistors in the 1 k\Omega to 100 k\Omega range.

Enter your values for R12 and R13 in ohms as a Python list [R12, R13]:

Let's build it. Grab the following components:

• MAX941 comparator
• two resistors for comparator
• add a jumper to J5

And assemble the circuit.

### 6.1) Code

Next, download this week's code, compile, and load it onto your Teensy. This code uses the Teensy to count the time between rising and falling edges as well lack of those events in certain cases, to infer the frequency. From that frequency, the speed of the moving target is calculated. The code then displays that frequency and the target's speed on the OLED. The system will also output an analog voltage proportional to the frequency on one of the Teensy's DAC pins.

Place your Teensy and OLED on the Doppler US board. You are ready to test!

### 6.2) Testing

Input a 5 Vpp square wave at 10 Hz with 2.5 V offset into the input of the S-K filter (TP6). Scope TP7 and make sure it looks roughly like a filtered sinusoid.

Then scope TP8 and make sure you get a 5Vpp square wave of the same frequency. Lower the frequency to a few Hz, and deviate it by 100s of mHz. Look at the dispaly on your Teensy and see if the Teensy is measuring the same frequency.

Slowly alter the frequency on the signal generator and make sure the frequency measured by the Teensy adjusts accordingly.

Checkoff 2:
Demonstrate your working comparator to the staff.

## 7) Cleanup

Before you leave, it's time to clean up again! Steps for cleanup:

• Carefully pick up your system and place into its plastic case.
• Throw away loose wires on your desk.
• Throw away paper, food, etc. on your desk.

Checkoff 3:
Show your cleaned-up lab space to a staff member.