Mach Discussion > Brains Development

Brain e/o Script per conteggio e Esecuzione Automatica Azzeramento Assi

(1/2) > >>

MircoCdc:
Ciao a Tutti, :)
mi servirebbe una mano per realizzare questa semplice funzionalita con Brain e/o VBScript.:

FUNZIONALITA
Dopo un certo numero di lavorazioni , conteggiabili da INPUT1, lancio in automatico un azzeramento assi, faccio eseguire l'home dei due assi.
Mi servirebbe una mano per fare:
1-CONTEGGIO (numero di volte che ho premuto il pulsante di avvio ciclo ( INPUT1 )
2-LANCIO HOME  ( CON VERIFICA CHE NON MI STO MUOVENDO E NON HO UNA LAVORAZIONE IN CORSO)

DOMANDE
1-CONTEGGIO mi dareste una mano per fare il BrainDiConteggio?
Ho visto che le variabili del VBscript sono senza memoria, quindi non ci posso salvare il numero di volte che premo il pulsante di avvio ciclo ( INPUT1 ), quinidi sto provando con un Brain ma non riesco a fare il conteggio.. qualcuno puo darmi una mano? HELP!!!
2-LANCIO HOME
Conviene fare tutto da Brain usando funzionalita di sistema per lanciare homing?
Oppure posso richiamare un VBScript da un Brain?
Perche se posso lanciare uno script dal BrainDiConteggio,  posso usare il codice qui sotto per lanciare home.




PROVE
posto delle prove di codice VBScript che possono tornare utili per spiegare cosa vorrei fare come logica:

----------------------------------------------------------Prova di codice VBScript--------------------------------------------------------

--- Code: ---MsgBox  "conferma inizio"

Dim CONTEGGIO As Integer
CONTEGGIO = 0

Dim NumeroDiPezzi
NumeroDiPezzi=50

Dim i
i=0

'While i<100000000

 '---CONTEGGIO---
 While Not IsMoving() And IsActive(INPUT1)              'INPUT1 è PULSANTE DI AVVIO CICLO
  CONTEGGIO = CONTEGGIO + 1
  'MsgBox  "debug CONTEGGIO=, " & CONTEGGIO & "."
  Sleep(5000)
 Wend

 
 '---AUTOHOME---
 If (CONTEGGIO >= NumeroDiPezzi) And Not IsMoving()  Then

  'MsgBox  "debug AVVIO AUTORIGINE"   
 
  DoButton( 24 )
  While IsMoving()
  Wend
 
  DoButton( 23 )
  While IsMoving()
  Wend
 
  DoButton( 22 )
  While IsMoving()
  Wend 
 
  DoButton( 25 )
  While IsMoving()
  Wend 
 
     
 End If

 Sleep(300)

'i=i+1
'Wend   

'MsgBox  "debug fine"
--- End code ---
------------------------------------------------------------------------------------------------------------------------------------------------------

MircoCdc:
Hi everyone, :)
I would need a hand to realize this simple functionality with Brain and / or VBScript .:

