reading Pokeys pins

C Scripting questions and answers
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

While normally all LEDs will have names that are different, when the system see's they have a variable name,
it doesnt try to rename them to different primary names. this has to do with the rather complex system of naming
which is necessary as various modules could share a led name internally. At startup various id's are checkled in
order and apparently it ignores the naming once it see's it has a variable name instead.  (Its been awhile since
Ive been in there..).
  I tested the script I posted, should work OK.. Still dont know why the block didnt work, more testing req

Art
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Yes Art That script seems to work my led will flash and also it will turn off..

Thanks gary

PS I'm sure I will be back for more advice

gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

New question go figure..

Is there a way to call a lib script from the button script...

Say I have a button it turns on the led and prints a message now in the same button script I want to call a script in the gcode lib like an mcode script I created Mcode330 or whatever ?

Thanks gary
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

You asked me to check the pokeys config program to see if pin 19 is being triggered and it is, still can't seem to get auggie to read a trigger on pin 19..

Thanks gary
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Sorry art another question problem even though I haven't sorted out reading pins but homing problem
I see the homing led lights up if I trigger the home switch but it keeps flashing while its tripped the led doesn't say lit but flashes

But the motor does stop and reverses direction I assume its back off  the problem when the motor reverses it never stops just keeps running
in the opposite direction I have soft limits off.. and switch untriggered now..

any suggestions how to stop the back off distance?...

Thanks gary
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

  You need to tell the pokeys to backoff the switch. Its a new setting in the pokeys engine config, if you test home on the
engine config page in Pokeys and it works, it should work the same in Auggie. Should be easier to test in the pokeys
software as it shows you what its doing on each stage.

Im doing some work in Auggie this week, Ill see what I can find on pin19, I need to hook one up to see..

  Art
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Thanks art did get homing working,
mad a little progress can make a new button and led and get buttons to turn on and off the led also can turn on a relay with button press..

Still haven't sorted out how to read a pin if trigged.

I tried to look at any scripts you have installed but couldn't fine one I know you reading pin triggers like turning on the homing led when hit but couldn't find the script you are using to do it looked at the all the scripts I could find...

Also is it normal for the homing led to blink on and off when the switch to not triggered mine seems to do that, but when its triggered it stays lite no flashing...
funny because I have been having the same problem with the probe led in mach3..

Thanks gary
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Hi Gary:


  Some functions like home are done by hardwire, there is no script. The pokeys for example reports homing as done or not and triggers
internal calls as its a priority function. The flashing shouldnt occur..doesnt here. Mine is either off or on. Ill take a look to see what may cause that symptom.

  For other inputs the software checks each pin and does an internal signal to Unblock using the words as we described earlier inj this thread. I just need to hook up something to trigger to see why it isnt calling you when the pin is triggered.

  Is it possible you wrote and forgot a script trying to light the home led? It woudl create a flashing as the system tried to reset it back to zero when not homed. Checking the software I cant fing anything to cause it to flash unless you checked an opion in its properties to tell it to flash when inactive
or something. (But its complex in there and I may be missing it..).

  When you actually home sucessfully, a signal is sent to scripts called "HomedAxis". So a block on "HomedAxis" should trip a script when a home occurs,
thought that doesnt tell you anything about which home it was. A call to GlobalGet( "Axis1Homed" ) will tell you if that axis is homed.

  You get a similar call when a pin goes active.. named MotionPin19 for example, though as I recall it can be off by a pin # as I used to count 0 as first pin.
I thought that changed but you may want to try "MotionPin18" or "MotionPin20" just in case soemthing is one off in there. Ill check this as soon
as I can get to hooking up a cable int here to use a pin.

Thx
Art
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

I noticed if I use m8 or m9 its calling SetMistFlood()

I changed the code to getrelay and if its on with setrelay the m8 seems to turn it on, but m9 doesn't I know is going though the function to the turn off relay I have it printing showing turning off but doesn't go off... if i call m8 again it shuts off,  i tried my own m8 call function but looks like the SetMistFlood() overrides it..

also i see variables IOpins setup in system variables But nothing for MotionIO would that matter when you are trying to get the MotionIO pin status

also i will try a different # if you start at 0 then i try 18..

I also didn't write any scrips to turn on or off homing or the leds..

Thanks gary
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

forgot I ran the pokey configuration and the home pin works ok led stays lite or stays off no flashing..

Thanks gary
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Hi Gary:

>>I noticed if I use m8 or m9 its calling SetMistFlood()

  Yes certain functions such as spindle, flood and mist are considered systemic and have their own script, it can be changed but not
replaced. Can you post the script your using for flood and mist, I may see something easier.

>>also i see variables IOpins setup in system variables But nothing for MotionIO would that matter when you are trying to get the MotionIO pin status

In the Motion library there is a global variable declared as Pokeys1 . global Pokeys1 = Motion();
So you shoudl be able to use

  PinState = Pokeys1.GetPinDig( 19 );



>>I also didn't write any scrips to turn on or off homing or the leds

  I cant understand why its flashing. It may be the screen set has that LED set to flash in its properties. Youd have to open the DROPanel screen from panels to see if its led properties are telling it to flash.

Art
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

//Set mist/flood control
//1 = mist, 2 = flood, 0 = off
global SetMistFlood = function( relayNumber )
{
    //Relay # 1-4
    //print("Flood change");

OnOrOff = MyMotion.GetRelay(relayNumber);
  if (OnOrOff == 0)
  {
  MyMotion.SetRelay(relayNumber,1);
  print("M8 Flood Relay Turned ON");
  GlobalSet("FloodOnLED",1);
  }
  else
    {
    MyMotion.SetRelay(relayNumber,0);
    print("M9 Flood Relay Turned OFF");
    GlobalSet("FloodOnLED",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
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

I believe the function gets a 0,1, or 2 in the parameters to indicate if this is an M7,m8 or M9. They way the commands for mist,flood work
is SetMistFlood(0) shoudl turn on whatever relay mist is contolling, 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( desiredstate )
{
   
  MistRelay = 1;
  FloodRelay = 2;


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

if (desiredstate == 1) //flood
{
    MyMotion. SetRelay(FloodRelay,1);
    print("M8 Flood Relay Turned ON");
  GlobalSet("FloodOnLED",1);
}

if (desiredstate == 2) //flood,mist off
{
    MyMotion. SetRelay(MistRelay,0);
    MyMotion. SetRelay(FloodRelay,0);
    print("M9 Flood and Mist Relays Turned ON");
    GlobalSet("FloodOnLED",0);
    GlobalSet("MistOnLED",0);
}
 
};

Art


 
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

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  MonitorPin19 = function()
{
  while(1)
  {
    print("Pin 19 Check");
    block( "MotionPiin19");  //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.. .
    }
  }

};
MonitorPin19();

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
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

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
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests