[【EtherCAT实践篇】四、TwinCAT 3实验1-基本操作](https://blog.csdn.net/zhandouhu/article/details/104092545) [Installation of the TwinCAT real-time driver](https://infosys.beckhoff.com/english.php?content=../content/1033/ethercatsystem/1036996875.html&id=) 安裝完要重開機 以下是 twincat 用 ESI update 燒錄 eeprom 的方法。 [Device description ESI file/XML](https://infosys.beckhoff.com/english.php?content=../content/1033/ek1110/4348710539.html&id=) --- 然後會一下 [siitool](https://github.com/synapticon/siitool) 的用法 ESI to sii eeprom `siitool ~/temp/Austone_ECAT_Description_1129.xml | hexdump` generate to file `siitool ~/temp/Austone_ECAT_Description_1129.xml -o ./austone_1129.bin` sii eeprom data explain `siitool -p ~/temp/sandal_twincat.bin` to see value in sii file `siitool ./austone_1129.bin | hexdump` `cat ./austone_1129.bin | hexdump` --- igh用法 **注意!!,只有在第一次插上網路線時下 sii_write 有用**(不要下任何指令),並且燒錄結束後要重上電。 get sii data from underline ethercat slaves `sudo ethercat sii_read | hexdump` config sii data `sudo ethercat sii_write ~/temp/sandal_twincat.bin` ## debug when error occur, best debug method is still journal/syslog. `sudo grep "EtherCAT" /var/log/syslog` `sudo truncate -s 0 /var/log/syslog` ## ESI 檔要修改的地方 加入`<Eeprom>` tag 到xml 後,有成功把ESI 的資料放進eeprom 了。 沒有加這個了話siitools 會segfault ```xml <Eeprom> <ByteSize>2048</ByteSize> <ConfigData>050e03cc64000000000000000000</ConfigData> <!-- first 7 words, 28 nibble--> </Eeprom> ``` 上面這個是一定要加的 ConfigData 的內容是 --- siitools 的 create binary 功能和 twincat 產生的binary 相比有loss 一些資訊。比如category string 不是全部。 DC sync 功能沒有顯示。 siitools 的 -p 功能有些分隔沒弄好,rx/txPDO2的mapping 會連在一起。 siitools 各種原因很容易 segfault。 SDO 就可用了。 --- 發現 **`Flag MBox Data Link Layer ...... enabled`** 不一樣,是 not enabled 的。 再加 child of `<Device>` ```xml <Info> <StateMachine> <Timeout> <PreopTimeout>1000</PreopTimeout> <SafeopOpTimeout>1000</SafeopOpTimeout> <BackToInitTimeout>1000</BackToInitTimeout> <BackToSafeopTimeout>100</BackToSafeopTimeout> </Timeout> </StateMachine> <Mailbox> <Timeout> <RequestTimeout>1000</RequestTimeout> <ResponseTimeout>1000</ResponseTimeout> </Timeout> </Mailbox> </Info> ``` 那個地方沒變。 再看到原本 `Device/Mailbox` 沒有 `<Mailbox DataLinkLayer="true">` ETG2000 說是mandatory,先加上。 **siitools 顯示結果還是沒變,我懷疑是siitools 的問題。** 用 twincat 重燒後,確實是siitools 的問題,用siitools 解讀是有變的。 `sudo ethercat sii_read | siitool -p` 現在 `ethercat xml`, `ethercat cstruct` 都是正常的。 要注意的是,看起來 igh 的這兩個功能都是直接使用 sii 的資料而不會去管 目前的mapping 是否已經被sdo改變。