Macro Programming Fundamentals - Page 28
Close
Login to Your Account
Page 28 of 28 FirstFirst ... 18262728
Results 541 to 547 of 547
  1. #541
    Join Date
    Sep 2010
    Location
    india
    Posts
    944
    Post Thanks / Like
    Likes (Given)
    56
    Likes (Received)
    147

    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 03: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,175
    Post Thanks / Like
    Likes (Given)
    909
    Likes (Received)
    489

    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
    944
    Post Thanks / Like
    Likes (Given)
    56
    Likes (Received)
    147

    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...


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
  •