Macro Programming Fundamentals - Page 28
Close
Login to Your Account
Page 28 of 28 FirstFirst ... 18262728
Results 541 to 553 of 553
  1. #541
    Join Date
    Sep 2010
    Location
    india
    Posts
    1,027
    Post Thanks / Like
    Likes (Given)
    62
    Likes (Received)
    171

    Default

    Quote Originally Posted by Dileep Dubey View Post
    I have fanuc oi-mate TD & TC control I want to use G71 rough turnaing cycle as rough boring cycle on CNC lathe please help.
    You may like to read my eBook on G71/72.

  2. #542
    Join Date
    Dec 2017
    Country
    AUSTRALIA
    Posts
    27
    Post Thanks / Like
    Likes (Given)
    5
    Likes (Received)
    3

    Default

    Just for something different, There were a few posts way back on how come "c" type languages weren't used for macros etc.
    Well it's the only choice I have (Andron 2060) control.

    Here's a Sub/ macro i've been working on for the past few days. Hopefully it will layout an NC file multiple times based on stock x,y and piece x,y values.

    I'm a few hundred miles and a week away from getting to test / debug this on the actual machine.
    Any feedback from the gurus (or anyone) would be greatly appreciated. I've stepped through the for loops etc and it looks good on paper.

    (I know it's oddball stuff, and pretty much i'm on my own)

    Also, any idea if this could run in block mode?

    Cheers

    Code:
    %
    (zero g54 at far right hand corner of material and work up Y axis, due to air blast blowing chips away from new work areas)
    N10 G90 G94 G17 G71 G191	(abs pos, feed in mm, x,y plane, metric, circ ctr point rel)
    (DO NOT DO A SAFE Z HERE, we need to keep g54 pure)
    
    #PARA_EXPR   
    //(work and stock constants)
    float PART_X,PART_Y,GAP_X,GAP_Y,STOCK_X,STOCK_Y,TOOL_CHECK,TEST_RUN
    
    // USER INPUTS FOR WORKPIECE AND STOCK
    PART_X = 10 			//TOTAL PART X SIZE
    PART_Y = 15 			//TOTAL PART Y SIZE
    GAP_X =  5 			//REQUIRED X SPACING BETWEEN PARTS
    GAP_Y =  5 			//REQUIRED Y SPACING BETWEEN PARTS
    STOCK_X = 500 			//X SIZE OF STOCK
    STOCK_Y = 600 			//Y SIZE OF STOCK
    TOOL_CHECK = 1 			//CHECK ALL TOOL LENGTHS/WEAR/BREAK BETWEEN PARTS 
    TEST_RUN = 2			//1=no,2=yes,3=yes with spindle at 25k manual stop(for warmup)
    //
    // !!!!!    DOUBLE CHECK FILE NAME OF GCODE PROGRAM HAS BEEN ENTERED   !!!!!!
    // !!!!!    IT'S JUST BELOW THE MAIN PROGRAM the G22 value      !!!!!!
    // !!!!!	double check only g54 is used in nc prog        !!!!!!
    
    declare float XREPEATS,YREPEATS,
    declare float XZERO_SHIFT,YZERO_SHIFT 				//values needed for G783 read / write zero offset params
    declare void main(void)
    declare void zero_offsets_testrun(void) 			// test run to check if the outside four corners of the nest will fit onto stock
    declare void nc_program(void)
    declare void kill_all(void)
    declare void safe_z(void)
    declare void tool_check(void)					//blum laser, still working on this
    
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    void main(void) 
    {
    int x,y
    G783,0 OG55 N0 D5 X0 Y0 Z0 					//WRITE (G54)MASTER HOME POS TO G55
    XZERO_SHIFT = STOCK_X / (PART_X + GAP_X) 
    YZERO_SHIFT = STOCK_Y / (PART_Y + GAP_Y)
    XREPEATS = floor(XZERO_SHIFT)      				// gives the number of repeat loops for x
    YREPEATS = floor(YZERO_SHIFT)					// ditto for y
    
    //run the very first part, we're already at initial g54 posistion
    safe_z()
    nc_program()  							
    safe_z()
    
    FOR (x=0, X<XREPEATS, X=X+1){					//!may need to change initial x val as 1
    		FOR (y=0,y < YREPEATS,y=y+1){			//!may need to change initial Y val as 1
      			G00 X0 Y0-YZERO_SHIFT 			//!MOVE UP TO NEXT Y POS for part, !!!!check for add or subtract needed, keep z at safe level
    			G783,0 G54 N0 X0 Y0  			//RESET G54 x and y to new pos
    			G54
    			safe_z()
    			nc_program()  				//run the part nc program, prog should return still in G54
    			safe_z()
    			}                 			// a full row of parts on y axis should now have completed
    
    	G55 
    	G00 Y0 X0+XZERO_SHIFT                               	//move to new X row start position
    	G783,0 G54 N0 X0 Y0  					//RESET G54 x and y to new pos
    	G54
    	safe_z
    	nc_program()						//so we dont miss a part due to this programs shitty structure
    	safe_z						
    	XZERO_SHIFT=XZERO_SHIFT+XZERO_SHIFT			//move row x over again
    	}							//all parts should now be done
    	
    G55
    safe_z()
    G00 x0y0
    G783,0 G54 N0 X0 Y0  						//RESET G54 x and y to new pos, ready for next job
    G54
    if test_run!=3 kill_all()
    }
    
    //-----------------------------------------------------------------------------------------------------------------------
    
    void nc_program(void)
    {
    G54
    
    switch(TEST_RUN)
    {
    CASE 1:	G22 N= "put prog name here!!"  					//runs the nc program. keep the quotes
    	
    CASE 2:	G0 Z50   							// TEST MODE, DROPS TO Z50 AT G54 X0,Y,0
    	safe_z()
    
    CASE 3: M03 S25000							// test mode with warmup, doesn't stop
    	G0 Z50
    	safe_z()		
    }
    
    //------------------------------------------------------------------------------------------------------------------------
    
    void kill_all(void)
    {
    safe_z()
    M05 M09  //kill spindle , kill coolant
    // work out to kill wtr chiller etc
    // work out plc output for email trigger
    // work out if full job had completed and send fault email if not
    // work out timer to kill air supply solonoids after 15 mins
    }
    
    //------------------------------------------------------------------------------------------------------------------------
    
    void safe_z(void)
    {
    G282 A1  //switch to mc co ords
    G00 D0 Z90
    G282 A-1 //back to work coords
    }
    
    //--------------------------------------------------------------------------------------------------------------------------------
    
    void tool_check(void)
    {
    // check blum manual
    safe_z()
    }
    
    //---------------------------------------------------------------------------------------------------------------------------
    ##
    %
    Last edited by itsallkuhlmann; 01-21-2018 at 02:00 AM.

  3. #543
    Join Date
    Jun 2013
    Location
    chennai
    Posts
    5
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    0

    Default What syntax to be used to find out the least or greatest number from given set of val

    Quote Originally Posted by 3t3d View Post
    Be careful using the EQ - (==) - Equals comparison. Depending on the variable type, esp. floating point, they might not compare, even though you know they should, due to rounding errors.

    What syntax to be used to find out the least or greatest number from given set of val

  4. #544
    Join Date
    May 2008
    Location
    Gauteng, South Africa
    Posts
    1,325
    Post Thanks / Like
    Likes (Given)
    1004
    Likes (Received)
    546

    Default

    Quote Originally Posted by harilulu View Post
    What syntax to be used to find out the least or greatest number from given set of val
    There are quite a few you could use
    GT (Greater than)
    LT (Less than)
    GE (Greater than or equal)
    LE (Less than or equal)

  5. #545
    Join Date
    Sep 2010
    Location
    india
    Posts
    1,027
    Post Thanks / Like
    Likes (Given)
    62
    Likes (Received)
    171

    Default

    Quote Originally Posted by harilulu View Post
    What syntax to be used to find out the least or greatest number from given set of val
    Do you mean that you want to know the highest and the lowest values from a given set of, say, ten numbers?

  6. #546
    Join Date
    Dec 2017
    Country
    AUSTRALIA
    Posts
    27
    Post Thanks / Like
    Likes (Given)
    5
    Likes (Received)
    3

    Default

    I couldn't edit the original post from a few days back, there must be a time limit on forum edits?

    Anyway after a few changes, the program works (updated below).

    Block mode works just as well, pretty much line by line.



    Code:
    ;--------- this program will place individual part files on a grid with the workflow starting from -----------
    ;--------- the far right hand corner and working up and across. ---------------------------------------------
    #Para_Expr 
    DECLARE void run_part()
    DECLARE void kill_all()
    DECLARE void safe_z()
    DECLARE void tool_check()					
    float XREPEATS, YREPEATS, XZERO_SHIFT, YZERO_SHIFT, BASE_Y, BASE_X				
    float PART_X, PART_Y, GAP_X, GAP_Y, STOCK_X, STOCK_Y, vTOOL_CHECK, TEST_RUN
    FLOAT XL,YL
    
    
    ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    ;!!!!------------------------------------------------------------------------------------------------------!!!!
    ;!!!!------------- USER INPUTS FOR WORKPIECE AND STOCK ----------------------------------------------------!!!!
    ;!!!!------------ change stock and part dimensions below --------------------------------------------------!!!!
    ;!!!!----- !!!  dont forget to change file name for part  !!!----------------------------------------------!!!!
    ;!!!!----- !!!   it's after the main prog the G22 value   !!!----------------------------------------------!!!!
    ;!!!!------------------------------------------------------------------------------------------------------!!!!
    ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    
    
    PART_X=100		;part x dimension (including cut)
    PART_Y=100		;part y dimension (including cut)
    GAP_X=0			;seperation gap x	
    GAP_Y=0			;seperation gap y
    STOCK_X=500 		;stock x size
    STOCK_Y=500 		;stock y size 	
    vTOOL_CHECK=0		;check tools on new part(wip)	 
    TEST_RUN=2		;1=no,2=yes,3=yes with spindle at 25k manual stop(for warmup)
    
    
    ;--------------------------------------------------------------------------------------------------------------
    ;--------------------------------------------------------------------------------------------------------------
    
    
    G90 G94 G17 G71 G191 G54					;(abs pos, feed in mm, x,y plane, metric, circ ctr point rel)
    
    
    G783 D5 O55 X0 	 						;WRITE (G54)MASTER HOME POS TO G55
    G783 D5 O55 Y0
    G783 D5 O55 Z0
    G783 D5 O54 X0				    			; WRITE (G54)MASTER HOME POS TO G55
    G783 D5 O54 Y0
    G783 D5 O54 Z0
    
    
    XZERO_SHIFT=STOCK_X/(PART_X+GAP_X); 
    YZERO_SHIFT=STOCK_Y/(PART_Y+GAP_Y);
    XREPEATS=floor(XZERO_SHIFT)      				; gives the number of repeat loops for x
    YREPEATS=floor(YZERO_SHIFT)					; ditto for y
    					
    [main]
    
    
    XZERO_SHIFT=PART_X+GAP_X 					;put this block here as it resets start values when in test mode 3
    YZERO_SHIFT=PART_Y+GAP_Y
    BASE_Y=YZERO_SHIFT
    BASE_X=XZERO_SHIFT
    
    
    FOR (XL=0,  XL<XREPEATS,  XL=XL+1)
     	{							
    			FOR (YL=0, YL<YREPEATS, YL=YL+1)
    			{				        
    			safe_z()
    			G00 X0 Y0	 			;!MOVE UP TO NEXT Y POS for part, !!!!check for add or subtract needed, keep z at safe level
    			run_part()				;run the part nc program, prog should return still in G54
    			G783 D5 O54 y=-yzero_shift		;RESET G54 x and y to new pos
    			YZERO_SHIFT=YZERO_SHIFT+BASE_Y
    			G54 		
    			}                 			;a full row of parts on y axis should now have completed
    
    
    	G783 D5 O54 X=-XZERO_SHIFT   				;RESET G54 x and y to new pos
    	G783 D5 O54 Y0
    	SAFE_Z()
    	G00 X0 Y0
    	run_part()
    	YZERO_SHIFT=part_y+gap_y				;reset y zero shift to original value
    	XZERO_SHIFT=XZERO_SHIFT+BASE_X				;move row x over again
    	}							;all parts should now be done
    	
    G55
    safe_z()
    G00 X0 Y0
    G783 D5 O54 X0   						;RESET G54 x and y to new pos, ready for next job
    G783 D5 O54 Y0
    G54								;should be back at original start x,y
    
    
    if test_run !=3	
    {kill_all()
    }						
    else 
    {GOTO MAIN 						;only want to go there if in warmup mode
    }
    
    
    ;-----------------------------------------------------------------------------------------------------------------------
    
    
    void run_part()
    {
    G54
    switch(TEST_RUN)
    	{
    	CASE 1:	
    	safe_z()
    	G22 N="!!put prog name here!!"  		;enter nc prog name here. between the quotes
    	safe_z()					
    	BREAK
    	
    	CASE 2:	
    	G282 A1  					;TEST MODE, DROPS TO Z50 AT G54 X0,Y,0
    	G00 D0 Z50
    	G00 D0 Z90
    	G282 A-1 							
    	BREAK	
    	
    	CASE 3: 
    	M03 S25000					;test mode with warmup, doesn't stop
    	G282 A1  
    	G00 D0 Z50
    	G00 D0 Z90
    	G282 A-1 
    	BREAK
    
    
    	DEFAULT:
    	kill_all()			
    	}
    }
    ;------------------------------------------------------------------------------------------------------------------------
    
    
    void kill_all()
    {
    safe_z()
    M05 M09 						;kill spindle , kill coolant
    G00 X0 Y0						;go to home ready for next job
    M30
    [gonowhere]						;there's gotta be a better way to do this 
    goto gonowhere
    }
    
    
    ;------------------------------------------------------------------------------------------------------------------------
    
    
    void safe_z()
    {
    G282 A1  
    G00 D0 Z90
    G282 A-1 
    }
    
    
    ;-------------------------------------------------------------------------------------------------------------------------
    
    
    void tool_check()					;w.i.p
    {
    safe_z()
    }

  7. #547
    Join Date
    Jan 2018
    Country
    NIGERIA
    Posts
    2
    Post Thanks / Like
    Likes (Given)
    0
    Likes (Received)
    0

    Default

    Wow! This is really a bunch of information to move one from low level to a professional. Thanks you all for sharing...

  8. #548
    Join Date
    May 2007
    Location
    Texas
    Posts
    1,567
    Post Thanks / Like
    Likes (Given)
    2158
    Likes (Received)
    266

    Default

    Great info thanks Tony it is a glimpse into a whole new science.

  9. #549
    Join Date
    Dec 2007
    Location
    Southeastern US
    Posts
    6,268
    Post Thanks / Like
    Likes (Given)
    761
    Likes (Received)
    2645

    Default

    Quote Originally Posted by Spinit View Post
    Great info thanks Tony it is a glimpse into a whole new science.
    It's not just me, it's a whole group of folks here who have contributed to this volume of information. I just started the thread....

    I think several folks have this thread printed out in a book by the computer. I need to print out a new copy since it's now 19 pages long.

  10. #550
    Join Date
    Jan 2012
    Location
    Savannah, Georgia, USA
    Posts
    1,644
    Post Thanks / Like
    Likes (Given)
    2610
    Likes (Received)
    597

    Default

    My fanuc 0 does not have a "measure" key to input work offsets. I must enter the numbers manually. I feel this lack of feature is the largest short coming of this machine.

    This macro will do just that. Scroll down to the register you want and cycle start through x, y, and z if needed. I been using this for a month and thought others might could use it also.

    %
    O7054(SET ALL)
    (G54 SET)
    N1054
    #2501=#5021(X);
    M00
    N2054
    #2601=#5022(Y);
    M00
    N3054
    #2701=#5023(Z);
    M30
    (G55 SET)
    N1055
    #2502=#5021(X);
    M00
    N2055
    #2602=#5022(Y);
    M00
    N3055
    #2702=#5023(Z);
    M30
    (G56 SET)
    N1056
    #2503=#5021(X);
    M00
    N2056
    #2603=#5022(Y);
    M00
    N3056
    #2703=#5023(Z);
    M30
    (G57 SET)
    N1057
    #2504=#5021(X);
    M00
    N2057
    #2604=#5022(Y);
    M00
    N3057
    #2704=#5023(Z);
    M30
    (G58 SET)
    N1058
    #2505=#5021(X);
    M00
    N2058
    #2605=#5022(Y);
    M00
    N3058
    #2705=#5023(Z);
    M30
    (G59 SET)
    N1059
    #2506=#5021(X);
    M00
    N2059
    #2606=#5022(Y);
    M00
    N3059
    #2706=#5023(Z);
    M30
    %

  11. #551
    Join Date
    Sep 2010
    Location
    india
    Posts
    1,027
    Post Thanks / Like
    Likes (Given)
    62
    Likes (Received)
    171

    Default

    Your macro assumes that external offset is zero which, of course, is the usual case.
    If, however, it is non-zero, a modification would be needed (would need to subtract external offset values from the RHS).

    Copied from this book (taking example of G54):
    Mathematically,
    X-external offset + X-offset of G54 = X-coordinate of the current tool position, in MCS
    Hence, if the external offset value is not to be changed, the X-offset of G54 will have to be made equal to the X-coordinate in MCS minus the X-external offset, that is,
    X-offset of G54 = X-coordinate of the current tool position, in MCS − X-external offset
    Similarly, for zero shift to the current Y-position of the tool,
    Y-offset of G54 = Y-coordinate of the current tool position, in MCS − Y-external offset

    The red terms are missing in your macro.

  12. #552
    Join Date
    Sep 2010
    Location
    india
    Posts
    1,027
    Post Thanks / Like
    Likes (Given)
    62
    Likes (Received)
    171

    Default

    Basically, one needs to subtract #5201/#5204 (or #2500/#2800) from the RHS.
    This will take care of non-zero external offsets as well.

  13. #553
    Join Date
    Sep 2010
    Location
    india
    Posts
    1,027
    Post Thanks / Like
    Likes (Given)
    62
    Likes (Received)
    171

    Default Macro for datum shift

    I have copied the following from one of the threads, as this has some useful information, to be retained as a permanent record in a sticky thread:

    macros can be used for simplifying several tasks, offset setting being an example. I would encourage you to use the following macros.

    Copied from this book (page 114)...

    O8009 (CURR WCS Z-DATUM SHIFT ON LATHE);
    #1 = #4014;
    #1 = #1 – 53;
    #1 = #1 ∗ 20;
    #1 = #1 + 5201;
    #[#1 + 1] = #5022 − #5202;
    M30;

    It is designed to identify and shift the datum of
    the current WCS. If the requirement is to shift the datum of, say, G56
    coordinate system, irrespective of which WCS is current, this is a simpler
    task, which can be done by program numbers 8010 and 8011. Of
    course, the effect of datum shift will be visible only after G56 becomes
    the current WCS.

    O8010 (G56 DATUM SHIFT ON MILL M/C);
    #5261 = #5021 − #5201;
    #5262 = #5022 − #5202;
    M30;

    O8011 (G56 Z-DATUM SHIFT ON LATHE);
    #5262 = #5022 − #5202;
    M30;

    The given programs may appear trivial (as one can shift the datum
    manually, using the usual offset setting procedure), but it can be very
    effectively used. For example, if the workpiece on a lathe is changed
    to a different one, having different dimensions, the datum setting for
    Z would need to be repeated (X-datum would remain the same,
    because the X0 position does not depend on the diameter of the workpiece).
    If the machine operator is not fully aware of the offset setting
    procedure, he may simply be asked to first bring the tool manually
    (in JOG or HANDLE mode) to the desired Z0 position, and then run
    program number 8009, without disturbing the position of the tool.
    This would place the Z-datum of the current WCS at the chosen location.
    Naturally, this has to be done in the same workpiece coordinate
    system which the machining program uses. If it is, say, G56, one will
    have to first execute G56 in the MDI mode, before running program
    number 8009 in AUTO mode. And the RESET key must not be pressed
    in-between, otherwise, the default workpiece coordinate system, G54,
    will again become the active coordinate system!


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •