I'm trying to run a program that loops a specifyed number of times, but when it loopes back to start i get a P-code error, as it begins on a lower code.
Is there any way to reset the priority codes?
I'm trying to run a program that loops a specifyed number of times, but when it loopes back to start i get a P-code error, as it begins on a lower code.
Is there any way to reset the priority codes?
You should be able to call a p0 on both turrets just before the loop statement.
Do I have to call it twice, and if so, how do I do that?
I've never ran a dual turret, but I'll take a stab at this.
Code:VC20 = 42 (**ENTER NUMBER OF PARTS**) (SET-UP CODE TO START LOOP HERE) (IE MOVE TO SAFE PLACE) NATS (START OF LOOP) (MAIN LOOP HERE) VC20 = VC20-1 IF [VC20 GT 0]GOTO NATS (EXIT LOOP CODE) NEND
You should be able to program a negative P code at the start of each turret to 'reset' your P Codes.
i.e.
G13
N100 P-100
G14
N100 P-100
.
.
.
Program as required...
.
.
.
Cheers
Brian.
Thanks for the replies..
I tryed both calling P-100 and P0, but i get the same error saying that the P-value is lower then the one befor..
Any other ideas?
Broby is right. The P with a negative (P-1) will work for you. Are you sure you re-selected after the edit? If yes, then check for out of sequence P-codes elsewhere.
A bit off topic, but another way to do the loop would be to use the Schedule program feature in the control with a Q value for the number of repeats.
I'm pretty sure I did, but I'll try it again, and post the entire code he.
I looked into schedule program but i had problems as i have to move the zero point with every loop. But i realy want to get the if, goto loop working.
Well you can still use a schedule program to do what you want.
Use a common variable in your program to count the number of parts machined.
Then reference this at the start of the program to "move" the Zeroset position.
Lathe program could be along these lines:
N0001 G13
N0002 P1
N0003 IF [V1 GT V3] NEND (SAFETY PROGRAMMING TO MAKE PROGRAM JUMP TO END IF YOU KEEP PRESSING CYCLE START TOO MANY TIMES!)
N0003 VZSHZ=V1*[-13.5]
N0004 P10
N0005 G00 X500 Z800
N0006 G14
N0007 P1
N0008 VZSHZ=V1*[-13.5]
N0009 P20
N0010 G00 X300 Z400
N0011 G50 S2500
*
*
*
Program as required
*
*
*
(End of Program Code, Used to count)
G13
V1=V1+1 (Total Parts Per Bar Counter)
V2=V2+1 (Total Running Parts Counter)
NEND M2
The Schedule Program Could be along these lines:
$BARFEED.SDF%
N1 VSET V1=0 (RESET COUNTER FOR PARTS PER BAR)
N2 PSELECT A.MIN
N4 IF [V1 LE V3] N2
N5 END
Explanation:
V1 Used to count the number of parts per bar in machine.
V2 Used to count the TOTAL number of parts machined.
V3 Used to set how many parts can be machined from the Bar before the bar is up to the chuck.
VZSHZ is the Shift Amount on Z axis for either turret.
By setting the variable V1 to zero at the start of the process and using the calculation VZSHZ=V1*[-13.5] you effectively are using a ZERO amount of Shift on Z axis.
The value of -13.5mm in the example program is the distance you need to shift the Z axis along the bar to machine the next part. Change that value to what ever amount you need.
Once you have machined the first part, your counter V1 now equals 1, so the equation VZSHZ=V1*[-13.5] will now produce a Z axis shift amount of 1*[-13.5] = -13.5mm
Thus the machine will move the program along the Z axis towards the chuck by 13.5mm and because the program is the same on A and B turret, both turrets will be moved.
The schedule program will reset the "bar" counter to Zero at the start of cycle.
V2 is used purely to keep track of the total number of parts that have been machined.
If you hit reset at any stage during machining, the Z axis shift amount is removed and the actual Z Zeroset amount will be at the first part position again.
Using a method like this will get rid of you P code issues.
There are other ways of running a program in the schedule file that will run the program multiple times such as PSELECT A.MIN,,,Qx where "x" is the number of times to repeat the program.
This way is a little faster to execute as you are not waiting for the program to be selected each time.
But I have generally found that operators can follow the logic above more easily and with less chance of making mistakes.
Hope this long winded explanation helps.
Regards
Brian.
Daimn broby.. Thats elegant!
And I'm glad you took the time to add the V3 - safety counter. That could have seriously screwed me over
I'll post when I've tried it out
Thanks