xPCI-3116 API
xPCI-3116 Analog inputs/outputs functions

Functions

_INT_ i_PCI3116_Write1AnalogOutput (HANDLE h_DeviceHandle, BYTE b_Channel, BYTE b_Polarity, WORD w_Value)
 
_INT_ i_PCI3116_WriteMoreAnalogOutputs (HANDLE h_DeviceHandle, BYTE b_ChannelNbr, PBYTE pb_Channels, PBYTE pb_Polarity, PWORD pw_Value)
 
_INT_ i_PCI3116_SetAnalogInputMode (HANDLE h_DeviceHandle, BYTE b_InputMode)
 
_INT_ i_PCI3116_GetAnalogInputMode (HANDLE h_DeviceHandle, PBYTE pb_InputMode)
 
_INT_ i_PCI3116_InitAndStartAnalogInputSequence (HANDLE h_DeviceHandle, DWORD dw_SequenceCount, DWORD dw_SequenceBeforeInterrupt, BYTE b_ChannelCount, PBYTE pb_Channel, PBYTE pb_Gain, PBYTE pb_Polarity, DWORD dw_ConvertingTime, DWORD dw_DelayTime, BYTE b_SoftTriggerMode, BYTE b_ExtTriggerMode, DWORD dw_SequenceTriggerCount)
 
_INT_ i_PCI3116_ReadMoreAnalogInputs (HANDLE h_DeviceHandle, BYTE b_ChannelCount, PBYTE pb_Channel, PBYTE pb_Gain, PBYTE pb_Polarity, DWORD dw_ConvertingTime, BYTE b_InterruptFlag, BYTE b_SoftTriggerMode, BYTE b_ExtTriggerMode, PWORD pw_ChannelValue)
 
_INT_ i_PCI3116_Read1AnalogInput (HANDLE h_DeviceHandle, BYTE b_Channel, BYTE b_Gain, BYTE b_Polarity, DWORD dw_ConvertingTime, BYTE b_InterruptFlag, BYTE b_SoftTriggerMode, BYTE b_ExtTriggerMode, PWORD pw_ChannelValue)
 
_INT_ i_PCI3116_InitAndStartAutoRefreshAcquisition (HANDLE h_DeviceHandle, BYTE b_ChannelCount, PBYTE pb_Channel, PBYTE pb_Gain, PBYTE pb_Polarity, DWORD dw_ConvertingTime, PDWORD *ppdw_Channels)
 
_INT_ i_PCI3116_StopAnalogAcquisition (HANDLE h_DeviceHandle)
 
_INT_ i_PCI3116_TriggerAnalogAcquisition (HANDLE h_DeviceHandle)
 
_INT_ i_PCI3116_GetAnalogInputChannelsNbr (HANDLE h_DeviceHandle, PBYTE pb_NumberOfInputChannels)
 
_INT_ i_PCI3116_GetAnalogInputResolution (HANDLE h_DeviceHandle, PBYTE pb_Resolution)
 
_LONG_ l_PCI3116_ReadSequenceData (HANDLE h_DeviceHandle, DWORD dw_Size, PVOID pv_Data)
 
_INT_ i_PCI3116_ReadPotis (HANDLE h_DeviceHandle, BYTE b_PotisId, PDWORD pdw_Value)
 
_INT_ i_PCI3116_WritePotis (HANDLE h_DeviceHandle, BYTE b_PotisId, DWORD dw_Value)
 
_INT_ i_PCI3116_SavePotis (HANDLE h_DeviceHandle)
 

Detailed Description

Function Documentation

_INT_ i_PCI3116_Write1AnalogOutput ( HANDLE  h_DeviceHandle,
BYTE  b_Channel,
BYTE  b_Polarity,
WORD  w_Value 
)

Write the value of one analog output of the board
In unipolar mode, output voltage range is 0V to 10V
In bipolar mode, output voltage range is -10V to 10V
Analog output values are 0x0 to 0x7FF in unipolar mode, 0x0 to 0xFFF in bipolar mode

