You're reading the documentation for an older, but still supported version (GL013300).
For information on the latest version, please have a look at GL013301.

get_analog_input

This function reads the current analog input signal from the specified analog port on the robot controller’s control box. Depending on the input mode (current or voltage), it returns the measured signal value in the corresponding physical unit.

It is mainly used for monitoring external sensors, potentiometers, or other analog devices connected to the robot controller.

Version Note
- If DRCF version = 2, this function internally calls _get_analog_input().
- If DRCF version = 3, it calls _get_analog_input_ex() for extended analog precision and range support.
Refer to get_library_version for checking the current DRCF version.

Definition
DRFLEx.h within class CDRFLEx, public section (line 839/844)

#if DRCF_VERSION == 2
float get_analog_input(GPIO_CTRLBOX_ANALOG_INDEX eGpioIndex) {
    return _get_analog_input(_rbtCtrl, eGpioIndex);
};
#elif DRCF_VERSION == 3
float get_analog_input(GPIO_CTRLBOX_ANALOG_INDEX eGpioIndex) {
    return _get_analog_input_ex(_rbtCtrl, eGpioIndex);
};
#endif

Parameter

Parameter Name

Data Type

Default Value

Description

eGpioIndex

GPIO_CTRLBOX_ANALOG_INDEX

Index of the analog input port on the control box.

Return

Value

Description

float

Analog input signal value.
- In current mode: 4.0 – 20.0 [mA]
- In voltage mode: 0.0 – 10.0 [V]

Example

#include "DRFLEx.h"
using namespace DRAFramework;

int main() {
    CDRFLEx drfl;

    // Set analog input #1 mode to current (mA)
    drfl.set_mode_analog_output(GPIO_CTRLBOX_ANALOG_INDEX_1, GPIO_ANALOG_TYPE_CURRENT);

    // Read the current analog input value from channel #1
    float fCurrent = drfl.get_analog_input(GPIO_CTRLBOX_ANALOG_INDEX_1);

    printf("Analog input #1 current value: %.2f mA\n", fCurrent);
}

This example sets the analog input channel #1 to current mode and reads the live signal value (in milliamps) from the connected sensor. When in voltage mode, the function returns values in volts (0.0–10.0 V).