int __stdcall SM_WriteAnalogOutputs ( SM_HANDLE  handle,
int  start,
int  number,
double *  analogValues,
unsigned char *  ranges,
unsigned char *  byteValues 
)

Writes one or more analog outputs.

Parameters
[in]handleValid handle returned by SM_Open().
[in]startStarting output (zero-indexed).
[in]numberQuantity of analog outputs to write.
[in]analogValuesDesired output values as floating point values (voltages).
[in]rangesArray of analog output ranges.
[in]byteValuesDesired output values as 16-bit byte values.
Return values
>=0Number of bytes successfully written.
-1Invalid SeaMAX handle.
-2Either 'byteValues' or 'analogValues' must be null. Supply either one, but not both.
-3If an array of doubles is supplied, a similar array of analog output ranges must also be supplied.
-4One or more of the analog output channel ranges was an invalid range.
-5Connection is not established. Check the provided Connection object state.
-6Read error waiting for response. Unknown Modbus exception.
-7Illegal Modbus Function (Modbus Exception 0x01).
-8Illegal Data Address (Modbus Exception 0x02).
-9Illegal Data Value (Modbus Exception 0x03).
-10Modbus CRC was invalid. Possible communications problem.

Writes one or more analog output values. This function may be called one of two ways: either as with an array of floating point voltage values (with corresponding ranges), or with an array of 16-bit byte values.

Note
This function will either take an array of doubles (and it's corresponding ranges), or an array of bytes - but not both.

Double Array - Output Voltages

If an array of doubles is supplied, the array must contain at least one double for each analog output to be written. Each floating point value corresponds to the desired voltage output for each channel. Along with an array of floating point values, an array of analog output channel ranges must also be supplied - which map directly to the target analog outputs.

For instance, if two analog outputs are to be written the values 2.56 V and 5.64 V consecutively starting at output 3, the following arrays and values would need to be supplied:

    analogValues[0] = 2.56
    analogValues[1] = 5.64
    ranges[0] = Analog Output 3's Range
    ranges[1] = Analog Output 4's Range

The analog output ranges can be found by calling the SM_GetAnalogHardwareInfo() function.

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 to be written. The byte array should be filled with two-byte values to be written directly to the analog I/O device's registers. The byte order is such that the high-byte is always first. For instance, if two analog outputs are to be written at input 4 with the values 0x0F73 and 0x011A, the byte array should contain:

    byteValues[0] = 0x0F
    byteValues[1] = 0x73
    byteValues[2] = 0x01
    byteValues[3] = 0x1A

Referenced by SM_WriteHoldingRegisters().

 
 
Generated on Mon Nov 26 2018.