top of page
Search

Practical use case: Assembling parts

  • Writer: Ivaylo Fiziev
    Ivaylo Fiziev
  • May 4
  • 3 min read

"Assembly is the process of putting parts together. It involves placement, joining and fastening of one or more parts in or on another. The process is carried out through manual means. However automatic equipment is used for mass production. For example a conveyor moves an assembly part to a number of workstations and at each one of them certain parts are added. This is the common assembly line. Assemblies are the outcome or the product of the assembly process."

In Process Simulate we represent assemblies by means of compound parts. The entities underneath represent the sub-assembly parts. Usually the assembly process is quite simplified in the virtual environment. This is because it is not that important for the purpose of the simulation. The goal is to check if the line works. Not that a part can be assembled. Therefore all it takes is generating appearances of the compound parts while deleting the ones of the sub parts.

From Material Flow we know how to perform this two actions so what is left is to combine them into a single "assemble" function.

And here it is:

FUNCTION "ASSEMBLE_PART_APPEARANCES" : VOID
VERSION:1.0
VAR_INPUT
	ASSY:STRING;				// assembly part name
	PARTS:Array[*] of STRING;	// entity part names	
	LOC:"ABS_LOC";			// absolute location of the generated assembly
	RANGE:LREAL;				// entity part detection range around the location
END_VAR
VAR_TEMP
	i: UINT;
	lbound:DINT;
	ubound:DINT;
END_VAR
BEGIN
	// delete all part appearances first
	#lbound := LOWER_BOUND(ARR:=#PARTS, DIM:=1);
	#ubound := UPPER_BOUND(ARR:=#PARTS, DIM:=1);
	for #i := #lbound to #ubound do
		DELETE_PART_APPEARANCE(PART:=#PARTS[#i], LOC:=#LOC, RANGE:=#RANGE);
	end_for;
	// create the assembly part appearance
	CREATE_PART_APPEARANCE(PART:=#ASSY, LOC:=#LOC);
END_FUNCTION

Here we are Using arrays of variable length as FC/FB arguments. The assembly consists of multiple parts and each assembly has a different number of them. The variable arrays allow us to reuse the code regardless of the number of parts.

Import the function (ASSEMBLE_PART_APPEARANCES.scl) or put it in the SCL_PATH so it is visible for the SCL script engine. Then continue with the rest of this post.


To illustrate the usage I am going to assemble a shock absorber. The shock is built from multiple parts as well - making it ideal for showing the use-case.

Here is how it works:

FUNCTION_BLOCK "MAIN"
VERSION:1.0
VAR_INPUT
	in : BOOL;
	assy : TX_OBJECT := 'Shock';			// assembly identifier
	part1 : TX_OBJECT := 'Body';			// part identifiers
	part2 : TX_OBJECT := 'Shaft';			//
	part3 : TX_OBJECT := 'Seal';			//
	part4 : TX_OBJECT := 'Retainer';		//
	part5 : TX_OBJECT := 'Preload Adjust';	//
	part6 : TX_OBJECT := 'Spring';			//	
END_VAR
VAR
	trig : R_TRIG;
	parts : Array [1..6] of STRING;
	loc : "ABS_LOC";
END_VAR
BEGIN
   #trig(CLK:=#in);
   if #trig.Q then 
   		// assemble the parts
   		#parts[1] := #part1.NAME;
   		#parts[2] := #part2.NAME;
   		#parts[3] := #part3.NAME;
   		#parts[4] := #part4.NAME;
   		#parts[5] := #part5.NAME;
   		#parts[6] := #part6.NAME;
   		GET_ABS_LOC(#loc);   		
   		"ASSEMBLE_PART_APPEARANCES"(ASSY:=#assy.NAME, 
   			PARTS:=#parts, RANGE:=500, LOC:=#loc);
   end_if; 
END_FUNCTION_BLOCK

I have an additional script that generates the parts on the rising edge of a signal. Once generated I trigger the assembly script the same way. All it does is to call the "assemble" function with proper arguments - the name of the assembly, the part names, the location of the assembly and the range around it.

Eventually this is the result:

Parts seem magically put into order, forming the final product. I think we should have this function OOTB!


With the recently (late 2606) introduced TRACE function you can also add a message to the simulation monitor, informing the user that the assembly has been built.

	TRACE(LVL:=0, MSG:='Shock assembled'); 

Part disassembly can be implemented in a similar way. Delete the assembly appearance first. Then generate all part appearances. It is that simple!

The scripts only approach makes this ideal for implementing more complex automation scenarios.

Make use of it!

 
 
 

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating

Subscribe Form

Thanks for submitting!

bottom of page