Active Velocity Control

Hello @michael_w,

this is a good remark to speed up the reaction. Thanks for this post.

But your code allows in some bad timing, the velocity to not beeing updated. If in the cycle the Movement Starts , the SetVelocity is changed, it will not be used, as the code will not correctly add a new Edge.

Example:

	30: 
			SetVelocity := 10.0; 
			
			MC_MoveAbsolute_0.Position			:= 200.0; 
			MC_MoveAbsolute_0.Direction			:= mcPOSITIVE_DIR; 
			MC_MoveAbsolute_0.Velocity 			:= SetVelocity; 
			MC_MoveAbsolute_0.Acceleration		:= 50.0; 
			MC_MoveAbsolute_0.Deceleration		:= 50.0; 
			MC_MoveAbsolute_0.Execute 			:= 1; 
			Step := 31; 
			
			SetVelocity := 5.0; 
		31: 	
			
			IF MC_MoveAbsolute_0.Busy THEN 
				MC_MoveAbsolute_0.Execute 	:= 0; 
			END_IF

			IF MC_MoveAbsolute_0.Velocity <> SetVelocity THEN 
				MC_MoveAbsolute_0.Execute 	:= 1; 
				MC_MoveAbsolute_0.Velocity 	:= SetVelocity; 
			ELSIF MC_MoveAbsolute_0.Done THEN 
				MC_MoveAbsolute_0.Execute 	:= 0; 
				Step := 40; 	
			END_IF

Not much difference but now it will generate a correct edge in any case. There is now mostly no
lose of cycle, only if you hit the Velocity-Change to the one cycle we need to reset the Execute.

	30: 
			SetVelocity := 10.0; 

			MC_MoveAbsolute_0.Position			:= 200.0; 
			MC_MoveAbsolute_0.Direction			:= mcPOSITIVE_DIR; 
			MC_MoveAbsolute_0.Velocity 			:= SetVelocity; 
			MC_MoveAbsolute_0.Acceleration		:= 50.0; 
			MC_MoveAbsolute_0.Deceleration		:= 50.0; 
			MC_MoveAbsolute_0.Execute 			:= 1; 
			Step := 31; 
			
			SetVelocity := 5.0; 
		31: 	
			
			IF MC_MoveAbsolute_0.Busy AND MC_MoveAbsolute_0.Execute = 1 THEN 
				MC_MoveAbsolute_0.Execute 	:= 0; 
			ELSIF MC_MoveAbsolute_0.Velocity <> SetVelocity THEN 
				MC_MoveAbsolute_0.Execute 	:= 1; 
				MC_MoveAbsolute_0.Velocity 	:= SetVelocity; 
			ELSIF MC_MoveAbsolute_0.Done THEN 
				MC_MoveAbsolute_0.Execute 	:= 0; 
				Step := 40; 	
			END_IF
1 Like