## Introduction: How to Make a Voltage-Controlled Oscillator

The objective of this Instructable is to show you one method of turning DC values, such as those from a thermometer, pH sensor, or pressure sensor into a frequency which can be used to send information over the microphone band of an audio jack to a smartphone.

We assumed an input DC voltage as our sensor and built a voltage-controlled oscillator (VCO) to turn different DC voltages into correspondingly different frequencies, which the microphone input into the smart phone’s audio port reads as different tones.

## Step 1: What You Need

Tools
Frequency generator
Device that plays audio and takes microphone over a 3.5mm audio jack (we are using a Samsung Galaxy Vibrant).

Parts
3.5mm TRRS Audio cable
Resistors (two 100kΩ and one 100Ω)
1μF Capacitor
10Ω-10kΩ Potentiometer

Assumed Knowledge
You can use a breadboard. If you’ve never used one before, see https://www.instructables.com/id/Breadboard-How-To/.
You can use an oscilloscope. If you’ve never used one before, see https://www.instructables.com/id/Oscilloscope-How-To/.

## Step 2: Build an Oscillator

Why: There are many designs of VCO, but we chose a hysteretic oscillator, which is a type of relaxation oscillator. If you're interested in oscillator design, this website has good information.

Theory: The comparator (an op-amp, in our case) generates a positive feedback loop between the positive and negative voltages. This feedback charges the capacitor when it draws from the positive voltage, then once the capacitor fills, it discharges, switching the power draw from positive to negative. This process repeats to oscillate continuously.

The frequency of the oscillation is thus dependent upon the size of the capacitor and on the input voltages.

Practice: Values should be selected so that the frequency output will be in the audio range, approximately 16 Hz to 20 kHz.
Power the op amp according to the values on its data sheet.

## Step 3: Control Voltage: Install a Potentiometer

Why: Since this oscillator is voltage-controlled, we need to change the voltage in order to watch the frequencies change. Changing the voltage on the power supply is not a good idea, because the op-amp needs a specific (and constant) power supply to function (we are only in possession of one variable DC voltage supplier). So in order to change the voltage to the inputs without changing the op-amp’s power, we will install a potentiometer between one of the voltage inputs and the power supply.

Theory: V = IR, so we can change the voltage of the input by changing the resistance of the potentiometer.

Practice: In order to test the response of the smartphone to the information you are sending, you will want some sort of feedback on your phone. Oscilloscope apps exist, but we picked a different option: we called another phone with our phone and listened over the call to the tones produced by our oscillation circuit.

We tested the system at < 6 V variable DC input just to be wary of our phone’s sound card limitations.

The system requires around 3 V amplitude input to trigger the audio jack on an iPhone. This trigger voltage is different for different types of smart phone.

Play with potentiometer to change voltage (modulating input from the DC power supply).

## Step 4: Control Voltage: Frequency Generator

Why: We need to determine the accuracy with which the device can determine the different voltages measured by your circuit and what range of input voltages this VCO will operate at.  If your device cannot tell what frequency is being sent in, then the VCO is useless.

Theory: Notice that the duty cycle changes depending on the input voltage. When one of the frequencies takes over too much of the duty cycle, it will no longer be a readable frequency.

Practice:  Plug in a frequency generator as shown in the circuit diagram above.  Have the frequency generator output a square wave. Modulate input using square wave on frequency generator hooked up to phone calling other phone and listen to changing square waves. When you can’t hear two distinct tones, you have reached beyond the limit of your frequency range. This defines the frequency range available.

## Step 5: Tips for Swapping in a Sensor Circuit

Why: If you are using this circuit to gain real information, not just play around with a potentiometer, you will want to swap in  a real voltage-changing circuit and read its frequency values.

Theory: We are currently modulating voltage with a potentiometer. If the frequency is altered based on this change in DC voltage, a change in DC voltage from a different source should also modulate the frequency.

Practice: You want the voltage from your sensing circuit to match the voltage range you identified by sweeping voltages above. If your sensing circuit voltages are higher or lower than that range, you will see clipping. If the range of your sensing circuit voltage output is very small, your readings will have low resolution.

Plug in your sensing circuit output in place of the potentiometer. Different output frequencies of your VCO will correspond to different voltages inputted by your sensor. All’s left is decoding by measuring the frequency of these new AC voltages on your phone. Congratulations, you can now send information to your phone over an audio jack!

## Step 6: Bonus: Pranking!

Why: Why not?

Theory: Recall that we tested our frequency generation capabilities not just visually over the oscilloscope, but also listened for a response over the phone. Specifically, we plugged in the audio/headset jack and listened on speaker phone. Since we are transmitting over the headset microphone, we can call another phone, and our call recipient should hear what we send the microphone: a bunch of frequencies. Wee-ooo-wee-ooo-waaaaaaaaaaaaaaaaaaaaaaaaaaaaa-ooo-wee-ooo

Practice: Hook up your frequency generator again. I think sine waves sound best. Then call somebody! Ideally someone close enough that you can watch their confusion.

Participated in the
Epilog Challenge V