#053 LM324 Function Generator
Use an Arduino to monitor the behaviour of a low-frequency LM324 OpAmp waveform generator (square,triangle,sine,cosine) and plot the results with Processing.
Notes
The circuit uses the 4 OpAmps in an LM324 to drive four waveforms: square,triangle,sine,cosine.
The frequency is designed to be very low, in order to drive output effects visible to the human eye.
Stage 1: Square Wave Generator
Stage 1 uses an RC network (R4,C1) to generate a low frequency square wave. It can oscillate from about 0.24Hz to about 4Hz by adjusting R4.
f = 1/(2πRC)
f = 1/(2π * 20kΩ * 33μF)
f = 0.24Hz
The non-inverting voltage reference is pegged to Vcc/2 using the R1/R2 voltage divider. A similar reference voltage is repeated for each OpAmp unit. Note that the reference voltage is not shared to avoid cross-over problems.
Stage 2: Triangle Wave Integrator
The square wave from stage 1 is fed to the second stage configured as an integrating amplifier. This results in a triangle wave.
Stage 3: Sine Wave Integrator
The triangle wave from stage 1 is fed to the third stage to perform a second integration. This results in a sine wave.
Stage 4: Cosine Wave Integrator
To transform the output from stage 3 (sine) to cosine, we use the final OpAmp unit as an inverting amplifier with gain = 1.
Measured Behaviour
LEAP#090 PlotNValues (a simple Processing sketch) reads the data from the serial port and plots the output values over time, with some coloration effects thrown in for good measure. In other words, we’re using Arduino and Processing as a basic oscilloscope … and it kind of works, mainly because the frequency is so low.
The behaviour is demonstrated in the following trace with R4 variable resistor at about 10kΩ.
- Stage 4 (upper trace) is the cosine output
- Stage 3 (upper middle trace) is the sine wave output
- Stage 2 (lower middle trace) is the triangle wave output
- Stage 1 (lower trace) is the square wave output
Construction
The Arduino only acts as a measurement device in this circuit. For simplicity, the circuit is powered from the Arduino 5V pin. That works fine, although it is equally possible to use a separate power supply (but ensuring there is a common ground connection).