[etherlab-users] Distributed Clock with Yaskawa SGDV drives

Graeme Foot GraemeF at touchcut.com
Mon Feb 6 22:18:48 CET 2012


Hi,

>From section 9.2.3 of the ET1100 Hardware Data Sheet:

"Internally, the SyncSignals are generated with an update rate of 100 MHz (10 ns update cycle).  The jitter of the internal SyncSignal generation in comparison to the System Time is 12 ns."

This may be the 10 ns dither you are seeing.

It looks like you are saying each subsequent slave has a slightly delayed sync signal.  At a guess a possible reason for this is that the master calculates each slaves System Time Delay (0x0928:0x092B) on activation (and rescan?) when there is no other data being sent.  Once pdo communications start each slave has a little more processing to do before sending on the packet to the next slave.

You could maybe try sending the dc clock sync at another time and see if that helps, or force a rescan when the system is up and running and see if the System Time Delays are calculated differently.

Regards,
Graeme.



-----Original Message-----
From: George Broz [mailto:GBroz at moog.com] 
Sent: Saturday, 4 February 2012 09:33
To: Graeme Foot
Cc: etherlab-users at etherlab.org
Subject: Re: [etherlab-users] Distributed Clock with Yaskawa SGDV drives

Graeme, thanks for the explanation - there are a lot of 
subtleties in dealing with DC so I appreciate the detail.

To force the slave's system time offset to be calculated, we
were clearing out the register (0x910:0x927) using the 
ethercat reg_write command for the same ends. Changing
EC_SYSTEM_TIME_TOLERANCE_NS is better, especially if a 
rescan occurs.

The timing between ecrt_master_activate() and starting the
real-time thread might explain an issue we're having with 
a slave here - we get a "Fatal Sync Error" soon after startup.
We will try putting activate() into the worker thread as you 
have.

One other issue we see here is that there is a constant
offset between the SYNC0 pulse of the reference slave 
and the SYNC0 pulses of other slaves around which there 
is some dithering. The constant offset is slave position
dependent - slave one 20 ns ... slave four 80 ns. The 
dithering is roughly 10 ns. I would have thought that 
the propagation delay algorithm would have soaked this up.

I have not seen any documentation indicating which registers
use sign and magnitude format.

Thanks again.

Best regards,
--George Broz
Moog Inc. Industrial Group


-----<etherlab-users-bounces at etherlab.org> wrote: -----
To: <etherlab-users at etherlab.org>
From: Graeme Foot 
Sent by: 
Date: 02/02/2012 05:04PM
Subject: Re: [etherlab-users] Distributed Clock with Yaskawa SGDV drives

I think I'm on track to getting it sorted.


First off, I didn't understand the distributed clock system well enough.

I was originally getting "Slave did not sync after 5000 ms" error messages.  To avoid this error I moved the ecrt_slave_config_dc call to the realtime section (making an rtdm version) and waiting for all of the slaves to be in op mode.  This is wrong, because ecrt_slave_config_dc needs to be called during the config stage as the dc settings are applied as the slave goes from PREOP to OP.

Instead to avoid the "Slave did not sync after 5000 ms" error I have changed the "EC_SYSTEM_TIME_TOLERANCE_NS" value to 10000 in fsm_master.c.  This is the value used to decide whether the slave's system time offset should be updated or not.  My slaves (when they are working) take a long time to settle and the default of 100000000 (100ms) was way too large.


Another thing I was doing wrong is that I was activating the master too early.  As part of my configuration setup I need to get the domain data addresses.  To be able to get these in user space the master has to be activated, at which point the domain data is allocated.  But my SGDV slaves need to have regular communications once the master is activated, and my realtime thread didn't start up until some time later.

So to sort this out I have added a user space method "ecrt_master_setup_domain_memory".  This will set up the domain data memory.  It needs to be called after all PDO entries have been registered and before activating the master.  This method is optional, so if it has not been called the ecrt_master_activate will set up the memory as usual.

I have also added a user space version of ecrt_domain_size.


The last piece of the puzzle is that I need to call ecrt_master_activate once my realtime loop has been activated.  This can't be an rtdm call because 1) it blocks for a few milliseconds and 2) it needs to be called in the context of the character device (especially if the domain memory needs to be set up).  Note: ecrt_rtdm_master_application_time should be called before the master is activated, otherwise the master will skip updating slave System Time Offsets.

So to be able to call ecrt_master_activate I have created a non-realtime worker thread that I use to make the ecrt_master_activate and ecrt_master_deactivate calls when appropriate.


So the general flow of commands is:

configure master
  ecrt_request_master
  ecrt_master_create_domain
configure slaves (pdos)
  ecrt_master_slave_config
  ecrt_slave_config_pdos
  ecrt_slave_config_reg_pdo_entry
connect to rtdm
  rt_dev_open(rtdm)
  ecrt_domain_index
  ecrt_rtdm_master_attach
setup domain memory
  ecrt_master_setup_domain_memory
  ecrt_domain_data
  ecrt_domain_size
configure slaves (sdos / dc)
  ecrt_slave_config_sdo8
  ecrt_slave_config_dc

create master_activate thread -------+
                                     |
start realtime                       |
  request master_activate     -->    | ecrt_master_activate
  ecrt_rtdm_master_recieve           | (after first sync dc)
  sync dc                            |
  ecrt_rtdm_master_send              |
                              <--    | master activated
  ecrt_rtdm_master_recieve           |
  ecrt_rtdm_domain_process_all       |
  check domain state                 |
  check master state                 |
  update domain data                 |
  sync dc                            |
  ecrt_rtdm_domain_queue_all         |
  ecrt_rtdm_master_send              |
                                     |
  request master deactivate   -->    | ecrt_master_deactivate
  ecrt_rtdm_master_recieve           |
  ecrt_rtdm_domain_process_all       |
  check domain state                 |
  check master state                 |
  update domain data                 |
  sync dc                            |
  ecrt_rtdm_domain_queue_all         |
  ecrt_rtdm_master_send              |
                              <--    | master deactivated
stop realtime                        |
stop master_activate thread          +

cleanup
  rt_dev_close(rtdm)
  ecrt_release_master



Unfortunately my slaves still do not always behave.
- Once I've had synchronization errors I need to power off the slave before it will start behaving again.
- The Speed Counter Diff (0x0932:0x0933) value stays zero, so I can't tell how much drift is occurring.
- I'm getting the odd synchronization error on shutdown.  I think I need to wait until all slaves are in PREOP state before stopping sending the pdo data.


Another thing I've found is that the Speed Counter Diff value seems to be an int16, whereas the System Time Diff (0x092C:0x092F) value is an sm32.  Is there any documentation as to which values are sm (sign and magnitude) vs int?


Hopefully the above all made sense and was not too rambling.

Regards,
Graeme.


-----Original Message-----
From: etherlab-users-bounces at etherlab.org [mailto:etherlab-users-bounces at etherlab.org] On Behalf Of Graeme Foot
Sent: Wednesday, 1 February 2012 20:28
To: etherlab-users at etherlab.org
Cc: George Broz
Subject: Re: [etherlab-users] Distributed Clock with Yaskawa SGDV drives


Hi,

After a bit more testing (still some to go):

- I have solved the problem where the System Time Delay values are wrong for the yaskawa SGDV's.  At the end of slave 8 we were using an EL9010 terminal.  The master then detected that port1 was open on slave 8, but there were no slaves to communicate too.  (The SGDV's are hanging off slave 2, EK1100.)  The drift still occurs.


- I have found that the Speed Counter Diff (0x0932:0x0933) value on the SGDV slaves remain zero whereas the rest of the slaves seem to be doing their jobs.

George, the Speed Counter Diff values you have below should be 16 bit, so your values will be more like:
  slave 1: Speed Counter Diff   0x0932:0x0933: 0xf1d6 -470
  slave 2: Speed Counter Diff   0x0932:0x0933: 0xf247 -583
  slave 3: Speed Counter Diff   0x0932:0x0933: 0xf1fa -506


