I often need a simple function generator. Just to generate a certain
frequency. After all the years I've worked with electronics, I still haven't got
me one. Even though I need it now and then, I just couldn't seem to justify the
cost of one.
So, standard solution - build one yourself.
I designed a simple sinewave generator based on a Analog Devices AD9832 chip. It will generate a sinewave from 0.005 to 12 MHz in 0.005 Hz steps.
That's pretty good, and definitely good enough for me ! But while waiting for the AD9832 chip to arrive, I came up with a very simple version of the DDS synth, using just the 2313 and a resistor network.
It's controlled over RS232 from a small Windows program, and can generate Sine-, Sawtooth-, Trangle- and Sqare-waves ranging from 0.07 Hz to about 200-300 kHz in 0.07 Hz steps (depending on your crystal).
There's not much to say about the schematic. It's as simple as can be. Just 4
major parts. A voltage regulator/switch, a RS232 interface chip, the 2313 and
the R2R resistor network. The R2R network is connected to PORTB on the 2313,
making it a simple D/A converter and makes it possible to output 256 voltage
levels. Neither the resistor network or port drivers of the 2313 is of perfect
linearity, but it works pretty well anyway. But you'll probably need a buffer
stage as the output impedance is rather high (tens of kOhms in my case).
The MAX603 handles the voltage regulation as well as the powerup/shutdown function, and is controlled by the DTR signal on the serial interface. So when you shut down the control program on the PC, the miniDDS will be shutdown, saving battery.
The software is written in assembler, as it is very short and it need the
speed in the main loop.
This is the heart of the synth. To be precise, it's in the 7 lines of assembler that makes up the main loop.
The rest of the code is the wavetables and the communication code.
The phase accumulator uses 24 bits, which determines the resolution of the output frequency. Maximum available frequency and resolution is also dependent on your crystal frequency :
Resolution = fCPU/150994944 and
fOut = Accumulator * Resolution
In my case with a 11.059200 MHz crystal, the resolution is
To get an output frequency of 1 kHz, we need to use a phase accumulator value of 0x003556 (13654 decimal).
This gives an output frequency of 1000.048835 Hz. Good enough for most hobby work !.
The communication is pretty simple and just allows you to set and read the
phase accumulator value, as well as selecting the type of output waveform.
It uses a 32 bit value for the phase accumulator to be compatible with the larger DDS circuit using the AD9832 chip.
Download Windows Control
Comments are always welcome at email@example.com