586,500 active members*
2,512 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > G-Code Programing > IF variable = bla THEN do this ELSE do that ?
Page 1 of 2 12
Results 1 to 20 of 22
  1. #1
    Join Date
    Jul 2006
    Posts
    25

    IF variable = bla THEN do this ELSE do that ?

    Can someone give me an example of the syntax for an "IF" statment ?

    Heres what we would like to do. As of now they use two different programs for the same part, program one is for pallet 1 and program two is for pallet 2.

    Would be nice to use one program and set a variable at the beginning to control what workshifts to use (yes, consistent fixtures would be nice ) .

    Example.
    P01 = pallet one
    P21 = pallet two

    N001 PL = 1
    N002 IF PL = 1 THEN G54.1 P01 ELSE G54.1 P21

    Then we would just edit line N001 when needed.

    Is this possable, never did anything like this with a CNC program before, but seen some stuff which is close in a few threads around here.

    Using a FANUC 16i control.


    _
    ~ What was once an Opinion, became a Fact, to be later proven Wrong ~

  2. #2
    Join Date
    Mar 2005
    Posts
    1498
    060726-1501 EST USA

    iMisspell:

    I do not know Fanuc details, and I am not where the HAAS manual is.

    On HAAS I would use G5x (in your case G54) as the base zero reference. This might be a location near one corner of the pallets. Then I would use G52 to offset from the G54 to the work zero for your part. This hopefully will be clear in the following example.

    If there is a machine variable that contains the the pallet number, assume for the following example it is #3028 (pallet number in receiver from HAAS manual on line -- I do not know what this is because we do not have a pallet changer machine), and that a 1 in this variable is pallet 1 and a 2 is pallet 2, then we can make your part zero relative to machine zero automatically set based on which pallet is in the machine. This is automatic as follows:


    You can either manually load G54 before you run the program or G54 can be loaded at the start of the program. But this G54 value will remain unchanged from part to part and pallet to pallet. So will the two different G52 values remain constant, but the ones loaded into the G52 location are determined by which pallet is in the machine.

    Within your program you will have

    IF [ #3028 NE 1 ] GOTO 110

    N100
    G52 X5.1260 Y4.8796 (for pallet 1 work zero from G54)
    GOTO 130

    N110
    IF [ #3028 NE 2 ] GOTO 120
    G52 X5.1753 Y4.9903 (for pallet 2 work zero from G54)
    GOTO 130

    N120
    (Pallet number error)
    M00


    N130
    (Your common program is here)


    .

  3. #3
    Join Date
    Jul 2006
    Posts
    25
    Thanks for your example and explanation, gar.

    Ive seen the GOTO and understand its use but think it would be a bit of a pain to implement for us.

    In short, heres the my situation. I was just moved on a machine in a prodution shop which has been running programs and parts for a while now (2-3 years). Ive been re-doing some of the programs but do not want to make two programs for each part (a program for each pallets Work-Shift with the only change being a P0# to P2#).

    Cutting a four sided casting they use a G54.1 and P# to set the origin for each side, pallet one would be P01=SideA, P02=SideB, P03=SideC, P04=SideD and P05 to control the bores (the old programer tryed to set up the programs so a compleat simpleton can run the machine and theres no real set-up to do, just plug in a few numbers and their done, i have to keep it like that, which is not my choice) for pallet two would be P21, P22, P23, P24, P25. I like the G52, but that would cause alot of confusion for the other guy running the machine, i cant make alot of "radical" changes.

    Anyway...
    Tool 1 is called up, does some work on Side-A which is P01, then the pallet indexs to Side-B and P02 is called up, all in the same operation. If we were using pallet 2 it would be SideA=P21 and SideB=P22.


    Heres a clip of one op (i edited out all the cutting lines)...

    (T2, 4" FACE MILL, FINISH 4 SIDES)
    N008 G54.1 P01 (work-shift SIDE-A)
    .... edited-out ...
    N016 G53 Z0.
    N017 M01
    N018 G0 B90.
    N019 G54.1 P02 (work-shift SIDE-B)
    .... edited-out ...
    N049 G53 Z0.
    N050 M01
    N051 G0 B180.
    N052 G54.1 P03 (work-shift SIDE-C)
    .... edited-out ...
    N060 G53 Z0.
    N061 M01
    N062 G0 B270.
    N063 G54.1 P04 (work-shift SIDE-D)
    .... edited-out ...
    N095 G53 Z0.
    N094 M01
    N095 M06
    N096 M01


    So for what your saying i would have to do somthing like this ???

    Default the code for P01 (pallet one) and use the IF's to skip over them if we're gonna use pallet 2...

    (T2, 4" FACE MILL, FINISH 4 SIDES)
    IF [ #3028 NE 2 ] GOTO 100
    N008 G54.1 P01 (work-shift SIDE-A)
    GOTO 101
    N100 G54.1 P21
    N101 X0 Y0 Z0
    .... edited-out ...
    N016 G53 Z0.
    N017 M01
    N018 G0 B90.
    IF [ #3028 NE 2 ] GOTO 200
    N019 G54.1 P02 (work-shift SIDE-B)
    GOTO 201
    N200 G54.1 P22
    N201 X0 Y0 Z0
    .... edited-out ...
    N049 G53 Z0.
    N050 M01

    ect...


    I dabble with VB (Visual Basics) and some other simple PC programing langs and was hopping that there was an 'ELSE' command that whent with the IF statment's.

    For the ease of editing i was hoping there was somthing along the lines of...

    (T2, 4" FACE MILL, FINISH 4 SIDES)
    IF [ #3028 NE 1 ] G54.1 P01 ELSE G54.1 P21
    .... edited-out ...
    N016 G53 Z0.
    N017 M01
    N018 G0 B90.
    IF [ #3028 NE 1 ] G54.1 P02 ELSE G54.1 P22
    .... edited-out ...
    N049 G53 Z0.
    N050 M01

    ect...


    Less to edit and i would not have to pay attention to line numbers, one less mistake which can be made .


    ------



    Anyway...
    When using the IF statment, NE is the equivalent for = (equals) ?


    Thanks again for the example, ger.
    - joe


    __
    ~ What was once an Opinion, became a Fact, to be later proven Wrong ~

  4. #4
    Join Date
    Mar 2003
    Posts
    4826
    Since you only have two conditions, why not just write two IF statements, on two lines?
    In computereez, when an IF condition is false, no further processing takes place on that line.
    An Else function may be too high order in command language for your cnc to interpret.
    First you get good, then you get fast. Then grouchiness sets in.

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  5. #5
    Join Date
    Mar 2005
    Posts
    1498
    060727-0728 EST USA

    iMisspell:

    If I understand your original question --- you have two pallets and the parts machined on these pallets are identical, but each pallet clamps in the machine in a slightly different position than the other one. Therefore, you effectively need different values in G54 for pallet 1 than for pallet 2.when clamped in the machine.

    Your second post introduces an unexpected factor, rotation. If you simply changed from one set of values in G54 for pallet 1 to a different set of G54 values for pallet 2, then would this cover all four rotational positions. My guess is not. That would mean that you actually required 4 different G54 sets for each part or a total of 8. This can be handled fairly easily, but I need to know if this is what is required, and do you have G52 that provides a modification to G54 without changing G54.

    If you do not have G52, it is not a major problem, just a different route.

    Do you have G65 which allows passing paramters to a subroutine?

    .

  6. #6
    Join Date
    Mar 2005
    Posts
    988
    Actually, you could just use IF statements to read G10s and use the same offset call for both pallets.....

    IF [ #3028 EQ 1 ] GOTO 100(PALLET 1 OFFSETS)
    IF [ #3028 EQ 2 ] GOTO 200(PALLET 2 OFFSETS)

    N100
    G10L2P1X??Y??Z??B??(G54 FOR PALLET 1)
    GOTO300
    N200
    G10L2P1X??Y??Z??B??(G54 FOR PALLET 2)
    GOTO300

    N300(START PROGRAM)



    Simple and easy and one program. G52 will work as well, but a lot of people today don't understand G52 and its relation since its not that common anymore in many places.
    It's just a part..... cutter still goes round and round....

  7. #7
    Join Date
    May 2006
    Posts
    10
    Can not use the else statement, so I just do it first then run my if:

    N001 PL = 1
    N002 IF PL = 1 THEN G54.1 P01 ELSE G54.1 P21

    N001 PL = 1
    G54.1 P21
    N002 IF PL = 1 THEN G54.1 P01

    My pallets are set at parameter #1000 and #1001 but I think that might vary by the machine manufacturer.

    O7999
    N010
    #1=0.(SAFTEY CHECK)
    IF[#1001EQ1]#1=1.(PALLET #1 ID)
    IF[#1000EQ1]#1=21.(PALLET #2 ID)
    IF[#1LE0.]THEN#3000=54(WHAT THE HELL W.O. ALARM)
    N020
    G54.1 P#1
    N100
    M99

    In my main program I run;
    M60(PALLET CHANGE)
    G65P7999(SET WORK OFFSET)

    Tom G

  8. #8
    Join Date
    Mar 2005
    Posts
    1498
    060727-1159 EST USA

    iMisspell:

    EQ is the logical function symbol for equals (a comparison function)
    others are NE for not equal, LT less than, etc.

    = is a symbol for inserting a value into a variable
    #100 = 1.23 causes the number 1.23 to be put into variable #100 obviously destroying what was previously in #100.
    #100 = #101 causes the content of variable #101 to be put into #100.
    A more descriptive symbol might be
    #100 <= 1.23 where <= means copy the evaluated value from the right side to the variable on the left side.


    psychomill's suggestion is a simpler way. In HAAS it does not always work, and is dependent upon the function following the implied THEN.

    What the G10 L2 P1 command does is to overwrite the contents of the variables that store the G54 offsets. Only the axes listed as parameters in the G10 command are overwritten.
    In HAAS some of the addresses are
    #5201-#5205 G52 X, Y ....
    #5221-#5225 G54
    #5241-#5245 G55
    etc.

    Assume that G54 is the current work offset, then in a HAAS mill in either HAAS or Fanuc mode the G52 values are added (added may mean subtracted) to the currently selected work offset (G54) to produce the actual work offset, but the value in the current work offset (G54) is not modified. For example:
    #5201 is added to #5221 to generate the actual X work coordinate.

    When the G52 values are all zeros the current work offset is the actual work offset.

    Suppose you make G54 the work offset for the part zero for pallet 1 side 1. Then the values you would load into G52 would be the offsets from that one reference position to the corrected position for the other faces and pallets. In other words the contents of G52 would be the error in part positon relative to the position for pallet 1 side 1.

    G52 is a very powerfull and useful tool in HAAS. In HAAS mode the values in G52 are retained even thru power down or program changes. In a HAAS machine in Fanuc mode G52 is zeroed on power on, program start, and some other conditions.

    .

  9. #9
    Join Date
    Jul 2006
    Posts
    25
    Quote Originally Posted by HuFlungDung
    Since you only have two conditions, why not just write two IF statements, on two lines?
    For the ease of editing and being that my hands are tied on the extent of editing i can do, im gonna try what thogib posted.

    PL = 1

    G54.1 P21
    IF [PL = 1] G54.1 P01


    Quote Originally Posted by gar
    Your second post introduces an unexpected factor, rotation.

    ...Do you have G65 which allows passing paramters to a subroutine?
    Sorry, i should have mentioned the table rotation.

    These programs are straight-up simple CAM programs, no subroutines of any sort (at least not that ive seen yet.) (i can post one if your bored and want to peek at it).


    Quote Originally Posted by psychomill
    Actually, you could just use IF statements to read G10s and use the same offset call for both pallets.....

    Simple and easy and one program. G52 will work as well, but a lot of people today don't understand G52 and its relation since its not that common anymore in many places.
    Im gonna try this some tiem when i get time, but i do not think my partner is gonna be too keen on this, his not real big on change Plus im not wrting the programs from scratch just editing them to fine tune them alittle, i just counted how many P0#'s (pallet rotations) in one program and it was 22, setting them all with G10's is alot-like-work for someone thats a bit lazy But for learning im gonna give it a shot on an op or two.


    thogib
    Im new to Milling (and subroutines (but understand the concept from PC programing)), from the reading ive done, thats somthing which i would like to do, but i know the other guy running the machine would flip, then he would have to keep track of what program numbers not to delete from the control and having two O### printed out or in the same file... just wont work with him.



    Quote Originally Posted by gar
    EQ is the logical function symbol for equals (a comparison function)
    others are NE for not equal, LT less than, etc.

    = is a symbol for inserting a value into a variable
    #100 = 1.23 causes the number 1.23 to be put into variable #100 obviously destroying what was previously in #100.
    #100 = #101 causes the content of variable #101 to be put into #100.
    A more descriptive symbol might be
    #100 <= 1.23 where <= means copy the evaluated value from the right side to the variable on the left side.
    Copy/Paste and print thanks.
    Its nice to see they keep the syntax close to other programming langs, those attributes can be used with PC SQL-DataBase work.

    gar, thanks alot for your explanations, im sure it will help others reading this thread as well for the help you've been to me.


    Another question.
    At the beging of the program im gonna define PL = 1
    Will the PL varable hole the value of 1 after we hit the Rest button on the control ?
    I would think it would loose its value once the machine is powered down but what about just hitting the re-set button ?

    Thanks again to every one, been a big help, nice to see different paths that can be takin.


    _
    ~ What was once an Opinion, became a Fact, to be later proven Wrong ~

  10. #10
    Join Date
    Mar 2005
    Posts
    988
    i just counted how many P0#'s (pallet rotations) in one program and it was 22, setting them all with G10's is alot-like-work for someone thats a bit lazy
    Yes, but you only need to set the G10 once at the top of the program, not 22 times through out the program. If you're using say 6 ofsets, then you could write it like this:

    IF[#3028EQ1]GOTO100(PALLET 1 OFFSETS)
    IF[#3028EQ2]GOTO 200(PALLET 2 OFFSETS)

    N100
    G10L20P1X??Y??Z??B??(G54.1 P1 FOR PALLET 1)
    G10L20P2X??Y??Z??B??(G54.1 P2 FOR PALLET 1)
    G10L20P3X??Y??Z??B??(G54.1 P3 FOR PALLET 1)
    G10L20P4X??Y??Z??B??(G54.1 P4 FOR PALLET 1)
    G10L20P5X??Y??Z??B??(G54.1 P5 FOR PALLET 1)
    G10L20P6X??Y??Z??B??(G54.1 P6 FOR PALLET 1)
    GOTO300
    N200
    G10L20P1X??Y??Z??B??(G54.1 P1 FOR PALLET 2)
    G10L20P2X??Y??Z??B??(G54.1 P2 FOR PALLET 2)
    G10L20P3X??Y??Z??B??(G54.1 P3 FOR PALLET 2)
    G10L20P4X??Y??Z??B??(G54.1 P4 FOR PALLET 2)
    G10L20P5X??Y??Z??B??(G54.1 P5 FOR PALLET 2)
    G10L20P6X??Y??Z??B??(G54.1 P6 FOR PALLET 2)
    GOTO300

    N300(START PROGRAM)
    .
    .
    .


    Then you use the same program, same offset calls to run both pallets. You won't need to do this:
    Tool 1 is called up, does some work on Side-A which is P01, then the pallet indexs to Side-B and P02 is called up, all in the same operation. If we were using pallet 2 it would be SideA=P21 and SideB=P22.
    Just use the one program and one set of offsets.

    :cheers:
    It's just a part..... cutter still goes round and round....

  11. #11
    Join Date
    Jul 2006
    Posts
    25
    Bad new for me
    Tried the IF statments and it kicked up an error, bad macro (or somthing, wrote it down but forgot the paper at work, i know the word 'macro' was in the error.) recived this same error when trying to set a varable, PL = 1. When keying in the ...
    PL = 1
    it would input...
    P L =1
    (space between P and L and removed space between = and 1), so i tried A=1 and kept getting the same error, didnt have time to play around.

    psychomill
    After re-reading what gar post, i now compleatly understand what you are saying and actuly think the day guy will like that, alot. Since we cant get the IF's working right now, maybe ill just write in both (pallet A and B) and then when we start the run we can just delete or skip/block what ever set we dont want to use.


    _
    ~ What was once an Opinion, became a Fact, to be later proven Wrong ~

  12. #12
    Join Date
    Mar 2005
    Posts
    1498
    060728-0632 EST USA

    iMisspell:

    More questions.

    On your pallet is there one part, or is it a tombstone with many parts?

    Assuming it is one part, then is it a raw blank, or has it had previous operations performed?

    These questions relate to whether you need different work zeros for each rotary position of the pallet, or just for the different pallets.

    Try the following to test for macro capability:

    IF [ 4 GT 1 ] GOTO 100
    M00

    N 100
    M00

    If there is an error it probably means you do not have macros functional.
    Note: the square brackets around 4 GT 1, these are not parens () because parens are used for comments. And they are not {}, at least on HAAS.


    In your machine is it possible to address a variable with an ahphanumeric label? You used the assignment PL = 1 where I might expect that you would have use the #number for a variable address. Thus, instead of
    PL = 1
    I have to use for example
    #100 = 1
    on a HAAS machine.

    In a previous post of mine I referenced the variable #3028. I believe this is a HAAS variable that they automatically load with the number of the pallet in the station. If this is the case, then you would not need to manually load the pallet number. Rather you would simply use a test on #3028 to determine your action.

    At this point we really need to know whether you have macro capability.

    If you do not have macros you may not be able to load values into variables except as allowed thru G-code parameters where everthing in terms of internal storage is hidden from you.

    .

  13. #13
    Join Date
    Mar 2005
    Posts
    988
    Post what macro statements you wrote to get the errors and what the errors were. As Gar said as well, #3028 is a Haas variable. Your machine may use a different variable for pallet number.

    And yes, you could alter my example slightly and get it to work on your machine by using other methods. Block skipping is one way. Do you have multi-skip? If so, then you could do this:

    /N100
    /G10L20P1X??Y??Z??B??(G54.1 P1 FOR PALLET 1)
    /G10L20P2X??Y??Z??B??(G54.1 P2 FOR PALLET 1)
    /G10L20P3X??Y??Z??B??(G54.1 P3 FOR PALLET 1)
    /G10L20P4X??Y??Z??B??(G54.1 P4 FOR PALLET 1)
    /G10L20P5X??Y??Z??B??(G54.1 P5 FOR PALLET 1)
    /G10L20P6X??Y??Z??B??(G54.1 P6 FOR PALLET 1)
    /GOTO300

    /2N200
    /2G10L20P1X??Y??Z??B??(G54.1 P1 FOR PALLET 2)
    /2G10L20P2X??Y??Z??B??(G54.1 P2 FOR PALLET 2)
    /2G10L20P3X??Y??Z??B??(G54.1 P3 FOR PALLET 2)
    /2G10L20P4X??Y??Z??B??(G54.1 P4 FOR PALLET 2)
    /2G10L20P5X??Y??Z??B??(G54.1 P5 FOR PALLET 2)
    /2G10L20P6X??Y??Z??B??(G54.1 P6 FOR PALLET 2)
    GOTO300

    N300(START PROGRAM)
    .
    .

    In this manner, you set block skip 1 to to ignore pallet one, or set block skip 2 on to ignore pallet two. This forces user input though. I prefer using a machine variable to identify the set up to eliminate the human input.
    It's just a part..... cutter still goes round and round....

  14. #14
    Join Date
    Jul 2006
    Posts
    25
    Quote Originally Posted by gar
    On your pallet is there one part, or is it a tombstone with many parts?
    ......
    Try the following to test for macro capability:

    IF [ 4 GT 1 ] GOTO 100
    M00

    N100
    M00
    One part (a casting) clamped in a fixture, no tombstone. The casting is not square.

    Ill give the example a test when i get to work, thanks.


    Quote Originally Posted by psychomill
    Post what macro statements you wrote to get the errors and what the errors were.
    ...
    Do you have multi-skip?
    ....
    I prefer using a machine variable to identify the set up to eliminate the human input.
    A=2
    IF[A EQ 2] G54.1 P21

    Recived the same error message for both lines.
    I'll have to post back the error, its on a peice of paper which i forgot at work.

    Nope, no multi-skip block.

    And we (me and the day guy) would agree, if we cant get the IF's to work, ill set up the G10 L2's for both pallets and we'll just delete the set we dont want to use during set-up.



    _
    ~ What was once an Opinion, became a Fact, to be later proven Wrong ~

  15. #15
    Join Date
    Mar 2005
    Posts
    1498
    060728-1332 EST USA

    iMisspell:

    Try the following:

    My previous suggestion

    IF [ 4 GT 1 ] GOTO 100
    M00

    N 100
    M00

    and then try this

    #100 = 1

    IF [ #100 GT 1 ] GOTO 100
    M00

    N 100
    M00

    See if either of these produce errors.

    If these are error free, then we can discuss how you might handle the non-square casting.

    .

  16. #16
    Join Date
    Mar 2005
    Posts
    988
    Try what Gar suggested......

    Also.....
    A=2
    IF[A EQ 2] G54.1 P21
    This won't work like this. You need to do this:

    #500=2
    IF[#100EQ2]GOTO100
    N100
    G90G10L20P21X??Y??Z??B??(SETS G54.1 P21)
    .
    .
    .
    .

    "A" is an argument setting attached to "#1". To set "A", you need to use it in a variable setting format like this:

    G65P1234A2.

    You could do this:

    #1=2
    IF[#1EQ2]GOTO100
    N100
    G90G10L20P21X??Y??Z??B??(SETS G54.1 P21)


    But I wouldn't use local variables this way. I'd set it to a common variable like #500 and above. Most machines on reset, will dump values in the local variables and even commons 100. This would cause a problem if you had to restart a program since now your value is "0" or null.
    It's just a part..... cutter still goes round and round....

  17. #17
    Join Date
    Mar 2005
    Posts
    1498
    060728-1554 EST USA

    psychomill:

    You may have a typo.

    I think you meant

    #500=2
    IF [#500 EQ 2] GOTO 100

    .

  18. #18
    Join Date
    Mar 2005
    Posts
    988
    Thanks Gar..... :cheers:
    It's just a part..... cutter still goes round and round....

  19. #19
    Join Date
    Jul 2006
    Posts
    25
    Ok...

    This worked fine...
    IF[4 GT 1] GOTO ###

    And this also worked fine...
    #123 = 2

    When i tried ...
    A=1 (the other night)
    and
    IF[4 GT 1] G54.1 P21 (tried this tonight)

    Recived 114 - FORMAT ERROR IN MACRO for each line.

    Thats all the time i had to play with that stuff.
    Was gonna try IF [#123 EQ 2] GOTO ### but got side tracked and forgot, will try on monday.

    Did use G10 L20 P#1-5 at the top of the program and it worked great, really hope the day guy digs this. Would be nice to save the current work and tool offsets to a file (gonna start a new thread about this) for reloading next time.

    Like i said earlyer, im new to this machine, after peek around alittle more and talking with the day guy alittle more (tring to get clear answers from him), pre-part he uses the same offset numbers for each pallet (as of now ive only been using one pallet), the reason for the two sets of work offsets P0# and P2# is so they can set up a job on pallet A and set up a different job on pallet B and not have to mess with anything after that and some where along the lines they where gonna run the same part on both pallets so there was no down time during a part change but somthing happened with that whent out the window... at times i just get frustreated at how they place operates and im like whatever and stop asking questions of why

    So with that said no reason for the IF statments any more. BUT im glad i asked about them, learned quit a bit in this one thread and im sure there will be a time where it will help.
    Setting the G10 L20 P0# at the beginning of the edited programs will be just fine and work well, but more ideas are wellcome

    Thanks again for all the help and explanations, been a big help.


    Quote Originally Posted by psychomill
    "A" is an argument setting attached to "#1". To set "A", you need to use it in a variable setting format like this:
    Just read abuot this in another thread, gonna have to see if i can find the book for the machine to see a listing of all the varable settings.


    Quote Originally Posted by gar
    If these are error free, then we can discuss how you might handle the non-square casting.
    Like i said earlyer, my hands are kind of tied with the amount and degree of changes i can make, but i deffinitly would like to hear what your thouhgts are about this, if you fell like sharing.


    _
    ~ What was once an Opinion, became a Fact, to be later proven Wrong ~

  20. #20
    Join Date
    Jul 2006
    Posts
    14
    I have done this many times in fanuc controls, and I've developed a different approach:

    O0001;
    (PALLET 1 DRIVING PROGRAM);
    #1=0;
    #2=1;
    M98P0003;
    M99;

    O0002;
    (PALLET 2 DRIVING PROGRAM);
    #1=10;
    #2=1;
    M98P0003;
    M99;

    O0003;
    (PART PROGRAM);
    IF[#2EQ0]GOTO9998

    M6T1;
    G90 G00 G54.1 P[1+#1] X0 Y0 S1000 M3;
    ...
    ...
    ...
    G90 G00 G54.1 P[2+#1] X0 Y0 S1000 M3;
    ...
    ...
    ...
    G90 G00 G54.1 P[3+#1] X0 Y0 S1000 M3;
    ...
    ...
    ...
    G90 G00 G54.1 P[4+#1] X0 Y0 S1000 M3;
    ...
    ...
    ...
    GOTO9999;
    N9998 #3000=1(PALLET NOT ASSIGNED);
    N9999M30;





    Variable #1 stores the value to be added to P in the G54.1P# line.
    This means that if you run program O0001, #1=0 so G54.1 P[3+#1] is the same as G54.1 P3
    But if you run program O0002, #1=10 so G54.1 P[3+#1] is the same as G54.1 P13
    Variable #2 is for error checking. Any time the machine is reset, or a program ends both #1 and #2 will return to zero. At the top of the part program we check to see that #2 does not equal zero. If it does, the program jumps to N9998. #3000 generates an alarm and stops the machine. This ensures that either program 0001 or 0002 was executed.


    I've made several different variations of this. Which one is best depends on the exact circumstances, but this works pretty well in most cases.

    Good luck!

Page 1 of 2 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •