Example Waveform -

This example will demonstrate the DSM operating in Master Free Run Mode. The entire project can be downloaded here.

For convenience here is the source code:

main.cpp

Code Breakdown

Namespaces

using	namespace	MOL;
using	namespace	MOL::DSM;
using	namespace	System::Threading;

#include <stdio.h>;

This section includes all of the namespaces that will be used in the program. The "MOL" and "MOL::DSM" namespaces are from the API, while the System::Threading namespace is from the .NET Framework. The "#include" is used for unmanaged code.


Instantiating Objects

DSM_Group_API	dsm_group;
DSMX		dsm;

Creates a "dsm_group" instance of the DSM_Group_API object and a "dsm" instance of the DSMX object.


Obtaining Number of Boards

if( dsm_group.number == 0 )
{
	printf( "No Module Exists!!\n" );
	return 1;
}

This section obtains the number of boards connected to the computer and if there are none then the program will display an error message.


Hardware Initialization

int	SeriesNumber = dsm_group.get_sn(0);
dsm.ini( SeriesNumber );

This section initializes the DSM and prepares it to receive instructions from the computer.


Hardware Model Check

if( dsm.module_id_number != (unsigned)MODULE_ID::DSM303 )
{
	printf( "Got ID number: %d\n", dsm.module_id_number );
	printf( "No DSM Module Exists!!\n" );
	return 1;
}

Checks to see if the hardware will be compatible with the software. If the hardware model is not correct, then the program will display an error message.


Signature Initialization

dsm.signature_ini_dir( "C:\\bin" );
if( !dsm.is_signtaure_file_exist )
{
	printf( "There is no signature file exist in the program folder\n" );
	return 1;
}
dsm.Clock_Frequency = 2e9;

Loads the signature data from the signature file located in the "bin" folder of C: drive. The is_signature_file_exist is checked to make sure that the correct signature file has been found. Once the "Clock_Frequency" property is set, the DSM will load the signature data to the module for that frequency.


Configure Control Settings

dsm.memory_depth	= 0x10000;
dsm.loop_count		= 0;
dsm.dds_reset_by_memory	= true;

Sets the various control settings of the DSM. For this waveform, the module will be in Continuous mode since loop count is set to "0" and phase reset from memory is enabled.


Pre-Waveform User Page Selection

dsm.user_page = 0;

Sets user page to the first page.


Waveform Parameter Definition

dsm.user_page 		= 0;
dsm.code		= (int) WAVEFORM_CODE::LINEAR_CHIRP;
dsm.delay		= 0;
dsm.data_length 	= 0x48;
dsm.chirp1		= 0x1000000;
dsm.chirp2		= 0x10000000;
dsm.chirp3		= 0x1000000;
dsm.RESET_T1		= 0;
dsm.RESET_T2		= 5;
dsm.RESET_T3		= 3;
dsm.marker_start	= 0x0;
dsm.marker_width	= 0x10;
dsm.marker_enabled	= true;
dsm.marker_polarity	= true;

Sets the various parameters to define the content of the waveform. Note that the "user_page" is set to 0 meaning the first page. The second waveform will set the "user_page" to 1 which is the second page.


Download Waveform to Board

dsm.stop();
dsm.flush();
dsm.download();

The program will stop the memory, reset the memory address to zero and download the waveform data to the hardware.


Start Waveform Output

dsm.stop();
dsm.flush();
dsm.restart();

The program will stop the memory, reset the memory address and start the memory counter so that the waveform output will begin.