- All slaves System Time Diff (0x092C:0x092F) values are bouncing around in the +-50 range.  Sometimes the SGDV values start to take off, but the drift is there whether they look stable or are taking off.


- My DC Reference Clock slave is slave 0 (the CX1100-0004).  This is also a 32 bit dc.  The master is only distributing the first 4 bytes from this ref slave to the rest of the slaves which looks correct.


- I still need to look into why the ecrt_slave_config_dc call is failing.



At the moment I'm suspecting a problem with the drives firmware (which is 3.1).  I'll contact Yaskawa and see if they have any ideas.


Regards,
Graeme.


-----Original Message-----
From: George Broz [mailto:GBroz at moog.com] 
Sent: Wednesday, 1 February 2012 08:45
To: Graeme Foot
Cc: etherlab-users at etherlab.org
Subject: Re: [etherlab-users] Distributed Clock with Yaskawa SGDV drives

Hello,

Regarding Speed Counter Diff (0x0932:0x0933) - I haven't paid too
much attention to it, but for us all of the slaves generally
settle on the same approx. large number when in sync - for example:

slave 1: Speed Counter Diff   0x0932:0x0933: 0x0c04f1d6 201650646
slave 2: Speed Counter Diff   0x0932:0x0933: 0x0c04f247 201650759
slave 3: Speed Counter Diff   0x0932:0x0933: 0x0c04f1fa 201650682



Regarding the place in the code where the reference slave 
is determined, see:

ec_master_find_dc_ref_clock()

This runs at the same times the propagation delay is calculated
(driver insertion, ethercat rescan, or bus change causes rescan).

It is in this function too where the sync slave datagram is setup
which is a FRMW (read/multiple write) instruction. Read 0x910 from
reference slave address and write it to the other slaves.


Not certain if the slave with the reference clock needs to have its 
distributed clock enabled (with ecrt_slave_config_dc). From the 
EtherCAT spec. it seems that DC synchronization and SYNC0/1 
generation are independent functions. The slave synchronization 
depends on distributing the 0x910 register which continues to update 
even when the slave is not "Activated". That's a good question.


Best regards,

--George Broz
Moog, Inc. Industrial Group

-----<etherlab-users-bounces at etherlab.org> wrote: -----
To: <etherlab-users at etherlab.org>
From: Graeme Foot 
Sent by: 
Date: 01/30/2012 11:04PM
Subject: Re: [etherlab-users] Distributed Clock with Yaskawa SGDV drives

Hi,

I have been playing with various options but I'm still getting a drift on my slave relative to the master.


What I have found so far:

1) It looks like my slave requires no other frames on the ring when first setting up the distributed clocks (thanks for pointing that out George).
- I now run only the distributed clock functions for 1 second before adding in the polling pdos.
- This seems to make the System Time Diff (0x092C:0x092F) value remain small, but the Speed Counter Diff (0x0932:0x0933) remains at zero.


2) The System Time Delay (0x0928:0x092B) is a negative number.  The reported slave delays are:
  Slave 0  (CX1100-0004)  0 ns
  Slave 1  (EK1110)       140 ns
  Slave 2  (EK1100)       2670 ns
  Slave 3  (EL2602)       2815 ns
  Slave 4  (EL2008)       2960 ns
  Slave 5  (EL1008)       3100 ns
  Slave 6  (EL1018)       3240 ns
  Slave 7  (EL3162)       3385 ns
  Slave 8  (EL4132)       3530 ns
  Slave 9  (Yaskawa SGDV) 2147486168 ns  (-2520)
  Slave 10 (Yaskawa SGDV) 2147487253 ns  (-3605)

The last two being the ones with the problems.  I still need to look into how the calculations are working with 32 bit dc.


