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! > Machine Controllers Software and Solutions > Fanuc


Fanuc Discuss Fanuc controllers here!


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 02-01-2006, 09:03 AM
 
Join Date: Sep 2003
Location: mn
Posts: 16
BROCD is on a distinguished road
Question Fanuc 15m Subroutines

Help.Anybody know the procedure for storing and calling subs in your main program instead of outside of it? For example Mazak uses (M98 H ) to call a sub stored within program and an N# to describe it.
M98H1000
.
.
.
.
.
.
N1000(SUB)

Thanks in advance
__________________
DB34
Reply With Quote

  #2   Ban this user!
Old 02-01-2006, 09:20 AM
Chris D's Avatar  
Join Date: Apr 2005
Location: USA
Posts: 390
Chris D is on a distinguished road

I have not done that in MANY years, but if memory serves me it works something like

M99 (either N or P) then the line number

M99N1422

or

M99P1422

This is not going to be a conditional jump (with IF-THEN) nor are you going to be able to use M99 as a typical "return".

Like I said, it has been a very long time since doing that so I would suggest opening up that FANUC programming manual and look at the descriptions for both M98 and M99.

Sorry, that's all I got.

Chris
Reply With Quote

  #3   Ban this user!
Old 02-01-2006, 07:30 PM
 
Join Date: Mar 2005
Location: Silicon Valley, CA
Posts: 982
psychomill is on a distinguished road

Fanuc doesn't really have an internal sub routine ability like Mazatrol, Haas, Yasnac, etc. You can use the "M99 P... " like Chris mentioned but it has some drawbacks. It will act like a GOTO statement and not really a sub. And I'm not sure if the 15M can use the code like that so you'll have to try it and see.

Other options are to use things like While/Do loops and such.
__________________
It's just a part..... cutter still goes round and round....
Reply With Quote

  #4   Ban this user!
Old 02-01-2006, 08:13 PM
 
Join Date: Jan 2006
Location: USA
Posts: 24
Cncjunkie is on a distinguished road

I know on the niigata with 15 you can call a sub program as a macro. Then after it's do it will return to the next line after the call.

G65P8012

but m98 jumps to a sub or macro
m99 jumps out of a sub or macro

but then i know that m99 also can be repeat program so ...
I'll double check when i get to work tomarrow and repost
Reply With Quote

  #5   Ban this user!
Old 02-01-2006, 08:21 PM
 
Join Date: Sep 2005
Location: USA
Age: 60
Posts: 755
Dan Fritz is on a distinguished road

Why not just call separate programs with M98Pxxxx. Each sub can return to the main program with an M99, and you can also nest subroutines by making M98 calls within subs.

The only downside to keeping your subs separate is is that you have to upload and download multiple programs to the CNC for each job (one main plus many subs). On the 15M, though, this is easy to overcome. Here's how you can do it:

Keep your program numbers together for each job. If you use, say, O1234 for the main program, and keep your subs called by that main program in sequence, like O1235, O1236, O1237, etc. You can then put the main program and all the subs in one FILE on your DNC system, like so:

%
O1234 (MAIN)
N1
N2
(etc)
M30
O1235 (SUB1)
N1
N2
(etc.)
M99
O1236 (SUB2)
N1
N2
(etc.)
M99
O1237 (SUB3)
N1
N2
(etc.)
M99
%

