Generates a point-by-point square wave using direct digital synthesis (DDS). The synthesis runs continuously using the block diagram clock rate to produce a real-time frequency. The block diagram clock rate is the top-level clock rate, unless the Square Wave Generator Express VI is inside a single-cycle Timed Loop configured with a different clock rate.
| Dialog Box Options |
| Block Diagram Inputs |
| Block Diagram Outputs |
| Parameter | Description |
|---|---|
| Square Wave Parameters | Contains the following options:
|
| Output | Contains the following options:
|
| Execution Mode | Contains the following options:
|
| Clock | Contains the following options:
|
| Signal Output Preview | Displays a preview of the configured square wave. |
| Parameter | Description |
|---|---|
| initialize | Sets the VI to the initial state determined by phase offset (scaled). The VI initializes automatically when it first runs. |
| frequency (scaled) | Specifies the scaled output frequency according to the following formula:
frequency (scaled) = [(frequency (Hz)/ FPGA clock rate) * 232] [ ] = rounded to the nearest integer To save FPGA resources, leave the frequency (scaled) input unwired and use the configuration dialog box to specify the frequency. If you change the value of the frequency (scaled) input at run time, the square wave updates on the next call. If you change the frequency, the DDS preserves the position in the period so only the rate changes on the next call. |
| phase offset (scaled) | Specifies the scaled phase offset according to the following formula: phase offset (scaled) = [(phase offset (deg) / 360) * 232] [ ] = rounded to the nearest integer To save FPGA resources, leave the phase offset (scaled) input unwired and use the configuration dialog box to specify the phase offset. If you change the value of the phase offset (scaled) input at run time, the square wave updates on the next call. To avoid glitch conditions, do not change the value of the phase offset (scaled) input by more than the value of the frequency (scaled) input for each call to the VI. |
| duty cycle (scaled) | Specifies the scaled duty cycle according to the following formula: duty cycle (scaled) = [(duty cycle (%) / 100) * 232] [ ] = rounded to the nearest integer To save FPGA resources, leave the duty cycle (scaled) input unwired and use the configuration dialog box to specify the duty cycle. If you change the value of the duty cycle (scaled) input at run time, the square wave updates on the next period edge. |
| amplitude | Specifies the amplitude of the square wave. The default is 32767, so square wave out is either –32767 or 32767. |
| offset | Specifies the DC offset of the square wave. The default is 0. |
| Parameter | Description |
|---|---|
| square wave out | Returns a Boolean or an 8-, 16-, or 32-bit integer containing the square wave output. If the Square Wave Generator Express VI is inside a single-cycle Timed Loop, square wave out is a sample point. If the Square Wave Generator Express VI is outside a single-cycle Timed Loop, square wave out is a level representing the edges. |
Amplitude is the distance between the offset and peak. In the following example, the offset is 5 and the amplitude is 10.
To pass the square wave to an output line, you can wire square wave out to an I/O resource using the FPGA I/O Node.
Over time, the Express VI returns the expected period length and frequency. However, some jitter might occur. For example, suppose you want to create a 6.25 MHz square wave using a 40 MHz top-level clock. In this case, a clock cycle is 25 ns and a square wave period is 160 ns, so the average square wave period should be 6.4 clock cycles long. Each square wave period is an integer number of cycles, but the Express VI returns period lengths of 6, 6, 6, 7, and 7. As a result, the average period length is 6.4 clock cycles, and the average frequency is 6.25 MHz.
If you place the VI outside a single-cycle Timed Loop and run the VI with an FPGA target emulator, the timing is not precise. So, the VI returns a square wave that alternates between the high and low value.