Hello Guest it is March 29, 2024, 02:35:44 AM

Author Topic: Brain e/o Script per conteggio e Esecuzione Automatica Azzeramento Assi  (Read 3993 times)

0 Members and 1 Guest are viewing this topic.

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: [Select]
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"
------------------------------------------------------------------------------------------------------------------------------------------------------
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: [Select]
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"
------------------------------------------------------------------------------------------------------------------------------------------------------
« Last Edit: January 09, 2019, 04:45:14 AM by MircoCdc »

Offline TPS

*
  •  2,501 2,501
    • View Profile
Re: Brain e/o Script per conteggio e Esecuzione Automatica Azzeramento Assi
« Reply #2 on: January 09, 2019, 05:08:41 AM »
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: [Select]
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

code not tested
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Brain e/o Script per conteggio e Esecuzione Automatica Azzeramento Assi
« Reply #3 on: January 09, 2019, 05:27:26 AM »
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!!)
« Last Edit: January 09, 2019, 05:45:57 AM by MircoCdc »
Re: Brain e/o Script per conteggio e Esecuzione Automatica Azzeramento Assi
« Reply #4 on: January 09, 2019, 08:48:12 AM »
If someone need  a script to make AUTOHOME i leave this tested example code:

Code: [Select]
'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"
Re: Brain e/o Script per conteggio e Esecuzione Automatica Azzeramento Assi
« Reply #5 on: January 09, 2019, 09:13:00 AM »
Syntax question to call the macro in GCODE:
in GCODE to call the macro AUTOHOME.m1s i have to:
1-save the file in the folder C:\Mach3\macros\Mach3Mill
2-write in GCODE file:

Code: [Select]
AUTOHOME
...other gcode..

but i have an ERROR when i load the file in mach3:
'Unknown word where unary operation could be, Block AUTOHOME'.

What it means?
The name of the macro have to be necessary M****.m1s ?
« Last Edit: January 09, 2019, 09:28:01 AM by MircoCdc »

Online ZASto

*
  •  423 423
    • View Profile
Re: Brain e/o Script per conteggio e Esecuzione Automatica Azzeramento Assi
« Reply #6 on: January 09, 2019, 09:51:00 AM »
Quote
The name of the macro have to be necessary M****.m1s ?

Yes :)
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: Brain e/o Script per conteggio e Esecuzione Automatica Azzeramento Assi
« Reply #7 on: January 09, 2019, 01:52:20 PM »
ok once again, as i have writen in reply #2

the macro Name has to be M***.m1s not myfantsiename.m1s
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
Re: Brain e/o Script per conteggio e Esecuzione Automatica Azzeramento Assi
« Reply #8 on: January 10, 2019, 11:19:16 AM »
 ;) Thanks!!