GearHeads Corner
June 19, 2019, 12:56:18 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: 1 2 [3] 4 5 ... 18
  Print  
Author Topic: reading Pokeys pins  (Read 4098 times)
0 Members and 1 Guest are viewing this topic.
gburk
Full Member
***
Posts: 133


View Profile
« Reply #30 on: December 09, 2018, 11:17:43 AM »

//Set mist/flood control
//1 = mist, 2 = flood, 0 = off
global SetMistFl ood = function( relayNumb er )
{
    //Relay # 1-4
    //print("Flood change");
 
OnOrOff = MyMotion. GetRelay(relayNumb er);
  if (OnOrOff == 0)
  {
  MyMotion. SetRelay(relayNumb er,1);
  print("M8 Flood Relay Turned ON");
  GlobalSet("FloodOnLE D",1);
  }
   else
    {
     MyMotion. SetRelay(relayNumb er,0);
     print("M9 Flood Relay Turned OFF");
     GlobalSet("FloodOnLE D",0);
    }
 };

If I call m8 the relay go's on, if I call m9 the relay stays on but it does do the print M9 flood relay turner off, if I call m8 a second time the relay turns off ok..

I will check to see if the led is set to flashing. .

Thanks gary
Logged
ArtF
Administrator
Hero Member
*****
Posts: 5280



View Profile
« Reply #31 on: December 09, 2018, 11:29:11 AM »

Gary:

I believe the function gets a 0,1, or 2 in the parameter s to indicate if this is an M7,m8 or M9. They way the commands for mist,flood work
is SetMistFl ood(0) shoudl turn on whatever relay mist is contollin g, a 1 to turn on the flood relay and a m9 to turn them both off.
Various machines use various logic for this , my script dopesnt actually use mist,flood but Id think its more..

//Set mist/flood control
//1 = mist, 2 = flood, 0 = off
global SetMistFl ood = function( desiredst ate )
{
     
   MistRelay = 1;
   FloodRela y = 2;

 
  if (desiredst ate == 0) //mist
{
    MyMotion. SetRelay(MistRelay,1);
    print("M7 Mist Relay Turned ON");
   GlobalSet("FloodOnLE D",1);
}

 if (desiredst ate == 1) //flood
{
    MyMotion. SetRelay(FloodRela y,1);
    print("M8 Flood Relay Turned ON");
   GlobalSet("FloodOnLE D",1);
}

 if (desiredst ate == 2) //flood,mist off
{
    MyMotion. SetRelay(MistRelay,0);
    MyMotion. SetRelay(FloodRela y,0);
    print("M9 Flood and Mist Relays Turned ON");
    GlobalSet("FloodOnLE D",0);
    GlobalSet("MistOnLED",0);
}
 
};

Art


   
Logged
gburk
Full Member
***
Posts: 133


View Profile
« Reply #32 on: December 09, 2018, 12:35:51 PM »

Ok thanks will try it out

Here is a script to read pin19 doesn't work

  global MyMotion = Motion(); //Will not exist unless lib is loaded
 
global  MonitorPi n19 = function()
{
  while(1)
  {
    print("Pin 19 Check");
    block( "MotionPii n19");  //pokeys57 Pin19
   //
   //  when you reach here, its because pin9 has changed..
    pinstate = MyMotion. GetPinDig (19); 
    if( pinstate == 1 )
    {
          print("Pin 19 Changed");
         //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.. .
    }
  }
 
};
MonitorPi n19();

prints the first print statement but never seems to read the pin when hit so never get the pin 19 changed message..

You were right the led in the homing was set to blink so fixed now...

Thanks gary
Logged
gburk
Full Member
***
Posts: 133


View Profile
« Reply #33 on: December 09, 2018, 01:02:30 PM »

Art

Tried the relays as your post but doesn't work,
m8 I get nothing no relays on and no printed message

m7 I get the printed message but no relays on

M9 I get the printed message but there isn't any relays on so don't know it that will turn them off..

in the script I first sent the relays did go on and off...
Not sure what the major change would have been to effect that..

Thanks gary
Logged
gburk
Full Member
***
Posts: 133


View Profile
« Reply #34 on: December 09, 2018, 01:54:52 PM »

I printer out the (desiredst ate)
and I get 3 when m8 is run
and also when I run m9 it seen to run twice first its = to 2 then it must run a second time and it = to 0;;

