Hello Guest it is October 22, 2019, 10:41:07 AM

Author Topic: VB Script  (Read 1984 times)

0 Members and 1 Guest are viewing this topic.

VB Script
« on: November 17, 2015, 03:08:15 PM »
Ok guys, still just finding my way around mach3 and am once again struggling with what I am trying to do.

When I first start up in mach3 I tend to follow a routine, first of all, I always click on "Ref All Home" then I manually move the spindle so as it`s sitting just above the rear left jaw of the vice. I know there will be a script that I could use to do this at the press of a button, but I`m afraid that writing the said script is way beyond my limited knowledge.

Would anyone be able to point me to a script, where I could then just fill in the blanks for X move --------,  Y move ---------,  Z move --------- , that in turn, would then place my spindle exactly over the rear left corner of my vice (which is nearly always my zero zero)

Once again, any help gratefully appreciated guys :)
Re: VB Script
« Reply #1 on: November 17, 2015, 10:32:11 PM »
The mach3 VB Script Manuals are here:
http://www.machsupport.com/wp-content/uploads/2013/02/VBScript_Commands.pdf
http://www.machsupport.com/wp-content/uploads/2013/02/Mach3_V3.x_Macro_Prog_Ref.pdf
https://www.google.co.uk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CCAQFjAAahUKEwiSwpLW_JjJAhWCXBQKHRmMBRI&url=https%3A%2F%2Fwww.machsupport.com%2Fforum%2Findex.php%3Faction%3Ddlattach%3Btopic%3D19482.0%3Battach%3D27839&usg=AFQjCNGJn1E7RpKyfyjY7STvwaxPFsA6ng&sig2=jRpIT8aMkgyYbOGQq5oDnw&bvm=bv.107763241,d.d24&cad=rja


I'd suggest setting up an M-code... say M1000 (anything greater than 1000 up to I think it's ~2400)

Then using a screen editor to add a button that will run the M-code and you can programme in a keyboard button press / hotkey that will run.
I use MachScreen: http://www.kd-dietz.com/klausphp/pages/eng/machscreen/description/ms_description.html


Something such as the following should work.... (just copy and paste it into the vb script editor and save it as M1000.m1s):
copied from here (sort of / updated): https://www.machsupport.com/forum/index.php?topic=19565.0

Code: [Select]
DoOEMButton(1024) ' Ref Z axis  (note presume that home is at the top away from the table!)
DoOEMButton(1022) ' Ref X axis
DoOEMButton(1023) ' Ref Y axis
' DoOEMButton(1025) ' Ref A axis (remove the first " ' " to uncomment out / use this axis ref command)
' DoOEMButton(1026) ' Ref B axis (remove the first " ' " to uncomment out / use this axis ref command)
' DoOEMButton(1027) ' Ref C axis (remove the first " ' " to uncomment out / use this axis ref command)

While IsMoving()
Wend

code("G00 X200")  'change the "200" to whatever number you desire
While IsMoving()
Wend

code("G00 Y200") 'change the "200" to whatever number you desire
While IsMoving()
Wend

code("G00 Z50") 'change the "50" to whatever number you desire
While IsMoving()
Wend

' uncomment out the first " ' " to activate the axis movement if you need them.

' code("G00 A200") 'change the "200" to whatever number you desire
' While IsMoving()
' Wend
' code("G00 B200") 'change the "200" to whatever number you desire
' While IsMoving()
' Wend
' code("G00 C200") 'change the "200" to whatever number you desire
' While IsMoving()
' Wend


'
Rob

Albert Einstein ― “If you can't explain it to a six year old, you don't understand it yourself.”
Re: VB Script
« Reply #2 on: November 17, 2015, 11:44:09 PM »
... In hindsight....

You could adjust the code to read as G00 X200 Y200 (edit the 200 as you desire) and it would speed up the code, given the machine movement would be interpolated from the home position to the coordinated x and Y ref position if that is what you desired.

You could also add in the zz too ..... As long as there is no object in the way... To crash into

And you could add in an automated zeroing of the dros ... If that is what you desired....
Just add to the last line:
DoOemButton (1007)


If you go to operator>>>edit button script, and click on the flashing refall button, you can replace the script with that above and it would save you a screen edit.
« Last Edit: November 17, 2015, 11:47:01 PM by robertspark »
Rob

Albert Einstein ― “If you can't explain it to a six year old, you don't understand it yourself.”
Re: VB Script
« Reply #3 on: November 18, 2015, 03:19:19 AM »
Many thanks my friend, I'll certainly be giving this a try tonight
Re: VB Script
« Reply #4 on: November 18, 2015, 01:31:51 PM »
A huge thanks to robertspark :)  That code worked a treat, so now I no longer have to manually move my spindle. Every day is indeed a learning day !!

Many thanks once again.
Re: VB Script
« Reply #5 on: November 18, 2015, 01:47:23 PM »
No problem, happy to help, and I'm by far still learning myself.

Rob

Albert Einstein ― “If you can't explain it to a six year old, you don't understand it yourself.”