説明
Switch the CiA 402 state.
Relevant Objects
- Object 6040h: Controlword
- Object 6041h: Statusword
構文
int setCiA402State(int state, uint32_t timeout_ms = 1000);
媒介変数
[in] mode
The CiA 402 state to be switched:
| 定義 | コード | State |
| CIA402_SWITCH_ON_DISABLED | 1 | Switch on disabled. |
| CIA402_READY_TO_SWITCH_ON | 2 | Ready to switch on. |
| CIA402_SWITCHED_ON | 3 | Switched on. |
| CIA402_OPERATION_ENABLED | 4 | Operation enabled. |
| CIA402_QUICK_STOP_ACTIVE | 7 | Quick stop active. |
[in] timeout_ms
タイムアウト値で、ミリ秒単位。
戻り値
error codeを返します。返された値が 0の場合、この関数が正常に完了したことを示します。
備考
この関数は、 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:
}詳細は EtherCAT CiA 402 User Manual QEC EtherCAT命令とAPI使用法参照