GearHeads Corner
February 27, 2021, 08:10:41 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: 1 ... 6 7 [8]
  Print  
Author Topic: My laser engraver from 0 knowledge to 32.461% .... probably  (Read 16084 times)
0 Members and 1 Guest are viewing this topic.
BobbyW
Jr. Member
**
Posts: 93



View Profile
« Reply #105 on: February 20, 2021, 11:18:14 AM »

Hi everyone .
Just to say i want to cut a small shape , doesn't matter the complexit y
and i dont want to travel all time to my PC to rewind the code and start my job.
So it is possible via script to program some push buttons connected to Pokeys IO ?
Like " Run " Stop " Rewind ' Cont.
That can be possible via script ?
Thanks
Bobby
Logged
ArtF
Administrator
Hero Member
*****
Posts: 5720



View Profile
« Reply #106 on: February 21, 2021, 10:36:46 AM »


  Bobby:


   When a valid input pin toggles its value.. say Pin 6 on the Main Pokeys,
a signal is sent to the scripting facility of "MotionPin 6". This means a script
waiting on such a signal will start running when it sees that toggle of value.

  You'd need to write a script that listens for that signal to do your operation .
You'd use the block command to pause a script, blocking  on that pin. Im forgettin g
many of these operation s as I rarely change scripts anymore.. but you need a
script similar to this and to call it in an mdi line or something to start the process.

ex script:

global MyRewindS ervice = function()
{
  while(1)
    {
       print("Waiting for Pin6 to rewind");
       block("MotionPin 6"); //this will wait for pin6 to toggle

       //do a Gcode call here to do a rewind.. I thinks like..
       print("Pin6 has been pressed");
       Engine.Gc ode("M30");
       
    }
};
//and start the service
MyRewindS ervice();
 

    The above script would be added to the end of your Gcode script in the
library, it will then start up as the system does and make pin6 a rewind button.
  Though you may want to test the pin6 value to see if its a 1 or zero.. I think
thats something like Motion.Ge tDigPin(6) .. you should see example of how
to use those calls in the various posts here or in the library in various scripts.

Art



Logged
BobbyW
Jr. Member
**
Posts: 93



View Profile
« Reply #107 on: February 22, 2021, 01:47:23 PM »


  Bobby:

       Engine.Gc ode("M30");

Art
Thanks Art
For rewind button , i found the other way
to automated rewind. Shame to me i didn't know
exist a " rewind " command in GCODE.
So i put it at the end on my extension footer , every time i generate GCODE
the code will rewind itself .
Code:
'header': """%
M5 ( LOCK LASER)
(Header)
""",
'footer': """(Footer)
M5 (LOCK)
G00 X0 Y0 (Move head out of way)
M2 (END)
M30 (rewind)
%"""
}
And that solve the rewind.
For RUN , STOP i look in the panel and i saw
the variable used by that buttons .
I think need something like when pin_X is toggled.
Code:
GlobalSet("Execute");
Thanks
Bobby
Logged
ArtF
Administrator
Hero Member
*****
Posts: 5720



View Profile
« Reply #108 on: February 22, 2021, 01:56:46 PM »

probably more like GlobalSet("Execute",1);
Logged
BobbyW
Jr. Member
**
Posts: 93



View Profile
« Reply #109 on: February 22, 2021, 10:43:53 PM »

probably more like GlobalSet("Execute",1);

Hi Art
Yes , you right . I didn't know the function have a argument.
It works , but with two issues .
One " Engine.Gc ode("M30"); " M30 is not recognize d .
and second , Doesn't matter how fast i press the button
the comand will always double execute.
I assume "toggle" is not perfect solution ,
because i assume the service will detect my press 0 to 1 and after i release
the button the service detect 1 to 0 normaly .
Maybe if i wait only from 0 to 1 the pin change ?
Usualy when a pin_X can be in/out type is necesary
pull up/down with 1-10k .
Thanks
Bobby
Logged
ArtF
Administrator
Hero Member
*****
Posts: 5720



