538,105 active members*
2,588 visitors online*
Register for free
Login
Results 1 to 19 of 19
  1. #1
    Registered
    Join Date
    Nov 2017
    Posts
    573

    I want to learn all about macros. Where to start?

    Currently I don't have much knowledge of computers in general. No experience with coding, scripting, etc. Learning to write macros is something I'm really interested in. With my current machine there's really only so much I could actually do with macros, but i may have other machines in the future. One thing I'm curious about, if I spent the time to learn about macros in mach3, is it similar for other control software if I switched to something else? I imagine this is a pretty huge subject and goes hand in hand with other things like fully understanding g code, editing posts, etc.
    Considering that I really have no knowledge on the subject at all, is it realistic to expect this is something I could learn on my own with info from Google, youtube, etc? Where would I start? Any recommendations on how to go about learning something like this?

  2. #2
    Registered
    Join Date
    Apr 2014
    Posts
    331

    Re: I want to learn all about macros. Where to start?

    Looking for a lot of the same info. Except I want to learn it for my Fadal and probing routines.

  3. #3
    Community Moderator ger21's Avatar
    Join Date
    Mar 2003
    Posts
    35373

    Re: I want to learn all about macros. Where to start?

    IMO, the best way to start is to study existing macros, and learn what each part of them is doing.
    Most macros are very basic, and don't really require a lot of programming knowledge. You can use Google to learn about VB.
    I'm a self taught programmer, and when I want to learn how to do something, I always just Google it.

    Mach3 uses a language called Cypress Enable, which they ;icensed from Cypress Software.
    It's really just a form of basic, and is practically identical to Microsoft Visual Basic.

    As far as the knowledge transferring to other programs, it depends on the language those programs use.

    Mach4 uses Lua, which imo is more difficult to learn and understand.
    UCCNC uses C#. It's actually quite similar to basic, and is not too difficult to learn.
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  4. #4
    Registered
    Join Date
    Nov 2017
    Posts
    573
    Quote Originally Posted by ger21 View Post
    IMO, the best way to start is to study existing macros, and learn what each part of them is doing.
    Most macros are very basic, and don't really require a lot of programming knowledge. You can use Google to learn about VB.
    I'm a self taught programmer, and when I want to learn how to do something, I always just Google it.

    Mach3 uses a language called Cypress Enable, which they ;icensed from Cypress Software.
    It's really just a form of basic, and is practically identical to Microsoft Visual Basic.

    As far as the knowledge transferring to other programs, it depends on the language those programs use.

    Mach4 uses Lua, which imo is more difficult to learn and understand.
    UCCNC uses C#. It's actually quite similar to basic, and is not too difficult to learn.
    Excellent, thanks. That's a start

  5. #5
    Community Moderator ger21's Avatar
    Join Date
    Mar 2003
    Posts
    35373

    Re: I want to learn all about macros. Where to start?

    Also, there are two manuals you can download at machsupport.com

    One that covers the language itself, and one with the Mach3 specific functions.
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  6. #6
    Registered
    Join Date
    Nov 2017
    Posts
    573

    Re: I want to learn all about macros. Where to start?

    Managed to make use of a couple macros, almost. Watched the intro to scripting tutorial video. From that I figured out how to send my machine to a specific location for tool changes which is pretty handy. Before my m6 did nothing at all but stop directly above the work where I can't reach the spindle with wrenches conveniently, now my tool changes are faster since I don't need to jog away first. The other thing I tried to implement is a probing routine for z. I used the common macro posted in here which seemed to work when running it directly in the vb script page. I didn't hook up a probe yet but it ran it's routine feeding down the specific distance at specific feed. I decided i want this to happen automatically after tool changes so I pasted the probing script into the m6 end. When running it in gcode, it almost works. When it comes to an m6, the spindle moves over to my specified tool change location, then stops and waits for cycle start, I then change my tool, hit start, at which point it continues with m6 end which is where I pasted the probing macro. It starts feeding down as it should (my probe plate will be directly below tool change location) but it continues to feed beyond the specified feed distance in the macro, even ignores z minimum soft limit. When running it in vb page it stopped when it was supposed to. It may or may not work properly once I actually have a probe plate there for it to stop against but I would still like to know why it's feeding beyond the specified distance. A probable issue is that I don't have the proper screenset. It's calling values that I don't know if they are actually there so I still need to get that figured out, but it still doesn't make sense to me that the script behaves differently when running in vb page vs running when triggered in gcode.

  7. #7
    Community Moderator ger21's Avatar
    Join Date
    Mar 2003
    Posts
    35373

    Re: I want to learn all about macros. Where to start?

    Can you post the macro?
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  8. #8
    Registered
    Join Date
    Nov 2017
    Posts
    573

    Re: I want to learn all about macros. Where to start?

    heres the one i used:

    PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO


    If GetOemLed (825)=0 Then 'Check to see if the probe is already grounded or faulty
    DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
    Code "G4 P1" ' this delay gives me time to get from computer to hold probe in place
    Code "G31Z-100 F500" 'probing move, can set the feed rate here as well as how far to move
    While IsMoving() 'wait while it happens
    Wend
    ZProbePos = GetVar(2002) 'get the axact point the probe was hit
    Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
    While IsMoving ()
    Wend
    Call SetDro (2, PlateThickness) 'set the Z axis DRO to whatever is set as plate thickness
    Code "G4 P0.25" 'Pause for Dro to update.
    Code "G0 Z25.4" 'put the Z retract height you want here
    Code "(Z axis is now zeroed)" 'puts this message in the status bar
    Else
    Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
    Exit Sub
    End If


    the only things i have changed are the feed distance from -40 to -100 and the delay before probe from 5 to 1 seconds since i really dont need any delay at all but wasnt sure if it would cause problems by deleting the line completely. one issue i know i have is when its grabbing user dro 1151. not sure if its getting a value form somewhere or what that value is. do i need to modify my screen set to add this in? can i temporarily just give it a value directly in the script rather than having it get the value from somewhere else? like i mentioned, i dont even have a probe plate hooked up yet, but i did enable the probe so it works up until the point where tool should touch the probe. probably a bit premature to start diagnosing this before i actually set up the probe and make the needed changes for get userdro 1151 , but like i mentioned, when running the script as is in vb page, it feeds the -100, then stops (since i dont have a probe there yet) then retracts and sets z zero to where it reached the max feed of -100. when i paste the script in my m6 end macro (so it executes automatically after tool change) it behaves differently and does not stop feeding when reaching -100. If you have an explanation why, that would be great, but at this point im assuming i should just set up the probe and figure out the dro 1151 thing. how do i need to go about doing that? its really not important to me to have an easy access place to enter a plate thickness. if theres an easy way to put it directly in the script rather than modifying screen set so it can get the value from there, im fine with that.

    another thing im curious about. i have a pretty rigid machine and run only carbide endmills. if it probes directly into a rigid mounted probe plate, is it really going to stop quick enough to not chip my carbide endmills? i would think a better approach might be a spring loaded touch plate that it feeds into, stops, then backs up at super slow feed and sets zero at the point it loses contact with the plate. i would assume that would be safer for the endmill and also more accurate, but im sure that would require some major changes to the scrip since its no longer a standard g31 probe. i suppose i can spring load the plate and still let it run the same way, just wont have the added accuracy of backing up at a much slower feed. reducing feed into the plate will help accuracy, but then the routine will take much longer. I did see one of your post mentioning a 2 stage probe, one fast, then a second time slow starting really close to the plate which i suppose would also work well. in the end i would really like to have at least .02mm accuracy.

  9. #9
    Community Moderator ger21's Avatar
    Join Date
    Mar 2003
    Posts
    35373

    Re: I want to learn all about macros. Where to start?

    Just use this:

    PlateThickness = 0.125 ' 1/8" plate thickness


    Try it like this:

    PlateThickness = 0.125 ' 1/8" plate thickness

    If GetOemLed (825)=0 Then 'Check to see if the probe is already grounded or faulty

    DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
    Sleep (150)

    Code "G4 P1" ' this delay gives me time to get from computer to hold probe in place
    While IsMoving()
    Wend

    Code "G31Z-100 F500" 'probing move, can set the feed rate here as well as how far to move
    While IsMoving() 'wait while it happens
    Wend

    ZProbePos = GetVar(2002) 'get the axact point the probe was hit

    Code "G0 Z" & ZProbePos 'go back to that point, always a very small amount of overrun
    While IsMoving()
    Wend

    Call SetDro (2, PlateThickness) 'set the Z axis DRO to whatever is set as plate thickness
    Sleep(150)

    Code "G4 P0.25" 'Pause for Dro to update.
    While IsMoving()
    Wend

    Code "G0 Z25.4" 'put the Z retract height you want here
    While IsMoving()
    Wend

    Code "(Z axis is now zeroed)" 'puts this message in the status bar
    Sleep(150)

    Else
    Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
    Exit Sub
    End If
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  10. #10
    Community Moderator ger21's Avatar
    Join Date
    Mar 2003
    Posts
    35373

    Re: I want to learn all about macros. Where to start?

    another thing im curious about. i have a pretty rigid machine and run only carbide endmills. if it probes directly into a rigid mounted probe plate, is it really going to stop quick enough to not chip my carbide endmills?
    It depends on how fast it's moving.
    After Mach3 receives the probe input, the Z axis will decelerate to a stop. The faster it's moving, the longer it will take to stop after it hits the plate.


    Technically, the speed shouldn't matter, as Mach3 records the point when contact is made. But testing has show that it does matter, which is why most of us use a two touch routine.
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  11. #11
    Registered
    Join Date
    Nov 2017
    Posts
    573

    Re: I want to learn all about macros. Where to start?

    excellent, thank you, i will try that. Out of curiosity, when it calls for plate thickness, why is there a 2, before plate thickness? Also, what is the sleep(150) you added?

  12. #12
    Community Moderator ger21's Avatar
    Join Date
    Mar 2003
    Posts
    35373

    Re: I want to learn all about macros. Where to start?

    Call SetDro (2, PlateThickness)

    This puts the PlateThickness value in DRO #2, which is the Z axis DRO.

    That's actually an older way to do it.

    I'd use this:
    SetOEMDro(802, PlateThicknesss)

    Which is the newer way to do it.

    DRO, Button and LED numbers can be found in the Wiki: Mach3Wiki

    Sleep() adds a pause, in milliseconds.
    Sometimes they are helpful to allow Mach3 to "see" what the macro just did before it moves onto the next step.
    The Mach3 interface only updates 10 times/second, and this gives the screen time to refresh before continuing.
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  13. #13
    Registered
    Join Date
    Nov 2017
    Posts
    573
    Quote Originally Posted by ger21 View Post
    Call SetDro (2, PlateThickness)

    This puts the PlateThickness value in DRO #2, which is the Z axis DRO.

    That's actually an older way to do it.

    I'd use this:
    SetOEMDro(802, PlateThicknesss)

    Which is the newer way to do it.

    DRO, Button and LED numbers can be found in the Wiki: Mach3Wiki

    Sleep() adds a pause, in milliseconds.
    Sometimes they are helpful to allow Mach3 to "see" what the macro just did before it moves onto the next step.
    The Mach3 interface only updates 10 times/second, and this gives the screen time to refresh before continuing.
    Ok, will do. So replace the line with just
    SetOEMDro (802,plateThickness)
    Or
    Call SetOEMDro (802,plateThickness) ?

    Also, is there a specific place where guys post various macros that I can play around with and dissect to figure out how they work?

    Nevermind, found the wizards, macros sub. Should find some stuff in there I assume

  14. #14
    Community Moderator ger21's Avatar
    Join Date
    Mar 2003
    Posts
    35373

    Re: I want to learn all about macros. Where to start?

    Call SetOEMDRO(802, PlateThickness)
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  15. #15

    Re: I want to learn all about macros. Where to start?

    How does Mach3 call a macro from within a g-code program?
    For instance, when you code G83, the macro M1083.m1s is what actually runs.

  16. #16
    Community Moderator ger21's Avatar
    Join Date
    Mar 2003
    Posts
    35373

    Re: I want to learn all about macros. Where to start?

    That's a special case, where Mach3 does that internally.

    If you want to call a macro like M999.m1s, you just call M999 from the g-code.
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  17. #17

    Re: I want to learn all about macros. Where to start?

    That's too bad. I was thinking it would be quite simple to edit G83 into G85.

  18. #18

    Re: I want to learn all about macros. Where to start?

    It turns out that Mach does do a call for G85. There just isn't a macro there for it.
    I copied M1083.m1s and renamed it M1085.m1s. I couldn't figure out how to get rid of the required Q-word so I just edited my post to stick a Q0.0 in there.
    Works fine.

  19. #19
    Member
    Join Date
    Jan 2021
    Posts
    3

    Re: I want to learn all about macros. Where to start?

    Special school

Similar Threads

  1. Replies: 3
    Last Post: 12-19-2015, 02:29 AM
  2. Learn IGF One touch or Learn a CAM?
    By brettcnc in forum Okuma
    Replies: 9
    Last Post: 05-08-2012, 02:37 AM
  3. Replies: 4
    Last Post: 01-06-2009, 05:20 PM
  4. newbie need to learn mach 3 where to start
    By markus_detroy in forum DIY CNC Router Table Machines
    Replies: 2
    Last Post: 04-18-2008, 02:19 AM
  5. So where do you start to learn post editing?
    By Gouge in forum Post Processors for MC
    Replies: 10
    Last Post: 03-10-2008, 03:40 AM

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
  •