我想找...

搜尋

分享

目錄

EthercatMaster.getSystemTime()

[Ethercat Master]

描述

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.

語法

uint64_t getSystemTime();

參數

回傳值

Return the system time for the current cycle.

備註

This function must be called after a successful execution of EthercatMaster::start() and before EthercatMaster::stop(). This function is non-blocking and can be called within the callback functions.

範例

#include "Ethercat.h"

EthercatMaster master;
uint64_t CurrentSystemTime;

void CyclicCallback() {
  CurrentSystemTime = master.getSystemTime();
}

void setup() {
  Serial.begin(115200);

  master.begin();
  master.attachCyclicCallback(CyclicCallback);
  master.start();
}

void loop() {
  Serial.print("Current System Time: ");
  Serial.print((uint32_t)(CurrentSystemTime >> 32));
  Serial.print(" ");
  Serial.println((uint32_t)(CurrentSystemTime & 0xFFFFFFFF));

  delay(1000);
}

Please see the EtherCAT Library User Manual for more QEC EtherCAT instructions and API usage.

返回頂端