![]() | |
| Home Page | Mark Forums Read | Today's Posts | My Replies | Classifieds | Reviews | Photo Gallery | Web Links | Share Files | Advertise With Us | Ad List |
| |||||||
| G-Code Programing Discuss G-code programing and problems here! |
| This forum is sponsored by: |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
| |||
| |||
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
| |||
| |||
| 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
| |||
| |||
| 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
| ||||
| ||||
| 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
| |||
| |||
| 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? . |
| Sponsored Links |
|
#6
| |||
| |||
| 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
| |||
| |||
| 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
| |||
| |||
| 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. . Last edited by gar; 07-27-2006 at 12:52 PM. |
|
#9
| ||||||
| ||||||
PL = 1 G54.1 P21 IF [PL = 1] G54.1 P01
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).
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.
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
| ||||
| ||||
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:
__________________ It's just a part..... cutter still goes round and round.... |
| Sponsored Links |
|
#11
| |||
| |||
| 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
| |||
| |||
| 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. . |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
| |