![]() | |
| Home Page | Mark Forums Read | Today's Posts | My Replies | Classifieds | Reviews | Photo Gallery | Web Links | Share Files | Advertise With Us | Ad List |
| |||||||
| Haas Lathes Discuss Haas lathe here! |
| This forum is sponsored by: |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
| |||
| |||
Ok, so I've written this macro program for our GT lathes and it doesn't work. I am vaguely familiar with the correct syntax, but obviously I still have some things to learn. This is only the third macro I've written, but by far the most complicated. I am very proficient in writing programs in BASIC for Texas instruments graphing calculators and I know that Macro is very similar except for variable naming and syntax. Somebody please help me correct my errors in the following program, but first I will describe my machine setup and the purpose of the program. Our machines are set up as multi-head internal grinders with the main spindle being the "work head". A gang-tool fixture holds up to three high speed air spindles but only two at a time are used in this program. These spindles are turned on with M51,M52, M54 and off with M61,M62, M64. Work offsets specify each air spindle's centerline to main spindle centerline X-coordinate. Tool offsets specify total Z-offset for tool and spindle and actual X diameter of tool. (I don't use "X dia. measure".) This macro program is written in the basic format that I've been using to create the stroking action necessary for cylindrical grinding. It is supposed to make it simple for other operators to simply enter part sizes into the macro variables page and hit start. Currently I am the only person at my company that can write programs that do what we want on these lathes and I'm trying to solve that problem with this macro. Here are the variables to be set by the user: 101: 1 if tenth indicator is in machine, 0 if not 102: #of air spindles used (1 or 2) 103: Rough spindle offset G# (54, 55, or 56) 104: ID start diameter 105: Rough stop diameter 106: Rough stroke front (Z coordinate) 107: Rough stroke back ("") 108: Rough dwell at back (Seconds) 109: # of rough dwell strokes 110: Rough tool # (set by program- G54=T1 G55=T2 etc..) 111: Rough step increment 112: Rough stroke feedrate 113-120 are same as 103-110 respectively but for finish 122: finish feedrate Here's the program cut and pasted: I hope this doesn't get all messed up due to line wrapping: % O09012 (ID GRIND: MANUAL VAR. ENTRY) G103 P0 (disable block buffering) #110= 0 (clear non-user set vars.) #120= 0 #130= 0 #131= 0 IF [ #103= 54 ] THEN [ #110= 1 ] (set T1 use with G54 in roughing cycle) IF [ #103= 55 ] THEN [ #110= 2 ] (set T2 use with G55 " ") IF [ #103= 56 ] THEN [ #110= 3 ] (set T3 use with G56 " ") IF [ #113= 54 ] THEN [ #120= 1 ] (set T1 use with G54 in finish cycle) IF [ #113= 55 ] THEN [ #120= 2 ] (set T2 use with G55 " ") IF [ #113= 56 ] THEN [ #120= 3 ] (set T3 use with G56 " ") IF [ #101= 0 ] GOTO10 (Skip Prog. 0 if no indicator in machine) M98 P0 N10 G20 G40 G98 IF [ #102= 1 ] GOTO20 (Skip roughing cycle if only 1 spindle specified) G [ #103 ] (Set spindle center offset) T [ #110 ] (Set tool to use with offset) IF [ #110= 3 ] THEN [ M54 ] (Start large spindle if using G56/T3) IF [ #110= 3 ] GOTO11 (Skip next line if previous was true) M [ #110 + 50 ] (Start either M51 or M52 spindle) N11 G00 X [ ABS[ #[ 2000 + #110 ] ] ] (Rapid to X center of current tool dia. offset) (ID tool dia. offsets: (variables 2001,2002,2003)are always negative: thus the absolute value cancels current tool diameter putting the tool in the exact center of the part for entry) Z0.1 M08 (Rapid to .1 in front of part, turn on coolant) M03 S [ 40 / [ [ #115 * 3.1416 ] / 12 ] ] (Calculates appropriate work-spindle RPM based on 40SFPM and finish ID size and starts work-spindle) G01 X [ #104 ] Z [ #106 ] F50. (Feed to Starting hole size and Z-tool-in-part) #130= [ [ #105 - #104 ] / #111 ] (Calculates number of strokes to perform at set step size and stores to #130) #130= FIX[ #130 ] (Truncate fraction associated with previous calculation) M97 P1000 L [ #130 ] (Perform step/stroke sub-routine #of times calculated in previous 2 lines) M97 P2000 L [ #109 ] (Perform dwell/spark-out sub-routine # of times set by user) G01 X [ ABS[ #[ 2000 + #110 ] ] ] Z0. M09 F50. (Feed to tool in center and face of part, turn off coolant) M [ #110 + 60 ] (Turn off active air spindle) G00 Z0.1 (Rapid out of part) M01 (optional stop before starting finishing cycle) N20 (FINISH) IF [ #5023 LT #[ 2100 + #120 ] ] THEN [ #131= 1 ] (These two lines determine if Z retraction is necessary before moving X to finish spindle position) (#5023 is current Z machine coordinate and 2101,2102, or 2103 are tool offset Z coordinates) (131 is set to 1 only if current Z coordinate is less than the Z coordinate of the position of Z0 on the next spindle) (If so, Z is moved to next tool Z.1 before X is positioned on center) IF [ #131= 1 ] THEN [ G00 G [ #113 ] T [ #120 ] Z0.1 ] G [ #113 ] (The finish cycle has the same elements as the roughing cycle but with different variable #s) T [ #120 ] IF [ #120= 3 ] THEN [ M54 ] IF [ #120= 3 ] GOTO21 M [ #120 + 50 ] N21 G00 X [ ABS[ #[ 2000 + #120 ] ] ] Z0.1 M08 M03 S [ 45 / [ [ #115 * 3.1416 ] / 12 ] ] G01 X [ #114 ] Z [ #116 ] F50. #130= [ [ #115 - #114 ] / 0.0002 ] #130= FIX[ #130 ] M97 P3000 L [ #130 ] M97 P4000 L [ #119 ] G01 X [ ABS[ #[ 2000 + #120 ] ] ] Z0. M09 F50. M [ #120 + 60 ] G53 G00 Z0. G53 X0. M30 (Subroutines) (Rough step/stroke) N1000 G01 Z [ #107 ] F [ #112 ] (Stroke in to part at user set feed) N1010 U [ #111 ] (Incrementally increase X by user set step size) N1020 G04 P [ #108 ] (Dwell at back of hole if set by user) N1030 Z [ #106 ] (Stroke out to front of hole) N1040 U [ #111 ] (Incrementally step out again) N1050 M99 (Return from subroutine) (Rough dwell stroke) N2000 G01 Z [ #107 ] F [ #112 ] (Rough Dwell/spark-out subroutine: No step) N2010 G04 P [ #108 ] N2020 Z [ #106 ] N2030 M99 (Finish step/stroke) (Finish subroutines are the same but with different variable #s) N3000 G01 Z [ #117 ] F [ #122 ] N3010 U0.0001 N3020 G04 P [ #118 ] N3030 Z [ #116 ] N3040 U0.0001 N3050 M99 (Finish dwell stroke) N4000 G01 Z [ #117 ] F [ #122 ] N4010 G04 P [ #118 ] N4020 Z [ #116 ] N4030 M99 % Thanks in advance for your guys' help. |
|
#2
| |||
| |||
| By the way, the machine gets to the first IF-THEN line near the beginning and alarms saying "Not expected or THEN is missing". I've tried not using brackets, I've tried not using THEN and same error every time. Don't know what I'm doing wrong. |
|
#3
| ||||
| ||||
| Have you read your book? If not, here is the if then part :
And hey, I'm not a macro pro but I think the";" is usefull in macro programming. Good luck. |
|
#4
| |||
| |||
| Yeah, I have read the book, but I'm missing something. In one of my other macros, I used IF-GOTO, but this is the first one where I've used THEN and the machine doesn't like it. There are actually semicolons at the end of each line in the program, but they somehow got removed when I transfered the program to the computer. Does there have to be a semicolon between the IF statement and THEN? I'm gonna try that. |
|
#5
| |||
| |||
| Nope. That doesn't work either. I've tried it these different ways: IF [#103=54] THEN [#110=1]; IF [#103=54];THEN [#110=1]; IF [#103=54] THEN #110=1; IF [#103=54] [#110=1] And probably other ways too... none of it works. Get the same error every time. Perhaps you are not allowed to store a value to a variable as the result of a conditional statement? |
| Sponsored Links |
|
#6
| |||
| |||
| AHH HA!!!! I figured it out! This is the magic syntax... IF [#103 EQ 54] THEN #110=1; And now I know what I did wrong on a bunch of lines. When comparing values, "EQ" is used, not "=". The Equal sign sets a variable to a value. This isn't over yet though-- let me keep debugging and see what error I get next. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Convert Fanuc Macro to Fadal Macro | bfoster59 | Fadal | 1 | 11-08-2007 11:41 PM |
| Macro | gm3211 | Mazak, Mitsubishi, Mazatrol | 2 | 09-06-2007 07:02 AM |
| Macro A | StinkFish | Fanuc | 8 | 08-08-2007 09:19 AM |
| Macro B On 10t? | TURNER | Fanuc | 4 | 05-03-2007 02:31 AM |
| Macro B | jorgehrr | G-Code Programing | 2 | 01-31-2007 02:23 PM |