APIs, concepts, guides, and more

◆ CreateDigitalOutput() [4/5]

IOPoint * CreateDigitalOutput ( MotionController * controller,
uint64_t memoryAddress,
int32_t bitNumber )
static
Description:
Parameters
controllerYour motion controller object
memoryAddressthe memory address you want to target
bitNumberThe bit number relative to the memory address
Returns
(IOPoint*) A pointer to the newly created IOPoint.
Sample Code:
IO: Input & Output
const int NODE_INDEX = 0; // the EtherCAT Node we will be communicating with
const int OUTPUT_INDEX = 0; // the PDO Index in that Node
// create IOPoint for digital output - automatically gets memory index of specified node and output index
IOPoint output0 = IOPoint.CreateDigitalOutput(controller.NetworkNodeGet(NODE_INDEX), OUTPUT_INDEX);
// set the output to false
output0.Set(false);
Console.WriteLine($"Output {OUTPUT_INDEX} set to: false");
// wait one sample for the change to take effect
controller.SampleWait(1);
// read back the value
bool outputValue = output0.Get();
Console.WriteLine($"Output {OUTPUT_INDEX} value: {outputValue}");
// set the output to true
output0.Set(true);
Console.WriteLine($"Output {OUTPUT_INDEX} set to: true");
controller.SampleWait(1);
outputValue = output0.Get();
Console.WriteLine($"Output {OUTPUT_INDEX} value: {outputValue}");