FUNCTIONALITY
After a certain number of operations, counted by INPUT1, I automatically start an axis zeroing, I run the home of the two axes.
I would need a hand to do:
1-COUNTING (number of times I pressed the cycle start button (INPUT1)
2-LAUNCH HOME (WITH CHECK THAT I'M NOT MOVING AND I HAVE NO WORKING IN PROGRESS)

QUESTIONS
1-COUNTING would you give me a hand to do the BrainDiConteggio?
I saw that the variables of VBscript are without memory, so I can not save the number of times I press the start button cycle (INPUT1), so I'm trying with a Brain but I can not do the count .. someone can give me a but no? HELP !!!
2-LAUNCH HOME
Is it convenient to do everything from Brain using system functionality to launch homing?
Or can I call a VBScript from a Brain?
Because if I can run a script from the BrainDiConteggio, I can use the code below to launch home.




TESTS
place some VBScript code tests that may come in handy to explain what I would like to do as logic:

----------------------------------------------------------TEST VBScript--------------------------------------------------------

--- Code: ---MsgBox  "conferma inizio"

Dim CONTEGGIO As Integer
CONTEGGIO = 0

Dim NumeroDiPezzi
NumeroDiPezzi=50

Dim i
i=0

'While i<100000000

 '---CONTEGGIO---
 While Not IsMoving() And IsActive(INPUT1)              'INPUT1 è PULSANTE DI AVVIO CICLO
  CONTEGGIO = CONTEGGIO + 1
  'MsgBox  "debug CONTEGGIO=, " & CONTEGGIO & "."
  Sleep(5000)
 Wend

 
 '---AUTOHOME---
 If (CONTEGGIO >= NumeroDiPezzi) And Not IsMoving()  Then

  'MsgBox  "debug AVVIO AUTORIGINE"   
 
  DoButton( 24 )
  While IsMoving()
  Wend
 
  DoButton( 23 )
  While IsMoving()
  Wend
 
  DoButton( 22 )
  While IsMoving()
  Wend 
 
  DoButton( 25 )
  While IsMoving()
  Wend 
 
     
 End If

 Sleep(300)

'i=i+1
'Wend   

'MsgBox  "debug fine"
--- End code ---
------------------------------------------------------------------------------------------------------------------------------------------------------

TPS:
i would put the code into a macro for example M110.M1s in your macro Folder.
this macro is called at the begin of your GCode with: M110

use a UserDro to make the Counts persitent.
in config ->General config you can make them persitent even mach3 is switched off.

code could be something like this:

--- Code: ---Sub Main()
  'do the count
  SetUserDro(1400,GetUserDro(1400)+1)

  If GetUserDro(1400) > 100 Then

 
   DoButton( 24 )
   While IsMoving()
   Wend
 
   DoButton( 23 )
   While IsMoving()
   Wend
 
   DoButton( 22 )
   While IsMoving()
   Wend 
 
   DoButton( 25 )
   While IsMoving()
   Wend 
 
   'clear the Counter
   SetUserDro(1400,0) 
 End If
  End If

End Sub

--- End code ---

code not tested

MircoCdc:
Thanks for Reply!!


I test this macro vbscript and it work with UserDro , the value is stored, TANKS!

Another question:
how i can launch the macro everytime i have INPUT#1 = TRUE ?

(Sorry!! I read better and i see that you told me to put the macro in the GCODE file. Thanks!!)

MircoCdc:
If someone need  a script to make AUTOHOME i leave this tested example code:


--- Code: ---'AUTOHOME
'1-CONTO N LAVORAZIONI OGNI VOLTA CHE LANCIO IL GCODE
    'scrivere a inizio gcode AUTOHOME, che richiama la macro vbscript
    'e salvare nel folder delle macro AUTOHOME.m1s
'2-RILANCIO AUTOMATICO DOPO N CICLI DI LAVORO---
'3-RESETTO CONTEGGIO
 
'MsgBox  "debug INIZIO"
   
Dim NumeroDiPezzi
NumeroDiPezzi=5


 '---INCREMENTO CONTEGGIO A OGNI LANCIO DEL GCODE---
 'UserDro1400 è var di sistema dove salvo il conteggio
 SetUserDro(1400,GetUserDro(1400)+1)
 'MsgBox  "debug CONTEGGIO=, " & GetUserDro(1400) & "."   

 Sleep(300)
 
 '---AUTOHOME---
 If (GetUserDro(1400) >= NumeroDiPezzi) And Not IsMoving()  Then
 
    'MsgBox  "debug 24"   
  DoButton( 24 )
  While IsMoving()
  Wend
    'MsgBox  "debug 23" 
  DoButton( 23 )
  While IsMoving()
  Wend
    'MsgBox  "debug 22"
  DoButton( 22 )
  While IsMoving()
  Wend 
    'MsgBox  "debug 25"
  DoButton( 25 )
  While IsMoving()
  Wend 
 
 'RESETTO IL CONTEGGIO
  SetUserDro(1400,0)   
 
 End If

 Sleep(300)

 
'MsgBox  "debug FINE"

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version