eth32_set_analog_assignment

int eth32_set_analog_assignment(eth32 handle, int channel, int source);

Summary

This function assigns a logical analog channel to one of the physical channels. The logical channel assignment specifies which physical pins are used to determine the value of the analog reading when that logical channel is read or monitored for events. There are eight logical channels, each of which may be arbitrarily assigned to physical channels using this function.

Parameters

  • handle - The value returned by the eth32_open function.

  • channel - The logical channel number (0-7) to configure.

  • source - The code identifying which physical channel to assign to the specified logical channel. This may be any of the ANALOG_ constants defined in the tables below.

Return Value

This function returns zero on success and a negative error code on failure. Please see the Error Codes section for possible error codes.

Remarks

The logical channels simply provide a way to select which of the many physical channel sources listed below will be continually updated for reading on the device and, if configured to do so, monitored for analog events.

The assignments given to the logical channels may be completely arbitrary. Also, it is permissible to have more than one logical analog channel assigned to the same physical channel source. This can occasionally be advantageous for event monitoring. Since there are two possible event definitions per logical channel, assigning more than one logical channel to the same physical channel allows more than two event definitions on that physical channel.

When the device is first powered up or the eth32_reset function is called, the logical channel assignments revert to their defaults. Logical channel 0 is assigned to single-ended channel 0, logical channel 1 to single-ended channel 1 and so on.

The assignments made with this function are effective until they are either overwritten by calling the function again or the board is reset (hard reset or by calling eth32_reset). There is no limitation on how often you may reassign logical channels.

The following settings are the valid physical channel sources to which a logical channel may be assigned. The constant definition should typically be used in your source code, but its hexadecimal value is shown for reference.

For single-ended channels, the reading comes from the voltage of the specified pin with respect to ground.

Table 1. Single-Ended Channels

ConstantValuePhysical Pin
ANALOG_SE00x00Port 3, Bit 0
ANALOG_SE10x01Port 3, Bit 1
ANALOG_SE20x02Port 3, Bit 2
ANALOG_SE30x03Port 3, Bit 3
ANALOG_SE40x04Port 3, Bit 4
ANALOG_SE50x05Port 3, Bit 5
ANALOG_SE60x06Port 3, Bit 6
ANALOG_SE70x07Port 3, Bit 7

For differential channels, the reading comes from the voltage difference between two pins. It is permissible for either to be positive or negative with respect to the other. They are simply labeled positive and negative inputs to specify how the reading is determined. Please note that the voltage on each pin must still remain within the range of 0 to 5V with respect to the ground of the device.

Table 2. Differential Channels

ConstantValuePositive InputNegative InputGain
ANALOG_DI00X100x08Port 3, Bit 0Port 3, Bit 010x
ANALOG_DI10X100x09Port 3, Bit 1Port 3, Bit 010x
ANALOG_DI00X2000x0APort 3, Bit 0Port 3, Bit 0200x
ANALOG_DI10X2000x0BPort 3, Bit 1Port 3, Bit 0200x
ANALOG_DI22X100x0CPort 3, Bit 2Port 3, Bit 210x
ANALOG_DI32X100x0DPort 3, Bit 3Port 3, Bit 210x
ANALOG_DI22X2000x0EPort 3, Bit 2Port 3, Bit 2200x
ANALOG_DI32X2000x0FPort 3, Bit 3Port 3, Bit 2200x
ANALOG_DI01X10x10Port 3, Bit 0Port 3, Bit 11x
ANALOG_DI11X10x11Port 3, Bit 1Port 3, Bit 11x
ANALOG_DI21X10x12Port 3, Bit 2Port 3, Bit 11x
ANALOG_DI31X10x13Port 3, Bit 3Port 3, Bit 11x
ANALOG_DI41X10x14Port 3, Bit 4Port 3, Bit 11x
ANALOG_DI51X10x15Port 3, Bit 5Port 3, Bit 11x
ANALOG_DI61X10x16Port 3, Bit 6Port 3, Bit 11x
ANALOG_DI71X10x17Port 3, Bit 7Port 3, Bit 11x
ANALOG_DI02X10x18Port 3, Bit 0Port 3, Bit 21x
ANALOG_DI12X10x19Port 3, Bit 1Port 3, Bit 21x
ANALOG_DI22X10x1APort 3, Bit 2Port 3, Bit 21x
ANALOG_DI32X10x1BPort 3, Bit 3Port 3, Bit 21x
ANALOG_DI42X10x1CPort 3, Bit 4Port 3, Bit 21x
ANALOG_DI52X10x1DPort 3, Bit 5Port 3, Bit 21x

Note that the entries above which show both the positive side and negative side with the same input pin can be used for calibration of the differential amplifier. Any nonzero reading from those indicates an offset error within the differential amplifier which you can subtract out of other channels that share the same negative input and gain.

Table 3. Calibration Channels

ConstantValueDescription
ANALOG_122V0x1EInternal 1.22V Voltage Reference
ANALOG_0V0x1F0V (Ground)

The above two entries connect a logical channel to internal chip voltages. They can be used as calibration points to determine errors within the analog conversions.

See Also

eth32_get_analog_assignment