Documentation Center

  • Trial Software
  • Product Updates

Configure and Sample Input Channels

Properties Associated with Configuring and Sampling Input Channels

The hardware you are using has characteristics that satisfy your specific application needs. Some of the most important hardware characteristics determine your configuration.

Analog Input Properties Related to Sampling Channels

Property Name

Description

ChannelSkew

Specify the time between consecutive scanned hardware channels.

ChannelSkewMode

Specify how the channel skew is determined.

InputType

Specify the analog input hardware channel configuration.

SampleRate

Specify the per-channel rate at which analog data is converted to digital data.

Configure Input Channel

You can configure your hardware input channels with the InputType property. The device-specific values for this property are given below.

InputType Property Values

Vendor

InputType Value

Advantech®

Differential|{SingleEnded}

Measurement Computing™

{Differential}|SingleEnded

National Instruments®

{Differential}|SingleEnded| NonReferencedSingleEnded|
PseudoDifferential

Sound Cards

AC-Coupled

The InputType value determines the number of hardware channels you can add to a device object. You can return the channel IDs with the daqhwinfo function. For example, suppose you create the analog input object ai for a National Instruments board. To display the differential channel IDs:

ai = analoginput('nidaq','Dev1');
hwinfo = daqhwinfo(ai);
hwinfo.DifferentialIDs
ans =
     0     1     2     3     4     5     6     7

In contrast, the single-ended channel IDs would be numbered 0 through 15.

    Note   If you change the InputType value to decrease the number of channels contained by the analog input object, the system returns a warning and deletes all channels.

Advantech and Measurement Computing Devices

For Advantech and Measurement Computing devices, InputType can be Differential or SingleEnded. Channels configured for differential input are not connected to a fixed reference such as earth, and the input signals are measured as the difference between two terminals. Channels configured for single-ended input are connected to a common ground, and input signals are measured with respect to this ground.

National Instruments Devices

For National Instruments devices, InputType can be Differential, SingleEnded, NonReferencedSingleEnded, or PseudoDifferential. Channels configured for differential input are not connected to a fixed reference such as earth, and input signals are measured as the difference between two terminals. Channels configured for single-ended input are connected to a common ground, and input signals are measured with respect to this ground. Channels configured for nonreferenced single-ended input are connected to their own ground reference, and input signals are measured with respect to this reference. The ground reference is tied to the negative input of the instrumentation amplifier. Channels configured for pseudodifferential input are all referred to a common ground but this ground is not connected to the computer ground.

The number of channels that you can add to a device object depends on the InputType property value. Most National Instruments boards have 16 or 64 single-ended inputs and 8 or 32 differential inputs, which are interleaved in banks of 8. This means that for a 64 channel board with single-ended inputs, you can add all 64 channels. However, if the channels are configured for differential input, you can only add channels 0-7, 16-23, 32-39, and 48-55.

Sound Cards

For sound cards, the only valid InputType value is AC-Coupled. When input channels are AC-coupled, they are connected so that constant (DC) signal levels are suppressed, and only nonzero AC signals are measured.

Sampling Rate

You control the rate at which an analog input subsystem converts analog data to digital data with the SampleRate property. Specify SampleRate as samples per second. For example, to set the sampling rate for each channel of your National Instruments board to 100,000 samples per second (100 kHz)

ai = analoginput('nidaq','Dev1');
addchannel(ai,0:1);
set(ai,'SampleRate',100000)

Data acquisition boards typically have predefined sampling rates that you can set. If you specify a sampling rate that does not match one of these predefined values, there are two possibilities:

  • If the rate is within the range of valid values, then the engine automatically selects a valid sampling rate.

  • If the rate is outside the range of valid values, then an error is returned.

After setting a value for SampleRate, find out the actual rate set by the engine.

ActualRate = get(ai,'SampleRate');

Alternatively, you can use the setverify function, which sets a property value and returns the actual value set.

ActualRate = setverify(ai,'SampleRate',100000);

You can find the range of valid sampling rates for your hardware with the propinfo function.

ValidRates = propinfo(ai,'SampleRate');
ValidRates.ConstraintValue
ans =
  1.0e+005 *
    0.0000    2.0000

