What this function generator can do:
- Generate digital square waves at 512 frequencies between 10MHz and 152 Hz, either directly output from an AVR's pin, or buffered via an op amp (the slew rate of the op amp will determine the upper limit of the square wave output). The square wave output is in the range 0 - 5v. From reading these waves on my logic analyzer, they appear to be well within 0.1% error rate. (The frequencies are selected directly from the calculated timings using TIMER0 CTC mode, so the accuracy should be pretty much as good as you can get with a given crystal).
- Generate a number of sampled waveforms from between 1000Hz and 10Hz (in 2Hz increments). Sampled waveforms include Sine, Triangle, Sawtooth (up and down), Staircase (up and down), and Square. These waveforms are output in (user selectable) 0 - 5v or -5 - 5v range. These waveforms are not quite as accurate as the digital square waves, since there is more work being done by the CPU and the 2Hz increment results in a bit of a rounding error on some of the frequencies. They are still pretty good though (I would say that a very rough estimate is that they are within 1% error rate).
- Generate a PWM signal appropriate for controlling hobby servos. The user selects a PWM phase between 400us and 2600us (in 2us increments), with a set period of 20000us (i.e the standard interface for hobby servos). As with the digital square wave output, this is done mostly with the timer code (albeit with two very short interrupts being added to handle some logic), and so the frequencies are very accurate.
- Generate an output voltage at the specified level (between -5 and 5V or 0 and 5V depending on the position of the range switch).
Future plans include arbitrary PWM waveform generation, where the user can specify the period and phase.
The entire project is placed within a custom built wooden (hickory) enclosure, with a 16x2 text LCD and some buttons for an interface.
Digital to Analog conversion for the sampled waveforms is handled by an R2R ladder constructed by non-precision resistors. The resistors were selected using the algorithm found on http://www.nerdkits.com/forum/thread/1815/ .
can i get the code by arduino?