Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Override DesPos in user-written servo routine
#1
Hi, I have computed all the servo reference positions offline. I would like to set them as the reference position for each servo update. Can anyone help me with the following questions:

1. There are hundreds of thousands of offline generated positions. How can I store it in the PMAC? and How does the servo routine access these data?

2. Is this possible to call the already tunned standard servo algorithm to generate the servo output, but use the offline position as the DesPos input?

Many thanks,
Wenbin
Reply
#2
(05-30-2019, 12:54 PM)wbzhong Wrote: Hi, I have computed all the servo reference positions offline. I would like to set them as the reference position for each servo update. Can anyone help me with the following questions:

1. There are hundreds of thousands of offline generated positions. How can I store it in the PMAC? and How does the servo routine access these data?

2. Is this possible to call the already tunned standard servo algorithm to generate the servo output, but use the offline position as the DesPos input?

Many thanks,
Wenbin

The picture illustration of my question is attached. Many thanks.


Attached Files Image(s)
   
Reply
#3
Power PMAC's user shared memory buffer is good for applications like this. You can create a giant array of your desired setpoints in the buffer. I would structure the array using "Ddata" (double-precision floating-point) elements, because this is the same format used by the servo algorithms.

You can load the buffer with a series of on-line Script commands like:

Sys.Ddata[1]=3.14159

To save some time, you can load several consecutive elements with a command like:

Sys.Ddata[1]=3.14159, 2.71828, 1.61803, 6.28318

which loads Ddata[1] to [4].

(I would not use Sys.Ddata[0], as it is too easy to have other tasks write to this register.)

Each Ddata element occupies 8 bytes. The default buffer size is 1 Mbyte, so 128K values can be stored without changing the size of the buffer. The buffer can easily be made bigger in the "Project Properties" control of the IDE. Set a bigger number in the "User Buffer" field. You must reload your project before the new size takes effect.

To use this data, the most flexible way is with a simple looping motion program. For example:

open prog 1
local Index;
abs;
spline (MyMoveTime);
Index = StartIndex;
while (Index <= EndIndex)
{
X(Sys.Ddata[Index]);
Index++;
}
close

If you set MyMoveTime to Sys.ServoPeriod, it will use one new point each servo cycle. But you can vary the time with this technique and it will interpolate smoothly.

You could also use a PLC 0 with Sys.RtIntPeriod=0 so it executes every servo cycle:

open plc 0
local Index;
Index = StartIndex;
while (Index <= EndIndex)
{
Motor[1].MasterPos = Sys.Ddata[Index];
Index++;
}
disable plc 0
close

In this approach, you cannot vary the update time from the servo period.
Reply
#4
Many thanks for your reply. It is a big relief to avoid developing my own servo routines. I will try these techniques in my application, and let everyone know how it works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)