Hello Guest it is March 28, 2024, 10:20:34 PM

Author Topic: Help to finish a button  (Read 3066 times)

0 Members and 1 Guest are viewing this topic.

Offline Alexi

*
  •  10 10
    • View Profile
Help to finish a button
« 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: [Select]


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

 
« Last Edit: January 31, 2021, 06:29:47 PM by Alexi »

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Help to finish a button
« Reply #1 on: February 01, 2021, 01:31:23 AM »
for the Problem with the Limit Switches you can "automaticly" drive the Limit Switch free by code.

example for X-Axis

Code: [Select]

  'check x-axis home Switch
  If GetOEMLed(830) then
    Code "G91 G1 X10 F100"
    Code "G90"
    While IsMoving()
    Wend
  End If

anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline ZASto

*
  •  423 423
    • View Profile
Re: Help to finish a button
« Reply #2 on: February 01, 2021, 04:49:44 AM »
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)

Make no mistake between my personality and my attitude.
My personality is who I am.
My attitude depends on who you are.

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Help to finish a button
« Reply #3 on: February 01, 2021, 12:33:11 PM »
example for softlimits:
Code: [Select]
If (Not GetOEMLed(23))  Then
DoOEMButton(119)
Sleep(200)
End If
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline Alexi

*
  •  10 10
    • View Profile
Re: Help to finish a button
« Reply #4 on: February 01, 2021, 07:47:58 PM »
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
 
Code: [Select]
  '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?
Code: [Select]

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
« Last Edit: February 01, 2021, 07:52:37 PM by Alexi »

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Help to finish a button
« Reply #5 on: February 02, 2021, 01:08:56 AM »
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:
Code: [Select]
'*** 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:
Code: [Select]
'*** turn soflimit's back on if they where on
If ((Not GetOEMLed(23)) And (SoftLimitswhereon = True)) Then
DoOEMButton(119)
Sleep(500)
End If

 
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline Alexi

*
  •  10 10
    • View Profile
Re: Help to finish a button
« Reply #6 on: February 02, 2021, 08:32:34 PM »
Hi there

Do you mean like this:

Code: [Select]
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

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Help to finish a button
« Reply #7 on: February 03, 2021, 01:15:51 AM »
the full code for the Limit Switch check would be:

Code: [Select]
'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


anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.

Offline Alexi

*
  •  10 10
    • View Profile
Re: Help to finish a button
« Reply #8 on: February 17, 2021, 06:08:55 PM »
Hi there

Thanks for all the help this is my final code.
Is it safe to use or something unexpected will appear?

Code: [Select]
'*** 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

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Help to finish a button
« Reply #9 on: February 18, 2021, 08:44:46 AM »
Code: [Select]
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
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.