Hello Guest it is March 28, 2024, 07:02:34 PM

Author Topic: Mach3 turn macro - Pause restart  (Read 8781 times)

0 Members and 1 Guest are viewing this topic.

Mach3 turn macro - Pause restart
« on: March 10, 2015, 02:04:38 PM »
Good afternoon all,

When I run this in Mach3 turn VB editor it executes but does not pause for any of the restarts.  When I run from the MDI line a message "Pause in Macro/Script". If run in a gcode fiilewith just one line M401 (the macro file) I get the same message.

Can someone tell me why this doesn't run in Mach 3 turn?

Sub main
'Domed Winding check
'0.5614 fixture diameter
'0.2804 fixture radius
'0.725 Raw NickelBlank Dia
DoOEMButton(1001)
code "(Mount back cut tool)"
systemWaitFor(restart)
DoOEMButton(1001)
Code "(Jog to Fixture surface)"
systemWaitFor(restart)
' Set Z to Fixture Radius
setDro(0,0.2807)
DoOEMButton(1001)
code "(Mount Front Cut Tool, position to back edge of mounted nickel)"
systemWaitFor(restart)
setDro(2,0.000)
' set spindle speed to 400
DoOEMButton(1001)
Code "(Turn Spindle on to 400RPM)"
code "m3 S400"
systemWaitFor(restart)
code "g01 f2 x0.285"
code "g0 x0.3625"
code "M5"
DoOEMButton(1001)
code "(stop spindle)"
systemWaitFor(restart)
End Sub

main 

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Mach3 turn macro - Pause restart
« Reply #1 on: March 10, 2015, 04:36:24 PM »
OK let's try,

first of all let's get a resadble code:

Sub main
  'Domed Winding check
  '0.5614 fixture diameter
  '0.2804 fixture radius
  '0.725 Raw NickelBlank Dia
  DoOEMButton(1001)
  code "(Mount back cut tool)"
  systemWaitFor(restart)
  DoOEMButton(1001)
  Code "(Jog to Fixture surface)"
  systemWaitFor(restart)
  ' Set Z to Fixture Radius
  setDro(0,0.2807)
  DoOEMButton(1001)
  code "(Mount Front Cut Tool, position to back edge of mounted nickel)"
  systemWaitFor(restart)
  setDro(2,0.000)
  ' set spindle speed to 400
  DoOEMButton(1001)
  Code "(Turn Spindle on to 400RPM)"
  code "m3 S400"
  systemWaitFor(restart)
  code "g01 f2 x0.285"
  code "g0 x0.3625"
  code "M5"
  DoOEMButton(1001)
  code "(stop spindle)"
  systemWaitFor(restart)
End Sub

main  

ok let's do some documentaion's to the code


Sub main
  'Domed Winding check
  '0.5614 fixture diameter
  '0.2804 fixture radius
  '0.725 Raw NickelBlank Dia
  DoOEMButton(1001)
  code "(Mount back cut tool)"   'what does this code mean ?? ???
  systemWaitFor(restart)            'where/or what is restart  ???
  DoOEMButton(1001)
  Code "(Jog to Fixture surface)" 'what does this code mean ?? ???
  systemWaitFor(restart)            'where/or what is restart  ???
  ' Set Z to Fixture Radius
  setDro(0,0.2807)
  DoOEMButton(1001)
  code "(Mount Front Cut Tool, position to back edge of mounted nickel)"  'what does this code mean ?? ???
  systemWaitFor(restart)             'where/or what is restart  ???
  setDro(2,0.000)
  ' set spindle speed to 400
  DoOEMButton(1001)
  Code "(Turn Spindle on to 400RPM)"  'what does this code mean ?? ???
  code "m3 S400"
  systemWaitFor(restart)   'where/or what is restart  ???
  code "g01 f2 x0.285"
  code "g0 x0.3625"
  code "M5"
  DoOEMButton(1001)
  code "(stop spindle)"     'what does this code mean ?? ???

  systemWaitFor(restart)       'where/or what is restart  ???

End Sub

main  

i am just talkin like MACH3 processor.

Thomas

if you try to get an answer post the real code.

« Last Edit: March 10, 2015, 04:44:58 PM by TPS »
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Mach3 turn macro - Pause restart
« Reply #2 on: March 10, 2015, 04:55:00 PM »
Hi Tom, thanks for taking a moment to look at the code.

I too would like 'resadble code'  :D as you suggest.

Let me see if I can explain.

the lines: code "(...)" output a message in the Status box.  I use it to remind me what each step is before I continue.  Tool change or jog primarily.

as for the combination before and after those lines they are supposed to pause and restart the execution of the macro see Poppa Bear;s response here:

http://www.machsupport.com/forum/index.php/topic,7491.0.html

