[etherlab-users] Patch for Distributed Clock?
Graeme Foot
Graeme.Foot at touchcut.com
Thu Jan 12 23:03:04 CET 2017
Hi,
Thats one of the older forum postings and is code for an older version of the master (revision 2266). The changeset I sent is for master revision 2526 (still old but I haven't needed to move on yet).
Have a look at this one:
http://lists.etherlab.org/pipermail/etherlab-users/2016/003026.html
Note: there is a bug in the ecMod_syncDistClock() funciton from that post. It should probably instead be (changed line in bold):
int32_t ecMod_syncDistClock(
void *this /**< pointer to module etherCATModule_s */
)
{
etherCATModule_s *ecMod = this;
uint32_t masterTime;
// cache lower 32 bits of prev master time and get now
masterTime = (uint32_t)ecMod->m_dcTime;
ecMod->m_dcTime = app_getTimeNS();
// use the dc ref slave to adjust the masters time base
// get lower 32 bit of clock time from reference slave (after first scan)
if (ecMod->m_getDCDiff)
{
int res;
uint32_t slaveTime;
res = ecrt_master_reference_clock_time(ecMod->master, &slaveTime);
switch (res)
{
case 0 :
{
// calc time diff
ecMod->m_dcDiff = masterTime - slaveTime;
} break;
default :
{
// no ref clock found or datagram failure
ecMod->m_dcDiff = 0;
}
}
}
else
{
ecMod->m_dcDiff = 0;
ecMod->m_getDCDiff = true;
}
// call to sync slaves to ref slave
// (which is used for ecrt_master_reference_clock_time)
ecrt_master_sync_slave_clocks(ecMod->master);
// set master time in nano-seconds
ecrt_master_application_time(ecMod->master, ecMod->m_dcTime);
return 0;
}
Graeme.
________________________________
From: Jiarui Lian <jerry at bertec.com>
Sent: Friday, 13 January 2017 04:57
To: Graeme Foot
Subject: not found Re: Patch for Distributed Clock?
Hi, Graeme:
I couldn't found the following functions in your patch:
(as you mentioned in: http://lists.etherlab.org/pipermail/etherlab-users/2012/001642.html)
1) ecrt_master_setup_distributed_clock()
2) ecrt_master_sync_slave_clocks_diff()
3) I have changed the ref_sync_datagram to 4 bytes instead of 8.
Did you send the wrong patch, or you change the function names?
Thanks!
Jerry
________________________________
From: "Graeme Foot" <Graeme.Foot at touchcut.com>
To: "Jiarui Lian" <jerry at bertec.com>
Cc: "etherlab-users" <etherlab-users at etherlab.org>
Sent: Wednesday, January 11, 2017 5:05:53 PM
Subject: Re: Patch for Distributed Clock?
Hi,
I've attached an hg changeset of the patches I use. You can get the DC related ones from it. If you look in the etherlab-dev forum you will also find Gavin's patchsets which will be more up to date.
Do a search for "etherlab-users dc" (or similar) to find posts related to how to set up distributed clocks. eg:
http://lists.etherlab.org/pipermail/etherlab-users/2016/003014.html
But to answer you question:
A system requires one master clock that all other clocks in the system sync to. That clock can either be the clock in the EtherCAT master or it can be a clock on one of the slaves (the dc reference slave). Separate to that, all dc slaves on the bus need to be synced to a reference slave clock. This should be the first slave on the bus that supports dc. The EtherLAB master will automatically select this for you, or with the patch you can select it yourself.
Generally the EtherCAT master clock has too much jitter to provide a nice stable system, so instead I use option two where my dc reference slave is the master clock and I adjust the EtherCAT master clock to it (this is the default option used by TwinCAT).
Also note (as described in the post I linked to above), there are two levels of dc support in slaves. DC clock level support (alot of simple IO slaves have this) and the ability to sync the IO to the dc clock (generally only more advanced slaves support this). The DC reference slave only requires the DC clock level of support.
In your case, if your AX5206 slave is the first slave it can be both the reference slave and the DC clock master.
Regards,
Graeme.
PS: Our system uses various IO modules and amps. Our dc reference slave is often our first IO module (an EL1008).
________________________________
From: Jiarui Lian <jerry at bertec.com>
Sent: Thursday, 12 January 2017 06:39
To: Graeme Foot
Subject: Patch for Distributed Clock?
Hi, Dear Mr. Graeme Foot:
I am studying IgH-EtherCAT-Master to control AX5206, and I saw your post in 2012:
http://lists.etherlab.org/pipermail/etherlab-users/2012/001642.html
* Would you mind to send a copy of the patch to me?
* And a question, when you said: "pick a ref slave and update my master time based on the ref slave time."
Does your system consist of at least two slaves with DC capability?
Master(Jitter) ---- Slave.1 (DC, Ref-to-Master) ---- Slave.2(DC, Ref-to-Slaves) ---- MoreSlaves
In my case, I have only one slave with DC:
Master(Jitter) ---- Slave.1(AX5206, DC) --- MoreSlaves
Any suggestion to me?
Thanks, your help is appreciated!
Sincerely,
Jerry
Bertec Corp.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20170112/c64676ed/attachment-0004.htm>
More information about the Etherlab-users
mailing list