A PIC controlled DDS-60 signal generator.


[ Home ]

Having confirmed that my DDS-60 was fully functional, the next step was to produce a portable 12V operated signal generator using a PIC microcontroller to provide the human interface. I had already played around with emulated DDS using a microprocessor. For more on this see  DDS Signal Generator using AVR & PIC micros  With some minor modifications the hardware and software from that project could form the basis of a DDS-60 controller. If you compare the hardware and software for the two projects the similarity will be immediately apparent.

As with the previous project a PIC16F876 was chosen as having sufficient port pins available for the job. Here is the hardware schematic.

The PIC  is clocked at 4 MHz. Speed is not an issue in this application. The PIC monitors a total of 9 miniature push switches. 8 of these change the frequency in 1Hz, 10Hz, 100Hz, 1KHz, 10KHz, 100KHZ, 1 MHz or 10MHz  steps. The 9th switch is an up/down switch. If this is held pressed then the frequency switches decrement instead of incrementing. An audible beep provides feedback on switch action. The frequency switches have an auto repeat action if held down. The frequency is displayed on a 2 x 16 LCD display.

Note that the frequency displayed is not measured by a frequency counter as it would be in a normal analogue generator. It is simply the contents of a binary counter incremented or decremented by the frequency switches. The PIC then calculates what phase increment the DDS-60 will require to generate this frequency and sends this via the serial interface.

The PIC software is written for compatibility with Microchip's MPLAB assembler MPASM. The required arithmetic for the DDS calculations is implemented in 64 bit fixed point for simplicity. The assembly code is well commented. 

The on-board clock module of the DDS-60 has no provision for fine frequency adjustment. On my unit the nominal 30MHz oscillator was found to be 1200Hz low in frequency. To overcome this the frequency of the oscillator module is stored in EEPROM and loaded from there at switch-on. When the PIC is programmed this is preset to 30MHz. This can be modified by holding down the up/down button at switch-on. The value can then be incremented / decremented with the 1 Hz or 10Hz buttons in conjunction with the up/down button. The nominal and new values are both displayed on the LCD. The new value is stored in EEPROM. The unit must be switched off and on again to use the new value.

The first step taken by the program is to calculate the phase accumulator value required by the DDS-60 to generate a frequency of 1 Hz (deltaHz). This is calculated as 232 / (6 * Fclock) which for a nominal Fclock of 30MHz gives a value of 23.860929422222. The program uses the adjusted value for Fclock which results in a slightly different value for deltaHz, the software equivalent of a trimmer capacitor !

To generate any other frequency, the program simply multiplies the frequency (Hz) by deltaHz to produce the phase accumulator value for the DDS-60. Within the program the deltaHz value is scaled by a factor of 100 million to give a nominal value of 2386092942,  this allows the use of fixed point math throughout. I limited the output to allow frequencies between 10KHz and 60MHz. These are easily changed. Above 60MHz waveform purity starts to suffer. Below 10KHz the 0.1uF coupling capacitors are showing some LF droop.

On my unit I routed the DDS-60 output signal through a 2 pole 6 way rotary switch. Position 1 sends the signal directly to the BNC output socket. The other 5 positions each select 1 of 5 pi attenuators of 6, 12,18, 24 or 30dB. The resistors are all mounted directly on the switch making a very compact arrangement. Here is a schematic of the attenuator. 

Performance of the completed unit is excellent, highly accurate and remarkably stable.

A picture of the completed unit

Download the PIC asm and hex files PICDDS60Rev2.ZIP (13Kb)