Application Programming Interface TpcAccess

TpcAccess API is based on a client/server architecture where the TpcAccess API represents the client. The server software is installed together with the TPCX/TPCE hardware driver (TpcServer). Several clients can be connected to one server. All parameters are managed on the server side and a messaging service keeps all connected client up to date. TpcAccess makes no difference between local or network connection. This allows developing flexible applications which can be run on local machines or be used as remote control application. As the connection is made over TCP/IP easy connection over Internet is possible. TpcAccess is a C++ DLL. A C# and Python wrapper is available, examples for C++, C# and Visual Basic on demand.

Elsys Software Architecture

Downloads

Introduction to TpcAccess

Initialize the connection to the instrument

int deviceIx;
TPC_ErrorCode err;

// Connecting to one device:
TPC_BeginSystemDefinition();
deviceIx = TPC_AddDevice("192.168.0.107:10010");	// Replace the IP address with your device address
err = TPC_EndSystemDefinition(1000); // 1s timeout till connection failed
if(err != tpc_noError)
	return 1;
// Set default parameters
TPC_ResetConfiguration();

		

Set some hardware parameters and the recording mode

// Set recording mode to scope
TPC_SetParameter(deviceIx, 0, 0, tpc_parOperationMode, tpc_opModeScope);

// Set single shot and turn on auto trigger
TPC_SetParameter(deviceIx, 0, 0, tpc_parScopeAutoTrigger, 1);
TPC_SetParameter(deviceIx, 0, 0, tpc_parScopeSingleShot, 1);

// Set Sampling frequency to 10MHz
TPC_SetParameter(deviceIx, 0, 0, tpc_parSamplingFrequency,10000000);

// Set trigger delay to -50%
TPC_SetParameter(deviceIx, 0, 0, tpc_parScopeTriggerDelay, -50);

// Set Block Size to 16k Samples
TPC_SetParameter(deviceIx, 0, 0, tpc_parScopeBlockLength, 4096);

// Set Board 0, Channel 0, Input Range to 5V, 0% Offset
TPC_SetParameter(deviceIx, 0, 0, tpc_parRange, 5);
TPC_SetParameter(deviceIx, 0, 0, tpc_parOffset, 0);

// Set Trigger Board 0, Channel 0, Positive Slope at 1V, 0.1V hysteris
TPC_SetTrigger(deviceIx,0,0,tpc_etrgSlope,tpc_etrgCompPositive,tpc_etrgNone, 1,0.1);	

Start the measurement and readout Meta Data

Meta data holds usefull information which are needed for correctly interpret the raw binary measurement data.

int measurementNumber = 0;
TPC_MakeMeasurement(2000,&measurementNumber); 	

// readout time meta data
TPC_TMetaData tmetaData;
TPC_GetTMetaData(deviceIx, 0, 0, m_iMeasurementNumber, &tmetaData, sizeof(TPC_TMetaData));
cout << endl << "Meas. Start Time: " << tmetaData.startTime.hour   << ":" 
									 << tmetaData.startTime.minute << ":"
									 << tmetaData.startTime.second << endl;
cout << "Trigger Sample: " << tmetaData.triggerSample << endl;
cout << "Trigger Time:   " << tmetaData.triggerTime   << endl;

// read out y meta data
TPC_YMetaData ymetaData;
TPC_GetYMetaData(deviceIx, 0, 0, m_iMeasurementNumber, &ymetaData, sizeof(TPC_YMetaData));
uint32_t analogMask		= ymetaData.analogMask;
uint32_t markerMask		= ymetaData.markerMask;
double bintoVoltFactor		= ymetaData.binToVoltFactor;
double bintoVoltConstant	= ymetaData.binToVoltConstant;

Get Raw binary data and scale them for having voltage

// get raw data
int32_t *rawData, *analogData, *markerData;
rawData	   = new int32_t[4096];
analogData = new int32_t[4096];
markerData = new int32_t[4096];
TPC_GetRawData(deviceIx, 0, 0, 0, m_iMeasurementNumber, 0, 4096, rawData);

double* voltageData;
voltageData = new double[4096];
// get analog an marker data
for(int i = 0; i < 4096; i++){
	analogData[i] = rawData[i] & analogMask; // Mask digital marker data from the analog data
	markerData[i] = rawData[i] & markerMask; // Extract the digital marker signals
		
	// scale to voltage (this gives the same data as the TPC_GetData function)
	voltageData[i] = (analogData[i]* bintoVoltFactor) + bintoVoltConstant;
	cout << voltageData[i] << endl;
}