Dual Channel Alternating Basic Sine Waves and Ramp Waveforms -
This example is demonstrates many of the same methods and properties as the first example. You should familiarize yourself with that example before following this example, which will only explain the additional sections necessary for dual channel setup. The primary difference in this example is that you will specify a channel and then download waveforms to each channel. If you are unsure of any of the methods or properties please refer to them in the detailed descriptions in the Methods and Properties sections.
This example uses the paging feature to alternate the output between two sine waveforms of differing frequencies on one channel and between two ramp waveforms of differing slopes on the other channel.
For convenience here is the source code:
Waveform Setup for First Page
awg.user_page = 0; ... [marker definitions] ...
Channel A Waveform
awg.channel_select = 0; awg.code = (unsigned) WAVEFORM_CODE::SIN_AB; awg.data_length = 0x2000; awg.waveform_parameter_u0 = 1; awg.waveform_parameter_u1 = 0x10;
All of the above code defines a simple sine wave that is 1/16ths of the output samping
rate with Data Length 2000 (hex). For the AWG252, AWG452, AWG272, and AWG472, the output sampling rate corresponds 1:1
with the input clock frequency. For the AWG801, the output samping rate is twice
the input clock frequency. Please refer to the
Properties section for a detailed description of each property.
Channel A Download
Downloads the waveform you specified to the hardware.
awg.stop(); awg.download();
Channel B Waveform
awg.channel_select = 1; awg.code = (unsigned) WAVEFORM_CODE::RAMP; awg.data_length = 0x2000; awg.waveform_parameter_u0 = 2; awg.waveform_parameter_u1 = 1;
All of the above code defines a simple ramp waveform with Data Length 2000 (hex).
The data length of each user page is determined by the data length of the waveform downloaded to Channel B on that user page. If the data lengths of the waveforms downloaded to Channels A and B are different, the output of Channel A may be padded or truncated, so we recommend that you use the same data lengths for each channel on a given user page. The markers and some timing signals are also downloaded to Channel B, so please use Channel B if you wish to use only one channel.
Channel B Download
awg.stop(); awg.download();
Waveform Setup for Second Page
awg.user_page = 1; ... [marker definitions] ...
Now we will use the second user page.
Channel A Waveform
awg.channel_select = 0; awg.code = (unsigned) WAVEFORM_CODE::SIN_AB; awg.data_length = 0x4000; awg.waveform_parameter_u0 = 1; awg.waveform_parameter_u1 = 0x40;
All of the above code defines a simple sine wave that is 1/64ths of the output samping
rate with Data Length 4000 (hex). This data
length is different from the data length used on the first user page.
Channel A Download
awg.stop(); awg.download();
Channel B Waveform
awg.channel_select = 1; awg.code = (unsigned) WAVEFORM_CODE::RAMP; awg.data_length = 0x4000; awg.waveform_parameter_u0 = 1; awg.waveform_parameter_u1 = 1;
All of the above code defines a simple ramp waveform with Data Length 4000 (hex), which is twice the data length of the ramp on the first user page. This ramp has half the slope of the ramp on the first user page.
Again, we matched the data lengths of the waveforms in Channels A and B.
Channel B Download
awg.stop(); awg.download();
and Start Waveforms
First, the module will output the waveform in the first page (Sine 1/16ths of clock frequency on Channel A and a Ramp on Channel B) for 5 seconds.
awg.user_page = 0; awg.stop(); awg.flush(); awg.restart(); Thread::Sleep( 5000 );
The first four lines above should be used every time you want to run a downloaded waveform. The stop function stops all activity on the AWG board. The flush function resets the memory address to 0. The restart function sends the signal to run the AWG memory and start the waveform.
Next, the module will output the waveforms in the second page (slower sine and slower ramp) for 5 seconds.
awg.user_page = 1; awg.stop(); awg.flush(); awg.restart(); Thread::Sleep( 5000 );
Finally, the module will alternate between the two pages repeatedly for 1 second each by switching the user page every second.
while( 1 )
{
awg.user_page = 0;
Thread::Sleep( 1000 );
awg.user_page = 1;
Thread::Sleep( 1000 );
}
Now you are ready to try the example code. Ensure that your module is set up with the proper clock and power sources, with a small fan blowing air across the module, and with a USB connection to your computer. Ensure that your compiler is set up with Common Language Runtime Support and with the Multi-threaded DLL Runtime Library, and, most importantly, ensure that your solution references the API Euvis_Module_V1p2.dll.
Compile the example code. Ensure there is a copy of the module signature file AWGyyy_SGN_xxx.dat, where the three digits xxx should be replaced by the serial number of your module(s) and yyy should be replaced by 272 or 472 in the specified directory, and run the example file. If you have connected the module outputs to your spectrum analyzer or oscilloscope, you should see the example waveforms as depicted in the following images: sine on Channel A and ramp on Channel B.