interesting approach. I still wonder if you could also have some absolute reference(not that you need it, but if you wanted it) for position of the actual external motor(if that motor had an encoder). I suppose the problem would be whether the beckhoff encoder terminals could be made to work on the fieldbus. Did you also consider using the system variable for actual velocity as a source(I think it is $VEL_ACT)? It would be relative to the active TCP/BASE, so that may or may not be useful to you. Is the WAIT required? or could you just let it loop at the SPS update rate(which is potentially not much faster than that anyway).
I don't need absolute reference in my application. I need only turn the tool relative (aprox 90degree) several times during trajectory. I don't have drivers for my motors yet but I want to order them asap. I have to decide between cheaper driver with analog speed control and expensive EtherCat driver with position control. I tested this approach all day today and I think that analog speed control will be enough for my application.
I tried to find suitable system variable for 7th axis velocity. But $VEL_ACT is one number, which is showing total speed of robot (not axis separately) and it is counted from internal axis only. There is also a variable $VEL_AXIS[n], which shows speed for any axis separately. But n can be only 1-6 (internal axis only).
The WAIT command I use for this reason: I cannot predict how long will be main loop executed. I want to add some additional tasks to main loop and its duration my vary. This command guarantee a minimal loop time for me. And moreover this time will dominate in loop duration so actual loop duration will be relative stable. So I can predict loop duration and I can predict counted velocity values also (which is necessary for level constant enumeration). I plane to replace WAIT command using timer, it will be more precise I hope.