サイト内検索

検索

Shares

Table of Content

EthercatMaster.getSystemTime()

[Ethercat Master]

説明

現サイクルのシステム時間を取得します。システム時間を正しいサイクルで取得するためには、これを循環コールバック内で使用することをお勧めします。

構文

uint64_t getSystemTime();

媒介変数

なし

戻り値

現サイクルのシステム時間を返します。

備考

この関数は、 EthercatMaster::start() が正常に実行された後で、 EthercatMaster::stop()の前に呼び出す必要があります。この関数はブロッキングされていないため、コールバック関数内で呼び出すことができます。

#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);
}

詳細は EtherCAT Library User Manual QEC EtherCAT命令とAPI使用法参照

上部へスクロール