top of page
Search

Practical use case: Applying a motion profile to a conveyor

  • Writer: Ivaylo Fiziev
    Ivaylo Fiziev
  • 1 day ago
  • 3 min read

If you recall, some time ago I showcased the usage of a custom motion profile on joints. It was just a function that calculates the current value of the joint, based on a specific velocity law in time. It was nice to see the joint moving but now I would like to extend the concept a little bit and apply the motion profile on something else - a conveyor. We already have the ability to drive the conveyor via a script so this should be relatively easy to do. In essence what we should do is: use the motion profile to calculate the conveyor position in time. Here again we have the acceleration phase (when the conveyor is getting up to speed), the cruising phase (moving at maximum speed) and the deceleration phase (stopping). Much like a luggage belt on the airport. The trapezoid motion profile should be capable enough to simulate it, right?


For now we focus on the simplest possible use case: Moving the conveyor from position A to position B with a given velocity and acceleration. The code is pretty similar to the one for move joint to value:

FUNCTION_BLOCK "MAIN"
VERSION:1.0
VAR_INPUT
	acc : LREAL; 		// acceleration (mm/s)
	speed : LREAL;	// velocity (mm/s)
	start : BOOL; 	// start signal
	dist : LREAL; 	// travel distance (mm)
	reverse : BOOL; 	// reverse flag
END_VAR
VAR_OUTPUT
	moving : BOOL;
END_VAR
VAR
	trig : R_TRIG;
	lastTime : LREAL;
	lastPos : LREAL;
	multiplier : INT := 1;
END_VAR
VAR_TEMP
	simTime : LREAL;
	newPos : LREAL;
END_VAR
BEGIN
    #simTime := SIM_TIME() / LREAL#1000; 	// ms to sec
    #trig(CLK:=#start);					// start ?	
    if #trig.Q then						//
    		#lastTime := #simTime;				// store the time
		#lastPos := CONVEYOR_POSITION();	// store the position
		if #reverse then					// reverse direction
			#multiplier := -1;			//
    		else								//
			#multiplier := 1;				//
		end_if;							//
	  	#moving := true;					// start
    end_if;
    if #moving then
		// calculate the new position based on the motion profile		#newPos :=  #lastPos + ("TRAPEZOID_MOP"(ACC:=#acc, VEL:=#speed,			DIST:=#dist, ELAPSED_TIME:=ABS(#simTime - #lastTime)) * #multiplier);		if ABS(#newPos - #lastPos) <= #dist then
    	DRIVE_CONVEYOR(#newPos); 				// drive the conveyor		end_if;
if ABS(#newPos - #lastPos) >= #dist then
	#moving := false;						// stop
end_if;
end_if;
END_FUNCTION_BLOCK

You can change the direction with a simple Boolean flag! With this it becomes easy to drive the conveyor back and forth a certain distance. Of course you should have the trapezoid function (Practical use case: Implementing a custom motion profile) imported in advance. Paste the code in the SCL editor, wire some signals to the inputs and watch it work.

While the conveyor is moving the output will be set to true.


Q: How about continuous motion?

A: Well, the motion profile is not really suitable for this use case since it relies on distance and time. On theory you can use a very big number for the distance but it's a compromise. Continuous motion is more in the area of drive simulation. Something like Telegram 1 can be of use here instead.


Q: How about changing velocity?

A: On theory you can combine two or more motion profiles into one to drive the conveyor. On the picture below we combine two trapezoid motion profiles to mimic a change in velocity. This however is not trivial to implement.

Q: How about an emergency stop?

A: The deceleration phase should be applied immediately in this case. You can fake it by artificially advancing the elapsed time for the motion profile. Not really straight forward to implement as well, but this is the best I can think of.


Overall it seems like motion profiles can be applied to conveyors with limited usage. Still they can be the easiest way to go in some situations. Compared to the complexity of motion control (telegrams) I think everyone will choose a profile if possible.


See you later!





 
 
 

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating

Subscribe Form

Thanks for submitting!

bottom of page