{"id":10627,"date":"2022-09-19T07:00:36","date_gmt":"2022-09-19T07:00:36","guid":{"rendered":"https:\/\/www.qec.tw\/?p=10627"},"modified":"2024-09-06T06:14:32","modified_gmt":"2024-09-06T06:14:32","slug":"ethercatmaster-getsystemtime","status":"publish","type":"post","link":"https:\/\/www.qec.tw\/ja\/ethercat\/api\/master\/ethercatmaster-getsystemtime\/","title":{"rendered":"EthercatMaster.getSystemTime()"},"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\">Get the system time for the current cycle. It is recommended to use this within the cyclic callback to ensure the system time is retrieved in the correct cycle.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Syntax<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>uint64_t getSystemTime();<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Parameters<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">None.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Return Value<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Return the system time for the current cycle.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Comment<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This function must be called after a successful execution of\u00a0<a href=\"https:\/\/www.qec.tw\/ethercat\/api\/master\/ethercatmaster-start\/\"><code>EthercatMaster::start()<\/code><\/a>\u00a0and before\u00a0<a href=\"https:\/\/www.qec.tw\/ethercat\/api\/master\/ethercatmaster-stop\/\"><code>EthercatMaster::stop()<\/code><\/a>. This function is non-blocking and can be called within the callback functions.<\/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;\nuint64_t CurrentSystemTime;\n\nvoid CyclicCallback() {\n  CurrentSystemTime = master.getSystemTime();\n}\n\nvoid setup() {\n  Serial.begin(115200);\n\n  master.begin();\n  master.attachCyclicCallback(CyclicCallback);\n  master.start();\n}\n\nvoid loop() {\n  Serial.print(&quot;Current System Time: &quot;);\n  Serial.print((uint32_t)(CurrentSystemTime &gt;&gt; 32));\n  Serial.print(&quot; &quot;);\n  Serial.println((uint32_t)(CurrentSystemTime &amp; 0xFFFFFFFF));\n\n  delay(1000);\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\u00a0<a href=\"https:\/\/www.qec.tw\/ethercat\/api\/ethercat-library-api-user-manual\/\">EtherCAT Library User Manual<\/a>\u00a0for more QEC EtherCAT instructions and API usage.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[Ethercat Master] Description Get the system time for the current cycle. It is recommended to use this within the cyclic callback to ensure the system [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":10628,"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-10627","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\/ja\/wp-json\/wp\/v2\/posts\/10627","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/comments?post=10627"}],"version-history":[{"count":0,"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/posts\/10627\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/media\/10628"}],"wp:attachment":[{"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/media?parent=10627"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/categories?post=10627"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qec.tw\/ja\/wp-json\/wp\/v2\/tags?post=10627"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}