我想找...

搜尋

函式庫參考

目錄

motor.setCiA402State()

[EtherCAT Device CiA402]

描述

Switch the CiA 402 state.

Relevant Objects

  • 物件 6040h:Controlword
  • 物件 6041h:Statusword

語法

int setCiA402State(int state, uint32_t timeout_ms = 1000);

參數

  • [in] mode
    The CiA 402 state to be switched:
定義代碼狀態
CIA402_SWITCH_ON_DISABLED1Switch on disabled.
CIA402_READY_TO_SWITCH_ON2Ready to switch on.
CIA402_SWITCHED_ON3Switched on.
CIA402_OPERATION_ENABLED4Operation enabled.
CIA402_QUICK_STOP_ACTIVE7Quick stop active.
  • [in] timeout_ms
    Timeout in milliseconds.

回傳值

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::start(). This function is blocking and will wait for the actual value to match the set value until a timeout occurs. When used in a callback function, it becomes non-blocking and will ignore the timeout parameter, not waiting for the actual value to match the set value.

範例程式碼

#include "Ethercat.h"

EthercatMaster master; 
EthercatDevice_CiA402 motor;
void setup() { 
  master.begin(); 
  motor.attach(0, master); 
  master.start();
  
  motor.setCiA402State(CIA402_OPERATION_ENABLED);
  delay(4000);
  motor.setCiA402State(CIA402_SWITCH_ON_DISABLED); 
}

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

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

返回頂端