[etherlab-users] Timing measurements
Inselmini Paolo
Paolo.Inselmini at ch.gfac.com
Thu Nov 26 11:22:15 CET 2009
Hi
EL5101 support distributed clock so if you want to measure the cycle time you can do it by evaluating the response of the slave synchronization datagram.
I do that to synchronize the master with the slave reference clock. I implemented the ecrt_get_slave_sync_time function in the etherCAT master.c file to read the cycle time.
This function should be called every cycle, you can then read the cycle time within the exported EtherCAT_timeSync structure.
It's what you need?
struct {
u64 ecat_time_ns; //absolute sync thelegram time
u32 delta_ecat_time_ns; //sync thelegram cycle time
u32 ecat_time_1;
bool isSync;
struct semaphore lock;
} EtherCAT_timeSync;
void ecrt_get_slave_sync_time(ec_master_t *master)
{
u32 ecat_time;
//s32 delta_ecat_time;
if((master->has_start_time == 1) && (EtherCAT_timeSync.isSync ==0))
{
down(&EtherCAT_timeSync.lock);
EtherCAT_timeSync.isSync =1;
EtherCAT_timeSync.ecat_time_ns = master->app_start_time;
EtherCAT_timeSync.ecat_time_1 = (u32)(EtherCAT_timeSync.ecat_time_ns & 0xFFFFFFFF);
up(&EtherCAT_timeSync.lock);
}
if(master->sync_datagram.state == EC_DATAGRAM_RECEIVED)
{
down(&EtherCAT_timeSync.lock);
ecat_time = (u32) le32_to_cpup((void *)master->sync_datagram.data);
EtherCAT_timeSync.delta_ecat_time_ns = (s32)ecat_time - (s32)EtherCAT_timeSync.ecat_time_1;
if(EtherCAT_timeSync.delta_ecat_time_ns < 0)
EtherCAT_timeSync.delta_ecat_time_ns = (u32)(0x100000000LL + (s64)decat_time);
EtherCAT_timeSync.ecat_time_ns &= ~0xFFFFFFFFLL; // remove low 32 bits of the time
EtherCAT_timeSync.ecat_time_ns |= (u64)ecat_time; // add low 32 bits of readed ethercat absolute time
if(ecat_time < EtherCAT_timeSync.ecat_time_1)
{ //overflow, increment the owerflowed value
EtherCAT_timeSync.ecat_time_ns += 0x100000000LL;
}
EtherCAT_timeSync.ecat_time_1 = ecat_time;
up(&EtherCAT_timeSync.lock);
}
}
EXPORT_SYMBOL(ecrt_get_slave_sync_time);
EXPORT_SYMBOL(EtherCAT_timeSync);
Paolo
-----Original Message-----
From: etherlab-users-bounces at etherlab.org [mailto:etherlab-users-bounces at etherlab.org] On Behalf Of Peter van Knippenbergh
Sent: mercoledì, 25. novembre 2009 15:05
To: etherlab-users at etherlab.org
Subject: [etherlab-users] Timing measurements
Hi
I want to measure the latency of sending and receiving cyclic data, one of the slaves is a Beckhoff EL5101. I want to read a timing register every cycle.
I want to map a register (not an object) to the process data, and therefore I tried to use the 3rd fmmu, but when going to OP, the ethercat master zero's the 3rd fmmu.
Is there a easy way to get a timestamp in a user-space program for every cycle. It is ok for me if the communicated timestamp is an older tempstamp, because I want to use it for latency measurements.
Kind regards
Peter van Knippenbergh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20091126/327e6569/attachment-0005.htm>
More information about the Etherlab-users
mailing list