I am working on a project where there are x, y and z directional control. I have a cage that moves forward and back on rail, this is the x axis. On that same cage there is a clamp on each side that clamps in on a tray, this is the y axis. These clamps then move up and down and lift up the part it has picked up, this is the z axis. Once it has lifted it up the part, the cage (x-axis) moves forward and then the clamps z axis goes down and drops it into a stacking area. The process then repeats. The z axis position comes from an encoder on the top and also has a homing position photoeye that gets active before picking up the next part. The encoder is wired into the HSC of an S7-200 PLC. The x axis has proximity sensors along the track that detect the fully forward and fully back position. All motion is driven by hydraulic motors connected to 2-way three position solenoids. Also the hydraulic motors are fed from proportional flow control valves to adjust the speed from start to end positions. This is only on the x and z axis. I am not an expert in programming this sort of thing but what I wanted to ask on this forum is what are some good guidelines for structuring the logic and basically what would be the best way to tackle this? I understand the encoder counts will need to be added and subtracted so that every time a new part is placed on top of the final stack it has to remember the last height position. Hope someone can help me here. Much appreciated. Thanks guys ad gals.