Join us today!

MC_BufferMode in Tw...
 
Notifications
Clear all

MC_BufferMode in TwinCAT

4 Posts
2 Users
3 Reactions
1,019 Views
twinControls
Posts: 115
Admin
Topic starter
(@twincontrols)
Member
Joined: 2 years ago

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: 

Adding a virtual axis

Jog an Axis

 

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.

mc aborting firstSpeedisLower

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: 

The function block starts as soon as the last commanded movement is terminated. No blending takes place here. The new movement starts at the velocity that the previous movement has when the end condition is reached (Done, InVelocity, InEndVelocity, InGear, InSync, EndOfProfile, etc.). If the previous movement was MC_MoveAbsolute or MC_MoveRelative, then the new movement starts at standstill.

 

mc buffered firstSpeedisLower

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: 

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 lower velocity of the two movement commands.

mc blendingLow firstSpeedisLower

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.

mc blendingPrevious firstSpeedisLower

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.

mc blendingNext firstSpeedisLower

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.

mc BlendingHigh firstSpeedisLower

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: 

mc aborting

Axis has reached to 400 m since the first motion command has been aborted. 

 

Buffered: 

mc buffered

Axis has moved to 600m and stopped, then moved additional 400m. 

 

BlendingLow: 

mc blendingLow

Axis has reached 600 m at the speed of 25 mm/s. 

 

BlendingPrevious:

mc blendingPrevious

Axis has reached 600 m at the speed of 70mm/s and when reduced his speed to 25 mm/s. 

 

BlendingNext: 

mc 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:

mc 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.

 

 

Reply
3 Replies
Posts: 3
(@trofimich)
Active Member
Joined: 2 years ago

Have you tried buffered mode with MC_MoveContinuousAbsolute and MC_MoveContinuousRelative?

Reply
1 Reply
twinControls
Admin
(@twincontrols)
Joined: 2 years ago

Member
Posts: 115

@trofimich If you don't use the EndVelocity input, you'd get the same results : 

MC_BlendingLow:

mcMoveContinuos
blendingLow continusAbsolute

 

When you use the EndVelocity input, you'd get the 0x4292 NC Error for the second motion command(MC_MoveContinuousRelative):

moveContinuosError
bufferedContinuous

 

bufferMode details
Reply
Posts: 3
(@trofimich)
Active Member
Joined: 2 years ago

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 не працює в режимі буферизації? Більше звітів про помилки = більше шансів, що проблему буде вирішено.

 

Reply
Share: