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.

set_analog_output

This function outputs an analog signal through the analog output port on the robot controller’s control box. Depending on the output mode (current or voltage), the analog signal value is transmitted in the range supported by the hardware.

It is mainly used to control external devices such as pneumatic regulators, servo amplifiers, or analog-driven instruments that require continuous voltage or current control.

Definition
DRFLEx.h within class CDRFLEx, public section (line 846)

bool set_analog_output(GPIO_CTRLBOX_ANALOG_INDEX eGpioIndex, float fValue)
{ return _set_analog_output(_rbtCtrl, eGpioIndex, fValue); };

Parameter

Parameter Name

Data Type

Default Value

Description

eGpioIndex

GPIO_CTRLBOX_ANALOG_INDEX

Index of the analog output port on the control box.

fValue

float

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

Return

Value

Description

0

Error — failed to output analog signal

1

Success — analog signal output successfully applied

Example

#include "DRFLEx.h"
using namespace DRAFramework;

int main() {
    CDRFLEx drfl;

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

    // Output 5.2 mA signal on analog output channel #1
    bool result = drfl.set_analog_output(GPIO_CTRLBOX_ANALOG_INDEX_1, 5.2f);

    if (result)
        printf("Analog output applied successfully.\n");
    else
        printf("Failed to output analog signal.\n");
}

This example sets the analog output #1 to current mode and sends a 5.2 mA signal to the connected device.
If voltage mode is configured instead, the same function can be used to output continuous voltages in the range of 0 – 10 V.