Ladder program for plc, using functions and motion data