Need some help getting started on a few macros


Results 1 to 11 of 11

Thread: Need some help getting started on a few macros

  1. #1
    Member
    Join Date
    Nov 2017
    Location
    United States
    Posts
    457
    Downloads
    0
    Uploads
    0

    Default Need some help getting started on a few macros

    I built a mill turn setup similar to simpson36's "inturn" or the tormach rapid turn (except mine is servo driven for index milling) and I need a few macros to get everything working the way I want. I already have the swap axis stuff figured out, now I need a few other things to handle the gang tooling offsets and coolant nozzles. Both follow similar logic so let's start with the coolant macro.

    Basically I want 8 individual coolant nozzles that are chosen based on tool number. I'll write out how it needs to happen and hopefully you guys can help me convert that to proper vb language

    Get selected tool

    If tool number < 100, activate signal output 1

    Else

    If tool number = 100, activate signal output 2

    Else

    If tool number = 101, activate signal output 3

    Else

    Etc, up to 8 outputs. The reason I have tools 1-99 grouped into 1 output is because those will be used in main milling spindle and all use the same nozzle. The rest will have their own specific location on the gang plate and need their own nozzle, however I may want to also use small groups of possible tools for a specific gang location. For example I might want something like:

    if tool number > 104 and < 111, activate signal output 3

    or something like that. As far as I know, mach3 won't allow me to modify m7, but it's easy enough to go into my post processor and assign a new m code for coolant. I'll also need a code to turn off all coolant outputs. I assume it will just look like this?

    Deactivate output signal 1
    Deactivate output signal 2
    Deactivate output signal 3
    Etc up to 8

    I'll also need to have this happen in the m30

    My tool change macro will have similar logic, but instead of activating signals, it will apply work offsets for specific tools or tool groups. I could use g52 offsets instead so the work offset can be moved around and have g52 tool offsets follow, but decided to go with work offsets instead since my zero position will always be the nose of the mill turn spindle and it will be easier to set up and make adjustments to tools. If I used g52, I would have to go into the macro to make ajustments.

    Any help is greatly appreciated. I think once I see a few examples of how to write out these if then else statements, like the ones I listed above, i should be able to get going on these.

    Similar Threads:


  2. #2
    Member
    Join Date
    Nov 2017
    Location
    United States
    Posts
    457
    Downloads
    0
    Uploads
    0

    Default Re: Need some help getting started on a few macros

    figured it out. heres my coolant macro,

    tool = GetCurrentTool


    If tool < 100 Then
    ActivateSignal(Output4)
    End If
    If tool > 99 And tool < 106 Then
    ActivateSignal(Output5)
    End If
    If tool > 105 And tool < 111 Then
    ActivateSignal(Output6)
    End If

    This is just part of it and uses one nozzle for tools 1-99, another nozzle for tools 100-105, and another nozzle for tools 105-110. I tried using "else if" for each condition instead of separate if then statements for each, but if didnt like it for some reason and was giving an error on the "if" of else if for some reason. guess it doesnt really matter, this is working. I also got my tool based work offsets working as well. Same format but instead of activate signal, i just use code g54, g55, g56, etc.



  3. #3
    Member ZASto's Avatar
    Join Date
    Apr 2005
    Location
    Vanuatu
    Posts
    90
    Downloads
    1
    Uploads
    0

    Default Re: Need some help getting started on a few macros

    Evaluation of your macro gives the folloving:

    Output 4: Tools 0 to 99
    Output 5: Tools 100 to 105
    Output 6: Tools 106 to 110



    Make no mistake between my personality and my attitude.
    My personality is who I am. My attitude depends on who you are.


  4. #4
    Member
    Join Date
    Nov 2017
    Location
    United States
    Posts
    457
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by ZASto View Post
    Evaluation of your macro gives the folloving:

    Output 4: Tools 0 to 99
    Output 5: Tools 100 to 105
    Output 6: Tools 106 to 110

    Ah yes, correct



  5. #5
    Member
    Join Date
    Nov 2017
    Location
    United States
    Posts
    457
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by ZASto View Post
    Evaluation of your macro gives the folloving:

    Output 4: Tools 0 to 99
    Output 5: Tools 100 to 105
    Output 6: Tools 106 to 110

    This was the other way I tried to write it but was getting syntax error:



    If tool < 100 Then
    ActivateSignal(Output4)

    Else If tool > 99 And tool < 106 Then
    ActivateSignal(Output5)

    Else If tool > 105 And tool < 111 Then
    ActivateSignal(Output6)
    End If

    Error shows up on the "if" of else if, but when writing it, it highlights blue like it recognizes it. What is wrong here? It works fine written the other way with individual if then's, I'm just curious so I know for the future.



  6. #6
    Community Moderator ger21's Avatar
    Join Date
    Mar 2003
    Location
    Shelby Township
    Posts
    34520
    Downloads
    0
    Uploads
    0

    Default Re: Need some help getting started on a few macros

    Try ElseIf, with no space.

    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)


  7. #7
    Member
    Join Date
    Nov 2012
    Location
    Canada
    Posts
    138
    Downloads
    0
    Uploads
    0

    Default Re: Need some help getting started on a few macros

    Wouldn’t it be easier to have one coolant but adjust the angle like the Haas programable ones?



  8. #8
    Member
    Join Date
    Nov 2017
    Location
    United States
    Posts
    457
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by ger21 View Post
    Try ElseIf, with no space.
    Yep. That was it. That was actually the first way I tried it and it didn't work, but then I remembered I also made the mistake of not adding if end, so that was the actual reason elseif wasn't working originally. I think I'll also try case select to see if I can get that method working too, just for learning purposes



  9. #9
    Member
    Join Date
    Nov 2017
    Location
    United States
    Posts
    457
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by tom o View Post
    Wouldn’t it be easier to have one coolant but adjust the angle like the Haas programable ones?
    That's one option, but I don't think it would be easier than just having a few lines and solenoids. An articulating coolant nozzle sounds more complex to me, also easier to direct coolant right where I want it with multiple lines. Other problem is, I wouldn't be able reach all the tools with one programmable nozzle



  10. #10
    Member Jim Dawson's Avatar
    Join Date
    Dec 2013
    Posts
    3716
    Downloads
    0
    Uploads
    0

    Default Re: Need some help getting started on a few macros

    Quote Originally Posted by QuinnSjoblom View Post
    Yep. That was it. That was actually the first way I tried it and it didn't work, but then I remembered I also made the mistake of not adding if end, so that was the actual reason elseif wasn't working originally. I think I'll also try case select to see if I can get that method working too, just for learning purposes
    I've never written a macro. But in other programming I normally use case select if there are more two possible conditions, the logic is just easier for me.

    Jim Dawson
    Sandy, Oregon, USA


  11. #11
    Member
    Join Date
    Nov 2017
    Location
    United States
    Posts
    457
    Downloads
    0
    Uploads
    0

    Default

    Quote Originally Posted by Jim Dawson View Post
    I've never written a macro. But in other programming I normally use case select if there are more two possible conditions, the logic is just easier for me.
    Yep, case select probably makes the most sense for this.

    I also came up with another option for my tool offset macro that is pretty simple:

    tool = GetCurrentTool

    If tool > 99 then
    code "G59P" & tool
    end if

    This basically applies an offset to every tool above 99 that matches the tool number. For example tool 110 would get offset G59P110. Kind of makes things convenient since the offset matches the tool, so there's never any confusion with being in the correct offset. Downside is I have to match the offset for groups of possible tools in same location, but I can just position at 0,0,0 and zero each offset for the group.

    Actually that script would also need code g54 when tool is less than 100 so it puts it back to regular offset when it changes back to a tool under 100

    Last edited by QuinnSjoblom; 05-23-2019 at 01:02 PM.


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

Need some help getting started on a few macros

Need some help getting started on a few macros

Need some help getting started on a few macros