我想找...

搜尋

函式庫參考

目錄

motor.enableTouchProbe1()

[EtherCAT Device CiA402]

描述

Enable the touch probe 1.

Relevant Objects

  • Object 60B8h: Touch probe function
  • Object 60B9h: Touch probe status
  • Object 60D0h: Touch probe source

語法

int enableTouchProbe1(int trigger_mode, int trigger_src, int trigger_timing);

參數

  • [in] trigger_mode
    Choose the trigger mode of touch probe 1:
定義代碼描述
CIA402_TPMODE_FIRST_EVENT0Trigger the first event.
CIA402_TPMODE_CONTINUOUS1Trigger events continuously.
  • [in] trigger_src
    Choose the trigger source of touch probe 1:
定義代碼描述
CIA402_TPSRC_TP_INPUT0x00010000Trigger with touch probe input.
CIA402_TPSRC_ENCODER_Z0x00020000Trigger with zero impulse signal or position encoder.
CIA402_TPSRC_DIGITAL_INPUT11Trigger with digital input 1.
CIA402_TPSRC_DIGITAL_INPUT22Trigger with digital input 2.
CIA402_TPSRC_DIGITAL_INPUT33Trigger with digital input 3.
CIA402_TPSRC_DIGITAL_INPUT44Trigger with digital input 4.
CIA402_TPSRC_HW_ENCODER_Z5Trigger with digital input 5.
CIA402_TPSRC_SW_ENCODER_Z6Trigger with digital input 6.
  • [in] trigger_timing
    Choose the trigger timing of touch probe 1:
定義代碼描述
CIA402_TPTIMING_NONE0Switch off all sampling of touch probe 1.
CIA402_TPTIMING_POS_EDGE1Enable sampling at positive edge of touch probe 1.
CIA402_TPTIMING_NEG_EDGE2Enable sampling at negative edge of touch probe 1
CIA402_TPTIMING_BOTH3Enable sampling at both positive and negative edges of touch probe 1 simultaneously.

回傳值

Return an error code. If the returned value is zero, it indicates a successful execution of this function.

備註

This function must be called after a successful execution of EthercatMaster::begin(). This function is blocking and cannot be called in callback functions.

範例程式碼

#include "Ethercat.h"

EthercatMaster master;
EthercatDevice_CiA402 motor;

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

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

  motor.enableTouchProbe1(CIA402_TPMODE_FIRST_EVENT, CIA402_TPSRC_TP_INPUT, CIA402_TPTIMING_POS_EDGE);
  while (motor.isTouchProbe1ValueReady(CIA402_TPVALUE_POS_EDGE) == false);
  Serial.print("Touch probe position 1 positive value: ");
  Serial.println(motor.readTouchProbe1Value(CIA402_TPVALUE_POS_EDGE));
  motor.disableTouchProbe1();
}

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

}

Please see the EtherCAT CiA 402 使用手冊 for more QEC EtherCAT instructions and API usage.

返回頂端