CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > MetalWorking Machines > Haas Lathes


Haas Lathes Discuss Haas lathe here!


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 03-04-2008, 10:39 AM
 
Join Date: Jan 2008
Location: USA
Posts: 30
Ceramic Man is on a distinguished road
Buy me a Beer?
Need a Macro-pro

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.
Reply With Quote

  #2   Ban this user!
Old 03-04-2008, 11:24 AM
 
Join Date: Jan 2008
Location: USA
Posts: 30
Ceramic Man is on a distinguished road
Buy me a Beer?

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.
Reply With Quote

  #3   Ban this user!
Old 03-05-2008, 04:07 PM
Wiseco's Avatar  
Join Date: Jul 2005
Location: Canada
Age: 31
Posts: 175
Wiseco is on a distinguished road

Have you read your book? If not, here is the if then part :

Conditional Execution (IF THEN)
Execution of control statements can also be achieved by using the IF THEN construct. The format is IF
[<conditional expression>] THEN <statement>;.
NOTE: To preserve compatibility with FANUC syntax “THEN” may not be used with
GOTOn.
This format is traditionally used for conditional assignment statements such as: IF [#590 GT 100] THEN
#590=0.0;
Variable #590 is set to zero when the value of #590 exceeds 100.0. In the Haas control, if a conditional evaluates
to False (0.0), then the remainder of the IF block is ignored. This means that control statements can also
be conditioned so that we could write something like: IF [#1 NE #0] THEN G1 X#24 Z#26 F#9;. This executes
a linear motion only if variable #1 has been assigned a value. Another example is: IF [#1 GE 180] THEN
#101=0.0 M99;. This says that if variable #1 (address A) is greater than or equal to 180, set variable #101 to
zero and return from the subroutine.

Here is an example of an “IF” statement that branches if a variable has been initialized to contain any value.
Otherwise, processing will continue and an alarm will be generated. Remember, when an alarm is generated,
program execution is halted.
N1 IF [#9NE#0] GOTO3 (TEST FOR VALUE IN F) ;
N2 #3000=11(NO FEED RATE) ;
N3 (CONTINUE) ;

And hey, I'm not a macro pro but I think the";" is usefull in macro programming. Good luck.
Reply With Quote

  #4   Ban this user!
Old 03-06-2008, 02:53 PM
 
Join Date: Jan 2008
Location: USA
Posts: 30
Ceramic Man is on a distinguished road
Buy me a Beer?

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.
Reply With Quote

  #5   Ban this user!
Old 03-06-2008, 03:05 PM
 
Join Date: Jan 2008
Location: USA
Posts: 30
Ceramic Man is on a distinguished road
Buy me a Beer?

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?
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 03-06-2008, 03:17 PM
 
Join Date: Jan 2008
Location: USA
Posts: 30
Ceramic Man is on a distinguished road
Buy me a Beer?

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.
Reply With Quote

  #7   Ban this user!
Old 03-06-2008, 04:09 PM
 
Join Date: Jan 2008
Location: USA
Posts: 30
Ceramic Man is on a distinguished road
Buy me a Beer?

No more errors. The program runs perfectly. I guess I solved my own problem.
But thanks anyway to any of you who scratched your heads over this.
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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




All times are GMT -5. The time now is 06:26 AM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361