891
Mach4 General Discussion / Re: Using M7 to run a script in a command window.
« on: January 18, 2022, 05:35:19 PM »
Hi,
What are you wanting to achieve?. Are you just trying to turn a solid state relay on or off?
m7 and m9, note the deliberate use of lower case....it is important as I will explain, are built in m-codes and are generally left alone, otherwise you risk upsetting Machs internal behavour
to those m-codes. That is not to say you cannot write your own but now Mach will execute YOUR m-code and if its not complete or the functionality differs from the standard m-code
you have created a f...up.
Its common practice that if you write custom m-codes that you number them 100 and above....as that will avoid clashing with any internal m-codes.
When Mach encounters an m-code in a Gcode file, it first parses the block to ALL lowercase, strips out leading zeros and strips out whitespace.
Thus: M 07 will be reduced to m7....and then Mach will search for that function, in the first instance in your profiles Macros folder, and if it does not find it there it will search up the file tree until it finds
a compliant macro. For this reason its a good idea to create and write macros using lowercase etc so that there is no possibility that Mach misses the macro you intended to run.
If you are just trying to turn on or off a solid state relay however you are going off the deep-end, there is a much MUCH simpler way to turn on or off a relay.
Craig
What are you wanting to achieve?. Are you just trying to turn a solid state relay on or off?
m7 and m9, note the deliberate use of lower case....it is important as I will explain, are built in m-codes and are generally left alone, otherwise you risk upsetting Machs internal behavour
to those m-codes. That is not to say you cannot write your own but now Mach will execute YOUR m-code and if its not complete or the functionality differs from the standard m-code
you have created a f...up.
Its common practice that if you write custom m-codes that you number them 100 and above....as that will avoid clashing with any internal m-codes.
When Mach encounters an m-code in a Gcode file, it first parses the block to ALL lowercase, strips out leading zeros and strips out whitespace.
Thus: M 07 will be reduced to m7....and then Mach will search for that function, in the first instance in your profiles Macros folder, and if it does not find it there it will search up the file tree until it finds
a compliant macro. For this reason its a good idea to create and write macros using lowercase etc so that there is no possibility that Mach misses the macro you intended to run.
If you are just trying to turn on or off a solid state relay however you are going off the deep-end, there is a much MUCH simpler way to turn on or off a relay.
Craig