reading Pokeys pins

C Scripting questions and answers
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Art

>It was great. Jamaica is nice and hot this time of year
Probably hotter than here in Florida we have had a couple good weeks high 70's low to min 80's and not humid, only time of year I like being out but went and had rotators cuff surgery in late January so haven't done much since, this is the time of year I ride my horse and work in the garage, but not this year and if a few week to a month it will be to hot.. but then you'll be able to go out and do stuff and I'll be stuck inside :'(.     

> No, I meant the reason why you used to have to run the script before the button script would work..I
>was curious as to why that happened.

I'm not totally sure but I think, when I created a script folder and had the scripts off the folder tree then I checked the script but not the script's main folder also
is when I had to run them in the script window... I'm pretty sure I was just checking the script but not the scripts main folder... not a good exaptation hopefully you
can get what I'm trying to say.. 

> Yeah, a toolbox was one of those things I figured if one need sit, theres always Mach3 or 4..

Yes I figure if I can get a tool change to work, I will know what tool is in what position anyway just won't work for other people but something they could start from..

I seem to have problems with mach4 things work then I edit the screen now it busted a lot of times won't even boot anymore and makes no sense I don't change any of the scripts, had a hell of a time getting the spindle working in mach4, easy in mach3, after many headaches did get it working but I think I already stated this in another post  I used ob5(10) for motor 5 and and in the spindle setup set this to ob5(10) and used then set to pin 1 for step and pin 16 for dir it works spindle relay kicks on and speed adjusts fine.

Creating a dialog can't seem to find a command to AddDRo is that in auggie? I see AddButton and many others are there.

also I have a dialog created  and ended with WaitDialog.DoModeless("none"); and also a button that call another global function this works great, now if I am in the called global function and I want to add or change the Addstatictext lines is that possible. I haven't been able to figure it out.. WaitDialog.AddStaticText doesn't seem to work..
in the function call from the button..

also I don't think the dialog is being killed I have a button that calls a dialog, now that dialog has a button that calls a function if there is an error the function calls another dialog, when I close the last dialog it go's back to the calling dialog but never finishes the function that was running before the error...
and now if I hit the stop or rewind the mdi doesn't react I have to hit EStop… is the dialog still running even though the window is closed?

Thanks gary
Last edited by gburk on Fri Apr 05, 2019 12:23 pm, edited 1 time in total.
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4648
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Hi Gary:

  I just uploaded version 3.6 of Auggie, it fixes your probing issues. I wasnt correctly setting the
engines current coordinate when you Used SetAxisPos(...).

  Getting your spindle to work shouldn't be too bad. If you use the pokeys to setup a PWM channel,
then tell Auggie to set that channel (in the Spindle on and off scripts) to a PWM % of 0 - 100%
with the SetPWMDuty script call it should pretty much do it. You will need to get the current spindle speed
and make whatever scaling you wish for your spindle to make it a demand of 0 - 100% though.

  Dialogs I haven't used in quite a while, but in looking to the code, when the script is deleted, the dialog is
closed and killed. If you close a dialog but are still in a script, it will not actually be deleted until the script
ends. I didn't envision a dialog being created in a script that never actually ends. So creating a new dialog
each time may fill you up in memory. Its possible anyway. There is no way to re display the dialog once
a user closes it. Its probably best to make a separate script that creates a dialog, waits while the user uses it,
then sets some globals your main script can read. It can then be called by your main script, it will close
and delete itself when it exits, and the main script never has to exit for the dialog to be deleted.

  Dialogs dont have DRO's, they are basically a windows dialog, and have text boxes, which can show numbers
so are kinda windows versions of DRO's.

  Im kinda impressed you got dialogs running, I figured they were more my own domain and YaNvrNo's as the complexity involved was higher than I figured any general user of Auggie would get to. YaNvrNo was the
main tester and retester in Auggies development so other than he or I some of the more esoteric
functions of Auggie I figured would never be used. Scripting in the Gcode for example is another one.


Anyway, test this latest version, I suspect your probe will work fine now, and I can tackle your spindle
or whatever thing your focusing on at the moment. :)

Thx
Art









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

Re: reading Pokeys pins

Post by gburk »

Art

