Sections of the site
Editor's Choice:
- Tortilla - what kind of Mexican dish is it and how to properly prepare it at home with photos
- Wheat tortilla Homemade tortilla recipe
- Calorie content of 1 eclair with custard
- Canned fish soup sardines with rice
- Dance with a woman in a dream
- Why dream of dancing with a guy
- Death tarot meaning in relationships
- Knight of Wands: meaning (Tarot)
- Read a love spell on a married man at a distance without a photo
- Dishes with porcini mushrooms. Recipes. Pickled boletus mushrooms for the winter - a step-by-step recipe with photos on how to pickle at home
Advertising
Generator circuits on an LCD microcontroller. Digital Function Generator DDS |
Recently, digital frequency synthesis (DDS) methods have become widespread, and the implementation methods are very diverse. The method and method of implementation depends on the requirements for the generator.
F max = 16000000Hz(atmega frequency) We take 15 cycles to change the phase accumulator, sample from the LUT and output. Total Fclk=16000000Hz/15=1066666.6667Hz For the required accuracy, I chose a 32-bit phase accumulator. Now let's calculate the minimum step: Step(Hz)= 1066666.6667Hz/(2^32)= 0.0002483526865641276041667(Hz) The generator code itself: while (1)( #asm ADD R1,R6 ADC R2,R7 ADC R3,R8 ADC R4,R9 #endasm PORTC=LUT_of_Signal; At 50000Hz, the signal per period will be formed by ~21 voltage changes at the DAC output. As a DAC, I chose a regular R-2R matrix - it does not require strobes and 8 bits completely satisfy the conditions. Those. (|12|+|-12|) / 2^8 = 0.09375~ 0.1V For convenience and speed of frequency adjustment, I used a valcoder, according to the scheme proposed by the radio amateur VK6BRO, from a stepper motor. To prevent false positives from the valcoder, the controller checks the directions several times during steps and only then records the changes.
I also added the function of scanning a given frequency range with an adjustable step. The step is set to 0.01Hz-0.1Hz-1Hz-10Hz-100Hz and vice versa. For ease of display and ease of writing the program, I used an LCD from Nokia 3310 (84x48). As the encoder itself I used a bipolar stepper motor from an old hard drive. I simulated the entire device and program in Proteus. Analogue part of the generator![]() Since the DAC produces a unipolar signal and the idea was to create a bipolar generator, it is necessary to use a bias on the amplifier. I chose TL431 as the voltage reference source. I implemented the amplifier itself on 2 stages. To enhance the load capacity, I used a voltage follower on the TDA2030A chip. ![]() The signal at the output of device U3 repeats the input signal in shape and amplitude, but has greater power, i.e. the circuit can operate on a low-impedance load. The repeater is used to increase the output power of the low-frequency generator (so that loudspeaker heads or acoustic systems can be directly tested). The repeater operating frequency band is linear from DC to 0.5...1 MHz, which is more than enough for a low-frequency generator. Power source - any (pulse or linear), preferably stabilized with +5, +12/-12V supplies. About the assemblyThere were no particular problems during assembly; the setup involved adjusting the analogue part of the symmetry and amplitude of the output signal. The bias is adjusted by resistors R1 and R6. The amplitude of the first stage is R5, the second is R8.This DDS function generator (version 2.0) of signals is assembled on an AVR microcontroller, has good functionality, has amplitude control, and is also assembled on a single-sided printed circuit board. This generator is based on the Jesper DDS generator algorithm, the program has been modernized for AVR-GCC C with assembly code inserts. The generator has two output signals: the first is DDS signals, the second is a high-speed (1..8 MHz) “rectangular” output, which can be used to revive the MK with incorrect fuzzes and for other purposes. Main characteristics of DDS generator V2.0: The block diagram below shows the logical structure of a function generator: As you can see, the device requires several supply voltages: +5V, -12V, +12V. Voltages +12V and -12V are used to regulate signal amplitude and offset. The power supply is designed using a transformer and several voltage stabilizer chips: The power supply is assembled on a separate board: If you don’t want to assemble the power supply yourself, you can use a regular ATX power supply from a computer, where all the necessary voltages are already present. . LCD screen All actions are displayed via an LCD screen. The generator is controlled by five keys The up/down keys are used to move through the menu, the left/right keys are used to change the frequency value. When the center key is pressed, the selected signal begins to be generated. Pressing the key again stops the generator. A separate value is provided to set the frequency change step. This is convenient if you need to change the frequency over a wide range. The noise generator does not have any settings. It uses the usual rand() function, which is continuously fed to the output of the DDS generator. The HS high speed output has 4 frequency modes: 1, 2, 4 and 8 MHz. Schematic diagram The function generator circuit is simple and contains easily accessible elements: Pay: The functional generator is assembled in a plastic box: ![]() Software As I said above, I based my program on the Jesper DDS generator algorithm. I added a few lines of assembly code to implement the generation stop. Now the algorithm contains 10 CPU cycles, instead of 9. void static inline Signal_OUT(const uint8_t *signal, uint8_t ad2, uint8_t ad1, uint8_t ad0)( The table of DDS signal forms is located in the flash memory of the MK, the address of which starts at 0xXX00. These sections are defined in the makefile, in the appropriate memory locations: You can take the library for working with LCD. I don't want to go into a detailed description of the program code. The source code is well commented (though in English) and if you have any questions about it, you can always use ours or in the comments to the article. Testing I tested the generator with an oscilloscope and a frequency counter. All signals are well generated over the entire frequency range (1...65535 Hz). Amplitude and offset adjustments work fine. In the next version of the generator I am thinking of implementing a rising sine wave signal. The latest version of the software (), source, files can be downloaded below. List of radioelements
I've been using the signal generator for a long time now. UDB1005S, built according to DDS technology, it was bought on Ali for $30. In short, the series UDB100 x includes 3 models UDB1002, UDB1005, UDB1008, the last digit determines the maximum operating frequency, and the letter S at the end, if present, indicates that the generator supports sweep_mode. The generator is based on a combination of plis + micron, micron serves the periphery (buttons, encoder, display), and the plis generates the signal. Now let's look at the main features. Analogue output:
Concerning sweep frequency generator, to configure it you need to set two frequency values and the time during which the generator frequency will change from fM1 to fM2. This is very convenient if you need to find out how a circuit reacts to different frequencies, for example, using a sweep frequency generator you can easily find the resonant frequency of a circuit with unknown elements. To do this, we connect the generator to the circuit through a series-connected resistor with a nominal value of several hundred Ohms, and connect the oscilloscope probe to the terminals of the circuit. If the circuit is serial, then at the resonant frequency the oscillation amplitude will be maximum, and if it is parallel, it will be minimum. By recording the amplitude on the oscilloscope screen, you can find out the resonant frequency of the circuit. But I will not deviate from the topic; below I will give several oscillograms for different types of oscillations and different frequencies. Sine 10KHz Sine 100KHz Sine 1MHz Sine 5MHz Saw 1KHz Saw 10KHz Saw 100KHz Saw 1MHz Saw 5MHz You can also change the inclination of the saw Square wave 1KHz Square wave 10KHz Square wave 100KHz Square wave 1MHz Square wave 5MHz Square wave 100KHz with TTL output Square wave 1MHz with TTL output Square wave 5MHz with TTL output The oscillograms show that the frequency stability is very different from the declared one; I would also like to note that if the frequency of the rectangular signal exceeds 1MHz, the signal begins to tremble strongly. All of the above can be attributed to advantages, but what can you want from a signal generator for $30? And now the downsides, there are only two of them for what..... but this is a small thing compared to adjusting the amplitude; when you rotate the amplitude adjustment knob, the latter changes abruptly, therefore it is very difficult to set the desired amplitude with an error of 100mV. A quick search on YouTube for “signal generator from Ali” showed that a signal generator whose amplitude can be precisely set is much more expensive, so in terms of price-capability ratio this generator is unrivaled. Continuing the topic of electronic constructors, this time I want to talk about one of the devices for replenishing the arsenal of measuring instruments for a novice radio amateur. Quite often, radio amateurs, and not only others, have to face the need to check various electronic devices. This happens both at the debugging stage and at the repair stage. To begin with, it’s worth explaining a little about what will be discussed in this review. There are different generators, for example below are also generators :) But we will assemble a signal generator. I've been using an old analog generator for many years. In terms of generating sinusoidal signals, it is very good, the frequency range is 10-100000 Hz, but it is large in size and cannot generate signals of other forms. As always, first, a little about packaging. Inside the package, the components were just loose, and when unpacked they looked something like this. The display was wrapped in bubble polyethylene. About a year ago I already made such a display using it, so I won’t dwell on it, I’ll just say that it arrived without incident. Separately, on a small piece of polyethylene foam there were microcircuits and sockets for them. The second chip is a dual operational amplifier LM358. The most common, widespread, operational amplifier. First, let's lay out the entire set and see what they gave us. Printed circuit board with double-sided printing, on the top side there are markings of elements. The metallization was done with high quality, I had no comments, the coating of the contact pads was excellent, and soldering was easy. The transitions between the sides of the print are made double. First, I started drawing a circuit diagram using the printed circuit board. But already in the process of work, I thought that some already known scheme was probably used when creating this constructor. Since we’re talking about it, it’s worth describing the functional units of this circuit and describing some of them in more detail. On the author's page, in addition to the diagram, firmware, etc. A block diagram of this device was discovered. We are done with the main part of the description, the expanded part will be further in the text, and we will move directly to the assembly. This time I used a slightly different installation technology. I like it less than the previous ones, but it also has the right to life. In some cases, this technology speeds up installation, especially on a large number of identical elements. On the reverse side, the leads are bent a little, but not much, the main thing is that the elements do not fall out, and the board is placed on the table with the leads facing up. Next, take the solder in one hand, the soldering iron in the other, and solder all the filled contact pads. At the end, we bite off the protruding leads of the components close to the solder. Side cutters can grab several leads at once (4-5-6 pieces at a time). Among the advantages: This installation method can often be found in cheap computer power supplies, although the leads are not bitten off, but cut off with something like a cutting disk. After installing the main number of resistors, we will have several pieces of different values left. We solder the last resistors, the board should look something like this after that. Color-coded resistors are a good thing, but sometimes there is confusion about where to count the beginning of the marking. To make the marking easier to recognize, the last stripe should be spaced apart from the rest, but this is ideal. In real life, everything happens completely differently from what was intended and the stripes are in a row at the same distance from each other. Okay, we’re done with resistors and their marking difficulties, let’s move on to simpler things. I talked about capacitors and a quartz resonator in the previous review, so I’ll just show you where they should be installed. Included with the microcircuits were a couple of sockets and several connectors. The sockets for installing microcircuits were the most ordinary, although when compared with the sockets from the times of the USSR, they were chic. When installing the sockets, we install them in the same way as the designation on the printed circuit board. After installing the panels, the board begins to take on some form. The device is controlled using six buttons and two variable resistors. I wrote above that the kit included two variable resistors, and the kit also included a trimming resistor. I'll tell you a little about these components. Also included was one trim resistor. in essence, it is the same as a variable, only it is not designed for operational adjustment, but rather, set it and forget it. We solder the resistors and buttons and move on to the BNC connectors. Although the BNC connectors are simpler than those in the oscilloscope review, I liked them better. The actual soldering of the main board is complete, now you can install the operational amplifier and microcontroller in place. Before installation, I usually bend the pins a little so that they are closer to the center of the chip. This is done very simply: take the microcircuit with both hands by the short sides and press it vertically with the side with the leads against a flat base, for example, against a table. You don’t need to bend the leads very much, it’s more a matter of habit, but then installing the microcircuit into the socket is much more convenient. We install the microcircuits in accordance with the key on the socket, which in turn is installed in accordance with the markings on the board. Having finished with the board, we move on to the display. That's it, you can wash the board. This time I decided to do it before testing, although I usually advise doing the flushing after the first turn on, since sometimes you have to solder something else. You can wash it in different ways and means, some use alcohol, some use an alcohol-gasoline mixture, I wash the boards with acetone, at least for now I can buy it. In my work, I have developed the habit, after washing the board, of covering it with protective varnish, usually from the bottom, since getting varnish on the connectors is unacceptable. After varnishing, the board becomes more glossy and pleasant to the touch, and there is a certain feeling of completion of the process :) Now it's time to install the display. To do this, the kit included four M3 screws and two mounting posts. We install the racks on the main board, then install the display, and at the end we fix this entire structure using the two remaining screws. Well, that's it, you can try. Then I would have moved on to testing, but that was not the case. If there were no problems with 5 Volts, and with +12 Volts as well, then -12 Volts became a small problem. I had to make a small temporary power supply. Since I had a transformer with only one winding, and I didn’t want to fence the impulse generator, I decided to assemble the power supply according to a circuit with doubling the voltage. I also supplied almost no reserve. But at the same time it is sufficient at normal mains voltage. As a result, I came up with a small scarf, slightly larger in size than a matchbox, mostly in height. The layout of the board at first glance may seem somewhat strange, since it was possible to rotate the transformer 180 degrees and get a more accurate layout, which is what I did at first. This is what the complete set of the device looks like. To connect the power supply to the device board, I soldered a small 4x4 pin hard connector. The power supply board is connected using a connector to the main board and now you can proceed to a description of the operation of the device and testing. The assembly is complete at this stage. Before testing begins, I will describe the controls and capabilities of the device. 1. Triangular 1-2. You can change the frequency at the DDS output in the range 1-65535Hz in 1Hz steps There are also two variable resistors on the board. Test results will follow. Sawtooth Reverse sawtooth Triangular Rectangular with DDS output Cardiogram Rectangular with RF output Noise-like in two scanning modes of the oscilloscope, so that it is more clear what it is. Testing has shown that the signals have a rather distorted shape starting from about 10 kHz. At first I was guilty of the simplified DAC, and the very simplicity of the synthesis implementation, but I wanted to check it more carefully. Well, a group photo of a small “stand” of a novice radio amateur :) Summary. Minuses My opinion. One can, of course, say that the characteristics of the device are very poor, but it is worth considering that this is a very entry-level DDS generator and it would not be entirely correct to expect anything more from it. I was pleased with the quality of the board, it was a pleasure to assemble, there was not a single place that had to be “finished.” In view of the fact that the device is assembled according to a fairly well-known scheme, there is hope for alternative firmware that can increase functionality. Taking into account all the pros and cons, I can fully recommend this set as a starter kit for beginner radio amateurs. Phew, that seems to be it, if I messed up somewhere, write, I’ll correct/add it :) The product was provided for writing a review by the store. The review was published in accordance with clause 18 of the Site Rules. I'm planning to buy +47 Add to favorites I liked the review +60 +126Maximum frequency - 65534 Hz (and up to 8 MHz HS output with square wave). And then I thought that a generator is an excellent task where the FPGA can show itself at its best. As a matter of sport, I decided to repeat the project on FPGA, while meeting the deadlines within two weekends, and getting the parameters not strictly defined, but the maximum possible. You can find out what came out of this under the cut. Day zeroBefore the weekend arrived, I had some time to think about the implementation. To simplify my task, I decided to make the generator not as a separate device with buttons and an LCD screen, but as a device that connects to a PC via USB. For this I have a USB2RS232 board. The board does not require drivers (CDC), therefore, I think it will work under Linux (for some this is important). Also, I will not hide that I have already worked with receiving messages via RS232. I will take ready-made modules for working with RS232 from opencores.com.To generate a sine wave signal you will need a DAC. I chose the DAC type, as in the original project - R2R 8-bit. It will allow you to operate at high frequencies, on the order of megahertz. I am convinced that the FPGA should cope with this I was thinking about how to write a program for transmitting data via a COM port. On the one hand, you can write in Delphi7; you already have experience writing such a program, and besides, the size of the executable file will not be large. I also tried to sketch out something to work with Serial in the form of a java script in an html page, but it more or less worked only through the Chrome serial API, but for this you need to install a plugin... in general, it’s also out of the question. I tried PyQt5 as an innovation for myself, but when distributing such a project, you need to drag a bunch of libraries. Having tried to compile a PyQt project into an exe file, it turned out to be more than 10 MB. That is, it will be no better than an application written in C++\Qt5. It’s also worth considering that I don’t have experience developing in python, but I do have experience in Qt5. Therefore, the choice fell on Qt5. Since the fifth version, a module for working with serial appeared and I have already worked with it. And an application based on Qt5 can be transferred to Linux and Mac (for some this is important), and from version 5.2, applications based on QWidgets can even be transferred to a smartphone! The first dayDue to the fact that I had already made the DDS module in my synthesizer project, I immediately took up the soldering iron and started soldering the DAC with resistors. I took a prototype board. The installation was done using wrapping. The only change that affected the technology was that I abandoned the F38N acid for tinning the stands in favor of the TT indicator flux gel. The essence of the technology is simple: I solder racks into a printed circuit board, and solder resistors on them from the printed circuit board side. I make the missing connections by twisting. Also, the racks are convenient because I can insert them directly into the FPGA board.Unfortunately, there were no 1 and 2 kilo-ohm resistors available at home. There was no time to go to the store. I had to give up one of my rules and remove resistors from the old unnecessary board. 15K and 30K resistors were used there. The result is this Frankenstein: After creating the project, you need to set the target device: Menu Assigments -> Device In the project, I coded the uncontrollable main DDS module to a fixed frequency. 1000 Hz Generator Module module signal_generator(clk50M, signal_out); input wire clk50M; wire output signal_out; wire clk200M; osc osc_200M reg accumulator; assign signal_out = accumulator; //try to generate 1000 Hz //50,000,000 Hz - clock frequency of the external generator //2^32 = 4,294,967,296 - DDS bit depth - 32 bits //divide 1000Hz / 50,000,000 Hz / 2 * 4294967296 => 42949, 67296 always @(posedge clk50M) begin accumulator<= accumulator + 32"d42949; end endmodule After that, I clicked “Start Compilation” so that the development environment would ask what input/output lines we have in the main module of the project and what physical PINs they are connected to. You can connect to almost anyone. After compilation, we assign the lines that appear to the real PINs of the chip FPGA: Menu item Assigments -> Pin Planner Please ignore the HS_OUT, key0 and key1 lines for now, they appear in the project later, but I didn’t have time to take a screenshot at the very beginning. In principle, it is enough to “register” only PIN_nn in the Location column, and the remaining parameters (I/O standard, Current Strench and Slew Rate) can be left by default, or you can select the same ones that are offered by default (default) so that there is no warning "ov. How can I find out which PIN corresponds to the connector number on the board? The connector pin numbers are marked on the board And the FPGA pins to which the connector contacts are connected are described in the documentation that comes with the FPGA board. After the pins are assigned, I compile the project again and flash it using a USB programmer. If you do not have drivers installed for the USB Byte blaster programmer, then tell Windows that they are located in the folder where you have Quartus installed. Then she will find it herself. The programmer must be connected to the JTAG connector. And the menu item for programming is “Tools -> Programmer” (or click the icon on the toolbar). The “Start” button, the joyful “Success” and the firmware are already inside the FPGA and are already working. Just don’t turn off the FPGA, otherwise it will forget everything. Tools -> Programmer The DAC is connected to the FPGA board connector. I connect an oscilloscope S1-112A to the DAC output. The result should be a “saw” because the high-order part of the DDS word of the phase accumulator is output to the 8-bit output. And it always increases until it overflows. Some 1.5 hours and for a frequency of 1000 Hz I see the following oscillogram: I would like to note that the “saw” has a small fracture in the middle. It is due to the fact that resistors have a range of values. Another important point that needed to be clarified is the maximum possible frequency with which the DDS generator will operate. With correctly configured TimeQuest parameters, after compilation in the “Compilation Report” you can see that the speed of the circuit is above 200 MHz with a margin. This means that I will multiply the generator frequency of 50 MHz by 4 using PLL. I will increase the value of the DDS phase accumulator with a frequency of 200 MHz. The final frequency range that can be obtained under our conditions is 0 - 100 MHz. Frequency setting accuracy: 200,000,000 Hz (clk) / 2^32 (DDS) = 0.047 Hz TimeQuest Timing Analyzer After I saw “saw” on the screen, family matters forced me to go to the country (it was my day off). There I mowed, cooked, barbecued and had no idea about the surprise that was waiting for me in the evening. Closer to night, before going to bed, I decided to look at the signal shape for other frequencies. For frequency 100 kHz For frequency 250 kHz For frequency 500 kHz For 1 MHz frequency Second dayDue to the fact that it was interesting how the DAC would work on resistors of 100 and 200 Ohms, I immediately took up the soldering iron. This time the DAC turned out to be more accurate, and it took less time to install it.We put the DAC on the FPGA board and connect it to the oscilloscope Checking 1 MHz - VO! It's a completely different matter! Saw 10 MHz Saw 25 MHz The shape of the 10 MHz saw is still similar to the correct one. But at 25 MHz it is no longer “pretty” at all. However, the C1-112a has a bandwidth of 10 MHz, so in this case the reason may already be in the oscilloscope. In principle, this issue with the DAC can be considered closed. Now let's take waveforms of the high-speed output. To do this, we will output the most significant bit to a separate PIN of the FPGA. We will take the data for this line from the most significant bit of the DDS accumulator. Assign hs_out = accumulator; Square wave 1 MHz Square wave 5 MHz Square wave 25 MHz The 50 MHz square wave is almost invisible now But I think that the FPGA output should be loaded with resistance. Perhaps the fronts would have been steeper. The sine is done according to the table. The table size is 256 values of 8 bits. It would have been possible to take more, but I already had a ready-made mif file. Using the wizard, we create a ROM element with sine table data from the mif file. Creating a ROM - Tools -> Mega Wizard Plugin manager Select 1 port ROM and give the module a name We agree We agree here too Using browse, we find our mif file with the sine table We don’t change anything here either. Uncheck the module sine_rom_bb.v - it is not needed. Next finish. Quartus will ask to add a module to the project - we agree. After this, the module can be used just like any other module in Verilog. The upper 8 bits of the DDS accumulator word will be used as the ROM address, and the data output will be the sine value. Code //sine rom wire sine_out; sine_rom sine1(.clock(clk200M), .address(accumulator), .q(sine_out)); The oscillogram of a sine wave at different frequencies looks... the same. If desired, you can consider DAC problems associated with resistor spread: Well, that's the end of the weekend. But software for control from a PC has not yet been written. I am forced to admit the fact that I did not meet the planned deadlines. Day threeThere is very little time, so we write the program in a hurry (in the best traditions). In some places, in order to reduce the number of letters and the convenience of entering information from the keyboard, an event filter is used by the widget name. Please understand and forgive.Interface Links with analoguesNot a complete listFunctional DDS generator. Created based on AVR. Frequencies 0… 65534 Hz. Review of DDS generator GK101. Created using Altera MAX240 FPGA. Frequencies up to 10 MHz. Multifunction generator on PIC16F870. Frequency range: 11 Hz - 60 kHz. generators Add tags |
Read: |
---|
Popular:
New
- Wheat tortilla Homemade tortilla recipe
- Calorie content of 1 eclair with custard
- Canned fish soup sardines with rice
- Dance with a woman in a dream
- Why dream of dancing with a guy
- Death tarot meaning in relationships
- Knight of Wands: meaning (Tarot)
- Read a love spell on a married man at a distance without a photo
- Dishes with porcini mushrooms. Recipes. Pickled boletus mushrooms for the winter - a step-by-step recipe with photos on how to pickle at home
- Grilled chicken - step-by-step marinade recipes and cooking technology in the oven, microwave or frying pan