Let me shed some light on Macro programming

Page 1 of 2 12 LastLast
Results 1 to 20 of 23

Thread: Let me shed some light on Macro programming

  1. #1
    Member arie kabaalstra's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    352
    Downloads
    0
    Uploads
    0

    Default Let me shed some light on Macro programming

    Folks, as the title of this thread states.. i want to give you some pointers on macro programming..

    i've found that a lot of people run into all kinds of problems, or simply do not know where to start, or how to use the functions available in EdingCNC.

    A little introduction first:
    I built my CNC machining Center in 2007, but only last year really (sort of) finished it.. because it was spitting out all kinds of parts in the mean time..



    This is how my machine looks now..
    Don't be intimidated by the very professional looking Control panel.. it's an old Heidenhain TE420 Panel i purchased on the internet

    I started working with my machine with ZEUS CNC, and old DOS based CNC control program, very similar to oldfashioned Fanuc's
    Putting programs on the machine was tedious to say the least, so i searched for a windows control.. found Mach.. installed it.. didn't like it al all.. found USBCNC ( the old name for EdingCNC) didn't like the layout of the control screens, but loved the posibillities of the software and programming language..

    a few weeks after discovering USBCNC, i met Bert Eding on a yearly meeting of a dutch CNC forum, and we discussed the layout of the screens.. because of my experience with professional CNC controls Bert asked me to help him design the new layout he had planned ( it turned out , i was the first with a professional CNC background using USBCNC. )

    From then on, i changed my machine from ZEUS to USBCNC, and started testing, also giving Bert Feedback.
    One fine day.. i was making some parts with a program that could mill out a rectangular pocket by setting some parameters in the program, Bert called me, and said: "go download the latest version.. i've put in something amazing.. i bet you'll love it".. this was the birth of "Macro.cnc"

    The File called "Macro.cnc" contains some subroutines (macro's) for basic tasks such as toolchange and homing, since every machine is different, one could change this file to his personal needs and desires..
    If one puts a subroutine in that file, it can be called from MDI, or from a running program.. or.. from the macro file itself, if it is called from another subroutine.

    Yes.. Subroutines can be "stacked" upon each other.

    Let's make some things clear:
    if i talk about a "Macro" that means the total of one or more subroutines working together
    If i talk about a subroutine, i only mean one subroutine (everyting between SUB and ENDSUB)

    one macro can contain from 1 to a number of subroutines ( subs)

    For instance.. if i wanted to make a subroutine that mills out circular pockets ( handy for boltholes with allen bolts), First, i would write a sub with a loop that keeps repeating until final depth is reached..
    from that sub, a second sub is called, milling every "layer" out to the desired diameter

    Bert went on and made another command possible.. DLGMSG, this stands for Dialog Message, this command enables you to create dialogs for entering values to use in macro's
    i first used this on a Lathe i had converted to USBCNC control at work, we used it to machine ballscrews for use in the CNC equippement we built
    When machining a ballscrew, i'd touch the tool at the front to the workpiece, and set the Z-value to 1, i then opened a program called "Facing.nc" with a dialog, and i entered : safety distance, starting diameter, finishing diameter,finshing Z coordinate Feed, cutting depth and cutting speed.
    Upon hitting Ok, the part was face turned, with the values i had put in..
    Next a program "turning.nc" was loaded, and after keying in the right values the part was turned to the desired diameter and length.
    A while later Bert introduced the User menu.
    this user menu connects a range of F-Keys to subroutines within Macro.cnc.
    you can write your macro's into these subs, and put a fitting Icon on the button connected to it.

    More to come... stay tuned

    Similar Threads:
    Attached Thumbnails Attached Thumbnails Let me shed some light on Macro programming-dscn1417-jpg  


  2. #2
    Registered
    Join Date
    Jan 2012
    Location
    USA
    Posts
    139
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming

    I'm seriously considering moving to Eding from Mach3. Mach3 is great WHEN it works. I had some recent behavior of my machine that has me about spent with Mach3 and I want to switch. I downloaded the software it looks great. The hardware price is really good as well.

    My only hesitation is that I can't find anything on how to touch off your tools, weather that be on a mill or lathe. Do all tool lengths need to be measured offline via a height gage? With the mill that's easy, but the lathe, that can get tricky. I understand custom macros can be written to use a touch plate, but I just need a simple function to be able to touch tools off on the machine. Is this possible? It seems elementary, but I must be missing something. Thanks in advance.

    www.benchtopprecision.com
    | BF20/G0704 Belt Drive Kits | X2 Mini-Mill Belt Drive Kits |


  3. #3
    Member arie kabaalstra's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    352
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming

    if you mount a "toolsetter" on the table somewhere, you can automatically measure your tools..

    i need to put mine back on the machine, but when i had it operational..
    when setting up a new job, i put the first tool in the spindle , and measured the length, that was automatically stored in the tool table.
    Then i touched off on my workpiece (i use an old endmill with a 6.00 mm shaft.. put that on top of my work, jog the tool down and then slowly up, untill the shaft just passes under the tool.. set the Z value to 6.00 mm..

    When i need to work with another tool.. i just insert it in the spindle, and measure the length... no need to touch off on my workpiece again.. since the new length is in the tool table..

    beauty part of this is.. i wrote a macro for tool measurement.. and Bert Eding included that in the Macro.cnc

    Touchplates are, in my opinion no good.. they have been invented by people that do not understand CNC machines..

    Take a look in your EdincCNC folder.. and find the file named Macro.cnc, open it with notepad, and take a look around..

    on my machine. i altered the sub toolchange, so that it always measures the tool length, when my toolsetter is connected.. the machine can detect that, since my toolsetter is an NC switch, and the status of that switch is in a parameter..(one of the many requests i had for Bert.. i'm one of his Beta Testers.. because of my professional background..

    if you have no means of measuring your tools.. common practice is set all toollengths to zero and touch of every tool.. but that can become a bit tedious if you have to make multiple parts with several tools per part..

    on a lathe.. what i have done in the past is write a calibration macro.. will write a new one when converting my lathe to EdingCNC.. what it did ( i had an USBCNC Controlled lathe at work once) was asking you to move the Z-axis to a known value ( i.e. facing your workpiece and let the tool stay at that position) then it opened a dialog where it asked for the Z-coordinate, and then it calculated the offset from tool 1 which had no offsets.. this is the "master tool", after that it asked you to turn a diameter, measure it up and enter the value for the X offset.. the new offsets were then loaded, and you were ready to go.. this only needed to be performed once, with a quickchange toolpost..

    All this was achieved by macro's.. they can be really powerfull and handy when well written.
    I hope to find some time in the coming days to write some more about some commands.. like dialogs and logmessages ( writing data to a text file.. can be handy if you use the machine as a coordinate measuring machine.

    and YES.. EdingCNC is also capable of that..



    this is also done with a macro.. took me 3 days to get it right ..



  4. #4
    Member arie kabaalstra's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    352
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming

    Before you start digging in to writing macro's, take a look at the EdingCNC manual, find the parameter table, and print it for reference..
    In the current manual, you will find this table on page 98 and further..

    Also.. Bert recently included a new feature into EdingCNC, the possiblity to make your own M-codes.. this is done by making a macro with a name of that M-code:

    For instance:

    if you would like a certain macro to be called upon writing "M99" in a program, you simply put
    SUB M99
    (some code here)
    ENDSUB

    in the Macro.cnc
    When working with dialogs, make use of #5398, this parameter is controlled by the dialog, if you press OK, the value of #5398 will be 1, if you press Cancel, #5398 will be -1

    After programming a Dialog you should include the following into a macro:

    IF #5398 <0
    M2
    ENDIF

    This stops the execution of the program or macro after you press cancel, if you press Ok, the program will continue.
    It is highly important to use this otherwise the machine will continue, even if you press cancel.. so we need this in order to prevent this.

    A handy trick is putting this into a separate sub...it saves a lot of typing if after a dialog you include :

    GOSUB DLGCHECK

    and DLGCHECK should contain the IF routine..like so:

    SUB DLGCHECK
    IF #5398 <0
    M2
    ENDIF
    ENDSUB

    Now for the DLGMSG Command:

    DLGMSG "Enter Values" "first parameter" 1 "Second Parameter" 2

    Copy this line of Code into the MDI of EdingCNC and hit enter to see what it does..it is quite self explanatory i guess... the first string is sort of the title of the dialog, telling the user for what operation to enter the values, then the names of the fields, and their respective parameters..
    It is not neccessary to use parameters from 1 to wherever you need in numerical order.. that's where the list comes in handy..here you can find some parameter that might be usefull to set certain machine functions

    In my Macro .CNC, i've made a second list.. for parameters i use for "defaults" and specific functions.. it is highly recommended you make a list yourself..

    Lets say you want to make a number of macro's for machining round pockets, rectangular pockets and slots., in every macro, you would enter for instance a setup-clearance, you could use a parameter in the "4000 range" since, as the manual states, these parameters are stored when the machine is shut off.. next time you use it.. it wil have the same value.. a bit like a default value..

    When opening the dialog, you'll notice it has a big Eding CNC logo on the right.. you can put your own pictures in there if you wish to do so..
    EdingCNC will try to find an image with the same name as the dialog title, those images are stored in the Dialogpictures folder.. it needs to be a *.PNG file, which you can make easily with all kinds of programs like paint,or export from a Cad program



    Like so.. and.. yes.. i put "r"in there two times, and i forgot the setup clearance.. this was cobbled together for documentation purposes only..

    How to build a macro that can perform this operation will be covered in a future posting



  5. #5
    Member arie kabaalstra's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    352
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming



    Cobbled something up in EdingCNC... to show how powerfull macro programming can be..

    in my setup i Checked WatchFileChanged and Load Automatically, so if a loaded file is changed on disc, it is automatically reloaded..
    I made a file called teach_in.nc, and loaded that.. it is just an empty file..

    then in the User Menu, i start User sub 10, which Starts a dialog, with a number of Cycles to choose from.. simply by entering "1"
    Upon loading, all parameters are set to "0", Upon Clicking Ok, a second dialog shows up, displaying the chosen cycle, just enter values, hit Ok.. and then.. magic happens..

    by means of the LogMsg Command.. all parameters and a gosub command ( as M199, since you can create your own M Codes ) are stored in Teach_in.nc, and.. because of the settings it is reloaded..

    This way, you can program your workpiece step by step.. and see the changes on the screen immediately.. kinda cool huh?.. but wait.. there's more.. you can also directly program and execute these cycles, if you call them from their own user subs, by means of the F2-F5 keys.. and if you open the UserSub 10 afterwards.. a "1" shows up as "switch" for the latest programmed cycle, you can simply hit Ok.. review and alter the parameters, and store the cycle in Teach_in.nc..
    There's also an "end of File"switch, which writes M2 to the program, and a New File switch, which erases the current file..

    when you open the file from the machining menu, you can save it under another name..



  6. #6
    Registered
    Join Date
    Feb 2015
    Location
    Norway
    Posts
    3
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming

    Hi

    i have tried to read your little tutorial here, and what the manual says about macros...
    i`m no machinist, so i have limited knowlage about g-code, and the capabilities.

    i have a CNC mill similar to yours arie, and feel i can much more out of the user experience if i enable som macroes and take full advantage of the CPU5A board i have.
    i use Fusion 360 for my CAD/CAM software, so i realy do not need to do much editing with G-codes. i just run them

    i not a complete noob, i did build my own cnc mill with pc and controller electronics. but i never got around to teach myself macro/g-code in dept.
    do you have any tips for where i can start?

    the one thing i am missing at this point is i siple program that can calculate an set the work coordinate for an axis devided by 2.
    say that i want to find the center of a hole og a part. i jog and touch of at one side, and jog to the other. then a want to push to write in the numbercoresponding to the axis i want to calibrate, and type "/2". but this does not work in eding CNC software. and i have to get a calculator and divide the number manualy, and type it in. do you have any tips for ovecoming my problem?



  7. #7
    Member arie kabaalstra's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    352
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming

    the one thing i am missing at this point is i siple program that can calculate an set the work coordinate for an axis devided by 2.
    say that i want to find the center of a hole og a part. i jog and touch of at one side, and jog to the other. then a want to push to write in the numbercoresponding to the axis i want to calibrate, and type "/2". but this does not work in eding CNC software. and i have to get a calculator and divide the number manualy, and type it in. do you have any tips for ovecoming my problem?
    I have used a Touchprobe for this.. when you have a touchprobe, you can store the coordinates in parameters.. and then calculate the center..
    When touching off with a tooll.. hmm there must be a way.. but that would require some programming..

    i'll get into more detail soon.. i'm very busy at the moment..
    most of the time, when setting coordinates at a hole.. i use a dial indicator and center manually..



  8. #8
    Registered
    Join Date
    Feb 2015
    Location
    Norway
    Posts
    3
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming

    I hope there is a way... But i can't seem to find it... But i'm a noob regarding edingcnc macro programming... I am not in any hurry anyway, so no rush.. Any help will be wery much appreciated


    Sent from my iPhone using Tapatalk



  9. #9
    Member arie kabaalstra's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    352
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming

    There is always a way.. you just have to find a way that works for you..

    i've Seen DRO's on conventional machines that could do this tric..

    basically.. what you need to do is calculate the difference between 2 points.. that's easy.. Point 2-Point 1.. ,then divide that through 2.. for instance, you touch of at X-2, and at X+5, Difference = 5--2=7, divide: 7/2 = 3.5.. now.. you can either move 3.5 mm back from point 2, or 3.5mm forward from point 1.. doesn't make any difference.. , you could also stay put.. and add the 3.5 to given center position.. that means.. say you want the center of the circle to be X10.. then.. you are now at X13.5.. 10.+3.5 =13.5.. so if you do a G92 X13.5 X10 will be the center..

    But.. there's the "problem" of chosing the axis of measurement.. how does the machine know which way you are moving to touch off?..

    you can do that.. by checking wich axis didn't move.. clever ey?

    EdingCNC uses "System parameters" and User parameters.. the User parameters are #1 through #4999, and #4000 through #4999 are stored in memory at switching off.. that means.. those parameters remain stored at power-down.. you could use those for default settings.. (there are some parameters "reserved" for Calibration routines, refer to the manual)

    System Parameters #5001 through #5006 are the X through C axis Coordinates.. you can use those in Calculations as well..

    Try the following.. start up the machine, home it.. and move to a random position.. then.. open MDI.. and type : MSG #5001
    in the message window below the graphic screen.. it will display the X position.. MSG #5002 will display the y position.. and so on..

    so.. if you touch off in X.. with the above example.. dlgmsg"X Centerposition" "Centerposition" 100
    enables you to enter a value for X Center.. then. calculate the correct position..
    You do need a way to capture the X positions at touch off first.. but that can be done too.. make a program basically like:

    MSG"move to First X-axis touch-off point and press start"
    M00 ; this halts execution of the program
    #200=#5001] ; this stores current position in #200
    MSG"move to second X-axis touch off point and press start"
    M00
    #201=[#5001] ; this stores the current position in #201
    #202=[[#201-#200]/2] ; half distance between touch-off points
    DLGMSG"centerposition X" "X-centerposition"100 ;this stores desired X Center in #100
    G92 X[#100+#202] ;this sets current position to center position + half distance
    M2

    and you're done..for the X-axis that is.. you could remove the M2 (end of program )
    and add:
    Msg"move to safe Z and press start
    G00 X#100 ; moves to center X
    M00
    MSG"move to First Y-axis touch-off point and press start"
    M00 ; this halts execution of the program
    #200=#5002] ; this stores current position in #200
    MSG"move to second Y-axis touch off point and press start"
    M00
    #201=[#5002] ; this stores the current position in #201
    #202=[[#201-#200]/2] ; half distance between touch-off points
    DLGMSG"centerposition Y" "Y-centerposition"100 ;this stores desired Y Center in #100
    G92 Y[#100+#202] ;this sets current position to center position + half distance
    M2



  10. #10
    Registered
    Join Date
    Feb 2015
    Location
    Norway
    Posts
    3
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming

    Hi
    Thanks for the tips
    i did try Your code today, and with some tveaking i did get it to work.
    See my final code here:

    MSG"move to First X-axis touch-off point and press start"
    M00 ; this halts execution of the program
    #200=[#5001] ; this stores current position in #200
    MSG"move to second X-axis touch off point and press start"
    M00
    #201=[#5001] ; this stores the current position in #201
    #202=[[#201-#200]/2] ; half distance between touch-off points
    DLGMSG"centerposition X" "X-centerposition"100 ;this stores desired X Center in #100
    G92 X[#100+#202] ;this sets current position to center position + half distance
    MSG"move to safe Z and press start"
    M00
    G00 X#100 ; moves to center X
    MSG"move to First Y-axis touch-off point and press start"
    M00 ; this halts execution of the program
    #200=[#5002] ; this stores current position in #200
    MSG"move to second Y-axis touch off point and press start"
    M00
    #201=[#5002] ; this stores the current position in #201
    #202=[[#201-#200]/2] ; half distance between touch-off points
    DLGMSG"centerposition Y" "Y-centerposition"100 ;this stores desired Y Center in #100
    G92 Y[#100+#202] ;this sets current position to center position + half distance
    MSG"move to safe Z and press start"
    M00
    G00 Y#100 ; moves to center Y
    M2

    I got the work when joging with the keyboard Connected, and the on screen jog-pad. but the code will not work when i am i "Wheel-mode"
    and that is the mode i use the most, it is realy convinient to jog around usin the Wheel, where you easy can make rapid movement over some distance, and fine stepping as i get closer to the edge i want to Reference.

    is it posible to make edingcnc not reset the current axis when pressing the "start" button when in Wheel-mode?



  11. #11
    Member arie kabaalstra's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    352
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming

    Folks, it has been a while, but recently i found something REALLY COOL in the manuals:

    the parameters 1-26 represent the letters of the alphabet: A=#1, B=#2 and so on until Z=#26

    This means that when writing your own M-Codes you can use whatever letter you like!
    About writing your own M-Codes: you can either customise existing MCodes,or make your own.

    With your own M-Codes you can execute whatever tickles your fancy.

    So i dreamt up the following: What if... I could store a Coordinate, and then position relative to that position using Angle and Radius?.. i.e. Polar coordinates, to enable programming a circular pattern in a jiffy..or,, machine polygons really easy..To maken Hexheads for instance.

    How do i pull that off?..
    well here's how!

    Code:
    SUB M33
        IF [#24==-10000000000.000]
            IF [#25==-10000000000.000]
                #3701=[#5001]
                #3702=[#5002]
                #1280=[3]
                GOSUB SET_PLANE
                RETURN
            ENDIF 
        ENDIF 
        #1280=[0]
        IF [#24>-10000000000.000] (X PROGRAMMED)
            #3701=[#24]
            #1280=[1]
        ENDIF
        IF [#25>-10000000000.000] (Y PROGRAMMED)
            #3702=[#25]
            #1280=[#1280+2]
        ENDIF
        IF [#26>-10000000000.000] (Z PROGRAMMED)
            #3703=[#26]
            #1280=[#1280+4]
        ENDIF
    ENDSUB
    
    
    SUB SET_PLANE    
        (DETERMINING WHICH PARAMETERS HAVE BEEN PROGRAMMED)
        IF [#1280==3]
            MSG "X-Y PLANE  CC = X:"#3701" Y:"#3702
            G17
        ENDIF
        IF [#1280==5]
            MSG "X-Z PLANE  CC = X:"#3701" Z:"#3703
            G18
        ENDIF
        IF [#1280==6]
            MSG "Y-Z PLANE  CC = Y:"#3702" Z:"#3703
            G19
        ENDIF
    ENDSUB
    
    
    SUB M34
        IF[#1>-10000000000.000]
            #2101=[#1] (COPY ANGLE)
        ENDIF
        IF[#18>-10000000000.000] (COPY RADIUS)
            #2118=[#18]
        ENDIF
            IF [#1280==3]
                MSG "G17 A= "#2101
                #3711=[COS[#2101]*#2118]
                #3712=[SIN[#2101]*#2118]
                IF[#6<0] 
                    G00 X[#3701+#3711] Y[#3702+#3712]
                ENDIF
                IF[#6>0] 
                    G01 X[#3701+#3711] Y[#3702+#3712] F[#6]
                ENDIF
            ENDIF
            IF [#1280==5]
                MSG "G18 A= "#2101
                #3711=[COS[#2101]*#2118]
                #3713=[SIN[#2101]*#2118]
                IF[#6<0] 
                    G00 X[#3701+#3711] Z[#3703+#3713]
                ENDIF
                IF[#6<0] 
                    G01 X[#3701+#3711] Z[#3703+#3713] F[#6]
                ENDIF
            ENDIF
            IF [#1280==6]
                MSG "G19 A= "#2101
                #3712=[COS[#2101]*#2118]
                #3713=[SIN[#2101]*#2118]
                IF[#6<0] 
                    G00 Y[#3702+#3712] Z[#3703+#3713]
                ENDIF
                IF[#6<0] 
                    G01 Y[#3702+#3712] Z[#3703+#3713] F[#6]
                ENDIF
            ENDIF
    ENDSUB
    And here's how it works:

    with M33 you set a Circle Center Coordinate (CC), you either move to the desired coordinate and program M33, which stores the X and Y coordinate, for G17 Positioning, OR, you program X and Y for G17, or X and Z for G18, or Y and Z for G19
    So:
    M33 means store Current Coordinate as CC, M33 X.. Y.. Means Store Entered Coordinate as CC in G17, M33 X.. Z.. Means Store in G18 and M33 Y.. Z.. means store in G19.

    With M34 you move to Polar Coordinates relative to CC, for the First move you need to program both angle and radius:
    M34 A45 R20 means Move to Angle 45° at 20mm radius. this move is a Rapid move, but when you also Program an F value it is considered a "G01" with Feedrate as programmed.
    For each following point you will only need to program what changes, i.e. if you want to move to a new angle, you only program that, if you want to move to another radius, you only program that as well.
    Meaning:
    M34 A90 Moves to 90° on the same radius, and M34 R40 moves to radius 40 at the same angle

    Pretty cool huh?



  12. #12
    Member arie kabaalstra's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    352
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming

    Code:
    SUB M33
        IF [#24==-10000000000.000]
            IF [#25==-10000000000.000]
                #3701=[#5001]
                #3702=[#5002]
                #1280=[3]
                GOSUB SET_PLANE
                RETURN
            ENDIF 
        ENDIF 
        #1280=[0]
        IF [#24>-10000000000.000] (X PROGRAMMED)
            #3701=[#24]
            #1280=[1]
        ENDIF
        IF [#25>-10000000000.000] (Y PROGRAMMED)
            #3702=[#25]
            #1280=[#1280+2]
        ENDIF
        IF [#26>-10000000000.000] (Z PROGRAMMED)
            #3703=[#26]
            #1280=[#1280+4]
        ENDIF
        GOSUB SET_PLANE
    ENDSUB
    
    
    SUB SET_PLANE    
        (DETERMINING WHICH PARAMETERS HAVE BEEN PROGRAMMED)
        IF [#1280==3]
            MSG "X-Y PLANE  CC = X:"#3701" Y:"#3702
            G17
        ENDIF
        IF [#1280==5]
            MSG "X-Z PLANE  CC = X:"#3701" Z:"#3703
            G18
        ENDIF
        IF [#1280==6]
            MSG "Y-Z PLANE  CC = Y:"#3702" Z:"#3703
            G19
        ENDIF
    ENDSUB
    
    
    SUB M34
        IF[#1>-10000000000.000]
            #2101=[#1] (COPY ANGLE)
        ENDIF
        IF[#18>-10000000000.000] (COPY RADIUS)
            #2118=[#18]
        ENDIF
        IF [#1280==3]
            MSG "G17 A= "#2101
            #3711=[COS[#2101]*#2118]
            #3712=[SIN[#2101]*#2118]
            IF[#6==0] 
                G00 X[#3701+#3711] Y[#3702+#3712]
            ENDIF
            IF[#6==-10000000000.000] 
                G01 X[#3701+#3711] Y[#3702+#3712]
            ENDIF
            IF[#6>0]
                G01 X[#3701+#3711] Y[#3702+#3712] F[#6]
            ENDIF
        ENDIF
        IF [#1280==5]
            MSG "G18 A= "#2101
            #3711=[COS[#2101]*#2118]
            #3713=[SIN[#2101]*#2118]
            IF[#6==0] 
                G00 X[#3701+#3711] Z[#3703+#3713]
            ENDIF
            IF[#6==-10000000000.000] 
                G01 X[#3701+#3711] Z[#3703+#3713]
            ENDIF
            IF[#6>0]
                G01 X[#3701+#3711] Z[#3703+#3713] F[#6]
            ENDIF
        ENDIF
        IF [#1280==6]
            MSG "G19 A= "#2101
            #3712=[COS[#2101]*#2118]
            #3713=[SIN[#2101]*#2118]
            IF[#6==0] 
                G00 Y[#3702+#3712] Z[#3703+#3713]
            ENDIF
            IF[#6==-10000000000.000] 
                G01 Y[#3702+#3712] Z[#3703+#3713]
            ENDIF
            IF[#6>0]
                G01 Y[#3702+#3712] Z[#3703+#3713] F[#6]
            ENDIF
        ENDIF
    ENDSUB
    New Version.. improved:
    When programming M34 A.. R.. without F, it performs a G01 with the Modal Feedrate.
    When Programming M34 A.. R.. F0 it performs a G00
    When Programming M34 A.. R.. F200 it performs a G01 with Feed 200, Which is then the new Modal Feedrate.



  13. #13
    Member deadlykitten's Avatar
    Join Date
    Jun 2015
    Location
    Antarctica
    Posts
    4131
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming

    hello, i just saw this you are doing something, but onestly, keep the macro codes only for miscelanous operations, where it can not be replaced, like tool change & magazine, gauging, bar feeders, n the like

    machine polygons really easy..To maken Hexheads for instance
    i dealed with hexagons in 2019, thorugh a code that could handle live milling in lathe :
    ... any number of flats on any diameter
    ... rough or finish
    ... regulat or free polygon
    ... corner radius
    ... self decision on Y or C axis, as to target shortest toolpath, considering rapid movements also
    ... toolpath mapped feeds, as to speed up machining on lead in/out movements, and other places
    ... cycle time reduction codes
    ... cuting specs parametrization, finish allowance
    ... comon, system, local, and array type variables
    ... data printing
    ... indentation
    ... and other details perhaps

    this was one of the last few macros that i wrote, because g-code language is limited, and some things are hard or impossible to implement

    it also structures your thinking in a less productive manner, thus you end up consuming more of your time for less results

    your codes are ok, it shows experience; i supose you like what you do let's talk more, exchange ideas

    we are merely at the start of " Internet of Things / Industrial Revolution 4.0 " era : a mix of AI, plastics, human estrangement, powerful non-state actors ...


  14. #14
    Member arie kabaalstra's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    352
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming

    Quote Originally Posted by deadlykitten View Post
    hello, i just saw this you are doing something, but onestly, keep the macro codes only for miscelanous operations, where it can not be replaced, like tool change & magazine, gauging, bar feeders, n the like
    There is a way to rewrite your M-Codes in EdingCNC, you could for instance put G28 into the M2 Routine to make the machine move to G28 at the end of a program.

    Furthermore, as you can clearly see, i made the M33 Code so that you either don't program any X or Y, just M33, and it will then assume the current location as Circle Center..
    or.. you write M33 X.. Y.. or M33 X.. Z.. or M33 Y..Z,, wich puts the CC there..
    as for the M34 Linear Polar coordinates, after the first move, where you need both angle and radius, you can skip one of these in the next.. meaning it will move to the programmed angle on the same radius, or to the programmed radius at the same angle..
    in the mean time i Also got the Circular moves sorted, only with feedrate, because most of the time it is unneccessary to do rapids in a circular move.
    with M33, if you skip F it will assume the current modal feedrate, when programming F0 it moves Rapid, and you can always override the current feed by programming a new feed..

    Quote Originally Posted by deadlykitten View Post
    this was one of the last few macros that i wrote, because g-code language is limited, and some things are hard or impossible to implement

    it also structures your thinking in a less productive manner, thus you end up consuming more of your time for less results

    your codes are ok, it shows experience; i supose you like what you do let's talk more, exchange ideas
    G-Code limited?.. Hold my beer!.. .. i wrote a small program with the macro i have now, to make a fillet on an XY contour.. by simply using polar coordinates..

    T3 M6 ( "BALLNOSE 3MM" )
    F1500
    G00
    X20 Y0 Z20
    M3
    M33
    X20 Z-10
    G00
    X[30+#5009] Z4
    #
    100=90
    WHILE
    [#100>0]
    GOSUB VERT_FILLET
    #100=[#100-3]
    ENDWHILE
    #
    100=0
    GOSUB VERT_FILLET

    M2


    SUB
    VERT_FILLET
    G00 X[30+#5009] Y0 Z4
    M33 X20 Z-10
    M34 A#100 R[10+#5009]
    M33 X50 Y0
    M36 A90
    G01 X[#5001+20]
    M33 X#5001 Y0
    M36 A270
    G01 X[#5001-20]
    M33 X#5001 Y0
    M36 A180
    G00 Z4
    ENDSUB

    and this is what it does..

    Let me shed some light on Macro programming-oblong-choke-jpg

    I do indeed have experience, i made a similar program on a Heidenhain Control years ago, which we used for rounding of Die parts.
    also i recently wrote a macro file for my EdingCNC controled Lathe.

    And i like to show people what is possible.. i'm used to program at the machine, and i worked with Heidenhain for many years, i just want the same functionality with my own machine, and i'm pretty close..

    Attached Thumbnails Attached Thumbnails Let me shed some light on Macro programming-oblong-choke-jpg  


  15. #15
    Member deadlykitten's Avatar
    Join Date
    Jun 2015
    Location
    Antarctica
    Posts
    4131
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming

    G00 X20 Y0 Z20 M3G00 X[30+#5009] Z4
    #
    100=90
    please arie, how did you formated ? is it possible to paste allready formated, and if so, from what editor ?

    thank you so far, good infos / i will reply more later, i have some stuff 2 do / kindly

    we are merely at the start of " Internet of Things / Industrial Revolution 4.0 " era : a mix of AI, plastics, human estrangement, powerful non-state actors ...


  16. #16
    Member arie kabaalstra's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    352
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming




    I did write my own Editor with Syntax Marking and Indentation, i could use NotePad++, but that has too many functions you don't need.. i wanted something compact, and the E++ Editor is only 84 kB, furthermore.. when i fill in a dialog in EdingCNC it writes to a file by means of LogMsg, everytime that file changes, E++ Pops back up to the foreground, and i can insert the programmed values in the program with F1.
    That's a "little trick" i've been using for the last 9 years, i started with filling in a Dialog, and then have the Macro compose the program, and write that to an NC file, to get the resulting program on my screen immediately..


    E++ Will become available for free, when i have translated the manual to English.


    Weil G-Code ist ürsprunglich in der USA erfunden, damit ist Englisch der originale sprache der CNC maschinen, und es hat keinen Grund es auf Deutsch zu übersetzen..


    I'm also Using Heidenhain Control panels to operate my EdingCNC controlled machines, for 2 reasons, i was getting fed up with normal keyboards breaking because chips would get in them, and a Heidenhain Panel is only 400 mm wide, instead of 460 for a Standard Logitech Keyboard, and a Standard Keyboard lack a number of keys..





    So i made this for my EMCO Compact 5 CNC lathe



  17. #17
    Member deadlykitten's Avatar
    Join Date
    Jun 2015
    Location
    Antarctica
    Posts
    4131
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming

    G-Code limited?.. Hold my beer!..
    i hope this is good beer holding

    T3 M6 ( "BALLNOSE 3MM" )
    F1500
    G00 X20 Y0 Z20 M3
    M33 X20 Z-10
    G00 X[30+#5009] Z4
    #100=90
    WHILE[#100>0]
    _____GOSUBVERT_FILLET
    _____#100=[#100-3]
    ENDWHILE
    #100=0
    GOSUBVERT_FILLET
    M2


    SUBVERT_FILLET
    _____G00 X[30+#5009] Y0 Z4
    _____M33 X20 Z-10
    _____M34 A#100 R[10+#5009]
    _____M33 X50 Y0
    _____M36 A90
    _____G01 X[#5001+20]
    _____M33 X#5001 Y0
    _____M36 A270
    _____G01 X[#5001-20]
    _____M33 X#5001 Y0
    _____M36 A180
    _____G00 Z4
    ENDSUB


    we are merely at the start of " Internet of Things / Industrial Revolution 4.0 " era : a mix of AI, plastics, human estrangement, powerful non-state actors ...


  18. #18
    Member arie kabaalstra's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    352
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming

    what are you trying to prove here?..



  19. #19
    Member deadlykitten's Avatar
    Join Date
    Jun 2015
    Location
    Antarctica
    Posts
    4131
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming

    nothing, i just have 'colors' on my list from some time, and seeing your code, i remember it

    .... how can i help ?

    i am ok with software graphics, macros, etc ...

    Last edited by deadlykitten; 07-18-2023 at 06:36 AM.
    we are merely at the start of " Internet of Things / Industrial Revolution 4.0 " era : a mix of AI, plastics, human estrangement, powerful non-state actors ...


  20. #20
    Member arie kabaalstra's Avatar
    Join Date
    Jan 2007
    Location
    Netherlands
    Posts
    352
    Downloads
    0
    Uploads
    0

    Default Re: Let me shed some light on Macro programming

    I wanted Colours as well, that is why i made E++.. I do need some "Time off" so i can Translate the manual to English, so i can put the link here..


    but there are plenty of Editors providing Syntax marking, and indentation, like Notepad++ and Visual Studio Code.
    E++ is however a G-Code Editor written specifically for EdingCNC.

    Oh.. and there needs to be a space after a Gosub and a Sub...



Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

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


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

Let me shed some light on Macro programming

Let me shed some light on Macro programming