Tested the new version it looks good, I have setup a panel with a few dro's Retract height, Travel distance, Touch Off plate thickness..
So I have changed there values a few times and it seems to probe ok and returns to Retract height consistently so if I probe to the Travel distance hit probe
then reset dro to Touch off plate thickness it has so far always reset to the right plate thickness, and now it will also retract to the retract height correctly..
probe to 2" hit probe at .75 then dro resets to .25 then retract to 1" now dro shows 1" so far every time..

As for the dialog I will try a better explanation!

I am working on doing a manual tool change
So I created a  DoModeless dialog because it doesn't lock up the gui and I can have the dialog on screen that displays a message to jog to a safe x y z position and also have a button (Z touch off) so after you have changed the tool you can put you touch off plate back on part and hit the button to probe the Z and reset the Z position for the new tool Hight. Problem is from the button I am calling a function to save all the work positions turn off the spindle and flood now call the Z touch to probe the Z
After the call to do the Z touch off it should return from when I called the z touch off, so I can reset the new z position  and jog back to the X Y Z original positions
turn on spindle and flood.
The problem I am having it doesn't seem to return to finish anything after the call to function Z touch off, doesn't complete script..
I have tried killing the dialog myself at end of script, but problem doing that its dead, so I have to run it again in the script edit run again..
Make any more sense?

Also I am back to the problem I thought was fixed, I have to run the probing script in the script edit run first or it won't run..
the strange thing is it seems to run the script, I have a few print statements in the script, they are being displayed but the motors and dros do not move
until I run the script in the script edit.. then motors and dros move..

Will worry about spindle later... just had some time on my hands so messed with dialogs

Did you think to check on how you could read the button id numbers?.

Here is an edit to message
I think the probing is working again without running the script first made one change not sure why it made it work again
If I didn't hit the probe and g31 ran to end of travel say 3", the script would not run again endless I reran it in the script edit, I have it sending the message probe not hit enter a higher value and returning a -2 so I added the code for the axis to return to the start of the probe position Right now its the Z height just before the return -2.
Now I don't have to run the script in the script edit anymore seems to run every button press...
Have any thoughts on that?


Thanks gary

   
   
Last edited by gburk on Sat Apr 06, 2019 1:57 pm, edited 1 time in total.
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4648
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

  You may have to post your dialog code so I can see it. I recommend any dialogs be made
as a library file of their own. Makes it easier to post for debugging or for others to use..

As to buttons as group buttons.. Here is the method I have used. You have to use a script
to initialize your buttons as a group..

Imagine I have 3 buttons and their ID's on your screen are Main_BUT_1 , 2 ,3 and 4.

First we identify a master of the group. We'll use button #1 here..

global MPG1group = Button("Main_BUT_1");


  Now we tell Auggie to add the rest of the buttons to our group, meaning only 1 may be pressed
at any time and one will always be pressed. ( Like selecting modes or axis)..

for( x = 2; x < 4; x = x + 1)
{&nbsp; //connect each button as a slave of this master
&nbsp; &nbsp; MPG1group.SetGroup("Main_BUT_" + x);
}

//finally set the state of the group

MPG1group.SetState(0); //this turns on the first button, all buttons should now act as
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // a group of buttons, one turning off all others when it turns on.

Note:&nbsp; Set all buttons to non-toggle button so the state toggle each press.

&nbsp; You can see this work in the MPG panel stored in the example panels.

Art




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

Re: reading Pokeys pins

Post by gburk »

Hi Art

Here is a mess not good looking code but been hacking it up and down, don't know if you will be able to follow it with not all the peace's I am going to zip up my
scripts and panels and hopefully post a link for you to download the hole mess..

So back to the buttons should I give them a id number and a variable name? or just leave the button named as there default names..?

I have tried to look at the scripts for jog panel I assume that's the mpg you are referring to but they don't show up in the scripter so you I may need a little help finding them how about a auggie for dummies doc.&nbsp; ???

