Hello Guest it is March 28, 2024, 06:53:24 PM

Author Topic: Can the M3/4 macros be edited  (Read 4150 times)

0 Members and 1 Guest are viewing this topic.

Can the M3/4 macros be edited
« on: December 26, 2009, 07:13:01 PM »
I would like to find a way to edit the way Mach does the M3,M4 macros

What I want to do is put a lever switch on the Back gear lever of a Bridgeport mill to tell Mach to reverse the output from the M code call

I tired this in the M3 macro but Didn't Work
IF IsActive (input1) then
DoSpinCWW()
Else
DoSpinCW()
End If
Adam

melee

*
Re: Can the M3/4 macros be edited
« Reply #1 on: December 29, 2009, 11:06:06 AM »
Hi

This brought back vague memories of when I tried something similar a couple of years ago, to overcome a logic problem on a machine, which I eventually cured the proper way by rewiring.

The answer is yes you can edit the macros, but you have to go outside the DoSpinC(C)W() functions if you want to change rotation direction from M3.m1s

I don't know exactly where the macro comes in the chain of processing a M3 GCode call, but as you say, simply substituting DoSpinCCW() does not produce the desired effect, albeit commenting out the command will prevent any rotation, so Mach does look for it in the macro.

I set the contents of M3.m1s as

If IsActive (input1) Then
      code "M4"
Else
      DoSpinCW()
      Message "CW Rotation"
End If


and M4.m1s as

DoSpinCCW()
Message "CCW Rotation"


This gives me the desired effect in simulation, depending upon the state of input1 and a visible confirmation that the M4 call went through on the message line.

Hopefully will work for you

regards

Melee

Re: Can the M3/4 macros be edited
« Reply #2 on: December 29, 2009, 09:40:07 PM »
I keep getting Scripter errors when using code in the M3.m1s getting a syntax error to the words then,else,if when stepping thru the code
« Last Edit: December 29, 2009, 09:42:57 PM by Cncman2nv »
Adam
Re: Can the M3/4 macros be edited
« Reply #3 on: December 29, 2009, 10:30:52 PM »
MeLee's code works fine here, did you copy/paste ?

If IsActive (input1) Then
      code "M4"
Else
      DoSpinCW()
      Message "CW Rotation"
End If

Russ
Re: Can the M3/4 macros be edited
« Reply #4 on: December 30, 2009, 07:47:16 PM »
In my original post as you can see i didn't indent from the then,else,end if, statements I now no that makes all the difference

so Thanks for all the help!
Adam
Re: Can the M3/4 macros be edited
« Reply #5 on: December 30, 2009, 08:40:24 PM »
Hi Adam,
 I believe you had a different syntax problem.
The indent doesn't really matter. I think that's just an easy way for a programmer to read or work with the script.
These work  just as well .
Russ
Re: Can the M3/4 macros be edited
« Reply #6 on: December 30, 2009, 08:54:25 PM »
Ya your right Russ the indent doesn't make any difference so I don't what I had going on but it seem to work now
Adam
Re: Can the M3/4 macros be edited
« Reply #7 on: December 30, 2009, 08:56:56 PM »
Another problem with your original,
you have   DoSpinCWW(),
instead of            CCW

Glad it's working for you now though.