top of page
Search
Writer's pictureIvaylo Fiziev

Practical use case: Palletizing part appearances

Palletization is a term used to describe the process of placing materials and packages onto pallets. Usually this is a use case for OLP but you can also do it with SCL. We already know how to do material flow with the script but a palletizing example seems more interesting to showcase.

On input we provide the name of the part, the number of parts along each axis, offset between parts along each axis and a clock signal that will trigger the generation on it's positive edge.

FUNCTION_BLOCK "MAIN"
VERSION:1.0
VAR_INPUT
	partName : STRING := 'Cell'; 	// The name of the origin part.
	clk : BOOL := true; 			// The clock signal. (part appearances will be created on positive edge)
	sizeX : UINT := 5; 			// Number of part appearances by X axis
	sizeY : UINT := 3; 			// Number of part appearances by Y axis
	sizeZ : UINT := 3; 			// Number of part appearances by Z axis
	offsetX : LREAL := 40; 		// Offset (mm) between part appearances on the pallet by X axis
	offsetY : LREAL := 150; 		// Offset (mm) between part appearances on the pallet by Y axis
	offsetZ : LREAL := 80; 		// Offset (mm) between part appearances on the pallet by Z axis
END_VAR
VAR
	trigger : R_TRIG; 			// Positive edge trigger
	absLoc : "ABS_LOC"; 			// Location of the underlying resource
END_VAR
VAR_TEMP
	indxX : UINT; 				// Array indexer by X
	indxY : UINT; 				// Array indexer by Y
	indxZ : UINT; 				// Array indexer by Z
	partLoc : "ABS_LOC"; 			// Location for the part appearance
END_VAR
BEGIN
#trigger(CLK:=#clk);
if #trigger.Q then
	GET_ABS_LOC(#absLoc);			// get the location of the underlying resource
	for #indxX := 0 to #sizeX-1 do
		for #indxY := 0 to #sizeY-1 do
			for #indxZ := 0 to #sizeZ-1 do
				OFFSET_ABS_LOC(	// calculate relative part location
					IN:=#absLoc,
					X:=#indxX * #offsetX,	// offset by X
					Y:=#indxY * #offsetY,	// offset by Y
					Z:=#indxZ * #offsetZ,	// offset by Z
					OUT=>#partLoc);
				CREATE_PART_APPEARANCE(PART:=#partName, LOC:=#partLoc);
			end_for;
		end_for;
	end_for;
end_if;
END_FUNCTION_BLOCK

The script uses the absolute location of the underlying resource (self frame) as the origin of the pallet. Part appearances a placed along the axes of the self frame.

Quite simple isn't it? Change the inputs and you'll get a different configuration of parts. Relocate the resource to get the pallet at a different location. Change the logic and implement it the way you want it to be. Imagine doing this with the classic material flow in PS... good luck :)


I hope you find this post useful.

See you in the next one!

45 views0 comments

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page