ser_sr24_input_analog


int   ser_sr24_input_analog(
     ser_sr24 handle,   //serial board handle
     int channel,   //analog channel to read
     int *value   //pointer to integer which receives the value read from the analog channel
     );

Summary

The ser_sr24_input_byte function reads the value currently present on the specified analog channel. Port 1 may be configured as a 10-bit, 8-channel A/D converter. Any of these channels may be read by simply calling this function and passing the desired channel number. Since the A/D converter has 10-bit precision, the value will range from 0 to 1023.

Note that this function will return an error if it is called while Port 1 is in digital mode. Also, this function may time out, based upon the current timeout value (see the ser_sr24_set_timeout() function).

Parameters

handle:
    This is the handle to the serial board; it is actually a pointer to the data structure for the board.
channel:
    This identifies the analog channel on Port 1 which is to be read; valid range is 0 - 7.
value:
    This is a pointer to the integer variable where you want to store the value read from the channel.

Return Values

Function returns 0 upon success (analog value was successfully read). Possible error codes include:

Visual Basic Notes

The Visual Basic equivalent of this function is the InputAnalog method. Note that the 'value' parameter is passed ByRef; the value read from the port will be stored in this variable. Return values are listed above.

Prototype:
object.InputAnalog(
     ByVal channel As Long   'analog channel to read
     ByRef value As Long   'variable where the read value is stored
     ) As Long

Example
result = object.InputAnalog(0, value)   'read analog Channel 0 (Port 1) and store in 'value'



Back to Contents Winford Engineering (2000)