P codes are used when a machine has 2 turrets (and usually 2 chucks as well) to either synchronize both turrets or to make the turret wait for something to complete before continuing. when the turret waits the axis control switches from that turret to the other turret. the part of the program that runs is the one with the lowest P number so a higher P number will cause the turret to wait until it sees the same number or a higher number on the other turret. it will continue until it reads a higher number then it will wait. without the P codes both programs (for A turret and B turret) will run at the same time which may not be desired.
here's a very simple example....
(any code on a single horizontal line shown here will run together)
Code:
(upper turret program) (lower turret program)
P10 (wait) M8
G4 F5.0
M9
P20 (wait)
M8
G4 F5.0
M9
P30 (wait)
M8
G4 F5.0
M9
P30 (now the same P code is active on both sides)
(so now both turrets will run together)
M8 M8
G4 F5.0 G4 F5.0
M9 M9
P100 P100
M02 M02