// Library Toolwait
// Created&nbsp; Thursday, April 04, 2019
// Author&nbsp; Gary&nbsp; &nbsp; &nbsp; -- Do not edit above this line
&nbsp;
//&nbsp; Enter Global vars below this line.
//&nbsp; the librarian no matter where they are, but its easier
//&nbsp; to find and edit them in one spot.
&nbsp;
&nbsp;
&nbsp;
//The 6 lines previous to a function will appear as&nbsp;
//comments to help users to understand the parameters&nbsp;
//required for use by each function, so try to&nbsp;
//always add as clear a set of instructions in these&nbsp;
//lines as an aid to fellow travellers.&nbsp;
//&nbsp;
global WaitDialog = Dialog();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
global ToolWait = function()
{
if ( WaitDialog != null )
{
&nbsp; if ( WaitDialog.IsOpen() )
&nbsp; {
&nbsp; return;
&nbsp; };
};

//global WaitDialog = Dialog();

WaitDialog.SetRect( 25, 20 );
WaitDialog.SetTitle( "Maunal Tool Change " );
WaitDialog.NextPosition( 5,5,80,50 );
WaitDialog.AddStaticText( " Manual Tool Change now Jog to a safe X Y Z Position");
WaitDialog.NextPosition( 5,15,80,50 );
WaitDialog.AddStaticText( " After new Tool is Inserted&nbsp; PRESS Touch OFF Z");
WaitDialog.NextPosition( 40,50,60,70 );
WaitDialog.SystemButtonsOnOff(false);
WaitDialog.AddButton("Touch OFF Z","MyToolChange");
WaitDialog.DoModeless("none");
};

global ProbeErrorDialog = Dialog();
global MyToolChange = function()
{
Touch_OFF = ZTouchOFF();
yield();
&nbsp; print("Touchoff 4 "+Touch_OFF);
if (Touch_OFF == -1 || Touch_OFF == -2 || Touch_OFF == -3 )
{
if ( ProbeErrorDialog != null )
{
&nbsp; if ( ProbeErrorDialog.IsOpen() )
&nbsp; {
&nbsp; return;
&nbsp; };
};
//&nbsp; global ProbeErrorDialog = Dialog();
&nbsp; ProbeErrorDialog.SetRect( 15, 10 );
&nbsp; ProbeErrorDialog.SetTitle( "Probe Error " );
&nbsp; ProbeErrorDialog.NextPosition( 5,5,80,50 );
&nbsp; if (Touch_OFF == -2)
&nbsp; {
&nbsp; &nbsp; ProbeErrorDialog.AddStaticText( "Error Probe not HIT Try jogging closer to Part");
&nbsp; }
&nbsp; &nbsp; else if (Touch_OFF == -3)
&nbsp; &nbsp; {
&nbsp; &nbsp; ProbeErrorDialog.AddStaticText( "Error Probe");
&nbsp; &nbsp; }
&nbsp; &nbsp; else if (Touch_OFF == -1)
&nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; ProbeErrorDialog.AddStaticText( "Error Probe not known");
&nbsp; &nbsp; };
&nbsp; ProbeErrorDialog.DoModal("none");
&nbsp; return;
&nbsp; }
&nbsp; return;
};

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

Re: reading Pokeys pins

Post by ArtF »

Gary:

Thx, Ill check the dialog to see what I think.

For the buttons example, the MPG panel, you can use the screen loader to load the MPG.panel,
once loaded if you open the scripter and checkout the main init script for that panel youll
see how the buttons are joined together.

&nbsp; You dont need to do this in an init script stored in the panel or screen though, thats just
how I used to do it. Id set each Button with an ID name. Then once your screen is loaded, look
at the name the editor gives you because it may decorate the name with MAIN_ as it loads.

&nbsp; Then in a library script make a global function that uses SetGroup and such to define those
buttons as being joined. Right after defining that function, call it.

ex: (assuming the end name of the buttons are Main_MYTOOLBUTS_1 through 4)

global MYgroup = Button("Main_MYTOOLBUTS_ 1");

Global MyGroupofButtons = function()
{

&nbsp; &nbsp; for( x = 2; x < 5; x = x + 1)
&nbsp; {&nbsp; //connect each button as a slave of this master
&nbsp; &nbsp; &nbsp; MYgroup.SetGroup ("Main_MYTOOLBUTS_" + x);
&nbsp; }

&nbsp; MYgroup .SetState (0); //this turns on the first button, all buttons should now act as
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // a group of buttons, one turning off all others when it turns on.
}

MyGroupofButtons();&nbsp; //now call it&nbsp; right after defining it so its in effect from the start


global Main_MYTOOLBUTS_1 = function( state )
{
&nbsp; &nbsp; if( state) dothis
&nbsp; &nbsp; else
&nbsp; &nbsp; dothis
}


&nbsp; You may now make scripts named as the buttons ID name and they will be called
when a button is pressed, and all other buttons will turn off. Above is untested, just out
of mind but its how it should work.

Art


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

Re: reading Pokeys pins

Post by gburk »

Art

Tested out the buttons a bit, not having any luck,&nbsp; I have 16 buttons and it seems like auggie has named them all the same "ToolChanger_BUT_0" with or without a name var, I tried with a var name of tool1 to tool16 got the same results...

You said load the mpg as a screen don't see how to load the panel as a screen and I don't see a mpg panel or screen the only panel with mpg is the jogpanel..

also can auggie return 4 values from a function I seem to get compile errors when I am trying to return 4 values, like return x,y,z,a; ?

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

Re: reading Pokeys pins

Post by ArtF »

Gary:

&nbsp; Ill check the buttons tomorrow to see why the numbers are sticking .. It is possible I didnt
include the MPG panel in the release, Ill check that too.
&nbsp; The buttons shouldnt have the same ID, I think you need to set each button to a different
ID number as you create them. Ill run a test and see.. You should be able to just enter an ID number instead of a variable name as you make the button.

&nbsp; You cannot return&nbsp; more than 1 item from a function unless the item is a table of values.
You can set multiple globals while in the script though....

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

Re: reading Pokeys pins

Post by gburk »

Hi Art

I figured that&nbsp; when you created a button and could give it an id name and id number there would be a way to retrieve either or both

This is what i had in mind but i am assumming the button id number can not be read.
Button.IDnumber is there just for example, Make any sense
All the button tool id names are Tool1 and idNumbers from 1 - 16
so all tool names are the same so doesn't matter what button that's pressed it will go to the same function but with its own id number the only one on the stack..
it could be read..

//Get button ID Number

global Tool1 = function( state )

{

&nbsp; Tool = Button.IDNumber("Tool1")&nbsp; &nbsp;
&nbsp; switch( Tool )
&nbsp; &nbsp;
{
&nbsp; &nbsp; &nbsp; &nbsp;
case 1:
{
//Too11
return;
}&nbsp; &nbsp; &nbsp; &nbsp;
case 2:
{
//Tool2
return;
}
case 3:
{
&nbsp; //Tool3
return;
}



};
};

just rambling on and on :-\

ok I will try it as a table I have had some trouble when setting global var they seem to want to change back to what its value when declared at originally&nbsp; I will also try that again,

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

Re: reading Pokeys pins

Post by ArtF »

Gary:

&nbsp; Unfortunatley the way the buttons are joined is simply a mechanism to ensure other buttons
in the group turn off so that one button is always exclusively on in the group.
You still need a script for each button as there is no way to tell which one was pressed other
than it calls its own script. Each script though could set a global to a set number, and then call
the same function as all the other buttons where it does a switch statement on that global.

&nbsp; I know it seems like a lot of scripts, but their really all the same with the minor change of what
the script sets the global to. Scripts dont take much memory so having lots of them doesnt really
run into troubles in my experience so far.

&nbsp; Globals will get set back if the scripting system resets. Doesnt usually happen during use, but
when editing and checking in scripts and such a global reset occurs and the scripting system
will reinitialize back to its original state with the declared variables.

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

Re: reading Pokeys pins

Post by gburk »

Yes I kind of figured that not a big problem... just running though my head,,

I did notice a funny thing with the dialog when I run the first dialog with the touch off button and let it run to the end I will get the error dialog close out the error box and hit the ztouch button again same thing let it run to error now the second time it displays the error dialog it has 2 of the ok buttons and 2 of the cancel buttons displayed.. Strange

I tried the return mytable; that seems to work fine...

The only problem with buttons is auggie only giving them all the same name all 16 are ToolChange_BUT_0

I am planning on connecting to mill tomorrow and see how the z probing works in real life..

But now I seem to have the problem again with having to run the probe script in the edit run first.. I thing I did say it seems to run all my print statements and are shown on screen in the probe script
but no motor movement till I run the script in the script run..
Also is doing the same thing in any of the button toolchange scripts.

and tried setting up FreeFeed to move 6 and 7 they move but dro's are not moving to entered feed to position and I always get a buffer over run or under run forget which one.



