587,925 active members*
3,225 visitors online*
Register for free
Login
Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2021
    Posts
    27

    M42/M42 for mill spindle ratio change

    Hi.
    I've been trying to determine if Mach 4 uses M41 and M42 to allow gear/ratio changes for a mill spindle but the documentation doesn't seem to list them.
    If it does support them, can someone give me a bit id a heads up on how to use them please.
    Thanks
    Phil

  2. #2
    Join Date
    Nov 2013
    Posts
    4554

    Re: M42/M42 for mill spindle ratio change

    Hi,
    to my knowledge m41 and m42 are not native to Mach4. You would have to code them yourself. How would Mach know how to change gears on your machine??

    Craig

  3. #3
    Join Date
    Aug 2021
    Posts
    27

    Re: M42/M42 for mill spindle ratio change

    Thanks Craig
    It's just that I've seen reference to the 2 codes in other posts/forums related to Mach 4 so I wondered if they were native.
    I'm really just trying to be able to use the 2 belt ratios I've got available and the new servo motor I'm currently setting up.
    Phil

  4. #4
    Join Date
    Aug 2021
    Posts
    27

    Re: M42/M42 for mill spindle ratio change

    Further to my earlier post.

    What I was hoping to be able to do is use the ratios defined like in this attachment.

    Phil

  5. #5
    Join Date
    May 2024
    Posts
    16

    Re: M42/M42 for mill spindle ratio change

    When you want to adjust the spindle speed, you'll utilize the M41 command followed by the desired speed percentage. For instance, if you wish to set the spindle speed to 50%, you'd input "M41 S50". This command essentially establishes the desired speed override percentage. Now, to activate this set percentage, you'd follow it up with the M42 command. Think of M42 as the trigger that brings your set spindle speed into effect.

  6. #6
    Join Date
    Aug 2021
    Posts
    27

    Re: M42/M42 for mill spindle ratio change

    I've found a macro, from on the Warp9 site (I'm using an ESS), that enabled M40 and uses a P position string like M40 P1 to access the "positions" in the table I listed above.
    This gives the ability to restrict the available spindle speeds to those outlined in the MIN/MAX settings at each line in the table.
    The macro can only use 2 lines of the table but it seems to do what I want with my manually changed spindle ratios.
    Thanks for everyone's input to this.
    Here is the link to the macro on the Warp9 site:

    https://documentation.warp9td.com/Ha...ange_Macro.htm

    Cheers
    Phil

  7. #7
    Join Date
    Nov 2013
    Posts
    4554

    Re: M42/M42 for mill spindle ratio change

    Hi,
    M40????? M40 and M41 open and close a probing data file. That has always been the case in Mach3 and are native to it. M40 and M41 are not native to Mach4. I wrote my own m40 and m41 to
    open and close probing data files that I use extensively for making circuit boards and have been using them for ten years.

    Note also that I use lowercase....you should too. When Mach4 parses code it converts all letters to lowercase, removes leading zeros and removes whitespace. Mostly Mach4 will parse M041
    to m41 without demur, but every once in a while it will not, and its a devilishly hard fault to pick. Don't do it. Use lowercase ALWAYS, no leading zeros, although I still use whitespace to make code
    more readable.

    As an example:

    someVariable, when complied by C compiler is NOT the same as somevariable....ie the name is case sensitive whereas someVariable, SomeVariable, somevariable and Somevariable are all treated as
    the same object in Mach4.

    Do yourself a favour and write code that is invariant AFTER being parsed....it will save some grief. Ask me how I know!!

    Look in the G code manual that accompanies Mach4, these are ALL and the ONLY M codes that are native to Mach4....every other M code is coded manually and applies only within a given profile in which it was defined.
    Note there is no m40, m41, m42 or m43. If you want to define them go right ahead. By-in-large all native Mach4 M codes are m99 or less, and if you are crafting your own M codes you are advised to use m100 and above.
    This was the same advice offered in Mach3, and for the same reason.

    You might ask then why did I break my own rule and write an m40 and m41? I use Autoleveller, a software utility that probes PCB blanks and 'massages' the G code to ensure even depth cutting. Autoleveller was written to work with Mach3
    and therefore called M40 and M41, both being native to Mach3. Given that I am using Mach4 I needed an equivalent functionality so I wrote my own m40 and m41. Note in addition to just opening and closing a file
    it is a data checking and verifying routine. Look on the Autoleveller website if you want the blow by blow reason-de-etre for the code.

    M3, or more precisely, m3 is a native Mach4 M code to turn the spindle on clockwise. If you chose to write your own m3...you can do so, but now m3 will do as you have coded rather than the built in code. If there is something
    that the built in code that you are not aware of and therefore did not include in your custom m3 then it won't happen. For this reason it is not advised that you overwrite the native Mach4 M codes, not that its impossible, but rather
    you take on the role of programmer, and that can be error ridden.

    Craig

  8. #8
    Join Date
    Aug 2021
    Posts
    27

    Re: M42/M42 for mill spindle ratio change

    Hi Craig
    Good point re not clobbering what could well be a M code used by something else.
    My point in my original post was after reading the Mach4 G-Code manual and not seeing M40/M41/M42 etc. listed.
    No real problem as I can soon reconfigure the macro code to another M number.
    Phil

Similar Threads

  1. Milling M42 Tool Steel?
    By dfearnow in forum MetalWork Discussion
    Replies: 0
    Last Post: 12-07-2011, 03:43 PM
  2. m41 m42 m43
    By dek in forum MetalWork Discussion
    Replies: 3
    Last Post: 07-06-2010, 12:29 AM
  3. Heian NC-431P M92/M42 command not working
    By cncuserg90 in forum Commercial CNC Wood Routers
    Replies: 0
    Last Post: 10-01-2008, 06:32 PM
  4. M42 x 2 thread, first thread is sharp! Help...
    By Driftwood in forum MetalWork Discussion
    Replies: 8
    Last Post: 08-24-2008, 08:17 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
  •