I want to find...

Search

Libraries

Table of Content

motor.readTouchProbe2Value()

[EtherCAT Device CiA402]

Description

Read the touch probe position 2 positive/negative value object.

Relevant Objects

  • Object 60BCh: Touch probe position 2 positive value
  • Object 60BDh: Touch probe position 2 negative value

Syntax

int32_t readTouchProbe2Value(int value_selector);

Parameters

  • [in] value_selector
    Choose the data source for reading the position value of touch probe 2:
DefinitionCodeDescription
CIA402_TPVALUE_POS_EDGE0Read the touch probe position 2 positive value. (60BCh)
CIA402_TPVALUE_NEG_EDGE1Read the touch probe position 2 negative value. (60BDh)

Return Value

Return the touch probe position 2 value.

Comment

This function must be called after a successful execution of EthercatMaster::begin(). This function is non-blocking and can be called in callback functions if the related object is mapped to PDO.

Example Code

#include "Ethercat.h"

EthercatMaster master;
EthercatDevice_CiA402 motor;

void setup() {
  Serial.begin(115200);
  while (!Serial);

  master.begin();
  motor.attach(0, master);

  motor.enableTouchProbe2(CIA402_TPMODE_FIRST_EVENT, CIA402_TPSRC_TP_INPUT, CIA402_TPTIMING_POS_EDGE);
  while (motor.isTouchProbe2ValueReady(CIA402_TPVALUE_POS_EDGE) == false);
  Serial.print("Touch probe position 2 positive value: ");
  Serial.println(motor.readTouchProbe2Value(CIA402_TPVALUE_POS_EDGE));
  motor.disableTouchProbe2();
}

void loop() {
  // put your main code here, to run repeatedly:

}

Please see the EtherCAT CiA 402 User Manual for more QEC EtherCAT instructions and API usage.

Scroll to Top