www.vtiinstruments.com
EX1200-1538: Programming the Instrument
55
::CoUninitialize();
printf("\nDone - Press Enter to Exit");
getchar();
return 0;
}
A
NALOG
O
UTPUT
F
UNCTION
This example illustrates the DAC functionality of EX1200-1538. Channel-1is configured to
produce voltage output and channel-2 is configured to produce current output. The channels are
configured to produce 2 V and 10 mA respectively.
Visual Studio C++
// Analog Output.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#import "IviDriverTypeLib.dll" no_namespace
#import "VTEXMultifunction.dll" no_namespace
using namespace std;
//This example explains how to program voltage and current output using Multifunction
DAC
int _tmain(int argc, _TCHAR* argv[])
{
::CoInitialize(NULL);
try
{
IVTEXMultifunctionPtr mfunction(__uuidof(VTEXMultifunction));
try
{
mfunction->Initialize("TCPIP::10.30.1.16::INSTR", VARIANT_TRUE,
VARIANT_TRUE, "");
//Any channel can be configured for voltage or current
mfunction->Dac->Channels->Item["DAC1"]->DriveMode =
VTEXMultifunctionDacDriveModeVoltage;
mfunction->Dac->Channels->Item["DAC1"]->Voltage = 6.6;//Voltage in volts
mfunction->Dac->Channels->Item["DAC1"]->Enabled = true;//Start giving out
the voltage
cout<<mfunction->Dac->Channels->Item["DAC1"]->DriveMode<<endl;
cout<<mfunction->Dac->Channels->Item["DAC1"]->Voltage<<endl;
cout<<mfunction->Dac->Channels->Item["DAC1"]->Enabled<<endl;
mfunction->Dac->Channels->Item["DAC2"]->DriveMode =
VTEXMultifunctionDacDriveModeCurrent;
mfunction->Dac->Channels->Item["DAC2"]->Current = 0.003;//Current in Amperes
mfunction->Dac->Channels->Item["DAC2"]->Enabled = true;//Start giving out
the voltage
}
catch (_com_error& e)
{
::MessageBox(NULL, e.Description(), e.ErrorMessage(), MB_ICONERROR);