Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: Anthony M on June 18, 2009, 01:06:05 PM

Title: VB Button: Pause and Raise Z
Post by: Anthony M on June 18, 2009, 01:06:05 PM
I am new to Mach3 and attempting to code the Pause button to stop the machine and raise the Z spindle height.  I am not very familiar with VB and am having trouble making the spindle rise after I have told it to pause... Any Ideas??

Thanks
Anthony
Title: Re: VB Button: Pause and Raise Z
Post by: ger21 on June 18, 2009, 01:42:31 PM
Something like this will move the Z up 2":


DoOEMButton(1001)
While IsMoving()
Sleep 100
Wend
Code "G0 Z2"
Title: Re: VB Button: Pause and Raise Z
Post by: Anthony M on June 18, 2009, 03:36:09 PM
Worked perfect!

Is there any way to change the delay between the time the pause button is pressed and when the machine actually halts movement?  There seems to be about a 1 second delay.

Thanks!
Title: Re: VB Button: Pause and Raise Z
Post by: zealous on June 19, 2009, 11:57:49 AM
Hi Anthony,
When you feedhold the machine the amount of time it takes to come to a stop will depend on your motor tuning Accel/Velocity.
You can either change this if your motors permit or use the "stop" (1003) rather than a "FeedHold" (1001)
Title: Re: VB Button: Pause and Raise Z
Post by: Cruiser on June 19, 2009, 12:26:23 PM
Not being familiar with this I have to ask ! The code snippet above must function in incremental ? Will it still go up if you are cutting above 2" or will it go down to 2" ?
Title: Re: VB Button: Pause and Raise Z
Post by: zealous on June 19, 2009, 01:02:15 PM
Yes in ABS it will go down to 2 inchs...so if your machine is at 2.000 and you run the script the machine will just sit there ;)
If you are at 3.000 it will come down/up (depending on your machine)  to 2.000.

If you want to increament in ABS you can:

Code: [Select]
DoOEMButton(1001)

'Wait for machine to stop
While IsMoving()
Sleep 100
Wend

'Get current Z
current_Z = GetOEMDRO(802)

'Add 2' to z
inc_z = current_Z + 2

'Sent command you can use G1 as well if need
Code "G0 Z" & inc_z
Title: Re: VB Button: Pause and Raise Z
Post by: ger21 on June 19, 2009, 01:38:20 PM
Sorry, my mistake. Ideally, you'd check if the machine is in abs or inc mode, change to incremental, move up, then change back to whatever it was set to before.
Title: Re: VB Button: Pause and Raise Z
Post by: Cruiser on June 19, 2009, 11:10:34 PM
So then Anthony M above, could have just as easily have crashed his machine ?
Curious indead !
Thanks for the Instruction
Title: Re: VB Button: Pause and Raise Z
Post by: zealous on June 20, 2009, 06:33:36 PM
Thank you for pointing that out...that is my bad!

Code: [Select]
'FeedHold
DoOEMButton(1001)

'What mode are we in
mode = GetOEMLed(49)

'Wait for machine to stop
While IsMoving()
Sleep 100
Wend

'Sent command you can use G1 as well if need
Code "G90 G0 Z2"

'If we have changed from abs to inc mode then change back
If mode = true Then
   code "G91"
End If