Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: Alexi on January 31, 2021, 06:28:10 PM
-
Hi there to all,
this is not my comfort area and is far from it, but in this crazy times found something that can improve my knowledge and simplify my work, so i am trying to create a button that does the starting routine that i always need to make when i start my machine
My manual routine is:
First press RESET button
Second press REF ALL HOME
Third press GO TO ZERO
fourth press zero x, zero y, and zero z (machine coordinates and work coordinates equal to zero )
Five press SOFT LIMITS
After this my machine is ready to safely work.
This is the script that i create:
Code "( STARTING MACHINE )"
DoOEMButton(119)
Dobutton( 24 ) ' ZeroZ
While IsMoving()
Wend
Sleep 300
ZDRO = 85 'var dro machine
ZWDRO = 2 'var dro work
Z = GetOEMDRO( ZDRO ) 'passa o valor do dro maquina
Call SetDro (ZWDRO, Z) 'passa o valor do dro maquina
Sleep 500
Dobutton( 22 ) ' Zerox
While IsMoving()
Wend
Sleep 500
XDRO = 83 'variavel dro maquina
XWDRO = 0 'variavel dro trabalho
X = GetOEMDRO( XDRO ) 'passa o valor do dro maquina
Call SetDro (XWDRO, X) 'passa o valor do dro maquina
Sleep 500
Dobutton( 23 ) ' ZeroY
While IsMoving()
Wend
Sleep 500
YDRO = 84 'variavel dro maquina
YWDRO = 1 'variavel dro trabalho
Y = GetOEMDRO( YDRO ) 'passa o valor do dro maquina
Call SetDro (YWDRO, Y) 'passa o valor do dro maquina
Sleep 500
Code "G28"
While IsMoving()
Wend
Sleep 500
DoOEMButton(119)
Code "( ZEROS DONE )"
So my questions are:
Is it safe to use?
Sometimes it doesn't work and it gives me error "limit switch triggered", and stops script. In this case i have to
manually remove axis from switch that triggers.What can it be?
Any tips to improve this are more then welcome.
Thanks to all
Alex
-
for the Problem with the Limit Switches you can "automaticly" drive the Limit Switch free by code.
example for X-Axis
'check x-axis home Switch
If GetOEMLed(830) then
Code "G91 G1 X10 F100"
Code "G90"
While IsMoving()
Wend
End If
-
First press RESET button
Second press REF ALL HOME
Third press GO TO ZERO <-- Why this one? Machine is already at 0
fourth press zero x, zero y, and zero z (machine coordinates and work coordinates equal to zero ) <-- Why this one? X, Y and Z coordinates are already at 0
Five press SOFT LIMITS <-- Here you should be checking if Soft limits are On or Off. Mach remembers state of soft limits (writes it to .xml file)
-
example for softlimits:
If (Not GetOEMLed(23)) Then
DoOEMButton(119)
Sleep(200)
End If
-
Hi there
thanks for help
ZASto i should told more about my settings.
I have offsets in all axis (X2.00, Y-318.00, Z2.00)
My softlimits are:
Xmax -1.00---- Xmin -3500
Ymax 315.00--- Ymin -315.00
Zmax -1.00---- Zmin-350
This way i lose 2mm in all axis but i guarantee that i work always a bit far from switches.
I have independent induction switch in all axis if that matters (1 pin for each) and board used is AXBB_E from CNCdrive.
TPS
'check x-axis home Switch
If GetOEMLed(830) then
Code "G91 G1 X10 F100"
Code "G90"
While IsMoving()
Wend
End If
On this code it checks if led is ON, and if it is it will move 10mm far from switch is it correct?
Where is the best spot on the script to check this condition. Should be the last thing like this?
Dobutton( 22 ) ' Zerox
While IsMoving()
Wend
Sleep 500
XDRO = 83 'var dro machine
XWDRO = 0 'var dro work
X = GetOEMDRO( XDRO )
Call SetDro (XWDRO, X)
If GetOEMLed(830) then
Code "G91 G1 X10 F100"
Code "G90"
While IsMoving()
Wend
End If
With softlimits example it checks if led is OFF and if it is activate softlimits is it?
If i remove Not to condition and place it at the beginning of the script will it check if softlimits are activated and if yes it will deactivate .
Thanks
Alex
-
Where is the best spot on the script to check this condition. Should be the last thing like this?
allways directly before you do the referencing of each axis
for the softlimits here a full example for begin of script:
'*** turn soflimit's off if they are on
Dim SoftLimitswhereon As Boolean
If GetOEMLed(23) Then
DoOEMButton(119)
SoftLimitswhereon = True
End If
this turns softlimits OFF, if they are ON and stores the original state in a variable.
so you can restore the original at the end of script with:
'*** turn soflimit's back on if they where on
If ((Not GetOEMLed(23)) And (SoftLimitswhereon = True)) Then
DoOEMButton(119)
Sleep(500)
End If
-
Hi there
Do you mean like this:
If GetOEMLed(830) then
Code "G91 G1 X10 F100"
Code "G90"
While IsMoving()
Wend
End If
Dobutton( 22 ) ' Zerox
While IsMoving()
Wend
Sleep 500
XDRO = 83 'var dro machine
XWDRO = 0 'var dro work
X = GetOEMDRO( XDRO )
Call SetDro (XWDRO, X)
In this case it will check this condition before making zero but i get the error when it makes the last move to go away from switch. Is that ok?
About the limit switch it looks great and much cooler then mine.
I don´t get "Dim SoftLimitswhereon As Boolean". Can you explain what Dim does? I understand the var SoftLimitswhereon stores the value but what Dim do?
Can´t wait to test this as soon as this confinement is over.
Thanks
-
the full code for the Limit Switch check would be:
'clear x-axis Limit Switch if needed
If GetOEMLed(830) then
Code "G91 G1 X10 F100"
Code "G90"
While IsMoving()
Wend
End If
'clear y-axis Limit Switch if needed
If GetOEMLed(831) then
Code "G91 G1 Y10 F100"
Code "G90"
While IsMoving()
Wend
End If
'clear z-axis Limit Switch if needed
If GetOEMLed(832) then
Code "G91 G1 Z-10 F100"
Code "G90"
While IsMoving()
Wend
End If
Dim is only a declaration for the variable not absolutly necessarily.
check this:
https://www.machsupport.com/wp-content/uploads/2013/02/VBScript_Commands.pdf
-
Hi there
Thanks for all the help this is my final code.
Is it safe to use or something unexpected will appear?
'*** turn soflimit's off if they are on
Dim SoftLimitswhereon As Boolean
If GetOEMLed(23) Then
DoOEMButton(119)
SoftLimitswhereon = True
End If
If GetOEMLed(832) then
Code "G91 G1 Z-10 F100"
Code "G90"
While IsMoving()
Wend
End If
Dobutton( 24 ) ' ZeroZ
While IsMoving()
Wend
Sleep 500
ZDRO = 85 'variavel dro maquina
ZWDRO = 2 'variavel dro trabalho
Z = GetOEMDRO( ZDRO ) 'passa o valor do dro maquina
Call SetDro (ZWDRO, Z) 'passa o valor do dro maquina
Sleep 500
'clear x-axis Limit Switch if needed
If GetOEMLed(830) then
Code "G91 G1 X10 F100"
Code "G90"
While IsMoving()
Wend
Dobutton( 22 ) ' Zerox
While IsMoving()
Wend
Sleep 500
XDRO = 83 'variavel dro maquina
XWDRO = 0 'variavel dro trabalho
X = GetOEMDRO( XDRO ) 'passa o valor do dro maquina
Call SetDro (XWDRO, X) 'passa o valor do dro maquina
Sleep 500
'clear y-axis Limit Switch if needed
If GetOEMLed(831) then
Code "G91 G1 Y10 F100"
Code "G90"
While IsMoving()
Wend
End If
Dobutton( 23 ) ' ZeroY
While IsMoving()
Wend
Sleep 500
YDRO = 84 'variavel dro maquina
YWDRO = 1 'variavel dro trabalho
Y = GetOEMDRO( YDRO ) 'passa o valor do dro maquina
Call SetDro (YWDRO, Y) 'passa o valor do dro maquina
Sleep 500
Code "G28"
While IsMoving()
Wend
Sleep 500
'*** turn soflimit's back on if they where on
If ((Not GetOEMLed(23)) And (SoftLimitswhereon = True)) Then
DoOEMButton(119)
Sleep(500)
End If
Code "( ZERO DONE )"
Thanks once again cause this will make my job a bit easier.
Alex
-
Sleep 500
'clear x-axis Limit Switch if needed
If GetOEMLed(830) then
Code "G91 G1 X10 F100"
Code "G90"
While IsMoving()
Wend
'!!!!!!!!!!!!!!! I A PRETTY SURE HERE SHOULD BE A -> End If !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Dobutton( 22 ) ' Zerox
While IsMoving()
Wend
-
'*** turn soflimit's off if they are on
Dim SoftLimitswhereon As Boolean
If GetOEMLed(23) Then
DoOEMButton(119)
SoftLimitswhereon = True
End If
If GetOEMLed(832) then
Code "G91 G1 Z-10 F100"
Code "G90"
While IsMoving()
Wend
End If
Dobutton( 24 ) ' ZeroZ
While IsMoving()
Wend
Sleep 500
ZDRO = 85 'variavel dro maquina
ZWDRO = 2 'variavel dro trabalho
Z = GetOEMDRO( ZDRO ) 'passa o valor do dro maquina
Call SetDro (ZWDRO, Z) 'passa o valor do dro maquina
Sleep 500
'clear x-axis Limit Switch if needed
If GetOEMLed(830) then
Code "G91 G1 X10 F100"
Code "G90"
While IsMoving()
Wend
End If
Dobutton( 22 ) ' Zerox
While IsMoving()
Wend
Sleep 500
XDRO = 83 'variavel dro maquina
XWDRO = 0 'variavel dro trabalho
X = GetOEMDRO( XDRO ) 'passa o valor do dro maquina
Call SetDro (XWDRO, X) 'passa o valor do dro maquina
Sleep 500
'clear y-axis Limit Switch if needed
If GetOEMLed(831) then
Code "G91 G1 Y10 F100"
Code "G90"
While IsMoving()
Wend
End If
Dobutton( 23 ) ' ZeroY
While IsMoving()
Wend
Sleep 500
YDRO = 84 'variavel dro maquina
YWDRO = 1 'variavel dro trabalho
Y = GetOEMDRO( YDRO ) 'passa o valor do dro maquina
Call SetDro (YWDRO, Y) 'passa o valor do dro maquina
Sleep 500
Code "G28"
While IsMoving()
Wend
Sleep 500
'*** turn soflimit's back on if they where on
If ((Not GetOEMLed(23)) And (SoftLimitswhereon = True)) Then
DoOEMButton(119)
Sleep(500)
End If
Code "( ZERO DONE )"
I forgot that one and i could`t test it yet, the factory still closed.
Now i think it is done
Thanks