[etherlab-users] Synchronizing the EtherCAT application time to the DC reference clock
Matthias Bartsch
mbartsch at aradex.com
Thu Feb 1 17:11:48 CET 2018
Hello everybody!
I'm using the unofficial patch set from https://github.com/ribalda/ethercat (2017-11-08).
My RTAI communication cycle is synchronized to the DC slave reference clock (average jitter < 1µs). I need to extrapolate the position of servo drives to the beginning of my cycle.
I'm not sure about the right use of the functions for reading the reference clock.
I want to start my cycle at the time of the "Sync0" interrupt.
My questions are: When is the time sampled that I get by calling
ecrt_master_64bit_reference_clock_time(m_poMaster, &ui64RefClockTime)); ?
How I have to initialize my application time (first call of "ecrt_master_application_time(...)")?
My synchronisation seems to work but I'm not sure about the phase shift between the Sync0 event and the start of my communication cycle.
My code looks something like this:
In the first real time cycle I call:
ecrt_master_application_time(m_poMaster, m_ui64AppTime_ns); // with m_ui64AppTime_ns=0
ecrt_master_sync_slave_clocks(m_poMaster);
ecrt_domain_queue(m_po_domainInput);
ecrt_master_send(m_poMaster);
// busy wait 25µs for getting the answer
ecrt_master_receive(m_poMaster);
ecrt_domain_process(m_po_domainInput);
//
// .... Later sending the output data
In the next cycles I do this:
ecrt_master_receive(m_poMaster);
ecrt_domain_process(m_po_domainOutput);
ecrt_master_64bit_reference_clock_time_queue(m_poMaster);
ecrt_domain_queue(m_po_domainInput);
ecrt_master_send(m_poMaster);
// busy wait 25µs for getting the answer
ecrt_master_receive(m_poMaster);
ecrt_domain_process(m_po_domainInput);
uint64_t ui64RefClockTime;
ecrt_master_64bit_reference_clock_time(m_poMaster, &ui64RefClockTime));
m_ui64AppTime_ns += static_cast<uint64_t>((m_io__dNominalCycleTime) * 1e9);
ecrt_master_application_time(m_poMaster, m_ui64AppTime_ns);
m_out_iDcSysTimeDifferenceMaster = m_ui64AppTime_ns - ui64RefClockTime; // Time drift value
ecrt_master_sync_slave_clocks(m_poMaster);
With kind regards
Matthias Bartsch
ARADEX AG
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20180201/15f34e8f/attachment-0002.htm>
More information about the Etherlab-users
mailing list