3) The System Time Diff (0x092C:0x092F) is jumping around small -ve and positive numbers but the Speed Counter Diff (0x0932:0x0933) is remaining at zero.  If there was drift in the local clock I would have expected the System Time Diff to get bigger or the Speed Counter Diff to become non-zero to compensate for the drift.  Some example values:
  Recieve Time Port 0 (0x0900:0x0903):  0x6c18cae8 1813564136
  Recieve Time Port 1 (0x0904:0x0907):  0x6c18d362 1813566306
  Recieve EPU         (0x0918:0x091F):  0x000000006c18cae8 1813564136
  System Time         (0x0910:0x0917):  0x00000000e7ce6469 3889063017
  System Time Offset  (0x0920:0x0927):  0x0000000048df3bfd 1222589437
  System Time Delay   (0x0928:0x092B):  0x800009d8 -2520
  System Time Diff    (0x092C:0x092F):  0x00000003 3
  Speed Counter Start (0x0930:0x0931):  0x1001 4097
  Speed Counter Diff  (0x0932:0x0933):  0x0000 0


4) In the examples there are two methods used to pass the time to ecrt_ master_application_time:
a) in the kernel space example it is just adding the scan time to the current time, eg:
  dcTime += 1000000;
  ecrt_master_application_time(master, dcTime);
b) in the user space example it gets the time every cycle, eg:
  clock_gettime(CLOCK_TO_USE, &time);
  ecrt_master_application_time(master, TIMESPEC2NS(time));

I'm using RTAI LXRT with rtdm.  I have confirmed that my cycle times are consistent and when using rt_get_cpu_time_ns (with method b) I am not getting drift at the master.  I've also tried method a with no different result.  I still need to match the slave time against the master time, but I'll need to read the register (via rtdm) to do that


5) I'm calling ecrt_slave_config_dc on the SGDV drives after the system is up and running but the sync Cyclic Unit Control and Activation (0x0980:0x0981) bytes remain zero as does the SYNC 0 Cycle Time (0x09A0:0x09A3).  eg:
  ecrt_slave_config_dc(slave->sc, 0x0300, g_app.scanTimeNS, 500000, 0, 0);

Results in:
  SYNC 0 Start Time   (0x0990:0x0997):  0x0000000048df3ad1 1222589137
  SYNC 0 Pulse Length (0x0982:0x0983):  0x03e8 1000
  SYNC 0 Cycle Time   (0x09A0:0x09A3):  0x00000000 0
  Sync activation     (0x0980:0x0981):  0x0000 0

I still need to look at the code as to why this might be happening.

If I fill in these values manually, the start time starts ticking away as it should, but I still get drift.  (ie setting SYNC 0 Cycle Time (0x09A0:0x09A3) to 1000000; Sync activation (0x0980:0x0981) to 0x0300)



Apart from a couple of things mentioned above that I still need to look into, does anyone have anything else I should consider?

