Alternating Basic Sine Wave and Ramp Waveform -

This example will take you through some of the methods and properties of the API. 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 a sine waveform and a ramp waveform.

For convenience here is the source code:

main.cpp


Object Instantiation

AWG_Group_API	awg_group;
AWG_API		awg;
		

The above code creates an object of the AWG_Group_API class called "awg_group" and an object of the AWG_API class called "awg". When you want to access any of the methods or properties in the AWG_Group_API you must use the "." operator and the "awg_group" object name. For example, if you wanted to read the number of existing AWG modules, you could write the following:

int AWG_totalmodules;
AWG_totalmodules = awg_group.number;
		

When you want to access any of the methods and properties in the Common_API class or the AWG_API class you must use the "awg" object name followed by the "." operator. For example, to set the waveform code you should write the following:

awg.code = (unsigned) WAVEFORM_CODE::SIN_AB;
		

Valid waveform codes are enumerated in the API and should pop up in your programming environment as long as you have already referenced the API.

Board Initialization

int SeriesNumber = awg_group.get_sn(0);
		

Gets the Series Number of the AWG board and stores it into the integer variable "SeriesNumber". The "0" argument is the module's index number. The indicies enumerate the existing AWG modules, starting from 0. The example assumes that there is only one AWG module connected. When there is only one AWG module connected, its index number will always be 0.


awg.ini( SeriesNumber );
		

Initializes the AWG module. This step is very important and must be done before sending any commands to the AWG module of that Series Number. Note that the argument being passed into the function is the Series Number of the board and not the index number.



Board Setup

awg.signature_ini_dir( "C:\\Program Files\\Euvis\\AWG" );
if( !awg.is_signature_file_exist )
{
	...
}
//awg.signature_ini();
awg.Clock_Frequency = 4e9;
		

The signature_ini_dir() function sets the path for the module signature file while the Clock_Frequency sets the input clock frequency. The Clock_Frequency property of course should match your real input clock frequency, and you should ensure there is a copy of the signature file for the module you are using in the directory you specified.


Configuration Setup

awg.memory_depth = 0x100000;
awg.loop_count = 0;


Waveform Setup for First Page

awg.user_page = 0; 
awg.data_length = 0x2000;
awg.waveform_parameter_u0 = 1;
awg.waveform_parameter_u1 = 0x10;
awg.marker1_start = 0x10;
awg.marker1_width = 0x100;
awg.marker2_start = 0x200;
awg.marker2_width = 0x100;
awg.marker3_start = 0x100;
awg.marker3_width = 0x100;
		

All of the above code defines a simple sine wave that is 1/16th of the output samping rate. For the AWG252, AWG452, and AWG272, 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.


Download Waveform on First Page

Downloads the waveform you specified to the hardware.

awg.stop();
awg.download();
		


Waveform Setup for Second Page

awg.user_page = 1;
awg.code = WAVEFORM_CODE::WAVEFORM_RAMP;
awg.data_length = 0x4000;
awg.waveform_parameter_u0 = 1;
awg.waveform_parameter_u1 = 1;
awg.marker1_start = 0x0;
awg.marker1_width = 0x200;
awg.marker2_start = 0x200;
awg.marker2_width = 0x200;
awg.marker3_start = 0x400;
awg.marker3_width = 0x200; 
		

All of the above code defines a simple ramp. Please refer to the Properties section for a detailed description of each property.


Download Waveform on Second Page

Downloads the waveform you specified to the hardware.

awg.stop();
awg.download();
		

and Start Waveforms

First, the module will output the waveform in the first page (Sine 1/16ths of clock frequency) 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 waveform in the second page (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 252, 452, 801, 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 waveform as depicted in the following images: 5 seconds of sine, 5 seconds of ramp, and then both sine and ramp alternating, which are superimposed in the third image.



faster sine

slower ramp

alternating ramp and sine, superimposed