Browse over 10,000 Electronics Projects

Build Your Own Function Generator Using Analog Devices’ AD9833

Build Your Own Function Generator Using Analog Devices’ AD9833

Main Routine

For the main code that will connect our AD9833, LCD, rotary encoder, and microcontroller together we are going to cheat a bit and use some very well written libraries for the LCD, which uses the I2C bus, and for the rotary encoder.

Our arbitrary waveform generator does not make good use of the phase functionality; I have decided to keep this feature unavailable, but you can use it by uncommenting the directive “//#define usePhase”. However, doing that will disable the ability to choose between the FREQ0 and FREQ1 registers.

I tried to make the software as user-friendly as possible. From the start, on the LCD you can see the frequency in the upper left corner and change it digit by digit, in the upper right corner is the power state of the analog output, which can be either ON or OFF, meaning you can turn off the output without turning off the device. In the bottom left corner, you can choose the register used for storing the frequency, either FREQ0 or FREQ1. This is useful in case you want to easily switch between two different frequencies. Lastly, in the bottom right corner is the type of waveform that you want to output, either sine wave, triangular wave, or rectangular wave. Keep in mind that the clock output will always have a higher amplitude, as the AD9833 outputs it at 2.5V as opposed to 0.65V for sinusoidal and triangular signals.



Advertisement1


 

This is how you make changes: Pressing the encoder makes the cursor active, and then you rotate the encoder to “scroll” (move) between the four settings (frequency, ON/OFF, FREQ0/1, and waveform type). After selecting the setting to be changed, pressing the encoder will either change the setting (if ON/OFF or FREQ0/1 has been selected), or you can change the setting’s value by rotating the encoder (rotating increments/decrements the current digit or changes the waveform type, depending on the chosen setting). Pressing again applies the setting (for waveform type) or goes to the next digit (for frequency).

I have tried to make the code as concise as possible, and comments are available to help you understand my thought process. If you have any questions, do not hesitate to leave a comment or contact me.

I sincerely hope that everything goes smoothly and you will be able to enjoy your very own Arbitrary Waveform Generator.

Pages: 1 2 3 4 5 6 7 8

 


Top