Hello Guest it is April 16, 2024, 06:44:18 PM

Author Topic: M3 and M5 not working  (Read 4137 times)

0 Members and 1 Guest are viewing this topic.

M3 and M5 not working
« on: June 04, 2012, 10:25:15 AM »
I have a small VB program assigned to a button that does a cycle start [DoOEMButton(1000)] and runs a Gcode file already loaded into Mach. Once the Gcode run is finished the VB code checks an input and if it is active, it loops back and does another cycle start. The issue is: when I run the Gcode manually (click on the cycle start button) everything works as it should, however when the cycle start comes from the VB code the M3 (spindle on) and M5 (spindle off) functions do not work. Any ideas?

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: M3 and M5 not working
« Reply #1 on: June 05, 2012, 05:13:08 PM »
COuld you post your code ?

Sometimes running a macro M3 from inside another macro strange things happen(;-)

(;-) TP
Re: M3 and M5 not working
« Reply #2 on: June 05, 2012, 09:03:45 PM »
As I said it's a small program.



Do
DoOEMButton(1000)

While IsMoving()
Sleep(200)
Wend

Loop While IsActive(Input4)
End

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: M3 and M5 not working
« Reply #3 on: June 08, 2012, 01:33:00 PM »
OK what does input 4 do.  What it seems is when you are running inside the Macro loop you are also running the Gcode program when in the loop??

NOT a good idea as you may have noticed. While inside that loop you would be calling other macros, not a good idea either as the results tend to be unpredictable as warned in the manual.

A better way would be to run the program then HAND controll OFF to the macro that can wait on the signal to restart. THEN restart the Gcode program from scratch. That way you do not have a gcode file running inside a macro loop.

Just make sure you plan a manual override to be able to escape the loops if needed.

(;-) TP

Re: M3 and M5 not working
« Reply #4 on: June 09, 2012, 10:50:36 AM »
OK, so how do I do that? Do I call the macro at the end of the Gcode by using a custom M code? If I do I won't have to use a loop, just check the input and issue a cycle start if the input is active.

If I do it this way, I will have to issue a M30 from the macro in order to close and rewind the current Gcode program before issuing a cycle start.

Am I on the right track or is there a better way?

Thanks for you help.

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: M3 and M5 not working
« Reply #5 on: June 09, 2012, 11:49:59 AM »
Build a simple Mcode (macro) somthing along the lines of


While Is not active(input4)  OR Is not Userled(*********)  'Safety to get out of the loop if needed

Wend

Rewind Gcode

Start program

End

« Last Edit: June 09, 2012, 11:53:01 AM by BR549 »
Re: M3 and M5 not working
« Reply #6 on: June 12, 2012, 07:07:42 AM »
Thanks for your help. I finally got a chance to get out to the shop last night and give this a try. I had to go with a slightly different approach, but it worked great. I really appreciate the guidance.