Join us today!
MC_BufferMode in TwinCAT
We will examine motion behavior of an axis with different buffer modes in this tutorial. The processing of subsequent move command is determined by BufferMode, which regulates the movement orders.
To get started, create a TwinCAT project and add a virtual axis. If you are not familiar with adding an axis and enabling power, you can check the tutorials below:
We will first command MC_MoveAbsolute and then we will command MC_MoveRelative when the axis starts moving . Add the code below in your MAIN program.
VAR Axis_1 : AXIS_REF; fbPowerOn : MC_Power; fbMoveAbs : MC_MoveAbsolute; fbMoveRel : MC_MoveRelative; mcBufferMode : MC_BufferMode; bGotoPos1: BOOL := FALSE; eMovePos : (E_Init, E_POS1, E_POS2 ) := E_init; bEnableAxis: BOOL; END_VAR
fbPowerOn(Axis:= Axis_1, Enable:= bEnableAxis, Enable_Positive:= bEnableAxis, Enable_Negative:= bEnableAxis); IF bGotoPos1 THEN eMovePos := E_POS1; END_IF CASE eMovePos OF E_init: fbMoveAbs(Axis:= Axis_1, Execute:= FALSE); fbMoveRel(Axis:= Axis_1, Execute:= FALSE); E_POS1: fbMoveAbs(Axis:= Axis_1, Execute:= bGotoPos1, Position:= 200, Velocity:= 30, Acceleration:= 10, Deceleration:= 10, BufferMode:= mcBufferMode ); IF fbMoveAbs.Busy THEN fbMoveAbs(Axis:= Axis_1, Execute:= FALSE); bGotoPos1 := FALSE; eMovePos := E_POS2; END_IF E_POS2: fbMoveRel(Axis:= Axis_1, Execute:= TRUE, Distance:= 550, Velocity:= 55, Acceleration:= 15, Deceleration:= 15, BufferMode:= mcBufferMode ); IF fbMoveRel.Done THEN fbMoveRel(Axis:= Axis_1, Execute:= FALSE); eMovePos := E_Init; END_IF END_CASE
First motion command is commanding the virtual axis to go to 200 mm at the sped of 30 mm/s and the second one is commanding to move additional 550 mm at the speed of 55 mm/s.
We will test the Aborting, Buffered, BlendingLow, BlendingPrevious, BlendingNext , BlendingHigh modes consecutively. For this test our first motion command velocity is lower than the second one.
Set to mcBufferMode to;
Aborting:
Default mode without buffering. The function block starts immediately and aborts an active movement. The command takes immediate effect on the axis.
We can see that MC_MoveAbsolute command is aborted and MC_MoveRelative command is executed immediately. Therefore the axis location at the end of the motion is 550 m.
Buffered:
|
With the buffered mode activated, the axis first went to 200 m and finished its movement and stopped, then it moved additional 550 m and reached the 750 m position.
BlendingLow:
|
Axis has moved to 200 m and didn't stop at all, started accelerating and reached the speed of 55 mm/s, finished its movement at 750 m.
BlendingPrevious:
The function block starts as soon as the last commanded movement is terminated. The axis does not stop between movements, but passes through the end position of the first movement at the velocity of the first movement command.
Axis motion has followed the same pattern as the MC_BlendingLow since the first motion command speed is lower than the second motion command speed. Axis has moved to 200 m and didn't stop at all, started accelerating and reached the speed of 55 mm/s, finished its movement at 750 m.
BlendingNext:
The function block starts as soon as the last commanded movement is terminated. The axis does not stop between movements, but passes through the end position of the first movement at the velocity of the second movement command.
Axis has reached the speed of 55 mm/s at 200m and finished its movement at 750m .
BlendingHigh:
The function block starts as soon as the last commanded movement is terminated. The axis does not stop between movements, but passes through the end position of the first movement at the higher velocity of the two movement commands.
Axis motion has followed the same pattern as the MC_BlendingNext since the first motion command speed is lower than the second motion command speed. Axis has reached the speed of 55 mm/s at 200m and finished its movement at 750m .
Now let's change the positions and speeds for the motion commands. This time we will use a higher velocity for the first motion command. Make the changes below in the program:
fbMoveAbs(Axis:= Axis_1, Execute:= bGotoPos1, Position:= 600, Velocity:= 70, Acceleration:= 30, Deceleration:= 30, BufferMode:= mcBufferMode );
fbMoveRel(Axis:= Axis_1, Execute:= TRUE, Distance:= 400, Velocity:= 25, Acceleration:= 20, Deceleration:= 20, BufferMode:= mcBufferMode );
MC_MoveAbsolute is commanding axis to go to 600 m at the speed of 70 mm/s, then MC_MoveRelative is moving the axis additional 400 m at the speed of 25 mm/s.
Set to mcBufferMode to;
Aborting:
Axis has reached to 400 m since the first motion command has been aborted.
Buffered:
Axis has moved to 600m and stopped, then moved additional 400m.
BlendingLow:
Axis has reached 600 m at the speed of 25 mm/s.
BlendingPrevious:
Axis has reached 600 m at the speed of 70mm/s and when reduced his speed to 25 mm/s.
BlendingNext:
Axis motion has followed the same pattern as BlendingLow since the first motion command speed is higher than the second motion command speed. Axis has reached 600 m at the speed of 25 mm/s.
BlendingHigh:
Axis motion has followed the same pattern as BlendingPrevious since the first motion command speed is higher than the second motion command speed. Axis has reached 600 m at the speed of 70mm/s and when reduced his speed to 25 mm/s.
After these tests we can say that when the speed of first motion command is lowered than the second one, BlendingLow/BlendingPrevious and BlendingHigh/BlendingNext would have the same result.
When the speed of first motion command is higher than the second one, BlendingLow/BlendingNext and BlendingHigh/BlendingPrevious would have the same result.
In case you want to say thank you !)
We'd be very grateful if you could share this community with your colleagues and friends. You can also buy us a coffee to keep us fueled 😊 This is the best way to say thank you to this project and support your community.
twinControls - https://twincontrols.com/
Have you tried buffered mode with MC_MoveContinuousAbsolute and MC_MoveContinuousRelative?
@trofimich If you don't use the EndVelocity input, you'd get the same results :
MC_BlendingLow:
When you use the EndVelocity input, you'd get the 0x4292 NC Error for the second motion command(MC_MoveContinuousRelative):
In case you want to say thank you !)
We'd be very grateful if you could share this community with your colleagues and friends. You can also buy us a coffee to keep us fueled 😊 This is the best way to say thank you to this project and support your community.
twinControls - https://twincontrols.com/
I wrote about this bug to Beckhoff support ~5 years ago and see that it's still not fixed.
They choose wrong implementation: one command (MC_MoveContiniousXxx) internally implemented as two commands in buffered mode. Implementation should be changed of buffer size should be increased, but Beckhoff decided to ignore this problem.
Possibly you also can write to support and ask why MC_MoveContiniousXxx does not work in buffered mode? More bug reports = more chances that problem will be fixed.
Можливо, ви також можете написати в службу підтримки і запитати, чому MC_MoveContiniousXxx не працює в режимі буферизації? Більше звітів про помилки = більше шансів, що проблему буде вирішено.
- 17 Forums
- 267 Topics
- 942 Posts
- 0 Online
- 722 Members