View Profile
« Reply #110 on: February 23, 2021, 08:58:47 AM »

Bobby:

   Yes, to stop it form toggling, you'd have to modify your script to check to
see that the current level is on that pin.  Ill try to get time to refresh my memory and
tell you the exact calls.. but its somethign like..

global MyRewindS ervice = function()
{
  while(1)
    {
       print("Waiting for Pin6 to rewind");
       block("MotionPin 6"); //this will wait for pin6 to toggle
      if( Motion.Ge tPinDig( 6 ) == 1) //this would make the rewind only occur if the switch toggles to 1..could be zero..
      {
       //do a Gcode call here to do a rewind.. I thinks like..
       print("Pin6 has been pressed");
         GlobalSet( "Rewind" , 1);
       }
       
    }
};

  I think the above will work.. You can also use GlobalSet with the name of any button
so to press the Rewind button on the screen, note the buttons variable name in the editor..
 "Rewind" in this case, and in your script just use GlobalSet( "Rewind" , 1);

In this way any macro script or file can press buttons even in the Gcode.
If you add the line

{ GlobalSet( "Rewind", 1) }

to the end of a Gcode file, its the same as an M30, or pressing the rewind button.
You can put anything in a Gcode file in {} and it becomes a script.

Art
 
Logged
BobbyW
Jr. Member
**
Posts: 93



View Profile
« Reply #111 on: February 26, 2021, 02:56:46 PM »


      if( Motion.Ge tPinDig( 6 ) == 1) //this would make the rewind only occur if the switch toggles to 1..could be zero..
   
Art
 
Hi Art .
Well the corect call was
Code:
//   if(IOPin8.GetState() == 1)
 //     if(MotionPin8.GetState() == 1)
       if (Pokeys1.GetPinDig(8) == 1)
or better like , normaly should got if is true
Code:
if (Pokeys1.GetPinDig(8))
Working fine with both codes.
I look arown from Gary probing scripts to see how he get the pin state.
I seen all variables but where are located all functions ?
Like that i will know how to call them.
Delay , count , reg exist in Auggie or i need to create a function
to call after ?

Thanks
Bobby
Logged
gburk
Sr. Member
****
Posts: 320


View Profile
« Reply #112 on: February 26, 2021, 08:54:07 PM »

this is how i check the probe pin its in the library

Code:
// Library PokeyPins
// Created  Thursday, December 06, 2018
// Author  Gary       -- Do not edit above this line
 
 //  Enter Global vars below this line.
//  the librarian no matter where they are, but its easier
//  to find and edit them in one spot.
   
   
   
 //The 6 lines previous to a function will appear as 
 //comments to help users to understand the parameters   
 //required for use by each function, so try to   
 //always add as clear a set of instructions in these 
 //lines as an aid to fellow travellers.
 
//myblock = block( "MotionPin19" , "IOPin9", "MotionPin11");
 
//if( myblock == "MotionPin9" ) { .......do whateer" };
                                           
global  MonitorPin19 = function()
{
  //Pokeys1.SetPinDig( 19 , 0 ); // turn off pin 19, ( assumed to be digital output)
 
  while(1)
  {
    //print("Pin 19 Check");
    GlobalSet("ProbeLED",0);
    block( "MotionPin19");  //or you cold use IOPin9
 
   //
   //  when you reach here, its because pin9 has changed..
    pinstate = Pokeys1.GetPinDig(19); 
    //print("Pin 19 Changed");
    GlobalSet("ProbeLED",1);
    block( "MotionPin19");
    //yield();
         //do what you need to do. Take not that if you change pin9, youll get called again..
         //so make sure you dont get into a loop where your change makes this gets called which then changes it..etc.. .
  };
};
MonitorPin19();

Gary
Logged
Pages: 1 ... 6 7 [8]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!