[etherlab-users] Timing measurements
Inselmini Paolo
Paolo.Inselmini at ch.gfac.com
Thu Nov 26 14:12:12 CET 2009
inline response in red,
best regards,
Paolo
-----Original Message-----
From: Peter van Knippenbergh [mailto:peter.van.knippenbergh at sioux.eu]
Sent: giovedì, 26. novembre 2009 13:32
To: Inselmini Paolo
Cc: peter.van.knippenbergh at sioux.nl
Subject: RE: [etherlab-users] Timing measurements
Hi
Thank you for your quick reply, but not is everything is clear yet, see inline (below)
From: Inselmini Paolo [mailto:Paolo.Inselmini at ch.gfac.com]
Sent: Thursday, November 26, 2009 10:22 AM
To: Peter van Knippenbergh
Subject: RE: [etherlab-users] Timing measurements
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);
The decat_time time is not defined, so in my opinion the line must be :
EtherCAT_timeSync.delta_ecat_time_ns = (u32)((0x100000000LL) + (s64)(EtherCAT_timeSync.delta_ecat_time_ns));
Is that correct ??
R: Yes, it is!! the delta_ecat_time was added for you, I only use the absolute time... I made a mistake.
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);
I assume I must export this function to user space, the same way as for example ecrt_master_send
R: Yes, you should. I use this function only in kernel space so I did not exported to user space.
EXPORT_SYMBOL(EtherCAT_timeSync);
I assume I must create a function to export this struct to userspace, where the parameter is a pointer to a EtherCAT_timeSync stuct.
R: In kernel space I access directly to the structure to read the delta_ecat_time_ns value, you can create a simple function without parameters that return the value you need (ecat_time_ns or delta_ecat_time_ns) and export this function to the user space like you will do with the ecrt_get_slave_sync_time function.
Kind regards
Peter van Knippenbergh
Paolo Inselmini
Development Engineer
_____
AGIE SA
via dei Pioppi 2, 6616 Losone, Svizzera
phone +41 (0) 91 806 95 73, Fax +41 (0) 91 806 92 42
paolo.inselmini at ch.gfac.com<mailto:paolo.inselmini at ch.gfac.com>, www.gfac.com<http://www.gfac.com/>
_____
GFAgieCharmilles - Achieve more
-----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/459b77fa/attachment-0004.htm>
More information about the Etherlab-users
mailing list