The maximum rate at which channels are sampled depends on the type of hardware you are using. The maximum board rate determines the maximum sampling rate for each channel if you are using simultaneous sample and hold (SS/H) hardware such as a sound card. For example, suppose you create the analog input object ai for a sound card and configure it for stereo operation. If the device has a maximum rate of 48.0 kHz, then the maximum sampling rate per channel is 48.0 kHz.

ai = analoginput('winsound');
addchannel(ai,1:2);
set(ai,'SampleRate',48000)

If you are using scanning hardware such as a National Instruments board, then the maximum sampling rate your hardware is rated at typically applies for one channel. You can apply the following formula to calculate the maximum sampling rate per channel:

For example, suppose you create the analog input object ai for a National Instruments board and add ten channels to it. If the device has a maximum rate of 100 kHz, then the maximum sampling rate per channel is 10 kHz.

ai = analoginput('nidaq','Dev1');
set(ai,'InputType','SingleEnded')
addchannel(ai,0:9);
set(ai,'SampleRate',10000)

Typically, you can achieve this maximum rate only under ideal conditions. In practice, the sampling rate depends on several characteristics of the analog input subsystem including the settling time, the gain, and the channel skew. See Channel Skew for more information

The hardware clock governs the list of valid sample rates on the device. Most devices offer a fixed speed hardware clock, used to drive the timing of an acquisition. In order to achieve a required sample rate, there is a programmable divider set from 1 to 65536. This limits the device to 65535 possible sample rates. For instance with a 100,000Hz clock, if you request 1,200 samples per second, you can set the divider to either 83 or 84. This setting results in a sample rate of either 1,204.82 (100,000/83) or 1,190.48 (100,000/84).

    Notes   For some sound cards, you can set the sampling rate to any value between the minimum and maximum values defined by the hardware. You can enable this feature with the StandardSampleRates property. Refer to for more information.

    When you change the SampleRate value, and the BufferingMode property is Auto the engine recalculates the BufferingConfig property value. BufferingConfig indicates the memory used by the engine.

Channel Skew

Many data acquisition devices have one A/D converter that is multiplexed to all input channels. If you sample multiple input channels from scanning hardware, then each channel is sampled sequentially following this procedure:

  1. A single input channel is sampled.

  2. The analog signal is converted to a digital value.

  3. The process is repeated for every input channel being used.

Because these channels cannot be sampled simultaneously, a time gap exists between consecutively sampled channels. This time gap is called the channel skew. The channel skew and the sample period are illustrated below.

As shown in the preceding figure, a scan occurs when all channels in a group are sampled once and the scan rate is defined as the rate at which every channel in the group is sampled. The properties associated with configuring the channel skew are given below.

Table 6-1. Channel Skew Properties

Property Name

Description

ChannelSkew

Specify the time between consecutive scanned hardware channels.

ChannelSkewMode

Specify how the channel skew is determined.

ChannelSkew and ChannelSkewMode are configurable only for scanning hardware and not for simultaneous sample and hold (SS/H) hardware. For SS/H hardware, ChannelSkewMode can only be None, and ChannelSkew can only be 0. The values for ChannelSkewMode are given below.

Table 6-2. ChannelSkewMode Property Values

Description

ChannelSkewModeValue

No channel skew is defined. This is the only valid value for simultaneous sample and hold (SS/H) hardware.

None

The channel skew is automatically calculated as [(sampling rate)(number of channels)]-1.

Equisample

The channel skew must be set with the ChannelSkew property.

Manual

The channel skew is given by the smallest value supported by the hardware.

Minimum

If ChannelSkewMode is Minimum or Equisample, then ChannelSkew indicates the appropriate read-only value. If ChannelSkewMode is set to Manual, you must specify the channel skew with ChannelSkew.

If you are acquiring samples using scanning hardware on multiple channels with large loads, increased settling time can cause incorrect measurements. You can mitigate this issue in one of the following ways:

  • Set the ChannelSkewMode to Manual and increase ChannelSkew to a value acceptable by the hardware.

  • Set ChannelSkewMode to Equisample. The ChannelSkew is automatically calculated based on the number of channels and the sampling rate.

Was this topic helpful?