Parameters
[in]h_DeviceHandleHandle of the board
[in]b_ChannelChannel to write (0 to 3)
[in]b_PolarityPolarity of the channel (PCI3116_OUTPUT_MODE_UNIPOLAR or PCI3116_OUTPUT_MODE_BIPOLAR)
[in]w_ValueValue to write to the output
Return values
0: No Error
-1: The device handle parameter is wrong
-3: Invalid channel
-4: Invalid polarity
-5: Invalid value in bipolar mode
-6: Invalid value in unipolar mode
-7: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_WriteMoreAnalogOutputs ( HANDLE  h_DeviceHandle,
BYTE  b_ChannelNbr,
PBYTE  pb_Channels,
PBYTE  pb_Polarity,
PWORD  pw_Value 
)

Write values of several analog outputs
In unipolar mode, output voltage range is 0V to 10V
In bipolar mode, output voltage range is -10V to 10V
Analog output values are 0x0 to 0x7FF in unipolar mode, 0x0 to 0xFFF in bipolar mode

Parameters
[in]h_DeviceHandleHandle of the board
[in]b_ChannelNbrNumber of channels to write (1 to 4)
[in]pb_ChannelsChannels to write (0 to 3)
[in]pb_PolarityPolarity of the channel (PCI3116_OUTPUT_MODE_UNIPOLAR or PCI3116_OUTPUT_MODE_BIPOLAR)
[in]pw_ValueValue to write to the output
Return values
0: No Error
-1: The device handle parameter is wrong
-2: b_ChannelNbr is invalid
-3: Invalid channel
-4: Invalid polarity
-5: Invalid value in bipolar mode
-6: Invalid value in unipolar mode
-7: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_SetAnalogInputMode ( HANDLE  h_DeviceHandle,
BYTE  b_InputMode 
)

Set analog input mode to single-ended or differential input
The input mode has to be set at least once before any call to an analog input function.
Once set, the configuration will last until the program ends, or another mode is set.

In single-ended mode, 16 analog inputs are available.
In differential mode, there are only 8 analog inputs available.
Please refer to the manual for further information.

Parameters
[in]h_DeviceHandleHandle of the board
[in]b_InputModeInput mode (PCI3116_INPUT_MODE_SINGLE_ENDED or PCI3116_INPUT_MODE_DIFFERENTIAL)
Return values
0: No Error
-1: The device handle parameter is wrong
-2: Invalid input mode
_INT_ i_PCI3116_GetAnalogInputMode ( HANDLE  h_DeviceHandle,
PBYTE  pb_InputMode 
)

Get analog input mode (single-ended or differential input)

In single-ended mode, 16 analog inputs are available.
In differential mode, there are only 8 analog inputs available.
Please refer to the manual for further information.

Parameters
[in]h_DeviceHandleHandle of the board
[out]pb_InputModeInput mode (PCI3116_INPUT_MODE_UNDEFINED, PCI3116_INPUT_MODE_SINGLE_ENDED or PCI3116_INPUT_MODE_DIFFERENTIAL)
Return values
0: No Error
-1: The device handle parameter is wrong
_INT_ i_PCI3116_InitAndStartAnalogInputSequence ( HANDLE  h_DeviceHandle,
DWORD  dw_SequenceCount,
DWORD  dw_SequenceBeforeInterrupt,
BYTE  b_ChannelCount,
PBYTE  pb_Channel,
PBYTE  pb_Gain,
PBYTE  pb_Polarity,
DWORD  dw_ConvertingTime,
DWORD  dw_DelayTime,
BYTE  b_SoftTriggerMode,
BYTE  b_ExtTriggerMode,
DWORD  dw_SequenceTriggerCount 
)

Initialize and starts an analog acquisition
To use this function you must set an interrupt routine where you will handle the data, and you must also define the input mode.
Gain acts as a multiplier for the input voltage. Possible gain values are :

  • PCI3116_GAIN_1 : Input range is between -10V and 10V (bipolar)
  • PCI3116_GAIN_2 : Input range is between -5V and 5V (bipolar)
  • PCI3116_GAIN_5 : Input range is between -2V and 2V (bipolar)
  • PCI3116_GAIN_10 : Input range is between -1V and 1V (bipolar)

