
In amateur radio practice, it is sometimes necessary to have on hand a signal generator of a given shape and frequency for testing and testing radio equipment nodes. With the increasing availability of microcontrollers, it is possible to assemble a digital signal generator, in which any signal would be generated by software.
')


Digital signal generator "Nyx" (nikta). Specifications:
The sampling rate is 131072 Hz.
The range of generated frequencies is 1 - 65536 Hz, with an adjustment step of 1 Hz.
32 bit battery that theoretically allows you to get a resolution of 0.000030518 Hz.
8 bit output, voltage range from -15V to + 15V.
The generator is based on the atmel ATMEGA16 microcontroller, the R-2R network was used as a DAC, the output of which was passed through operational amplifiers, which made it possible to regulate the amplitude of the generated signal and its displacement relative to the ground.
The software was written in C, with insertion in an assembler. The generator works on the principle of direct digital synthesis. You can read the theoretical material on the problems of digital signal synthesis in detail using the links at the end of the original page. The program is structured as follows. In RAM MK allocated array of 256 elements, which stores the value of the generated signal in the amount of one period. Filling the array of values is performed before the start of the synthesis, depending on what signal you need to get at the output. It is this mechanism that makes it possible to describe the generated signal by a formula, and not manually clog the table, as is done in other constructions. After starting the generator 131072, the interrupt starts to trigger once a second, in which the accumulator value increments, the first 8 bits are cut off from the variable value and the corresponding array element is called. The whole process takes 113 microcontroller cycles.
Unlike analogs, the frequency setting is performed from the numeric keypad, and not using the “+” and “-” buttons, which increases the speed of use of the generator. Consider the instrument control interface. How much is necessary to make gestures to set the frequency 32698 Hz? A good idea to use the encoder.
If at the output it is necessary to receive only a sinusoidal signal, then it would be a good idea to install a low-pass filter that would cut off the noise at the harmonics of the sampling rate. But this is unacceptable if the output signal generator has a rectangular signal - the filter will fill up the fronts.


Despite the fact that, according to the Kotelnikov (Nyquist) theorem, for reconstruction with a frequency f, it is necessary to make samples (sampling) with a frequency of 2f, the recoverable signal will have shape distortions. Thus, at least the limiting recoverable frequency is 65536 Hz, in fact, the ceiling is about 20 000 Hz. At high frequencies, the waveform will not resemble a sine wave at all, therefore, when adjusting the circuits, consider this feature.
The keyboard is an incomplete 4 * 4 matrix which is polled dynamically. LCD screen WH1602. The instrument case is industrial, purchased in IEC. Windows sawn Dremel.
Firmware source codeWhat would be nice to do:
1) Implement software or hardware PWM, which will allow you to use the generator to control the power given to the load.
2) Separate separately the high-frequency square signal generated by timers on the MC (frequencies of the order of megahertz)
Original article (as usual will probably fall)