Re: [etherlab-users] DC questions
Hi, Try having a look at: https://www.mail-archive.com/etherlab-users@etherlab.org/msg02641.html The post above shows the general flow of my program. I use RTAI. Below are the structures and functions I currently use to sync the master to the slave reference master. I think there's also some other versions out there in past forum posts. Some of the structures used: struct _etherCATModule_s { ... ec_master_t*master; /**< the ethercat master reference once attached */ ecDevice_s *m_dcRefSlave; /**< is there a configured ref slave? */ uint64_tm_dcTimeStart;/**< distributed clock first now time */ uint64_tm_dcTime; /**< distributed clock now time */ int32_t m_dcDiff; /**< distributed clock master to ref slave diff time */ bool_t m_getDCDiff; /**< we are ready to get the distributed clock diff time */ ... }; /** the global application data structure */ typedef struct _app_s { ... uint64_t scanTimeNS; /**< the amount of time per scan in nanoseconds */ uint64_t scanTimeMS; /**< the amount of time per scan in milliseconds */ doublescanTimeSec; /**< the amount of time per scan in seconds */ int32_t rtTimeDiff; /**< master time source time diff (ns) */ int32_t rtTimeDelta; /**< master time source time diff delta (ns) */ uint64_t rtTimeStart; /**< master time source time base start (ns) */ uint64_t rtTimeCurr; /**< master time source time base current (ns) */ int64_t rtAdjBy; /**< master time source cycle adjustment value (ns) */ uint64_t nextWakeTime;/**< next cycle wake time time (ns) */ uint64_t actualWakeTime; /**< actual cycle wake time (ns) */ uint64_t overruns;/**< the number of overruns that have occured */ ... } app_s; When preparing to run: intecRes; ec_slave_config_t *refSlaveConfig = NULL; // set up distributed clocks ecMod->m_dcTimeStart = app_getTimeNS(); ecMod->m_dcTime = ecMod->m_dcTimeStart; if (ecMod->m_dcRefSlave) { refSlaveConfig = ecMod->m_dcRefSlave->slaveConfig; } // set initial app time (time must be in phase with realtime cycle) ecrt_master_application_time(ecMod->master, ecMod->m_dcTimeStart); // select the slave device to be the reference clock ecRes = ecrt_master_select_reference_clock(ecMod->master, refSlaveConfig); if (ecRes < 0) return E_EC_ACTIVATE_ERROR; // activate the master ecRes = ecrt_master_activate(ecMod->master); if (ecRes < 0) return E_EC_ACTIVATE_ERROR; The "sync distributed clock" function is something like: 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, ); 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); // update the master time for the next cycle (in nano-seconds) // (this is required for the master to figure out the modules initial // dc time) ecrt_master_application_time(ecMod->master, ecMod->m_dcTime + g_app.scanTimeNS); return 0; } The "calc slave to master time drift and adjust master clock and cycle period to match" function is: #define DC_FILTER_CNT 1024 static bool_t u_dcStarted = false; static int32_t u_dcLastDiff = 0; static int64_t u_dcDiffTot = 0LL; static int64_t u_dcDeltaTot = 0LL; static int u_dcIdx = 0; /** update the master time based on ref slaves time diff * * called after the ethercat frame is sent to avoid time jitter in * ecMod_syncDistClock() */ int32_t ecMod_updateMasterClock( void *this/**< pointer to module module_s */ ) { etherCATModule_s *ecMod = this; assert(ecMod->master); if (u_dcStarted) { // calc drift (via un-normalised time diff)
[etherlab-users] ethercat absolut encoders
Hey there, Anybody are interested in a absolute ethercat encoder?, I have two, It was purchased for a hexpod project but it was no going. Best regards Javier Gomez ___ etherlab-users mailing list etherlab-users@etherlab.org http://lists.etherlab.org/mailman/listinfo/etherlab-users
[etherlab-users] Detect the loss of EtherCAT communication
Hi All, is there any other way for a slave to detect a failure of EtherCAT communication besides the syncmanager watchdogs e.g. connection loss between 2 slaves or a failure of the user application? The syncmanager watchdog only works for buffered mode but not for mailbox mode which has acyclic communication. Background: our slaves will use mainly mailbox communication (VoE) which is most suitable for our purpose. We solved this problem by introducing a status byte as PDO which also has a watchdog configured. I am still eager to know if there is some other possibility for a slave to detect missing EtherCAT communication. Thanks and best regards, Christoph Helmholtz-Zentrum Berlin für Materialien und Energie GmbH Mitglied der Hermann von Helmholtz-Gemeinschaft Deutscher Forschungszentren e.V. Aufsichtsrat: Vorsitzender Prof. Dr. Dr. h.c. mult. Joachim Treusch, stv. Vorsitzende Dr. Beatrix Vierkorn-Rudolph Geschäftsführung: Prof. Dr. Anke Rita Kaysser-Pyzalla, Thomas Frederking Sitz Berlin, AG Charlottenburg, 89 HRB 5583 Postadresse: Hahn-Meitner-Platz 1 D-14109 Berlin http://www.helmholtz-berlin.de ___ etherlab-users mailing list etherlab-users@etherlab.org http://lists.etherlab.org/mailman/listinfo/etherlab-users
[etherlab-users] R: DC questions
Thank you both for your answers. I would like to get again your help in order to find a little example, focused only on the synchronization part, for the b method introduced by Graeme, because I have already tried something but the application continuosly sends the "Failed to get reference clock time: Input/Output error" error. Thank you again. Best regards, Tommaso ___ etherlab-users mailing list etherlab-users@etherlab.org http://lists.etherlab.org/mailman/listinfo/etherlab-users