Reference Designs

Phase Shift Oscillator

Figure 1: Phase Shift Oscillator

Phase shift oscillators produce sinusoidal outputs. The oscillation frequency in Hz is given by \(f_{osc} = \sqrt{3}/(2\pi RC)\). In order for this to operate, \(R_1/R_2\) must be 8, and it helps if \(R_2\) is fairly large (>100 k\(\Omega\)). The oscillation amplitude is hard to control, but we’ve seen ~ 1 Vpp in the past. The oscillation tends to be centered mid-rail. Since this requires four op-amps, it’s natural to implement it on one MCP6004.

555 Sine Wave Generator

Figure 2: 555 Square Wave Generator and LC Low Pass Filter

You can use 555 timers to produce sinusoidal outputs by attaching a low-pass filter to the output of a square wave generator. If the frequency of the low-pass is low enough, then harmonics of the square wave will be attenuated. We recommend a LC low-pass filter here because it’s a second order filter instead of a first order filter. This design has well-controlled frequency (see lab 3 for setting the 555 frequency), and it’s easy to control its amplitude (by setting VCC, perhaps with a voltage regulator). However, it doesn’t produce pure sine waves, it’s sometimes tricky to control its offset, and it’s very susceptible to power supply inductance: bypassing and careful layout are important to avoid intermittent errors with this design.

Maximum and Minimum Detectors

(a) Max Detector
(b) Min Detector
Figure 3: Maximum and minimum detector circuits.

Maximum and minimum detector circuits use a combination of a diode and a low-pass filter to have asymmetric charge and discharge time constants. Considering the max detector circuit as an example: the capacitor can charge quickly through the diode, but only discharges slowly through the resistor. This means the circuit will hold maxima of the input waveform. This behavior is particularly effective when the input is periodic because the input will refresh the charge on the capacitance each period, reducing the effect of the slow RC decay in the output. The RC discharge allows the detector to be updated if the amplitude of the input sinusoid changes. Select the RC time constant to be larger than the input period and smaller than the period of changes in your amplitude.

The op-amp serves to match the voltage on the capacitor to the input voltage, effectively hiding the typical 0.7 V drop across the diode. However, this has the effect of limiting the maximum or minimum output: in the case of the max detector, the capacitor output can’t go higher than 0.7V below the op-amp maximum output.

Variable Gain

Figure 4: An inverting amplifier with a variable gain controlled by a Teensy pin

This amplifier has a gain that can be controlled by the Teensy, which can be useful if you’re really unsure of the size of your input signal. The gain here is \(-R_f/R_i\) as usual, with the wrinkle that \(R_f\) is made up of some combination of \(R_{f1}\) and \(R_{f2}\). The Teensy pin controls a switch that puts \(R_{f2}\) in parallel with \(R_{f1}\), and thereby changes the total effective \(R_f\). You can achieve more gain control with more parallel feedback branches.

The switch is drawn as a N-type MOSFET, and that will work well for most final projects. However, there are some subtleties to selecting a transistor switch like this, and you can talk to a professor if your think your switch is acting strangely.

It’s also possible to simplify this design by replacing the transistor switch with a jumper that you manually install before deploying. Doing so will let you tune your gain to specific values by adding and removing jumpers, which doesn’t require soldering. This is particularly handy if you need to trim your gain during deployment. However, doing this presents other potential challenges: be sure to record your jumper configuration for each deployment, and make sure your jumpers aren’t mechanically sensitive. Extending this idea, you can simplify even further by replacing eliminating the \(R_{f2}\) path and replacing \(R_{f1}\) with a potentiometer (a variable resistor), but doing so poses significant deployment challenges since you need to measure your potentiometer value before each deployment.

Salinity Sensor

Salinity is a measure of the total dissolved salt content of water. It is an extremely important and common measurement in oceanographic studies. Salinity measurements are used to track the flow of water and map the hydrological cycle, calibrate acoustic communication links, and understand biological phenomena like algal blooms.

You measure salinity by measuring salt water’s conductivity, then backing out the salt concentration that would result in that conductivity. Some online calculators can help with this process. This converts from a measured conductivity to salinity, and this converts from salinity to conductivity. Note that both converters depend on water temperature, so you’ll probably need to deploy a temperature probe at the same time. Here’s an example of some measurements performed by E80 staff that show the temperature effects.

Salt, water and electrons will undergo chemical reactions at the surface of your salinity probe that can deposit metal salts on your electrodes. These salts can form non-conductive films that corrupt your conductivity measurements. You can prevent salt buildup by reversing the surface reactions, so applying an AC voltage to your probe prevents buildup over time. This same chemistry can also cause your circuit to fail if the electrode area is too small or the voltage applied to the solution is too low. We also recommend stainless steel as your probe material. Stainless steel wire can help too because salt water readily corrodes copper.

