VTI Instruments Corp.
44
EX1200-1538: Programming the Instrument
//Enable Fifo for the channels
mfunction->Counter->Channels->Item["CH2"]->FifoEnabled = VARIANT_TRUE;
mfunction->Trigger->Source = VTEXMultifunctionTriggerSourceImmediate;
//Start measurement
mfunction->Measurement->Initiate();
int fifocount,loopcount = 0;
do
{
//Take measurement for 10 times.
fifocount = mfunction->Measurement->FifoCount;
Sleep(1000);
if(loopcount > 10)
{
printf("Expected Fifo count (10) is not Available, Exiting
loop\n");
break;
}
lo+;
} while (fifocount < 10);
printf("Fifo Count = %d\n",fifocount);
if(fifocount <= 0)
{ //Exiting function when no data available
printf("No Fifo data, Exiting function...\n");
return 0;
}
//No. of enabled channels(here it is two. Channel 1 and channel 2)
int no_of_channels_enabled = 2;
/*For each trigger all channels data will be stored. In our case 2
channels is enabled and 10 readings are taken.
So we will get 20 data points in the data array*/
SAFEARRAY *data = NULL;
SAFEARRAY *time = NULL;
SAFEARRAY *time_fraction = NULL;
//Read the measurements
mfunction->Measurement->ReadFifo(0, fifocount, &data, &time,
&time_fraction);
for (long scan = 0; scan<fifocount; scan++)
{
double dSecond, dFraction;
SafeArrayGetElement(time, &scan, (void *)&dSecond);
SafeArrayGetElement(time_fraction, &scan, (void *)&dFraction);
fprintf(stderr, "@Time = %f\n", d dFraction);
for (int channel = 0; channel < no_of_channels_enabled; +)
{
long dataindex = scan * no_of_channels_e channel;
double dData;
SafeArrayGetElement(data, &dataindex, (void *)&dData);
fprintf(stderr, "Channel = %d, Frequency = %f\r\n", 1,
dData);
}
}
//Abort the measurement.
mfunction->Measurement->Abort();
}
catch (_com_error& e)
{
::MessageBox(NULL, e.Description(), e.ErrorMessage(), MB_ICONERROR);
}