make sense?

But the relays still don't turn on makes no sense to me using the same MyMotion. SetRelay(MistRelay,1); command as the script I sent you
and mine turns them on and off... as far as I can tell the only differenc e is in mine its using the m8 as the relay number and looks like to # 3
so its sending #3 as the relay #

in your script its using 1 and 2..

//Set mist/flood control
//1 = mist m7, 3 = flood m8, 2 and 0 = off m9
global SetMistFl ood = function( desiredst ate )
{
   print("M Number = ",desiredstate);
   MistRelay = 1;
   FloodRela y = 2;
 
  if (desiredst ate == 1) //mist
{
    MyMotion. SetRelay(MistRelay,1);
    print("M7 Mist Relay Turned ON");
    GlobalSet("FloodOnLE D",1);
}
   if (desiredst ate == 3) //flood
{
    MyMotion. SetRelay(FloodRela y,1);
    print("M8 Flood Relay Turned ON");
    GlobalSet("FloodOnLE D",1);
}
   if (desiredst ate == 2) //flood,mist off
{
    MyMotion. SetRelay(MistRelay,0);
    MyMotion. SetRelay(FloodRela y,0);
    print("M9 Flood and Mist Relays Turned OFF");
    GlobalSet("FloodOnLE D",0);
    //GlobalSet("MistOnLED",0);
}
};
Logged
ArtF
Administrator
Hero Member
*****
Posts: 5280



View Profile
« Reply #35 on: December 09, 2018, 02:48:54 PM »

Hi Gary:

 I think we may be using differern t versions, I just refreshed the download to be sure so please reinstall auggie. If you changed
and screens but didnt rename them, do that first as it will overwrite changes you made to my screens.

   Hers is the script I just tested as working, But read on after..

global SetMistFl ood = function( state )
{
    //1 = CW, 2 = CCW, 0 = off
     
   
    if( state == 0)
      {
          Pokeys1.S etRelay(1,0);
          Pokeys1.S etRelay(2,0);
      }
     if( state == 1)
      {
          Pokeys1.S etRelay( 1,1 );
      }
      if( state == 2)
      {
          Pokeys1.S etRelay( 2,1 );
      }
 
print( "flood/mist state: " + state );
   
};

  The relays in a pokeys arent in bit order, so auggie sees them as different numbers.

auggies Relay 1 is Pokeys OC2
            Relay 2 is Pokeys OC1
            Relay 3 is Pokeys hard relay 1
            Relay 4 is Pokeys hard relay 2


   Now this script assumes a relay for mist, one for flood and turns them both off on m9. This is conventio nal with
some cnc systems where one relay turns on the mist pump, and the second speeds it up. M9 then turns off both relays.
I jst tested this and it seems to work fine.

Art
Logged
gburk
Full Member
***
Posts: 133


View Profile
« Reply #36 on: December 09, 2018, 06:53:33 PM »

That works now had a different version of auggie

do you think reading the pins may work now also, haven't tried that yet with this version..

Thanks gary
Logged
gburk
Full Member
***
Posts: 133


View Profile
« Reply #37 on: December 09, 2018, 07:24:30 PM »

nope pin state never seems to change
when first run it prints pin 19 check
but never seems to change the pinstate

global  MonitorPi n19 = function()
{
  while(1)
  {
    print("Pin 19 Check");
    block( "MotionPin 19");  //or you cold use IOPin9
   //
   //  when you reach here, its because pin9 has changed..
    pinstate = Pokeys1.G etPinDig(19); 
    if( pinstate == 1 )
    {
          print("Pin 19 Changed");
         //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.. .
    }
  }
};
MonitorPi n19();

Thanks gary
Logged
gburk
Full Member
***
Posts: 133


View Profile
« Reply #38 on: December 09, 2018, 07:59:57 PM »

sorry for all the messages
It almost seems like once auggie is booted it checks the pin 19 script then and not again...

this is what I have found I boot auggie pin 19 not shorted I get the message pin 19 change then pin 19 checked
if I boot auggie with pin 19 shorted I only get the message pin 19 checked

after the initial booting of auggie and received the message at boot
that's the end doesn't see a short or no short almost seems like its not running after auggies first boot

Gary
Logged
ArtF
Administrator
Hero Member
*****
Posts: 5280