With these considerations, we recommend the following circuit to measure salinity.

Figure 5: A salinity sensor

This circuit consists of an oscillator, which can be implemented as a phase shift oscillator, a 555 oscillator, or another oscillator of your choice, an offset amplifier gain stage, a max detector and a min detector. Each of these components has a purpose

  • The oscillator stimulates the probe with an alternating Voltage to prevent buildup of metal salts. You need to pick the frequency to get the best possible measurement, which is complicated because the probe equivalent circuit is a resistor in parallel with a capacitor. You may want to read this reference for further information. The exact R and C of your probe depend on probe construction, notably because the separation of probes is a key component of calculating both resistance and capacitance.
  • The positive input of the op-amp is set to mid rail in order to pin the negative input at the same voltage, which also helps prevent metal salt buildup. The voltage across the probe is set by the difference between the oscillator voltage and the negative input, and setting the negative input to mid-rail guarantees zero DC voltage on the probe because oscillators usually oscillate above and below mid-rail.
  • The offset amplifier scales and shifts the oscillator output. Select RF to achieve your desired output amplitude. The output amplitude is directly proportional to probe conductivity because the gain is \(-R_f/R_i = -R_f \cdot G_{probe}\). Picking RF will require you to know the conductivity of the solutions you’ll test in, fortunately there are many references that can help you find the expected salinity and conductivity of the ocean.
  • Measuring amplitude of an oscillating signal is hard with the Teensy because of its slow sampling rate. The max and min detectors make it possible for the Teensy pins on the far right to pick off amplitude without any risk of sampling in the middle of the sine wave.

Calibration curves for salinity sensors are typically log-log plots of output Voltage vs. input concentration.

PH Sensor and Interface Circuit

pH needs no introduction, but in oceanography it can be an important indicator of acidic runoff from the surface. The pH of the water also has a strong impact on the health of various plant and animal species, notably coral. You will build a circuit to interact with a pH sensor and calibrate it against buffer solutions.

We stock a small number of Pasco pH electrodes for pH measurements. These electrodes are usually used with interface boxes provided by Pasco (the Pasport system), but you can hook circuits directly to the BNC connector of the pH probe.

The pH probes are delicate instruments, so be sure to always re-cap them in a bath of pH 7 buffer solution and never leave them sitting exposed to air. Rinse them in a bath of deionized water and shake off any excess droplets before returning them to buffer solution. Buffer solutions are relatively expensive chemicals, so use them thoughtfully: Use the smaller 50mL beakers to hold buffer solutions at your station and take pains not to spill any buffer solution when pouring it from the main supply. Buffer solutions may be rinsed down the sink when you are done with them.

The probes need special care to make repeatable and accurate measurements, so a few experimental tips will help you to get consistent results when taking calibration measurements. We stock pH 4, 7 and 10 precursor powders that can be used to make solutions of different pH. When you measure the pH of those solutions, stir the probes gently when you first immerse them, and be sure to wait for the probe voltage to stabilize when taking a measurement because their time constants are long. Finally, keep your hands away from the probes during measurement because the unshielded connections are sensitive to noise that can couple in through your body. Motor currents can couple through seawater to mess up this measurement too.

This application note has a ballpark estimate for the output impedance of a pH probe, which is very high (order 1 G\(\Omega\)). This reference is a handy guide to the operation of pH sensors. The pH sensor guide explains that ions diffusing through glass, a slow process, provide the output current from a pH sensor, which explains why the output impedance for this sensor is so high.

You can amplify the voltage out of these probes using an MCP601 configured as a non-inverting amplifier. You must use a non-inverting amplifier because inverting amplifiers and offset amplifiers have input impedances that will react poorly with the probe’s very large output impedance; inverting amplifiers and offset amplifiers dangle the \(R_i\) resistor off of the output node of the pH probe. (We also like the TL081 for this circuit because it has even higher input impedance than the MCP601, but putting a dual rail op-amp on your robot is deeply tedious work.)

Thermocouple Interface Circuit

Thermocouples generate very small voltages, so the Voltages must be amplified to be read by the Teensy. The easiest way to do the amplification is with an instrumentation amplifier. The one we have available is the Analog Devices AD623ANZ (data sheet here).

Pay special attention to the AD623 voltage supply range. It can operate with a dual rail supply Voltage of ±2.5 V to ±6 V, or it can operate with a single rail supply voltage from 0V to 5-12V. If you exceed the voltage supply range, you will destroy the chip. The op-amp standard of ±15 V will destroy it immediately. Don’t be tempted.

Figure 79 in the AD623 data sheet shows the basic circuit for connecting a thermocouple. Note that in Figure 79, the amplifier is powered with a dual rail supply. You should use a single rail supply because your AUV will be powered by a battery. However, when you use a single rail you must also offset your thermocouple Volage to mid-rail (e.g., if you supply with 0-to-5 V, your thermocouple should be offset to 2.5 V). The circuit shown below in Figure 6 will accomplish that offset. Note that the offset uses a unity-gain, non-inverting op-amp to provide a low output impedance for the offset voltage.

Figure 6: Schematic for AD623 thermocouple circuit.

You’ll need a thermocouple to test this amplifier, and we have spare type-E thermocouple wire available (specifically, Omega FF-E-24-SLE-200). The simplest way to construct a thermocouple for this task is to use one of the recycled ones. Otherwise, take a 1-foot length of thermocouple wire, strip the wires at one end and twist them firmly together so they make electrical contact. DO NOT USE SOLDER. It will not stick to the wires.

You’ll also need cold junction compensation. We recommend using a solid-state linear sensor (because temperature inside your robot should be pretty constant). You’ll need ot keep the solid-state linear sensor and the cold junction in good thermal contact, and a block of metal can provide a thermally conductive platform to mount your sensors.

The AD623 is expensive ($7/chip), so return undamaged chips to stock.

Acoustic Time-of-flight Distance Measurements

You can measure the distance between a speaker and an object by launching a pulse of sound then measuring how long it takes to receive an echo. This is called a time-of-flight (ToF) measurement. Implementing ToF on a robot requires a transmit (TX) circuit, a receive (RX) circuit and some special software.

For TX, we recommend using the LM384 audio amplifier to drive the DAEX25W-8 speaker. The “Typical 5 W Amplifier” reference circuit in the LM384 datasheet is a good design for our purposes, though we can make a few small changes to improve it by omitting the volume control potentiometer and adding some bypass and coupling capacitors. These changes are illustrated below:

Figure 7: Acoustic time-of-flight transmit circuit.

If you want to simplify your Teensy code, you can drive this circuit with a 555 timer instead of the Teensy. If you do so, note that you can easily turn your timer on and off, and therefore turn your speaker on and off, by controlling the 555 reset pin with a Teensy output pin. Adding a pull-down resistor between the 555 reset pin and ground can prevent annoying squawks while the Teensy starts up.

For RX, you will need to build an amplifier. There are several possible strategies for this amplifier, and we recommend one of the simplest here: we recommend using only non-inverting amplifiers. Doing so will deliberately cause your zero-centered microphone signal to clip, so we are throwing away possible signal power in favor of a simple implementation. However, we only care about the presence/absence of a signal, so clipping isn’t a problem if we can muster enough gain. Depending on the range you’re working at, you may need a gain as high as 10,000, but we’ve seen OK results with gains in the 100-1000 range. You will need to split this gain across several stages to avoid running afoul of your op-amp’s gain-bandwidth product.

Two extra circuits in the receive chain can simplify your analysis work. A filter tuned to your transmit freuqency will prevent your very-high-gain amplifier from picking up ocean noise (e.g.: boat propellors). A second-order, band-pass Sallen-Key filter has worked in the past, and so has a cascade of op-amp low-pass and high-pass filters. Finally, a max detector at the end of your receive chain reduces the required sampling rate on the Teensy.

These recommendations are combined in the figure below:

Figure 8: Acoustic time-of-flight receive circuit.

For software, you will need to increase the sampling rate of the Teensy. You can do so using the BurstADCSampler library provided in our default Github package. Invoking BurstADCSampler by calling burst_adc.sampler() in the main Default_Robot.ino will cause the ADC to rapidly sample data (at about 7.4 kHz) and save that burst data to a separate file. You need to disable analog read averaging to use the BurstADCSampler, and you do that by adding the following line to your Default_Robot.ino setup function:

void setup() {
    analogReadAveraging(0);
    ... 
    EXISTING SETUP CODE 
    ...
}

If you are trying to drive your speaker pin directly instead of using a 555 timer, you will need to use the Teensy’s analogWrite functionality. Do so by editing Pinouts.h to set SPEAKER_PIN to your speaker output pin number. Then add the lines below to your setup function, and trigger a write by running analogWrite(SPEAKER_PIN, 0) in Default_Robot.ino.

void setup() {
    pinMode(SPEAKER_PIN, OUTPUT);
    // set frequency to 3 kHz, change for your application
    analogWriteFrequency(SPEAKER_PIN, 3000); 
    ...
    EXISTING SETUP CODE
    ...
}

