getCiA402State()

描述

Get the current CiA 402 state.

Relevant Objects

  • Object 6041h: Statusword

語法

int getCiA402State();

參數

回傳值

Return the current CiA 402 state:

定義代碼State
CIA402_NOT_READY_TO_SWITCH_ON0Not ready to switch on.
CIA402_SWITCH_ON_DISABLED1Switch on disabled.
CIA402_READY_TO_SWITCH_ON2Ready to switch on.
CIA402_SWITCHED_ON3Switched on.
CIA402_OPERATION_ENABLED4Operation enabled.
CIA402_FAULT5Fault.
CIA402_FAULT_REACTION_ACTIVE6Fault reaction active.
CIA402_QUICK_STOP_ACTIVE7Quick stop active.

If the return value is less than 0, it indicates an 錯誤代碼.

備註

This function must be called after a successful execution of EthercatMaster::start(). This function is non-blocking and can 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);
   master.start();
}

void loop() {
  Serial.print("CiA402 State: "); 
  Serial.println(motor.getCiA402State()); 
  delay(1000);
}

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

返回頂端