This week’s How-To comes from our newest contributor: Logan Williams.
This simple guide will show you how to build a digital synthesizer that generates and manipulates square waves. Your synthesizer will have one oscillator, which produces a variable pitch controlled by a potentiometer, as well as an LFO which modulates that pitch at a variable frequency. The part count for this project is quite low, and it can be built for under $20.
Finding the Parts
The first step in building this digital synthesizer is to procure the parts that you will need. Most of these can be bought at RadioShack, but RadioShack’s prices are often much more expensive than ordering online. All of the parts for this project can be purchased at Jameco, Digi-Key, or Mouser. We’ve provided Jameco part numbers below. If you don’t mind waiting, this is the best way to order parts.
|9V Battery Clip||270-325||$1.99||11280||$0.30|
|100K Linear Potentiometer||R2||271-092||$2.99||255696||$1.35|
|1M Linear Potentiometer||R3||271-211||$2.99||255582||$1.35|
|50K Linear Potentiometer||R4||271-1716||$2.99||255549||$1.35|
|10K Linear Potentiometer||R5||271-1715||$2.99||255522||$1.35|
|IRF 510 MOSFET Transistor||Q1||276-2072||$1.99||209234||$0.69|
|3.5mm Audio Connector||274-333||$2.99||109496||$0.53|
|7805 5V Voltage Regulator||IC1||276-1770||$1.59||51262||$0.20|
|0.1 uF capacitor||C1||272-135||$1.49||151118||$0.20|
|1.0 uF capacitor||C2||272-1055||$1.59||544956||$0.20|
|40106 Hex Inverter||IC2||Fairchild||$0.00||785071||$0.47|
Note: The potentiometers and audio jack must be either taped or soldered to 22 AWG solid core wire. Soldering is highly recommended, as it produces a more secure connection.
Creating an oscillator
Before we can begin with the digital synthesizer, we must generate the correct voltage. Most of you will be familiar with using a 7805 5V voltage regulator. It is very simple; connect the +9V from the battery to the left hand pin, ground the middle pin, and the right hand is +5V.
The most basic circuit in any synthesizer is the oscillator. A square wave oscillator constantly alternates between two voltages, in this case +5V and 0V. We have a logic inverter to create this, which operates quite simply; if it is given +5V in (a logic 1), it give
s 0V out
(a logic 0) and if it is given a logic 0, it gives a logic 1 as output. When the input and output are connected together, it will oscillate rapidly between those two values: a 0 goes in, comes out as a 1, goes in, comes out as a 0, and so on.
The problem is that it oscillates much too fast. A resistor capacitor (RC) delay circuit can be added to slow it down. This forces the output current to charge the capacitor before it can pass through to the input. The resulting brief delay slows the oscillations to audible frequencies.
To build the oscillator, assemble the schematic below on a breadboard.
When done, the oscillator should look something like this:
Connect one side of the audio jack to 0V and the other side to the output, and it will sound like this:
Controlling the oscillator
We can make things more interesting by allowing the user to change the frequency. We replace the constant resistor R1 with a potentiometer, such as the 100K R2. This is a simple change to do, and is reflected in this altered schematic.
Now the oscillator sounds like this:
Much more interesting. Try playing an actual song, if you dare.
Duty cycle adjustment
We can add some basic timbre control to make the oscillator more interesting. The duty cycle of a square wave is how long it spends at logic 1 vs. at logic 0. For example, a wave that spends 1 ms at +5V and 1ms at 0V per cycle would have a 50% duty cycle. 1.5 ms at +5V and 0.5 ms at 0V would be a 75% duty cycle. To adjust the wave’s duty cycle, we can add another potentiometer and diode to the circuit. When the input is high and the output is low, current will be able to flow through both potentiometers, decreasing the amount of time it takes to charge the capacitor, and increasing the duty cycle.
It should sound like this when completed:
Creating an LFO
A low-frequency oscillator (LFO) is an oscillator that oscillates very slowly, from 1 to 100 cycles per second. We will use an LFO to alternate the pitch of our oscillator between two different frequencies. This can be used for siren like sound effects, timbre control, or musical sequences.
The circuit to control the LFO is slightly more complex than the ones we have used before. Because it uses a capacitor with 10x the capacitance, and a potentiometer with 10x the resistance, the oscillations are 100x slower than our first oscillator. The LFO connects to the gate of the IRF 510 MOSFET transistor. When the output of the LFO is +5V, the transistor connects its source and drain pins. With these pins connected, current can flow through the second potentiometer, increasing the pitch. When the LFO returns to 0V, the potentiometer is disconnected, and the pitch drops back to its original level.
There are quite a number of sounds that can be produced with the LFO, such as this:
You have now made your own simple digital synthesizer. Keep experimenting with different control methods. The frequency is adjusted with just resistance, so almost anything can be used for an input. Try a photocell, or a flex sensor. Try combining the LFO and the duty cycle adjustment. Try using it to actually make music! We’d love to see what you come up with.