# KUKA PALLETIZING CODE

• A question ,someone would have some backup of some palletizing cell that works by assembling more than one mosaic on different pallets.
I have already done some palatization work, I developed mathematics but since I am working with the “FOR” instruction to index positions in a arrays at times I need to leave the instruction so that the robot can assemble another pallet ... I would like an example of a similar cell with that of the figure that is attached. If you have something I am grateful.

This and the code normally used

This code works well for an assembly of a pallet line only.

I left a picture attached,I wanted a help to make a code that works on two lines or more simultaneously.

FOR XCount = 1 TO 3

FOR YCount = 1 TO 3

FOR ZCount = 1 TO 4

;assuming that "StartPos" is programmed to the first position in the pallet pattern

NextPos[XCount, YCount, ZCount].X = StartPos.X + ((XCount - 1) * 100) ; set X value, shifted by pallet count

NextPos[XCount, YCount, ZCount].Y = StartPos.Y + ((YCount - 1) * 200) ; set Y value, shifted by pallet count

NextPos[XCount, YCount, ZCount].Z = StartPos.Z + ((ZCount - 1) * 300) ; set Z value, shifted by pallet count

NextPos[XCount, YCount, ZCount].A = StartPos.A ; set Rz to the same as the StartPoint

NextPos[XCount, YCount, ZCount].B = StartPos.B ; set Ryto the same as the StartPoint

NextPos[XCount, YCount, ZCount].C = StartPos.C ; set Rx to the same as the StartPoint

ENDFOR

ENDFOR

ENDFOR

Thanks

## Images

• there is no motions in this code segment, it only calculates positions and... only for one stack.

even that is incomplete, it does not take into account any changes in layer patterns to ensure product interlocking which is shown in your photo.

forum is not a substitute for training. it is suited to solve/answer specific question. in your case this seem to be how to leave FOR loop. in KRL this can be done in more than one way. one is to use EXIT command. this leaves one FOR loop. when trying to leave several nested loops GOTO is much cleaner...

but i would leave calculation separate and use it in initialization at the start of the program - without exiting loops. for production portion of the code i would create completely separate code structure.

2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

• Example:

I could use the Loop structure to store the positions in a separate array that is outside of a Loop structure. This type of code you need to finish the layer of palet1 to be able to make pallet 2 because it is attached to the Loop. I need a code so that it does not lose its position when leaving the LOOP to be able to make another pallet and return in the same position.

Do you know what I mean?

Edited once, last by Jeff_Rob ().

• of course i do. you need to make sure that:

1. your variables are retentive so the values are not lost when program is cancelled or robot is rebooted. for example this means clear understanding of life and scope of your variables.

2. your variables are initialized when it is ok to initialize them.

this means understanding process and structuring code correctly. in your code example, loop variables for populating pallet are initialized every time program runs. this is obviously incorrect because this only need to be done when pallet is empty. i sure as hell would not want to be the user of such cell because according to your program, user would have to remove all items from partially populated pallets in order to resume or restart production. doing it once would be too much - that's why they have a robot.

2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

• Do you have an code example of this setting ?

• I know how these variables work I just needed an example of palletizing with Multi pick and multi drop in diferent pallets

• How can I do to index calculated positions into an array of positions....

• when picking you need to know how many items are picked.

when placing you need to consider if they all can be dropped at once or not.

whatever is number that is dropped, that is the number to increment stack count for the pallet.

suppose you pick 3 boxes.

then when placing you may only need to place 2 to complete pallet1, so do that and increment stack count for that pallet by 2, then move to pallet2 and drop remaining box. increment that stack count by 1.

in other words you need separate variables for tracking each pallet.

2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

• At the risk of tooting my own horn:

Grid/Palletizing library and example

This is a support library for handling "grid" mathematics. However, it is not a "smart" palletizing program that handles box sizes&shapes, dynamic pick group sizing, etc.

How can I do to index calculated positions into an array of positions....

The code in your first post already does this. I'm not clear on what you're asking here.

I know how these variables work I just needed an example of palletizing with Multi pick and multi drop in diferent pallets

You're going to need to define that in more detail. Are you talking about multi-pick/drops of varying sizes, or constant sizes?

To create "retentive" variables, which do not lose their values when a program is cancelled, or the robot is rebooted, you need to DECL the variable in the program's .DAT file, with an initial value:

DECL INT XCounter = 0

The '0' could be any integer value, it's irrelevant. As your FOR loops write new values into XCounter, the value stored in the .DAT file will change to match. But adding the "= 0" is the only way to make a variable retentive. If the "= 0" is left out:

DECL INT XCounter

Then the value of XCounter will be lost as soon as the program whose .DAT file contains XCounter is no longer running. Even if you DECL'd XCounter in \$CONFIG.DAT (which I generally recommend against), the value would still be lost if/when the robot was rebooted for any reason.

• of course you cannot do that... need to structure your code to do what you need.

in your example your goal is to preserve counter loop value so you can leave the loop, do something else, then come back and continue where you left of. the trouble for you seem to be that FOR loop is initializing counter value every time you start...

that tells me that you don't have a solid understanding of the working of the FOR instruction....

in other words you are not in shape yet to write something like palletizing program... if you want to use some instruction, you need to understand it first.

FOR loop is one of the most fundamental things in programming and there is no room for doubt. to remove any doubt you need to evaluate what happens with loop counter variable before, during and after loop....

this is not black magic, it simply means you need to create some code and test the instruction until you have a solid understanding how it behaves. and you need to do the same thing for each and every instruction you want to use. then you can start using what you have learned to write programs.

here is an example of a possible test bed program for evaluation of FOR loop:

then you can try to figure out what could be done to make the code do what you want it to do.

and you should learn how to format your posts so that only code is inside code tags

2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

• FOR loop is by far the most complex one so perhaps this helps... ask yourself where the counter variable "n" gets modified and when. then try to figure out how is that handled in your code. good luck...

2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

• You only lose the count if you don't save it anywhere. Create a struc to save a pallet state: patterns for odd and even levels, amount of parts on the pallet and then use that as a function parameter to find either pick up or place position.

Also I suggest passing box/part size as parameter and using that to find offsets from starting position. And make your life easier - use geometric operator.

• that is a solid advice... but i think OP has long way to go to get there. still wrestling with first part - retaining loop counter value.

Quote

You only lose the count if you don't save it anywhere...

... and if you don't overwrite the value yourself.

this is exactly what happens when re-entering FOR loop ( see "n = Val1" ).