![]() | |
| 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
| |||
| |||
Fanuc 16i control Macro B Hello all first post on here, and completely green on macro programming. I got something that should be easy for you macro gurus out there. I'm trying to set-up engraving parts with the shift letter on them. 12hr shifts currently...so shift "A" is between 5a.m. and 5p.m. and shift "B" 5p.m. to 5a.m. I know that variable #3012 reads current time and 50000 is 5am and 170000 is 5pm. I'm having trouble at the beginning where the current time determines what program to run, I'm not sure what function to use (GE,LE,EQ,GT,LT,WHILE,OR)etc...etc.. Here's what i have so far, (try not to laugh) % O0006 G0 G17 G20 G40 G80 G90 G91 G28 Z0. #501=#3012 IF[#501GE50000]GOTO100 N100 IF[#501LE170000]GOTO500 GOTO N1000 IF[#501GE170000]GOTO200 N200 IF[#501LE50000]GOTO600 GOTO1000 N500 (A-SHIFT) /G0 G17 G90 G54 X-.4 Y.7451 S5000 M3 /G43 H1 Z.02 /Z.015 /G94 G1 Z-.01 F3. /X-.6 Y.7949 F5. /X-.4 Y.8451 /G0 Z.02 /X-.5 Y.82 /Z.015 /G1 Z-.01 F3. /Y.7702 F5. /G0 Z.02 GOTO1000 N600 (B-SHIFT) /G0 G17 G90 G54 X-.4 Y.7451 S5000 M3 /G43 H1 Z.02 /Z.015 /G94 G1 Z0. F3. /Y.7953 F5. /X-.401 Y.8039 /X-.4038 Y.8122 /X-.4087 Y.82 /X-.4144 Y.8271 /X-.4221 Y.8333 /X-.4308 Y.8384 /X-.4404 Y.842 /X-.45 Y.8443 /X-.4615 Y.8451 /X-.4721 Y.8443 /X-.4817 Y.842 /X-.4913 Y.8384 /X-.5 Y.8333 /X-.5077 Y.8271 /X-.5135 Y.82 /X-.5183 Y.8122 /X-.5212 Y.8039 /X-.5221 Y.7949 /X-.524 Y.8047 /X-.5269 Y.8118 /X-.5308 Y.818 /X-.5356 Y.8235 /X-.5413 Y.8282 /X-.5481 Y.8314 /X-.5538 Y.8333 /X-.5615 Y.8341 /X-.5683 Y.8333 /X-.574 Y.8314 /X-.5808 Y.8282 /X-.5865 Y.8235 /X-.5913 Y.818 /X-.5952 Y.8118 /X-.5981 Y.8047 /X-.599 Y.7973 /X-.6 Y.7898 /Y.7451 /X-.4 /G0 Z.02 /X-.5221 /Z.015 /G1 Z0. F3. /Y.7953 F5. /G0 Z.02 GOTO1000 N700 (C-SHIFT) /G0 G17 G90 G54 X-.5519 Y.8451 S5000 M3 /G43 H1 Z.02 /Z.015 /G94 G1 Z0. F3. /X-.5644 Y.8404 F5. /X-.5769 Y.8337 /X-.5865 Y.8263 /X-.5942 Y.8176 /X-.5981 Y.8086 /X-.6 Y.7992 /X-.5981 Y.7898 /X-.5942 Y.7808 /X-.5865 Y.7722 /X-.5769 Y.7643 /X-.5644 Y.7576 /X-.55 Y.7522 /X-.5346 Y.7482 /X-.5173 Y.7459 /X-.5 Y.7451 /X-.4827 Y.7459 /X-.4654 Y.7482 /X-.45 Y.7522 /X-.4356 Y.7576 /X-.4231 Y.7643 /X-.4135 Y.7722 /X-.4058 Y.7808 /X-.4019 Y.7898 /X-.4 Y.7992 /X-.4019 Y.8086 /X-.4058 Y.8176 /X-.4135 Y.8263 /X-.4231 Y.8337 /X-.4356 Y.8404 /X-.4481 Y.8451 /G0 Z.02 GOTO1000 N1000 M5 M9 G91G28Z0. M30 % Thanks, |
|
#3
| |||
| |||
From what I see first glance, 3 things: the tests are wrong and the block skips are not needed, serve no function the n100,etc. line numbers are in the wrong places. To make the tests be right, there are 3 cases and you need to have each case accounted for in order. There are 3 cases because the clock is linear from 0 o'clock to midnight. So the order of our cases needs to follow that (so we can fall thru to the next test correctly). 1st case, it is before 5am 2nd case, it is between 5am and 5pm 3rd case, it is after 5pm Cases 1 and 3 go to the same code, for shift B Case 2 goes to the code for shift A. so, some pseudo-code: if before 5am, goto shift B code if before 5pm, goto shift A code if after 5pm, goto shift B code Shift A code for shift A goto 1000 Shift B code for shift B goto 1000 Shift C (or not, as your example has 3 shifts but description has 2) N1000 (continue...) I program it the way I did because it is nice and orderly, and easy to figure out next year when you modify it (grin). It could be made shorter (though slightly less obvious what is going on) by reversing the order of the shift a and shift b code, which means it falls through for the third test and then the 3rd test is not needed. Like this: if before 5am, goto shift B code if before 5pm, goto shift A code Shift B code for shift B goto 1000 Shift A code for shift A N1000 (continue...) But that is less clear to me so I would program it the first way, so everybody reading it gets it clearly. Hope that helps--you may have already solved this since the Orig. Post was a while ago. Skm |
![]() |
| 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 |
| Problem- Serialized Engraving Macro help | Kennebec | Fanuc | 1 | 06-09-2010 12:36 PM |
| number engraving macro | gravy | Parametric Programing | 2 | 02-22-2010 04:05 PM |
| Testing program for Macro (Fanuc Macro B) | NickDP | Fanuc | 2 | 03-27-2009 03:15 PM |
| Convert Fanuc Macro to Fadal Macro | bfoster59 | Fadal | 1 | 11-08-2007 11:41 PM |
| Engraving Macro | MachineSMM | General CNC (Mill and Lathe) Control Software (NC) | 12 | 03-03-2005 05:32 AM |