The converting time stands for the time spent to acquire one channel. The time to acquire a sequence is dw_ConvertingTime * b_ChannelCount
The software trigger is a combination of 2 parameters

  • The first one enables or disabled the trigger
    • PCI3116_SOFT_TRIGGER_ENABLED : The trigger is enabled
    • PCI3116_SOFT_TRIGGER_DISABLED : The trigger is disabled
  • The trigger type is selected with one of the following parameters
    • PCI3116_TRIGGER_ONE_SHOT : The acquisition starts when the trigger is set
    • PCI3116_TRIGGER_SEQUENCE_TRIGGER : A pre-defined number of sequence is acquired : dw_SequenceTriggerCount
    • PCI3116_TRIGGER_SINGLE_SEQUENCE : One whole sequence is read for each trigger

The external trigger is a combination of the following parameters :

  • The first one defines the trigger edge
    • PCI3116_EXT_TRIGGER_DISABLED : Trigger is disabled
    • PCI3116_EXT_TRIGGER_ENABLED_LOW : Triggers on low edge
    • PCI3116_EXT_TRIGGER_ENABLED_HIGH : Triggers on high edge
    • PCI3116_EXT_TRIGGER_ENABLED_BOTH : Triggers on both edges
  • The second one defines the trigger type
    • PCI3116_TRIGGER_ONE_SHOT : The acquisition starts when the trigger is set
    • PCI3116_TRIGGER_SEQUENCE_TRIGGER : A pre-defined number of sequence is acquired : dw_SequenceTriggerCount
    • PCI3116_TRIGGER_SINGLE_SEQUENCE : One whole sequence is read for each trigger
Parameters
[in]h_DeviceHandleHandle of the board
[in]dw_SequenceCountThe total number of sequence to acquire. Set it to 0 if you want to use continuous acquisition (i.e. infinite acquisition)
[in]dw_SequenceBeforeInterruptSpecify the number of sequence to wait before generating an interruption. For high frequency, set a high number (512 if using maximum frequency for example).
[in]b_ChannelCountThe number of channels in one sequence. Rule: (b_ChannelCount * dw_SequenceBeforeInterrupt) must be a multiple of 2
[in]pb_ChannelDefine the channels in the sequence (single ended : 0 to 15, differential : 0 to 7). Depending on your board, this number may be different.
[in]pb_GainDefine the gain for each channel
[in]pb_PolarityDefine the polarity for each channel (PCI3116_OUTPUT_MODE_UNIPOLAR or PCI3116_OUTPUT_MODE_BIPOLAR)
[in]dw_ConvertingTimeDefine the time between two channels acquisition (5us to 65 535 000us). If you choose 16 channels with a conversion time of 5us, an entire sequence will be acquired in 16 * 5 = 80us
[in]dw_DelayTimeDefine the time between two sequences acquisition (5us to 65 535 000us).
[in]b_SoftTriggerModeDefines the software trigger
[in]b_ExtTriggerModeDefines the external trigger
[in]dw_SequenceTriggerCountIf you choose a trigger with mode PCI3116_TRIGGER_SEQUENCE_TRIGGER, it defines the number of sequence to acquire when a trigger occurs (1 to 0xFFFFFFFF). If not use, give 0.
Return values
0: success
-1: The device handle parameter is wrong
-2: The sequence size is wrong
-3: The input mode has not been set
-4: A channel index is invalid (single-ended mode)
-5: A gain value is wrong
-6: A polarity value is wrong
-7: The converting time is invalid
-8: The delay time is invalid
-9: The interrupt routine is not installed
-10: dw_SequenceBeforeInterrupt is not valid
-11: (b_ChannelCount * dw_SequenceBeforeInterrupt) is not a multiple of 2
-12: both software and hardware trigger are enabled. In that case, they must have the same type (one shot, sequence trigger or single sequence)
-13: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_ReadMoreAnalogInputs ( HANDLE  h_DeviceHandle,
BYTE  b_ChannelCount,
PBYTE  pb_Channel,
PBYTE  pb_Gain,
PBYTE  pb_Polarity,
DWORD  dw_ConvertingTime,
BYTE  b_InterruptFlag,
BYTE  b_SoftTriggerMode,
BYTE  b_ExtTriggerMode,
PWORD  pw_ChannelValue 
)