(be sure that there are only percent signs at the begining and end, and NOT in between the programs.

Then, when you download to the CNC, just queue up the file on your DNC system and press READ then ALL to download all the files together. When sending them back to your DNC system, press PUNCH then PROG#, then key in "1234", then press PROG# again and press the number of the last sub (1237) then press EXEC. That will send all the files within that RANGE to the DNC system for storage in one file. Just make sure your DNC system will not break down the data into 4 separate files by O-numbers. If your DNC system receives until a timeout occurs, you'll have no problem with uploads.

Keeping your subs separate from the main has several advantages. You can call each sub multiple times, or you can call subs from other subs (nesting up to 5 layers deep).
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 02-02-2006, 09:10 AM
 
Join Date: Mar 2005
Location: Silicon Valley, CA
Posts: 982
psychomill is on a distinguished road

To finish my earlier reply, .....

I'm with Dan here. Why not just use nested subs (M98 calls).
__________________
It's just a part..... cutter still goes round and round....
Reply With Quote

  #7  
Old 02-02-2006, 09:53 AM
*Registered User*
 
Join Date: Nov 2005
Location: USA
Posts: 274
Bluesman is on a distinguished road

Originally Posted by psychomill
To finish my earlier reply, .....

I'm with Dan here. Why not just use nested subs (M98 calls).

DITTO Keep it simple, The biggest mistake I see a programer or an engineer (Such as myself) make is thinking just way to much. Just let go your mind and use the "FORCE" It always works for me

Bluesman
Reply With Quote

  #8   Ban this user!
Old 02-02-2006, 12:14 PM
 
Join Date: Sep 2003
Location: mn
Posts: 16
BROCD is on a distinguished road

Thanks guys.The reason I like to do this is to keep the file transfering down to 1 file per program for the operators sake.
__________________
DB34
Reply With Quote

  #9   Ban this user!
Old 02-16-2006, 09:09 PM
 
Join Date: Feb 2006
Location: United States
Posts: 273
dpuch is on a distinguished road

Well I prefer seperate files, but if you must....

#100=500 (set to return N number)
GOTO 1000
N500
...

N1000
(sub)
...
GOTO #100
Reply With Quote

  #10   Ban this user!
Old 02-17-2006, 07:47 AM
 
Join Date: Sep 2003
Location: mn
Posts: 16
BROCD is on a distinguished road
Question

Thanks all but I need to loop these subs many times per program and although WHILE DO loops will work they are somewhat wordy for what I am trying to accomplish. Also, I like to keep these subs local because most are part specific. Any part families w/common features will have macros instead.
Here is an example of 2 simple routines that need to be called repeatedly .It is for a 2.913 x .85 slot


N80(.75 PLUNGE MILL)
G65P6000T28A27
G0G90G56X-5.375Y0.Z5.M3S2900M39M51
Z1.
G98G81R.1Z-2.1F26.
M98 H1000 L13 (incremental plunge sub 13 x's)
/
N90(.75 HI POS)
G65P6000T27A27
G0G90G56X-5.5Y0.Z5.M3S3000M39M50
Z1.
G1Z0.Y.05F50.G41D27
M98 H3000 L15(slot finish sub 15 x's)
G90G3Y0R.025F30.
G0Z5.G40
.
.
.
.
.
.M99
.N1000(PLUNGE SUB)
G91
X.125
M99
N3000(FINISH SUB)
G91
G3Y-.1R.05Z-.063F20.
G1X2.063Z-.063F40.
G3Y.1R.05Z-.063F20.
G1X-2.063Z-.063F40.
M99
%
As you can see this saves much cutting an pasting of code
While I realize these could be changed into macros, time is often not permitting and the quick and dirty way is needed.
Please let me know if what I'm doing can be done a better way.
As for storing subs in sequencial order; our numbering system won't allow this
__________________
DB34

Last edited by BROCD; 02-22-2006 at 09:04 AM.
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 02-24-2006, 11:37 PM
 
Join Date: Feb 2006
Location: United States
Posts: 273
dpuch is on a distinguished road

Well other than breaking your subs out to seperate programs like Dan mentioned I don't see an easy way to do what you want on a Fanuc control. And really the only differance between that and what you just posted is how many programs show up on the control (just change the N1000 and N3000 to O100 and O3000). You can keep them together as a single file on the computer.

If you only have 1 part program loaded to the control at a time you don't have to worry about program numbers interfearing. Just remove all programs before loading a new part.

If that isn't good enough I suggest spending the time to make the macros for what you do most.

Dale
Reply With Quote

  #12   Ban this user!
Old 02-27-2006, 07:04 AM
 
Join Date: Jan 2005
Location: USA
Posts: 237
cogsman1 is on a distinguished road

Try this. I can't prove it right now but it should do the trick for you.

N80(.75 PLUNGE MILL)
G65P6000T28A27
G0G90G56X-5.375Y0.Z5.M3S2900M39M51
Z1.
G98G81R.1Z-2.1F26.
M99P1000 (incremental plunge sub 13 x's)
N1001
/
N90(.75 HI POS)
G65P6000T27A27
G0G90G56X-5.5Y0.Z5.M3S3000M39M50
Z1.
G1Z0.Y.05F50.G41D27
M99P3000 (slot finish sub 15 x's)
N3001
G90G3Y0R.025F30.
G0Z5.G40
.
.
.
.
.
.M99
.N1000(PLUNGE SUB)
#100=0
WHILE[#100LE13]DO1
G91
X.125
#100=#100+1
END1
M99P1001

N3000(FINISH SUB)
#101=0
WHILE[#101LE15]DO1
G91
G3Y-.1R.05Z-.063F20.
G1X2.063Z-.063F40.
G3Y.1R.05Z-.063F20.
G1X-2.063Z-.063F40.
#101=#101+1
END1
M99P3001
%
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





All times are GMT -5. The time now is 01:23 PM.





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