Hello Guest it is October 05, 2024, 08:10:52 PM

Author Topic: Run macro "M5" from button push  (Read 14726 times)

0 Members and 1 Guest are viewing this topic.

Run macro "M5" from button push
« on: August 30, 2013, 02:08:53 AM »
Is there an explanation better than the Mach3 Programmers Manual for turning off the spindle by a pushbutton?  It appears that there is no OEM code to shut off the spindle. My M5.m1s macro contains the following;

ActivateSignal(Output 3)
Sleep(4000)
DeActivateSignal(Output 3)

The M5 activates a relay, that drops out the Mag Contactor for the spindle motor

When the spindle is ON, doing a MDI; M5, works just fine. When the program is running, M5, and/or M30 also turn off the spindle.

I would like to also have available a panel button that will run a Brain to do the same thing;  run the M5 macro.

I have looked in vain for an OEM code for "Spindle OFF" that will work in a brain.
There are OEM codes for Spindle ON, Mist ON, Mist OFF, Flood ON, Flood OFF, ................etc.

I read the section on "SetTriggerMacro", and it is certainly not user friendly. The example goes into using OEM Code 301, and says to assign the M5 macro to "SetTriggerMacro(5). Nowhere is it explained where to write the sentence "SetTriggerMacro(5).
I understand the programmers understand all this perfectly, and like to write in terse, minimal sentences.

My pushbuttons work via Modbus. I have everything working imaginable through brains, and OEM codes, except turning OFF the spindle.

I would appreciate a "heads up" where to learn how to do this.

Thanks
John





Offline BR549

*
  •  6,965 6,965
Re: Run macro "M5" from button push
« Reply #1 on: August 30, 2013, 02:47:13 AM »
There IS a spindle TOGGLE in BRAINS that toggles between ON and OFF. In Brains you just have to set up a second node point that looks at the Spindle ON led.

Then when you want the spindle off you look at the function that tells it to turn off AND see if the Spindle is already on(led) as a "AND" function.

If BOTH = true then it Toggles the spindle off. IF the spindle is already OFF it will NOT turn it on.

The example show an input driving the spindle on/off. It can turn it OFF but cannot turn it ON.

It sounds a lot harder than it is.

THE CB code is   DoSpinStop()

(;-) TP
« Last Edit: August 30, 2013, 02:48:58 AM by BR549 »

Offline ger21

*
  • *
  •  6,295 6,295
    • The CNC Woodworker
Re: Run macro "M5" from button push
« Reply #2 on: August 30, 2013, 07:05:22 AM »
What about the OEM code for spindle toggle on/off?
If the spindle is on, the on/off button will turn it off.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html

Offline ger21

*
  • *
  •  6,295 6,295
    • The CNC Woodworker
Re: Run macro "M5" from button push
« Reply #3 on: August 30, 2013, 07:06:54 AM »
Or, try changing your M5 macro to:
DoSpinStop()
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html
Re: Run macro "M5" from button push
« Reply #4 on: August 30, 2013, 10:24:56 AM »
press F5 on the keyboard
Re: Run macro "M5" from button push
« Reply #5 on: August 30, 2013, 01:00:43 PM »
Thanks for all the suggestions.

I will write a brain as suggested by TP.
My M5 macro already has DoSpinStop() as the first line, and when that was all in the M5, it would not work from program or MDI.
Sounds like the spindle toggle thru a brain will do the job.

I want to be able to push a panel button to turn off the spindle when doing a program dry run, leaving the tool holder out of the spindle before doing actual cutting. When I built the panel, I put six buttons in a row above the four main Cycle Start ... etc., buttons, for coolant and spindle actions. My two CNC mills are commercially built, and they both have/had the above mentiond buttons. I used the spindle OFF button often.

This mill was my first CNC, and I retro-fitted it to a dspmc controller, modbus, and Mach3 after the original control "expired" a few years ago. A touch screen might have made things simpler. As you know, when doing actual machining, keyboards and coolant on fingers don't work well together.

Thanks for the suggestions. I will post what worked.
 

Offline ger21

*
  • *
  •  6,295 6,295
    • The CNC Woodworker
Re: Run macro "M5" from button push
« Reply #6 on: August 30, 2013, 01:39:26 PM »
If DoSpinStop() in the M5 isn't working, there may be an issue with your installation. It's the same macro that everyone else is using to stop there spindle, and it works for everyone else.

I'd try an uninstall and reinstall.
Gerry

2010 Screenset
http://www.thecncwoodworker.com/2010.html

JointCAM Dovetail and Box Joint software
http://www.g-forcecnc.com/jointcam.html

Offline BR549

*
  •  6,965 6,965
Re: Run macro "M5" from button push
« Reply #7 on: August 30, 2013, 07:16:16 PM »
IF you do not want to run the SPindle during a dry run simply use the block delete function of the line with the M5. When you want a dry run just hit block delete and it will NOT run the code.

OR set a switch to disable the spindle(axis(0))

(;-) TP
Re: Run macro "M5" from button push
« Reply #8 on: August 31, 2013, 01:18:50 AM »
Well, I spent some time playing with brains, and inputs. I made a brain as per TP's suggestion, and it tested ok watching all the stuff flash on the brain view. However, with the spindle running, nothing happened.

Next, I wrote a simple brain that turned on (Output 3) as the brain terminator, and this worked OK, but now the M5 from the MDI line would not stop the running spindle. So, I checked the the brain enable box, to disable the brain, and now M5 worked again, when the spindle runs.

Apparently, using Modbus + a brain to activate Output 3 with my panel push-button, interferes with the M5, which also has to activate Output 3. I also tested M3 with my panel buttons, and the same thing happened.

The Spindle CW push-button brain was a short one line, like Spindle Stop push-button brain, only difference was Output 1 as the terminator. This Spindle CW push-button would start the spindle, but now entering M3 on the MDI would not start the spindle. As before, I disabled the Spindle CW push-button brain, and now the M3 worked again from the MDI.

As TP says, I can use the block delete for test runs.

The M3 macro is the standard M3.

The M5 macro contains;

ActivateSignal(Output 3)
Sleep(4000)
DeActivateSignal(Output 3)

Both M3, and M5 macros would stop working when I used the Modbus/Brain enabled buttons to Start Spindle, and Stop Spindle.

To use the push-buttons, in addition to the standard start/stop functions, I will have to forego using Modbus. After all, it is just turning on/off two small relays.

The additional code in the M5 macro was necessary to get the M5 to function with Modbus. This was implemented a couple of years ago, when I retro-fitted the controller, and the Cubloc Modbus hardware. My first screen set was the MSM set.

I believe if the panel Spindle ON/OFF pushbuttons are wired into the dspmc I/O board, and set-up in ports and pins to activate a trigger #, they would not interfere with the regular function of M3 and M5.

At least, I learned what works. As things stand, my machine and Ger's 2010 screen are working superbly.

Thanks again for all the good suggestions.

John


 



Offline BR549

*
  •  6,965 6,965
Re: Run macro "M5" from button push
« Reply #9 on: August 31, 2013, 11:46:02 AM »
The problem is in YOUR M5 macro. It is NOT a standard M5 macro. The DoSpinStop() call it uses is tied to output pins and THAT is what MACH3 controls. Your macro bypasses all that and does it directly.

Is there a reason you do not set it up as a standard spindle that uses M3/M5 to control it?

(;-) TP