Read analog inputs from the board
You must call the set analog input mode function before calling this function.
Gain acts as a multiplier for the input voltage. Possible gain values are :

  • PCI3116_GAIN_1 : Input range is between -10V and 10V (bipolar)
  • PCI3116_GAIN_2 : Input range is between -5V and 5V (bipolar)
  • PCI3116_GAIN_5 : Input range is between -2V and 2V (bipolar)
  • PCI3116_GAIN_10 : Input range is between -1V and 1V (bipolar)

The converting time stands for the time spent to acquire one channel. The time to acquire a sequence is ul_ConvertingTime * uc_ChannelCount
The software trigger is a combination of 2 parameters

  • The first one enables or disabled the trigger
    • PCI3116_SOFT_TRIGGER_ENABLED : The trigger is enabled
    • PCI3116_SOFT_TRIGGER_DISABLED : The trigger is disabled
  • The trigger type is selected with one of the following parameters
    • PCI3116_TRIGGER_ONE_SHOT : The acquisition starts when the trigger is set

The external trigger is a combination of the following parameters :

  • The first one defines the trigger edge
    • PCI3116_EXT_TRIGGER_DISABLED : Trigger is disabled
    • PCI3116_EXT_TRIGGER_ENABLED_LOW : Triggers on low edge
    • PCI3116_EXT_TRIGGER_ENABLED_HIGH : Triggers on high edge
    • PCI3116_EXT_TRIGGER_ENABLED_BOTH : Triggers on both edges
  • The second one defines the trigger type
    • PCI3116_TRIGGER_ONE_SHOT : The acquisition starts when the trigger is set

If the interrupts are enabled, the function returns, and the value can be read in the interrupt routine once available.
If the interrupts are disabled, the function waits for the results and return the values in the pus_ChannelValue parameter.

Parameters
[in]h_DeviceHandleHandle of the board
[in]b_ChannelCountSet the number of channels in a sequence (1 to 16)
[in]pb_ChannelDefine the channels in the sequence (single ended : 0 to 15, differential : 0 to 7)
[in]pb_GainDefine the gain for each channel
[in]pb_PolarityDefine the polarity for each channel (PCI3116_OUTPUT_MODE_UNIPOLAR or PCI3116_OUTPUT_MODE_BIPOLAR)
[in]dw_ConvertingTimeDefine the tine between two channels acquisition (5us to 65 535 000us)
[in]b_InterruptFlagEnable the interrupts
[in]b_SoftTriggerModeDefines the software trigger
[in]b_ExtTriggerModeDefines the external trigger
[out]pw_ChannelValueValue of the sequence, if interrupts are disabled
Return values
0: No Error
-1: The device handle parameter is wrong
-2: The sequence size is wrong
-3: The input mode has not been set
-4: A channel index is invalid (single-ended mode)
-5: A channel index is invalid (differential mode)
-6: A gain value is wrong
-7: A polarity value is wrong
-8: The converting time is invalid
-9: The interrupt routine is not installed
-10: The software trigger is invalid
-11: The external trigger is invalid
-12: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_Read1AnalogInput ( HANDLE  h_DeviceHandle,
BYTE  b_Channel,
BYTE  b_Gain,
BYTE  b_Polarity,
DWORD  dw_ConvertingTime,
BYTE  b_InterruptFlag,
BYTE  b_SoftTriggerMode,
BYTE  b_ExtTriggerMode,
PWORD  pw_ChannelValue 
)

Read one analog input from the board
You must call the set analog input mode function before calling this function.
Gain acts as a multiplier for the input voltage. Possible gain values are :

  • PCI3116_GAIN_1 : Input range is between -10V and 10V (bipolar)
  • PCI3116_GAIN_2 : Input range is between -5V and 5V (bipolar)
  • PCI3116_GAIN_5 : Input range is between -2V and 2V (bipolar)
  • PCI3116_GAIN_10 : Input range is between -1V and 1V (bipolar)

