EthercatDevice_Generic.attach()

[EthercatDevice_Generic]

描述

指定從站編號並掛載至主站上。

格式

int attach(uint16_t slave_id, EthercatMaster &master, EthercatAttachMode mode = ECAT_SLAVE_NO);

語法

EthercatDevice_XXX slave;
slave.attach(0, master);

參數

  • uint16_t slave_id
    • ECAT_SLAVE_NO:EtherCAT從站編號。
    • ECAT _ALIAS_ADDRESS:EtherCAT從站別名地址。
  • EthercatMaster &master
  • EthercatAttachMode mode
    • ECAT_SLAVE_NO
    • ECAT_ALIAS_ADDRESS

回傳

Int:0表示成功;如果返回值小於0表示錯誤。

範例

#include "Ethercat.h"

EthercatMaster master;
EthercatDevice_QECR11D0FS slave;

void setup(void) {
    master.begin();
    slave.attach(0, master);
    master.start();
}

void loop() {
    slave.digitalWrite(0, HIGH);
    delay(4000);
    slave.digitalWrite(0, LOW);
    delay(1000);
}

函式庫參考主頁面

86Duino 參考的文本是根據 Creative Commons Attribution-ShareAlike 3.0 License,部分文本是從 the Arduino reference 修改的。 參考中的代碼示例已發佈到公共領域。

發表評論

上部へスクロール