View Profile
« Reply #39 on: December 09, 2018, 10:21:01 PM »

Hmm..

Does sound like a script that is stopping. The script you have shoudl be

global  MonitorPi n19 = function()
{
  while(1)
  {
    print("Pin 19 Check");
    block( "MotionPin 19");  //or you cold use IOPin9
   //
   //  when you reach here, its because pin9 has changed..
    pinstate = Pokeys1.G etPinDig(19); 
    print("Pin 19 Changed");
    //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.. .
   }

};

   Probably wont make a differenc e, but the == 1 is nbot needed to check for a change. So long as the block is signaled, you should
get a message. Ive been fighting some hardware issues, but Ill see if tomorrow I can find out why it may only run the once..

Art
Logged
gburk
Full Member
***
Posts: 133


View Profile
« Reply #40 on: December 10, 2018, 09:09:22 AM »

I tested without the if pinstate == 1 and I think it may be needed

when I booted auggie I got both printed messages pin 19 changed first then pin 19 check
it didn't matter if the pin was shorted or open same order of messages. ..

So I think it may be need if I remember correct when I had the pinstate == 1 check it would switch the order of the printed message depending if the pin was shorted or open

Gary   
Logged
ArtF
Administrator
Hero Member
*****
Posts: 5280



View Profile
« Reply #41 on: December 10, 2018, 10:59:42 AM »

Hi Gary:

  I added thius to my motionio library..

global  MonitorPi n19 = function()
{
  while(1)
  {
    print("Pin 19 Check");
    block( "MotionPin 19");  //or you cold use IOPin9
   //
   //  when you reach here, its because pin9 has changed..
    pinstate = Pokeys1.G etPinDig(19); 
    print("Pin 19 Changed to state " + pinstate);
   
  }
};

  And though I cant yet hook up a pin19 to my system, I did config the pokeys so that pin19 is a digitial output.
I then changed the code in auggie so that as it reads the incoming pin states, it toggles pin19 to 0 as long
as the ctrl key is held, this allowed me to test the script. Its responds properly and shows the message that
the pin has toggled and its state.

  Take note though, that youd miss fast presses, this is a slow way to read an input, fine for switches and knobs
but youd never be able to probe with it, probing is a hardwired fucntion due to its complexit y and timing
requirmen ts. Ive checked on adding it, but it looks complex enough that I dont think its feasable for the
small amount of people that use auggie or would use it for probing.

Art
Logged
gburk
Full Member
***
Posts: 133


View Profile
« Reply #42 on: December 10, 2018, 06:02:27 PM »

I understan d thanks for giving it a shot let me know if anything changed

Gary
Logged
gburk
Full Member
***
Posts: 133


View Profile
« Reply #43 on: February 23, 2019, 05:08:13 PM »

I see you decided to give probing a try in the new release great...

Have a request to be added if possible as you progress with probing.

I have requested pokeys developer s to add some probing return codes for mach4's register's and they have done so not working correct yet but close..

Code that if probe is hit send a say 1 that can be read from a script or to the probe status register or -1 if no probe hit my reason for this is if probing for the center of a block
and you enter a distance that is to small, what I do is use a g31 not a g1 to move the probe down so if the probe returns a -1 I know probe wasn't hit
and then will do the move towards the part, but if I get a value of 1 I know the probe was hit going down and I am not off the block edge and I will send a message
stock size to small enter a lager size retract to start z Hight and back to we probe move x and y started.

I find doing this the probe doesn't crash into the part on the z down move..

make sense?

thanks art
gary     
Logged
ArtF
Administrator
Hero Member
*****
Posts: 5280



View Profile
« Reply #44 on: February 23, 2019, 05:27:04 PM »

Gary:

  That will be in the next release. After a G31 motion, you will be able to do something
like this..

Engine.GC ode("G31Z-20");
h = GlobalGet("Probehit");
if( h )
{
  px = GlobalGet("ProbeX"); //etc for each axis you wish to use..
}

   The probe hit variable will tell you if the probe actually hit.
It should be possible to easily script a button to do something like
find the center of a hole. I haven't done much testing with scripts
doing repetitiv e calls as yet, so be cautious about the use of G31,
it should now be safe for zeroing. I already get back a 1 or -1 for
hit or miss I just haven't passed them back to the user yet.

Art

 
Logged
Pages: 1 2 [3] 4 5 ... 18
  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!