NI-DAQmx .NET Framework 4.0 API Reference

CIChannelCollection.CreateLinearEncoderChannel Method (String, String, CIEncoderDecodingType, Boolean, Double, CIEncoderZIndexPhase, Double, Double, CILinearEncoderUnits)

  • Updated2023-02-21
  • 3 minute(s) read
CIChannelCollection.CreateLinearEncoderChannel Method (String, String, CIEncoderDecodingType, Boolean, Double, CIEncoderZIndexPhase, Double, Double, CILinearEncoderUnits)
Creates a CIChannel that uses a linear encoder to measure linear position. This method adds one channel to the CIChannelCollection.

Namespace:  NationalInstruments.DAQmx
Assembly:  NationalInstruments.DAQmx (in NationalInstruments.DAQmx.dll) Version: 20.7.40.49302

Syntax

public CIChannel CreateLinearEncoderChannel(
	string counter,
	string nameToAssignChannel,
	CIEncoderDecodingType encoderDecodingType,
	bool zIndexEnable,
	double zIndexValue,
	CIEncoderZIndexPhase zIndexPhase,
	double distancePerPulse,
	double initialPosition,
	CILinearEncoderUnits units
)
Public Function CreateLinearEncoderChannel ( 
	counter As String,
	nameToAssignChannel As String,
	encoderDecodingType As CIEncoderDecodingType,
	zIndexEnable As Boolean,
	zIndexValue As Double,
	zIndexPhase As CIEncoderZIndexPhase,
	distancePerPulse As Double,
	initialPosition As Double,
	units As CILinearEncoderUnits
) As CIChannel

Parameters

counter
Type: SystemString
The name of the counter to use to create the virtual channel.
nameToAssignChannel
Type: SystemString
The name to assign to the created channel. To use the physical channel name as the local virtual channel name, set this value to Empty.
encoderDecodingType
Type: NationalInstruments.DAQmxCIEncoderDecodingType
The count and interpretation of the pulses that the encoder generates on signal A and signal B. X1, X2, and X4 are valid for quadrature encoders only.
zIndexEnable
Type: SystemBoolean
Whether to use z indexing for the channel.
zIndexValue
Type: SystemDouble
The value, in units, to which to reset the measurement when signal Z is high, and signal A and signal B are at the states you specify with zIndexPhase.
zIndexPhase
Type: NationalInstruments.DAQmxCIEncoderZIndexPhase
The states signal A and signal B must be at while signal Z is high for NI-DAQmx to reset the measurement. If the signal Z is never high while the signal A and signal B are high, for example, you must choose a phase other than AHighBHigh.
distancePerPulse
Type: SystemDouble
The distance measured for each pulse that the encoder generates. This value is in the units that you specify in the units parameter.
initialPosition
Type: SystemDouble
The position of the encoder when the measurement begins. This value is in the units that you specify in the units parameter.
units
Type: NationalInstruments.DAQmxCILinearEncoderUnits
The units to use to return linear position measurements from the channel.

Return Value

Type: CIChannel
The newly created CIChannel.

Exceptions

ExceptionCondition
DaqExceptionThe NI-DAQmx driver returned an error.

Remarks

With the exception of devices that support multi-counter tasks, you can create only one CIChannel at a time with this function because a task can contain only one CIChannel. To read from multiple counters simultaneously, use a separate task for each counter.

This method creates a virtual channel for the physical channel name you specify.

If you do not provide a value for nameToAssignChannel, NI-DAQmx uses the counter as the local virtual channel name. If you use nameToAssignChannel to create a name for the local virtual channel, you must use this name in other properties and methods.

X2 and X4 decoding are more sensitive to smaller changes in position than X1 encoding, with X4 being the most sensitive. However, more sensitive decoding is more likely to produce erroneous measurements if vibration exists in the encoder or other noise exists in the signals.

When signal Z goes high and how long it stays high varies from encoder to encoder. Refer to the documentation for the encoder to determine the timing of signal Z with respect to signal A and signal B.

The NI-DAQmx driver does not determine if the requested settings are possible until the task is verified. This method does not throw an exception for parameter values that are not compatible with your hardware or other settings in your task. To determine if all of the settings for a Task are valid, you must verify the task by starting the task, either with Start or by reading from or writing to the task, or by calling Control(TaskAction) with Verify.

See Also

Log in to get a better experience