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 |
Index of the analog output port on the control box. |
||
fValue |
float |
Analog signal output value. |
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.