The converting time stands for the time spent to acquire one channel. The time to acquire a sequence is ul_ConvertingTime * uc_ChannelCount
The software trigger is a combination of 2 parameters

  • The first one enables or disabled the trigger
    • PCI3116_SOFT_TRIGGER_ENABLED : The trigger is enabled
    • PCI3116_SOFT_TRIGGER_DISABLED : The trigger is disabled
  • The trigger type is selected with one of the following parameters
    • PCI3116_TRIGGER_ONE_SHOT : The acquisition starts when the trigger is set

The external trigger is a combination of the following parameters :

  • The first one defines the trigger edge
    • PCI3116_EXT_TRIGGER_DISABLED : Trigger is disabled
    • PCI3116_EXT_TRIGGER_ENABLED_LOW : Triggers on low edge
    • PCI3116_EXT_TRIGGER_ENABLED_HIGH : Triggers on high edge
    • PCI3116_EXT_TRIGGER_ENABLED_BOTH : Triggers on both edges
  • The second one defines the trigger type
    • PCI3116_TRIGGER_ONE_SHOT : The acquisition starts when the trigger is set

If the interrupts are enabled, the function returns, and the value can be read in the interrupt routine once available.
If the interrupts are disabled, the function waits for the results and return the values in the pus_ChannelValue parameter.

Parameters
[in]h_DeviceHandleHandle of the board
[in]b_ChannelDefine the channel to acquire (single ended : 0 to 15, differential : 0 to 7)
[in]b_GainDefine the gain for the channel
[in]b_PolarityDefine the polarity for the channel (PCI3116_OUTPUT_MODE_UNIPOLAR or PCI3116_OUTPUT_MODE_BIPOLAR)
[in]dw_ConvertingTimeDefine the time needed to acquire the channel (5us to 65 535 000us)
[in]b_InterruptFlagEnable the interrupts
[in]b_SoftTriggerModeDefines the software trigger
[in]b_ExtTriggerModeDefines the external trigger
[out]pw_ChannelValueValue of the channel, if interrupts are disabled
Return values
0: No Error
-1: The device handle parameter is wrong
-3: The input mode has not been set
-4: A channel index is invalid (single-ended mode)
-5: A channel index is invalid (differential mode)
-6: A gain value is wrong
-7: A polarity value is wrong
-8: The converting time is invalid
-9: The interrupt routine is not installed
-10: The software trigger is invalid
-11: The external trigger is invalid
-12: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_InitAndStartAutoRefreshAcquisition ( HANDLE  h_DeviceHandle,
BYTE  b_ChannelCount,
PBYTE  pb_Channel,
PBYTE  pb_Gain,
PBYTE  pb_Polarity,
DWORD  dw_ConvertingTime,
PDWORD *  ppdw_Channels 
)

Starts an auto-refresh acquisition
You must call the set analog input mode function before calling this function.
Auto-refresh mode is started once, and returns an array of values, each one corresponding to a channel.
These values are automatically refreshed after each conversion cycle, so the values in this array are always the latest ones.
Gain acts as a multiplier for the input voltage. Possible gain values are :

  • PCI3116_GAIN_1 : Input range is between -10V and 10V (bipolar)
  • PCI3116_GAIN_2 : Input range is between -5V and 5V (bipolar)
  • PCI3116_GAIN_5 : Input range is between -2V and 2V (bipolar)
  • PCI3116_GAIN_10 : Input range is between -1V and 1V (bipolar)

The converting time stands for the time spent to acquire one channel. The time to acquire a sequence is dw_ConvertingTime * b_ChannelCount