I just converted my bench lathe to CNC and do not as of yet have spindle control so a couple of those code entries remind to start/stop the spindle.
This is just the first part of code to turn a part.


Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Mach3 turn macro - Pause restart
« Reply #3 on: March 10, 2015, 06:42:22 PM »
 systemWaitFor(restart)   'where/or what is restart  Huh

restart is NOT valid for that piece of code. It is WAITING on a Signal Number (integer) which represents a valid INPUT number.

PLEASE read the manual (;-)

Just a thought, (;-) TP

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Mach3 turn macro - Pause restart
« Reply #4 on: March 11, 2015, 04:16:19 AM »
Hi rhtuttle,

i think now what you tryed to do.
Pause is not working because there is no movement.

Try this:

Code: [Select]
Sub main
  'Domed Winding check
  '0.5614 fixture diameter
  '0.2804 fixture radius
  '0.725 Raw NickelBlank Dia
  Message "(Mount back cut tool)"
  DoOEMButton(1003)
  WaitForStart

    DoOEMButton(1003)
  Message "(Jog to Fixture surface)"
  WaitForStart

  ' Set Z to Fixture Radius
  setDro(0,0.2807)
  DoOEMButton(1003)
  Message "(Mount Front Cut Tool, position to back edge of mounted nickel)"
  WaitForStart

  setDro(2,0.000)
  ' set spindle speed to 400
  DoOEMButton(1003)
  Message "(Turn Spindle on to 400RPM)"
  WaitForStart

  code "m3 S400"
  code "g01 f2 x0.285"
  code "g0 x0.3625"
  While Ismoving()
   sleep(200)
  Wend
  
  DoOEMButton(1003)
  Message "(stop spindle)"
  WaitForStart
  code "M5"

  Message "(finshed)"
  
End Sub
 
Sub WaitForStart
Sleep(300)
While Not GetLed(4) 'check Start LED
Sleep(200)
Wend
End Sub



Thomas
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Mach3 turn macro - Pause restart
« Reply #5 on: March 11, 2015, 10:57:12 AM »
Thomas, thank you so much for taking time to look at this.  I haven't done any Mach scripting in a couple of years and had been banging my head against a wall for a few hours when I posted.

Contrary to TP's opinion I do RTFM but the programmers reference manual only has this:

SystemWaitFor
Sub SystemWaitFor(Signal As Integer)
This function it is used to tell Mach that a macro script is ending, and that any further
GCode execution should wait for the Signal to go active. If used, this function should
always be the last line in a macro and it should never be used within a loop.
Arguments:
SignalID must be one of the pre-defined Mach3 CB output signal constants (see
CB Constants), or other value or expression that evaluates to one of those values.
Return Value:
None
Example:
See also:

Since the manual does not contain the CB Constants it refers to I assumed, wrongly, that Poppa bear's use of ReStart was a constant.  After leaving it alone for a few hours I reread his example.  I missed a line of code:

ReStart = IsActive(INPUT4)            'this is input signal 4

I like your code, thanks again

Offline BR549

*
  •  6,965 6,965
    • View Profile
Re: Mach3 turn macro - Pause restart
« Reply #6 on: March 11, 2015, 04:08:43 PM »
Ya read the wrong manual (;-)


"Customising Mach2" page 4-10

SystemWaitFor ( SigNo as integer)
Waits for the given signal to become active.This allows interfacing with physical controls on the machine.

(;-) TP

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Mach3 turn macro - Pause restart
« Reply #7 on: March 11, 2015, 04:37:20 PM »
Hi,

sorry, i am not realy shure what you want to tell me (may be caused of my bad english).


Thomas, thank you so much for taking time to look at this.  I haven't done any Mach scripting in a couple of years and had been banging my head against a wall for a few hours when I posted.

Contrary to TP's opinion I do RTFM but the programmers reference manual only has this:

SystemWaitFor
Sub SystemWaitFor(Signal As Integer)
This function it is used to tell Mach that a macro script is ending, and that any further
GCode execution should wait for the Signal to go active. If used, this function should
always be the last line in a macro and it should never be used within a loop.
Arguments:
SignalID must be one of the pre-defined Mach3 CB output signal constants (see
CB Constants), or other value or expression that evaluates to one of those values.
Return Value:
None
Example:
See also:

Since the manual does not contain the CB Constants it refers to I assumed, wrongly, that Poppa bear's use of ReStart was a constant.  After leaving it alone for a few hours I reread his example.  I missed a line of code:

ReStart = IsActive(INPUT4)            'this is input signal 4

I like your code, thanks again

simple question  working yes/no.

Thomas
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Mach3 turn macro - Pause restart
« Reply #8 on: March 11, 2015, 04:46:54 PM »
Yes, thank you.