[etherlab-users] Slave DC start time calculation
Philippe Leuba
pleuba at swissonline.ch
Wed May 16 18:22:15 CEST 2018
Hi All,
I can not understand how to configure correctly my slaves with the ecrt_slave_config_dc() function.
I use nine EL7211-9014 servo controllers and the XML declarations is:
<Dc>
<OpMode>
<Name>DC</Name>
<Desc>DC-Synchron</Desc>
<AssignActivate>#x700</AssignActivate>
<CycleTimeSync0 Factor="1">0</CycleTimeSync0>
<ShiftTimeSync0 Input="0">30000</ShiftTimeSync0>
<CycleTimeSync1 Factor="-1">0</CycleTimeSync1>
<ShiftTimeSync1>1000</ShiftTimeSync1>
</OpMode>
</Dc>
SYNC0 and SYNC1 should be fired at each cycle.
My realtime cycle is at 500us, so initially I used:
ecrt_slave_config_dc(sc, 0x0700, 500000, 30000, 1000, 0);
but I sometimes faced some hiccup on some motor movements (almost always on the same motor, but sometimes not), most probably due to frames late regarding SYNC events, so I increased the sync1_shift to half of the cycle time:
ecrt_slave_config_dc(sc, 0x0700, 500000, 250000, 1000, 0);
This help, but I’m still not convinced that it is correct.
How can I debug this, I did not see any error on slaves COEs 1c32 or 1c33 ?
Startup debug messages are the followings:
EtherCAT DEBUG 0-12: Checking for synchrony.
EtherCAT DEBUG 0-12: 19 ns difference after 1 ms.
EtherCAT DEBUG 0-12: app_start_time=64456682505935
EtherCAT DEBUG 0-12: app_time=64460192975876
EtherCAT DEBUG 0-12: start_time=64460292975876
EtherCAT DEBUG 0-12: cycle=501000
EtherCAT DEBUG 0-12: shift_time=250000
EtherCAT DEBUG 0-12: remainder=263941
EtherCAT DEBUG 0-12: start=64460293462935
EtherCAT DEBUG 0-12: Setting DC cyclic operation start time to 64460293462935.
EtherCAT DEBUG 0-12: Setting DC AssignActivate to 0x0700.
-
-
-
EtherCAT DEBUG 0-13: Checking for synchrony.
EtherCAT DEBUG 0-13: 9 ns difference after 1 ms.
EtherCAT DEBUG 0-13: app_start_time=64456682505935
EtherCAT DEBUG 0-13: app_time=64460854977928
EtherCAT DEBUG 0-13: start_time=64460954977928
EtherCAT DEBUG 0-13: cycle=501000
EtherCAT DEBUG 0-13: shift_time=250000
EtherCAT DEBUG 0-13: remainder=444993
EtherCAT DEBUG 0-13: start=64460955283935
EtherCAT DEBUG 0-13: Setting DC cyclic operation start time to 64460955283935.
EtherCAT DEBUG 0-13: Setting DC AssignActivate to 0x0700.
I’m really surprised that the remainder can be so different, so I looked in the source code and can not understand the logic:
// set DC start time
start_time = master->app_time + EC_DC_START_OFFSET; // now + X ns (X being 100000000 = 100 ms)
if (sync0->cycle_time) {
// find correct phase
if (master->has_app_time) {
u64 diff, start;
u32 remainder, cycle;
diff = start_time - master->app_start_time;
cycle = sync0->cycle_time + sync1->cycle_time;
remainder = do_div(diff, cycle);
start = start_time + cycle - remainder + sync0->shift_time;
Why the cycle is the sum of the two sync->cycle_time, in my case 501000, should not it be: sync0->cycle_time (500000) ?
This was changed on 2016-09-16, but It seems it was right before.
I can see that sync0->cycle_time is written to register 9A0 (500000)
and sync1->cycle_time is written to register 9A4 (1000), this is correct.
It seems to me that the sync1_cycle parameter of the ecrt_slave_config_dc() is handled as as sync1_shift, this is really confusing.
Is it normal, can someone explain this ?
Philippe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20180516/4349b11e/attachment-0002.htm>
More information about the Etherlab-users
mailing list