For Testing, it’s handy to be able to test your circuit from a function generator without getting all the Teensy code working. The old function generators (the HP/Agilent 33120A) can help with that. You can send a burst of sine waves, i.e.: a small number of sine wave cycles, by using internally triggered burst modulation on the HP/Agilent 33120A. This function is not available on the function generators built into the oscilloscope.

You can control burst mode by pressing the series of keys shown below. Read the manual for clarification on how these key presses work.

  • Turn burst modulation mode on: Shift + the ramp/burst button / The text ‘burst’ will be highlighted at the top of the screen.
  • Turn burst modulation mode off: Shift + the ramp/burst button / The text ‘burst’ will no longer be highlighted at the top of the screen.
  • Turn manual triggering on and internal triggering off: Shift + the TRIG button / The text ‘trig’ will be highlighted at the top of the screen
  • Turn manual triggering off and internal triggering on: Shift + the TRIG button / The text ‘trig’ will no longer be highlighted at the top of the screen
  • Change the number of cycles sent out in each burst or the burst repetition rate:
  • Shift + Enter / Screen says “A: Mod Menu,”
  • v / Screen says “AM Shape,”
  •  / Screen says "AM Source,"
  •  / Screen says "FM Shape,"
  •  / Screen says "Burst CNT, "
  • v / Screen says some number.” OR > / “Burst Rate,” and then V / “some number.”
  • Edit the number you see and press enter to save the setting.

Sometimes the tank room is noisy. By gathering data that is synchronized with the signal you are sending and averaging over many samples, you can cancel out signals that are not at the same frequency as the burst repetition rate of your signal. This is called coherent averaging. Set this up using the following steps:

  • Use a second oscilloscope channel to probe the output of your function generator (or attach the trigger output of your function generator to your scope’s trigger input)
  • Trigger your oscilloscope on the channel attached to the output of the function generator (or on the trigger input)
  • Set your oscilloscope to normal mode acquisition (so that it will only capture a new screen of data when it receives a trigger) and adjust the horizontal position of your oscilloscope trigger so that you don’t waste samples recording data before you send out a burst.
  • Turn on averaging on your oscilloscope using the Acquisition/Mode button.

You may refer to this picture of an example range finding setup. It is extremely important that your electronics and the tank water are not mixed, so Use tape to hold electronics down so they can’t fall into the tank, and keep bench top equipment as far from the tank edge as possible. Always dry your test apparatus with a towel as you remove it from the water and be mindful of nearby electrical setups.

AUV Turbidity Meter

This design adapts the lab turbidity meter to the requirements for being immersed and waterproofed. The instructions and procedure are here. A zip file of the design files is here.

Anemometer

An anemometer is used for measuring wind speed. It is useful for a surface vehicle, but not so much for a submersible. The instructions and procedures are here. A zip file of the design documents is here.

Weather Vane

A weather vane is used for indicating wind direction relative to the local coordinates of a surface craft. It is not so useful for a submersible. There are three possible sensors for the weather vane.

  • The first is the MLX90316. The instructions and procedure are here.
  • The second is the ACE128. The instructions and procedures are here.
  • For convenience, a zip file of the design files for both is here.
  • The third is a simple potentiometer. If you attach the rotor to the weather vane, then as it rotates, the wiper output should produce a time varying analog voltage. This can run into issues with mechanical stiffness of the potentiometer, but the readout circuit is very easy (perhaps as simple as a unity gain buffer).

Velocity Sensors

The reference design for the velocity sensor was not terribly successful. Perhaps you can learn from other’s mistakes. The instructions and procedures, such as they are, are here. A spreadsheet with the design calculations is here. A spreadsheet with the experimental results is here. A zip archive with the design documents is here.

Sufficiently ambitious teams might try using Doppler techniques with acoustic sensors to measure velocity. This type of measurement is called a frequency modulated continuous wave (FMCW) measurement because (1) unlike time of flight measurements, you transmit a continuous sine wave, and (2) you vary the frequency of your wave during operation. This document describes the basics of FMCW processing. You’re on your own for making a triangle wave generator, a voltage controlled oscillator, and the receive mixers.

You can use recorded video of your robot, particularly if you have a reference scale in frame, to get a “true”, ground-truth measurement of velocity. VLC works well as capture software for a USB camera, and tripod-stabilized phones also record great video. We recommend tracker for tracking video tracking software. Some some students have used video-physics. Make sure a length reference like a meter stick is visible in the image that you capture. Also, attach a brightly colored piece of pool noodle to your robot so that it is visible above the water. This will enable you to use auto tracking features in the video analysis software.

Future Designs

If you had a design that was particularly successful and you would like to share it with future generations of E80 students, let the professors know, and it may show up here.