Thanks gary
Last edited by gburk on Mon Apr 08, 2019 1:42 pm, edited 1 time in total.
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4648
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

>>The only problem with buttons is auggie only giving them all the same name all 16 are ToolChang e_BUT_0


Did you set the ID numbers to numbers 1 - 16, the _0 shoudl be _1 , _2 etc is the id numbers are set...

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

Re: reading Pokeys pins

Post by gburk »

No I removed the id numbers and added the id names, that works I can call the button function with the id name and all have a different name..
but still have to run the script first before I hit a button almost seems if you don't run it in the script edit first the Engine.code isn't run it will show all the print statements in that script but no motor movement..

I am finding more g code errors seems to mostly be this type of code
on different lines.. also looks like its being displayed incorrectly on the screen slots and holes in wrong places..
would you like a copy of the complete g code file?.. to look at
Error--44,&nbsp; N2205 G2&nbsp; Y-1.0185&nbsp; I0.0000&nbsp; J-0.0895

also here is the code I am getting buffer underrun
//Engine.FreeSetAxisType( 6, 0 );
&nbsp; //Engine.FreeSetAxisType( 7, 0 );
&nbsp; //Engine.FreeFeed( null, RackMovein, RackRotate, null);
&nbsp; //block("MotionStill");

can I use 8 dro's and run all 8 motors from the main dro's and home? or do I have to rub from freeaxis I only see home and zero 1-4?.

Thanks gary

Last edited by gburk on Tue Apr 09, 2019 11:48 am, edited 1 time in total.
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4648
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

&nbsp; >>it will show all the print statement s in that script but no motor movement. .

&nbsp; Have you jogged and such before pressing the button? By&nbsp; that I mean do we know all motor motions are
working prior to the button being pressed? Im just trying to figure out why no motion is occuring, its
as if there is some condition stopping it from running the motions if the print statements are happening.

Error 44 is&nbsp; "Radius different from start and end in Arc" , this almost always means a mismatch
in incremental vs absolute arc settings. Does the code have a G90.1 in it for abs or G91.1 for incremental
in it? You may need to add it to your postprocessor depending on your arc generation. Post
your Gcode file and Ill check what errors I get.. or add G90.1 to the file and see if it, or G91.1 fixes those
G2/G3 errors.

>>also here is the code I am getting buffer underrun
//Engine.FreeSetAxisType( 6, 0 );
&nbsp; //Engine.FreeSetAxisType( 7, 0 );
&nbsp; //Engine.FreeFeed( null, RackMovei n, RackRotat e, null);
&nbsp; //block("MotionSti ll");

&nbsp; This one is my fault. I recently sped up Auggies engine by
slowing threads when the trajectory buffers were empty. I neglected
to look at the FreeTrajectories as well, so any free motion fails at the moment. I fixed
this as I found the reason and my system runs the above commands
fine. I will recompile a release for you tomorrow that fixes the free axis
planner.&nbsp; You can use FreeSetWorkPos(..) to set a zero on any free axis.
&nbsp; You can drive all 8 motors if you wish, BUT, the two planners,
one for axis 0-4 and the other for axis 5-8 are separate planners. They act
independantly so one has no idea what the other is doing. They are fine for
tool changers or conveyors and such but you cannot do synced motion
between the two. I think home will work with free axis if they are properly
set up to use home switches.

Art








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

Re: reading Pokeys pins

Post by gburk »

Art

Ok I only want to use the freeaxis's for hopefully later on if we can figure out how to set motor 5 for spindle, I plan on using 6 and 7 for the auto tool changer positions.

I did get it to move on motor 6 and 7 but like I said I have buffer underrun error's, and doesn't move to the correct entered distances..
and if I rapid the x y z and free rapid 6 and 7 they all move and after all axis's reach there final distance, then I will do a rapid to return to start position only with x y z but the 6 and 7 also move back with the x y z it seems like a random distance.. hopefully that's part of the problems you said should be fixed...&nbsp;

also I if I print out zeroing axis numbers when I zero Y it shows axis number 4 and when I zero A it show axis number 8, X and Z seem to be the correct numbers being sent to your script updating onzero ..

didn't get it hooked up to my mill today forgot I hadn't wired the estop switch yet, but got that working today, and auggie reads it, so if thing go array I can kill it now.

Thanks gary

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest