Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: Harley95 on June 08, 2020, 12:37:03 PM

Title: Spindle Brake Switch
Post by: Harley95 on June 08, 2020, 12:37:03 PM
HI All,
I am looking for a way to add a switch to my spindle break that will prevent the spindle from starting while it is engage. I have a linear actuator that is manually controlled and if I forget to retract it after a tool change and start the spindle the VFD faults out. I am looking to add a simple limit switch to notify Mach4 whether or not  it is OK for the spindle to start.

How would you add this to Mach4? Would you need a special LUA script or is there something in there already? Maybe like a door interlock type of setting.

Any help would be appreciated.

Stay safe

Jeff
Title: Re: Spindle Brake Switch
Post by: Graham Waterworth on June 11, 2020, 08:39:28 PM
The safest way is to wire the switch into the spindle run relay so it can not energise.
Title: Re: Spindle Brake Switch
Post by: KatzYaakov on June 12, 2020, 05:41:15 AM
graham i think its dangerous yours solution
because if you press after spindle already run ,then its will stop run ,but not brake ,so it can rotate about 5 min ,and user can think
if no any message no alarm spindle already  stop,and put his hand inside
i think bater pass the controler  ,the M3 function not try bypass it
Title: Re: Spindle Brake Switch
Post by: Graham Waterworth on June 12, 2020, 11:49:30 AM
Yes but with a double pole switch you can signal Mach that the switch is open and in the M3.m1s macro check the switch.
Title: Re: Spindle Brake Switch
Post by: Harley95 on June 13, 2020, 06:35:21 PM
Is there a way in the software to not allow an m3 or m4 command if a switch is triggered.  Kinda like a door interlock. I would like an error code or message to pop up if I try to start the spindle. Because we all know without a message we will be standing there scratching our heads wondering why the spindle will not work.
Title: Re: Spindle Brake Switch
Post by: KatzYaakov on June 14, 2020, 01:28:33 AM
sure ,override the M3 by yours ,its much better solution i think then add external "cut" between inverter and spindle
Title: Re: Spindle Brake Switch
Post by: Harley95 on June 14, 2020, 09:45:37 PM
What do mean by "override the M3 by yours"? Is there something already in Mach 4 to do this?
Title: Re: Spindle Brake Switch
Post by: joeaverage on June 14, 2020, 10:11:45 PM
Hi,
when Mach's Gcode interpreter encounters an 'm' code (note the use of lowercase) it first searches in the
macros folder of the current profile, if it doesn't find it there it searches 'up the file tree' until it does.

For example if you have an m3 in your code Mach will search for m3 in your macros folder. If it doesn't find it there
it searches upwards until it find Mach's built in standard m3 macro and executes that.

If you wanted you own code to run you write your own m3 and stick it in the macros folder of your profile. Then when the
Gcode interpreter is searching for 'm3' it will find your macro and execute that instead.

You need to use some caution, it maybe that Machs built in code does something like turn a signal on that you are not aware of.
Thus when it runs your m3 that signal would not get turned on because you didn't explicitly code it to happen. In short you need to
include in your m3 all the functionality of Machs built in m3 plus whatever extra you want.

Second issue is that Machs Gcode interpreter parses code it converts all uppercase to lowercase, strips out leading zeros and whitespace.
So  Mach will search for 'm3' but if you named your macro 'M3' it might get missed because they are strictly speaking different names.
Get into the habit of writing all Lua  and Gcode in lowercase without leading zeros. I find to make my code readable I leave whitespace emedded
within the string....and have thus far not encountered any problems.

Craig