www.vtiinstruments.com
EX1200-1538: Programming the Instrument
39
T
OTALIZE
F
UNCTION
This example counts (totalize) the rising and falling edges of a ±19 V sine wave.
Visual Studio C++
// Totalize Measurement.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#import "IviDriverTypeLib.dll" no_namespace
#import "VTEXMultifunction.dll" no_namespace
//This example counts the Rising and Falling edges of the sinewave ±19 volts.
//This example can be also used for Edge count measurement
int _tmain(int argc, _TCHAR* argv[])
{
::CoInitialize(NULL);
try
{
IVTEXMultifunctionPtr mfunction(__uuidof(VTEXMultifunction));
try
{
mfunction->Initialize("TCPIP::10.20.11.158::INSTR", VARIANT_TRUE,
VARIANT_TRUE, "");
//Differential measurement
//EX1200-1538 has only two voltage ranges - 48V and 100mV. Since the sine
wave is of ±19 volts, 48V range is being used.
//This example uses AC coupling to cutoff offset voltage in the sinewave.
//Analog channels Configuration
mfunction->Counter->Channels->Item["CH2"]->ConfigureInput(VARIANT_TRUE,
VTEXMultifunctionCounterInputTypeAnalog,
VTEXMultifunctionCounterInputModeDifferential, 48,
VTEXMultifunctionCounterCouplingAC);
mfunction->Counter->Channels->Item["CH2"]->Function =
VTEXMultifunctionCounterFunctionTotalize;
//Totalize measurement setting
/* You can also work with the following functions by changing the channel
function
* VTEXMultifunctionCounterFunctionEdgeCount
*/
//±5V hysteresis for measuring the sine wave.
mfunction->Counter->Channels->Item["CH2"]->ConfigureThreshold(0, 5,
VTEXMultifunctionCounterSlopePositive);
//Polarity setting will NOT have any effet on totalize measurement, since
it counts both the rising and falling edges.
//But in case of Edgecount measurement, normal polarity will count rising
edges and inverse polarity will count falling edges.
mfunction->Counter->Channels->Item["CH2"]->Polarity =
VTEXMultifunctionCounterPolarityNormal;
//This measures the frequency between 5000Hz and 1Hz.
mfunction->Counter->Channels->Item["CH2"]->UpperFrequencyLimit = 5000;
//Maximum frequency of 5000Hz
mfunction->Counter->Channels->Item["CH2"]->LowerFrequencyLimit = 1;
//Lower frequency of 1Hz
//Enable Fifo for the channels
mfunction->Counter->Channels->Item["CH2"]->FifoEnabled = VARIANT_TRUE;