[etherlab-users] Calculation of time_diff in ec_fsm_master_dc_offset()
Gavin Lambert
gavinl at compacsort.com
Tue Apr 30 04:11:09 CEST 2013
Quoth Florian Pose:
> Am 23.01.2013 17:36, schrieb Jun Yuan:
> > 1. I must call ecrt_master_application_time() once somewhere before my
> > run loop, otherwise I'll get error "No app_time received up to now",
> > and ec_fsm_master_state_dc_read_offset will not be executed. The app
> > time given to the ecrt_master_application_time() at this point is not
> > important, it will not be used anywhere. Calling the function
> > ecrt_master_application_time(master, dummy_time) can avoid
> > master->has_app_time = 0 in ec_fsm_master_enter_write_system_times().
>
> you should not call ecrt_master_application_time() at an arbitrary time
> before cyclic operation, because the initial value is used to calculate
> the phase offset of the sync0 start times. You should call it in cyclic
> operation only.
Just to bring this topic back again: I've tried pulling the latest tip code
and noticed that you've added a note to this effect to the docs. But using
the dc_user sample (modified for my slave device layout) or my own test
program which does only call ecrt_master_application_time() during the cycle
always results in "no app_time received up to now, but master already
active" -- which in turn still implies that it is actually supposed to be
called before activating the master.
(Typically afterwards I also get "slave did not sync after 5000 ms"; I'm not
sure whether this is the master's fault or the slave's, or the specific DC
settings being used.)
This warning doesn't occur if I do actually call
ecrt_master_application_time() at any time prior to the cyclic loop. For
the moment, the compromise I am making is to call it from within
cyclic_task() but above the while loop -- this way it will be approximately
in phase as the first thing the loop does is to wait for the cycle time.
Although it does do other processing before calling it within the loop.
(Also this seems to improve but not completely fix the "slave did not sync"
thing.)
Which "end" of the cycle is it best to call it from? Closer to
ecrt_master_receive()/ecrt_domain_process(), or closer to
ecrt_master_send()? If the latter then it's probably not feasible to call
it at the same phase each time, as domain processing time may be variable.
More information about the Etherlab-users
mailing list