Also a couple of questions:
- The first slave with a distributed clock becomes the reference slave.  Is there any way to find out which slave that is?  (I haven't looked into the code yet.)
- Does the slave that is being used as the reference clock need to have its distributed clock enabled (with ecrt_slave_config_dc)?



I am using the latest 1.5.0 stable master:
  # ethercat version
  IgH EtherCAT master 1.5.0 ec8e1151b8a7+



Regards,
Graeme.





-----Original Message-----
From: etherlab-users-bounces at etherlab.org [mailto:etherlab-users-bounces at etherlab.org] On Behalf Of George Broz
Sent: Saturday, 28 January 2012 14:36
To: Graeme Foot
Cc: etherlab-users at etherlab.org
Subject: Re: [etherlab-users] Distributed Clock with Yaskawa SGDV drives

Hi,

It looks like the propagation (transmission) delay determination 
is failing. That algorithm runs on driver insertion, if there is 
a bus change, or if you use the command line tool and issue 
'ethercat rescan'. You can see the result (its register is 
0x0x928) using:

ethercat -p $1 -t uint32 reg_read 2344 4
(where $1 is your slave position.)

The number returned is in nanoseconds.

It should return with something that's a couple of 
hundred or a few thousand nanoseconds. This is then
used with the the System offset register (0x920) to
produce a System time from the slave's local time.

For starters, I'd try to write directly to the 
0x928 register supplying something reasonable. For example:

ethercat -p $1 -t uint32 reg_write 2344 1300

That value will stay in there as long as your bus configuration
does not change or is not scanned. That's just to make sure
the slave takes a value. 

If that works, you can take a quick look at the receive times 
for each port. These will change whenever the propagation delay
algorithm is run (e.g. ethercat rescan). These are what make 
the propagation measurement possible. Only pay attention to the 
ones where you have a physically connected slave (unconnected 
ports return a number - something that looks uninitialized, 
perhaps down at the slave?).

echo "Receive Time Port 0 - 0x0900:0x0903:" `ethercat -p $1 -t uint32 reg_read 2304 4`
echo "Receive Time Port 1 - 0x0904:0x0907:" `ethercat -p $1 -t uint32 reg_read 2308 4`
echo "Receive Time Port 2 - 0x0908:0x090B:" `ethercat -p $1 -t uint32 reg_read 2312 4`
echo "Receive Time Port 4 - 0x090C:0x090F:" `ethercat -p $1 -t uint32 reg_read 2316 4`
(where $1 is the slave position).

The difference between the numbers returned for connected ports
should be small (thousands of nanoseconds). 

There is a note in the EtherCAT spec that states that for some 
slaves the ring has to be empty of all other frames before the 
broadcast write packet associated with this measurment can work 
(see Beckhoff EtherCAT ET1100 datasheet section 9.1.2, just above 
table 26.) That would require support from the master. Perhaps 
your Yaskawa drives fall into that category. 

I have no experience with 32 bit DC slaves. Maybe there is a 
bug there?


BTW - if you want to view 0x92c (or others like it) with sign 
bit removed use -

ethercat -p $1 -t sm32 reg_read 2348 4


Best regards,

--George Broz
Moog, Inc. Industrial Group

-----<etherlab-users-bounces at etherlab.org> wrote: -----
To: <etherlab-users at etherlab.org>
From: Graeme Foot 
Sent by: 
Date: 01/26/2012 06:38PM
Subject: [etherlab-users] Distributed Clock with Yaskawa SGDV drives


Hi,
 
I'm having a problem with my Yaskawa SGCV drives.  I am using them with Cyclic Synchronous Position Mode.  The problems is that while moving they frequently get an unstable position error.  The unstable position errors last for about ΒΌ of a second and occur regularly every 4 (approx) seconds.
 
The position error is always less than the cycle delta position.  I am setting up the drives to use the distributed clock but I am suspecting that something is not set up correctly and the position error is occurring due to a drift in cycle relative to the master.
 
 The "DC system time transmission delay" (from the "ethercat slaves -v" command) for the drives are:
drive 1 (slave 9): 2147486148 ns
drive 2 (slave 10): 2147487218 ns
They are being reported as 32bit distributed clocks.
 
 
When doing the "ethercat reg_read -p<slave> -tint32 0x092C" command on each of the slaves then the slaves prior to the yaskawa drives get numbers such as:
0x00000010 16
0x00000024 36
0x80000011 -2147483631
0x80000004 -2147483644
 
Where the low order bytes contain low numbers but the sign bit may be on or off.
 
However, the yaskawa slaves are more like:
0x66a32ed9 1721970393
0x669f8483 1721730179
0x669d0223 1721565731
0x669b553f 1721455935
 
 
If I disconnect the drives then the rest of the slaves still behave the same (where the sign bit may be on or off).
 
 
Does anyone have any ideas what I should be looking at next?
 
 
Regards,
Graeme Foot
_______________________________________________
etherlab-users mailing list
etherlab-users at etherlab.org
http://lists.etherlab.org/mailman/listinfo/etherlab-users
_______________________________________________
etherlab-users mailing list
etherlab-users at etherlab.org
http://lists.etherlab.org/mailman/listinfo/etherlab-users
_______________________________________________
etherlab-users mailing list
etherlab-users at etherlab.org
http://lists.etherlab.org/mailman/listinfo/etherlab-users
_______________________________________________
etherlab-users mailing list
etherlab-users at etherlab.org
http://lists.etherlab.org/mailman/listinfo/etherlab-users
_______________________________________________
etherlab-users mailing list
etherlab-users at etherlab.org
http://lists.etherlab.org/mailman/listinfo/etherlab-users



More information about the Etherlab-users mailing list