{"id":10532,"date":"2024-08-27T09:13:09","date_gmt":"2024-08-27T09:13:09","guid":{"rendered":"https:\/\/www.qec.tw\/?p=10532"},"modified":"2024-08-28T03:19:55","modified_gmt":"2024-08-28T03:19:55","slug":"ethercatmaster-begin","status":"publish","type":"post","link":"https:\/\/www.qec.tw\/zh\/ethercat\/api\/master\/ethercatmaster-begin\/","title":{"rendered":"EthercatMaster.begin()"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">[Ethercat Master]<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Description<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Initialize the EtherCAT master, scan all EtherCAT slave devices on the network, and switch the EtherCAT state machine to the Pre-Operational state.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Syntax<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>int begin(EthernetPort eth = ECAT_ETH_0, const char *eni_filename = NULL);<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Parameters<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>[in] EthernetPort eth<\/code><br>Selection of the Ethernet interface for EtherCAT communication. The default is <code>ECAT_ETH_0<\/code>.\n<ul class=\"wp-block-list\">\n<li><code>ECAT_ETH_0<\/code>: Only&nbsp;eth0&nbsp;is used as the EtherCAT communication interface.<\/li>\n\n\n\n<li><code>ECAT_ETH_1<\/code>: Only&nbsp;eth1&nbsp;is used as the EtherCAT communication interface.<\/li>\n\n\n\n<li><code>ECAT_ETH_REDUNDANCY<\/code>: Enable EtherCAT Cable Redundancy with&nbsp;eth0&nbsp;as the primary port and&nbsp;eth1&nbsp;as the secondary port.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><code>[in] const char *eni_filename<\/code><br>The file name of the EtherCAT Network Information (ENI). For details about the ENI content supported by this library, please refer to&nbsp;<a href=\"https:\/\/www.qec.tw\/ethercat\/api\/ethercat-library-api-user-manual\/#elementor-toc__heading-anchor-49\">EtherCAT Network Information<\/a>. The default is <code>NULL<\/code>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Return Value<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Return an <a href=\"https:\/\/www.qec.tw\/ethercat\/api\/error-code\/\">error code<\/a>. If the returned value is zero, it indicates a successful execution of this function.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example<\/h2>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>#include &quot;Ethercat.h&quot;\n\nEthercatMaster master;\n\nvoid setup()\n{\n    master.begin();\n    master.start(1000000); \/\/ cycle time set as 1 millisecond.\n}\n\nvoid loop()\n{\n\n}<\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">Please see the <a href=\"https:\/\/www.qec.tw\/ethercat\/api\/ethercat-library-api-user-manual\/\">EtherCAT Library User Manual<\/a> for more QEC EtherCAT instructions and API usage.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[Ethercat Master] Description Initialize the EtherCAT master, scan all EtherCAT slave devices on the network, and switch the EtherCAT state machine to the Pre-Operational state. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":10533,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[250],"tags":[162,54,191],"class_list":["post-10532","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-master","tag-86duino","tag-ethercat","tag-qec"],"_links":{"self":[{"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/posts\/10532","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/comments?post=10532"}],"version-history":[{"count":0,"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/posts\/10532\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/media\/10533"}],"wp:attachment":[{"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/media?parent=10532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/categories?post=10532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qec.tw\/zh\/wp-json\/wp\/v2\/tags?post=10532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}