Reads one or more Sealevel I/O device analog output(s).
- Parameters
-
[in] | handle | Valid handle returned by SM_Open(). |
[in] | start | Starting output. |
[in] | number | Quantity of analog outputs to read. |
[out] | analogValues | Output values as floating point values (voltages). |
[in] | ranges | Array of channel ranges that correspond directly to each requested output. |
[out] | byteValues | Register state values as 16-bit byte pairs. |
- Return values
-
>=0 | Number of bytes successfully returned in result array. |
-1 | Invalid SeaMAX handle. |
-2 | Both 'byteValues' or 'analogValues' are null. Supply either one or both. |
-3 | If an array of doubles is supplied, a similar array of analog output ranges must also be supplied. |
-4 | One or more of the analog output ranges in the 'ranges' array is invalid. |
-5 | Connection is not established. Check the provided Connection object state. |
-6 | Read error waiting for response. Unknown Modbus exception. |
-7 | Illegal Modbus Function (Modbus Exception 0x01). |
-8 | Illegal Data Address (Modbus Exception 0x02). |
-9 | Illegal Data Value (Modbus Exception 0x03). |
-10 | Modbus CRC was invalid. Possible communications problem. |
Reads one or more analog outputs. There are two ways that the analog output values can be returned: an array of 16-bit byte values, or as an array of double (floating-point) values.
- Note
- This function will return, via parameters, either an array of bytes, an array of doubles, or both. If you pass either the byte array or double array as null, that type of data will not be returned.
Double Array - Voltage Values
If an array of doubles is supplied, the array must contain at least one double for each analog output requested. The array will be filled with floating point voltage values after a successful completion. An array of analog output ranges is also required to convert the device's response to appropriate floating point values. The ranges array must have one byte corresponding to an appropriate channel range for each output requested. For instance, if three analog outputs are requested starting at output 2, the ranges array should contain:
ranges[0] = Output 2 Channel Range
ranges[1] = Output 3 Channel Range
ranges[2] = Output 4 Channel Range
The channel ranges for analog outputs are hardware specific. Additionally, some hardware supports manual configuration via DIP switches.
Byte Array - 16-bit Byte Values
If an array of bytes is supplied, the array must contain at least two bytes for every analog output request. If only a byte array is supplied, the ranges parameter is not required. The byte array will be filled with the two byte values read directly from the analog I/O device. The byte order is such that the high-byte always comes first. For instance, if two analog outputs are read starting at output 4, the byte array returned will contain:
byteValues[0] = Output 4 (High Byte)
byteValues[1] = Output 4 (Low Byte)
byteValues[2] = Output 5 (High Byte)
byteValues[3] = Output 5 (Low Byte)
- Warning
- If a doubles array is supplied, it should contain space allocated for one double for each of the analog outputs requested. If a byte array is supplied, it should contain two bytes of space allocated for each output.