Parameters
[in]h_DeviceHandleHandle of the board
[in]b_ChannelCountSet the number of channels in a sequence (1 to 16)
[in]pb_ChannelDefine the channels in the sequence (single ended : 0 to 15, differential : 0 to 7)
[in]pb_GainDefine the gain for each channel
[in]pb_PolarityDefine the polarity for each channel (PCI3116_OUTPUT_MODE_UNIPOLAR or PCI3116_OUTPUT_MODE_BIPOLAR)
[in]dw_ConvertingTimeDefine the tine between two channels acquisition (5us to 65 535 000us)
[out]ppdw_ChannelsPointer to an array that contains the value of each channels
Return values
0: No Error
-1: The device handle parameter is wrong
-2: The sequence size is wrong
-3: The input mode has not been set
-4: A channel index is invalid (single-ended mode)
-5: A channel index is invalid (differential mode)
-6: A gain value is wrong
-7: A polarity value is wrong
-8: The converting time is invalid
-9: Error while calling IOCTL function (wrong handle ?)
-20: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_StopAnalogAcquisition ( HANDLE  h_DeviceHandle)

Stops any analog acquisition

Parameters
[in]h_DeviceHandleHandle of the board
Return values
0: No Error
-1: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_TriggerAnalogAcquisition ( HANDLE  h_DeviceHandle)

Triggers any analog acquisition

Parameters
[in]h_DeviceHandleHandle of the board
Return values
0: No Error
-1: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_GetAnalogInputChannelsNbr ( HANDLE  h_DeviceHandle,
PBYTE  pb_NumberOfInputChannels 
)

Get the number of analog inputs available on this board

Parameters
[in]h_DeviceHandleHandle of the board
[out]pb_NumberOfInputChannelsNumber of analog inputs available on this board
Return values
0: No Error
-1: The device handle parameter is wrong
_INT_ i_PCI3116_GetAnalogInputResolution ( HANDLE  h_DeviceHandle,
PBYTE  pb_Resolution 
)

Get the resolution of the analog inputs of this board, in bits

Parameters
[in]h_DeviceHandleHandle of the board
[out]pb_ResolutionResolution of the analog inputs of this board, in bits
Return values
0: No Error
-1: The device handle parameter is wrong
_LONG_ l_PCI3116_ReadSequenceData ( HANDLE  h_DeviceHandle,
DWORD  dw_Size,
PVOID  pv_Data 
)

Enables to read data acquired by a sequence acquisition.
This function can be called in the interrupt routine that you registered. (see samples)

Parameters
h_DeviceHandlehandle to the board
dw_Sizesize of data to read. To be powerfull, should be ( sequence size * sequence before interrupt ) * sizeof ( USHORT )
pv_Datapointer on data buffer where the acquired data will be stored
Return values
>=0: size of data read
-1error while reading
_INT_ i_PCI3116_ReadPotis ( HANDLE  h_DeviceHandle,
BYTE  b_PotisId,
PDWORD  pdw_Value 
)

Reads the value of a digital potentiometer (for calibration purposes)

Parameters
h_DeviceHandlehandle to the board
b_PotisIdthe ID number of the potentiometer to be read
  • 0 : Offset poti bipolar
  • 1 : Offset poti unipolar
  • 2 : Gain poti unipolar
  • 3 : Gain poti bipolar
  • 4 : Analog output gain
  • 5 : Analog output offset
pdw_ValueA pointer to a value that will be filled with the read value
Return values
0: No Error
-1: The device handle parameter is wrong
-2: The potis id parameter is wrong
-3: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_WritePotis ( HANDLE  h_DeviceHandle,
BYTE  b_PotisId,
DWORD  dw_Value 
)

Writes the value of a digital potentiometer (for calibration purposes)

Parameters
h_DeviceHandlehandle to the board
b_PotisIdthe ID number of the potentiometer to be written
  • 0 : Offset poti bipolar
  • 1 : Offset poti unipolar
  • 2 : Gain poti unipolar
  • 3 : Gain poti bipolar
  • 4 : Analog output gain
  • 5 : Analog output offset
dw_ValueThe value to be written (0-255)
Return values
0: No Error
-1: The device handle parameter is wrong
-2: The potis id parameter is wrong
-3: The value parameter is wrong
-4: Error while calling IOCTL function (wrong handle ?)
_INT_ i_PCI3116_SavePotis ( HANDLE  h_DeviceHandle)

Save the values of the digital potentiometers in the EEPROM (for calibration purposes)

Parameters
h_DeviceHandlehandle to the board
Return values
0: No Error
-1: The device handle parameter is wrong
-2: Error while calling IOCTL function (wrong handle ?)