GlobalGet and var Name

Discussions and file drops for Auggie
MaynardC
Old Timer
Posts: 35
Joined: Wed Feb 27, 2013 4:28 am

GlobalGet and var Name

Post by MaynardC »

Hello All,
Have my 57CNC up and running with Auggie, powering a stepper on Axis 6 on the benchtop. I haven't been able to find an explanation of Control property Var Name in any of the discussions. It seems to bind the value property of an DRO to the assigned name, not sure about other controls. Anybody have a brief explanation of how Var Name works and the modes of operation for each Axis?

A long the same lines, I would like to get the current position of axis 6,as I jog along.Tried GlobalGet("Axis6CurPos") but returns 0 always.

Code: Select all

FreeSetAxisMode(6,1); 
FreeSetSpeed(6,500);
count=0;
while(1) {
  if(count%30==0) {
    print(GlobalGet("Axis6CurPos")); // always 0
  }
  count=count+1;
  yield();
}
Thanks
Maynard

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

Re: GlobalGet and var Name

Post by ArtF »

Hi Maynard:

 

  A DRO, Button or whatever, may be set to a Var name. If its empty, then the DRO is refered to only by getting its interface
in a script as in

  myDro = DRO("MAIN_DRO_1");
 
v = myDro.GetCurrent(); //etc..

    as shown in the first video, BUT, if you place a variable name in the VarName, the control
becomes a new variable, OR attaches to one already existing. For exmaple, to show the system current feedrate, one only needs to
tell the DRO is a var name of "FeedRate".  Most of the controls on the release screen are variable named to internal names, so really
they are attaching to variables declared internally. So if you want to find a value you dont know how to get, simply open the
scripter, turn it on, then right click any control that shows what you want, if you click the FreeAxis A position ( axis 8), youll see
its a var name of "Axis8CurPos", unfortunatley , youd have to open the freeaxis panel to see that as the scripter
and the editor will not show that for a panel control.

  So when you see such a variable, that means it is a global one, so in a script you may use

current8 = GlobalGet("Axis8CurPos");

  If you enter a varname you make up, like "Toyota" in a DRO, then you may send or gets its value with GlobalGet and GlobalSet
as by naming it, you have created a global value all scripts can see.

  Thats the short version of how variables work.

  As to the FreeAxis, they work any of them can be speed or postion based, you canot switch their mode while moving them.
So set them once and dont change them unless they are stopped. Mode 0 is position, mode 1 is speed. When in speed
any speed set is in units/min .  Any not in speed mode, are considered to be in position mode. Any speed axis is ignored
for a FreeFeedTo move. I will be adding a vector3 based call for getting the x,y,z of the free axis in one call.




Art
MaynardC
Old Timer
Posts: 35
Joined: Wed Feb 27, 2013 4:28 am

Re: GlobalGet and var Name

Post by MaynardC »

Thanks for the explanation, Art

Should a Free axis in Speed mode show it's position via GlobalGet("Axis6CurPos")?
I place a new DRO on the screen with Var Name set to Axis6CurPos ... and it stays at 0 as I jog Axis 6
When Var Name is changed to Axis6Vel ... it shows the correct velocity of axis 6 in the  DRO
Seems Axis6CurPos isn't working

Maynard
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4591
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: GlobalGet and var Name

Post by ArtF »

Maynard:

  No, an Axis in free mode will not show a position, this is to reflect the fact it is
capable only of velocity, AND to reflect the fact the other 4 axis are still in
a coordinate system just that any speed axis will always read zero as a potion..

Art
MaynardC
Old Timer
Posts: 35
Joined: Wed Feb 27, 2013 4:28 am

Re: GlobalGet and var Name

Post by MaynardC »

I'm driving a conveyor of sorts, and need the position as I drive it. I moved it back to one of the first four axis's,and used the Jog*P/Jog*M to move it. Couldn't get the Jog to work on the Free axis.

Thanks for the insight
Maynard

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

Re: GlobalGet and var Name

Post by ArtF »

HI Maynard

Jogging cant be done to a free axis.. BUT, I can see where youd want to know a conveyor location..
so Ill add a global for free speed axis locations..

Art
MaynardC
Old Timer
Posts: 35
Joined: Wed Feb 27, 2013 4:28 am

Re: GlobalGet and var Name

Post by MaynardC »

Thanks Art

Maynard
Ya-Nvr-No
Old Timer
Posts: 188
Joined: Wed Sep 08, 2010 11:15 am

Re: GlobalGet and var Name

Post by Ya-Nvr-No »

Could you not just compute the number of steps sent, as where it should be at after homing & zeroing? Then update the DRO the computed value? (send it toward home when it sees the limit it sets zero position)

It takes so many pulses per unit and that step value should beable to tell your where your at.
Then just update the DRO as to that value.
MaynardC
Old Timer
Posts: 35
Joined: Wed Feb 27, 2013 4:28 am

Re: GlobalGet and var Name

Post by MaynardC »

How would I access the settings (Steps/unit) ,and get notified when homing/zeroing occurred. You would also have to allow for accel/decel, which I believe is handled on Pokeys in speed mode.  On the same note, I can see the global functions from the drop down list in the scripting debugger, but is there a way to see there parameters?
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4591
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: GlobalGet and var Name

Post by ArtF »

HI Maynard:

  In the next version will be able to use Engine.SetPosition to set any of the 8 axis positions.
I will also allow for a call to get the positions of any "speed" axis.

  TO be notified of homing , limits and Zeroing, you will be able to use a kernal callback function in the library
which will (hopefully) also appear in the next version. The callback library should be modified by you to do
any activity you wish for the events named by the callback. Such as OnEnable() or OnZero(axis).. As users determine they wish to be notified of various internal events, I will add callbacks for that notification.

  Many other things you will use a block to get notification for. For example, there is no sense updating
a DRO constantly from a loop using up system time and resources.. so the new signal named MotionUpdate will allow
a script to only do its work after the axis have moves, and no more than 4 times a second by using a script such as

global MyDROUpdate = function()
{
    GoPara(); //this function will run in parallel in the system
    while(1)
  {
        block("MotionUpdate");
      //update your dro's here, they will update no more than 4 times a second, and only after motion..
  }
};

  You would put such a function in one of your libraries, ( because mine get overwritten on install), and then
in  a mainscreen init script, call

thread( MyDROUpdate); //this will spin this function off into space to work in the background..

  Ill explain more on next release, within a few days..many bugs have been scratched from the ground..

Art
Joakim
Old Timer
Posts: 56
Joined: Mon Sep 17, 2012 5:48 am

Re: GlobalGet and var Name

Post by Joakim »

Code: Select all

GoPara(); //this function will run in parallel in the system
Is the GoPare() needed (and what is it doing)?
I was of the impression that the call thread() would make the function MyDROUpdate execute on a new thread. Maybe combined with a yield() to force a context switch.

Code: Select all

thread( MyDROUpdate); //this will spin this function off into space to work in the backgroun d..
It is properly me, not understanding how threading works in script...  :D
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4591
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: GlobalGet and var Name

Post by ArtF »

Hi Joakim:

>>Is the GoPara() needed (and what is it doing)? I was of the impression that the call thread() would...

  Its really just a matter of my not explaining this well as yet. If you were to call

thread( MyUpdateLoop);

                    in a screen init script and never call it from Gcode, then the
GoPara(); would not be required. But having it there, allows it to also be used in a
Gcode program without the thread command. So while, when placed in a screen script,
it isnt used, when placed in the Gcode, its a way to tell the system not to hold program
flow while that script runs.

  To put it another way, imagine you wish to only run a particular update loop
in the context of a particular type of Gcode program. As in

G1X10Y10
G1Z5
{ StartSpindleMonitor(); }
G0X0Y0
...

  The script StartSpindleMonitor is run , but as its in Gcode, its assumed
the following move to G0X0Y0 will be held back until the script completes.
After all , a script may intend to make a great deal of motion to do a task required
before the following Gcode.

By starting the script with GoPara(); it tells the GCode processor to start the Spindle
monitoring, but continue with Gcode without waiting. So GoPara(); is really just a
way for you to say "Run this in Parallel, not in sequence. ".

  This has no real meaning when called from a button or screen script, and will
be ignored. SO whether you call a routine directly,

DoLoop();

  or Thread it off into space..

thread(DoLoop);

  or ,make it run from Gcode in parallel with a GoPara inside..

global DoLoop = function() { GoPara(); ...

  depends on how you want that script to operate. Auggie
allows pretty much complete control and these allow you to
decide just how a script will behave.

    My goal here is to allow the designer to control program flow in
various ways, since one can have up to 11 axis in total if one includes
3 axis in the secondary pokeys, it may be important to have many parallel
processes at play. Commands like thread() and GoPara() as well as
the various block signals will, once fully implemented allow a person
with an understanding of how the system execution flows, to make a very
complex logical relationship to the machine and its operation.

Art

   
Joakim
Old Timer
Posts: 56
Joined: Mon Sep 17, 2012 5:48 am

Re: GlobalGet and var Name

Post by Joakim »

So the Gcode:

G1X10Y10
G1Z5
{ thread( StartSpindleMonitor() ); }
G0X0Y0
...

Would be legal and run StartSpindleMonitor() in parallel with in Gcode and

G1X10Y10
G1Z5
{ StartSpindleMonitor(); }
G0X0Y0
...

requires the GoPara() in StartSpindleMonitor() to do the same. GoPara() has no effect outside Gcode.
GoPara must be something like:

global GoPara = function {
  if (RunningInGcode()) { // RunningInGcode() returns true if we are running in Gcode
    yield(); // Go parallel
  }
}

Hope it's not stupid questions.

Really like threading and the potential when used properly... I lot easier to make control loops this way.
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4591
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: GlobalGet and var Name

Post by ArtF »

Hi J:

"So the GCode:
 G1X10Y10
 G1Z5
 { thread( StartSpindleMonitor() ); }  
  G0X0Y0"
...Would be legal and run StartSpindleMonitor() in parallel with in Gcode?"


 No. While "thread" will start SpindleMonitor under its own parallel system,
unless GoPara() in is that script, the Gcode will wait for it to finish..

 Think of it this way..

  A script is itself like a small Gcode program, if, in its line by line execution,
it see's a call like thread(myroutine), it tells the system to run myroutine()
but not wait for the result.

 Gcode, is like a string of scripts, and if, in its linear run of command, it runs
a script. That script is given an ID number, the system is told to wait till that scriptID
is complete before running the next GCode line. GoPara(), when it is interpreted,
asks the system to zero the Script ID its waiting for, stop waiting, store the ScriptID
in an infinite array called ParallelThreads, ( who's DRO on the screen shows how many
are in it.), and the Gcode continues immediately upon seeing the GoPara().

  This is important, because the Gcode will continue as soon as it see's GoPara(), so where you
place it in the script can be ( but not always is) important. If you need to do something
important before the Gcode continues, put the GoPara in the script after the
important thing is done.

 The StopPara's button on the screen, stops all parallel threads. It might be called also
by a script in an M30 call, thus stopping any number of parallel threads you may have
started in the run of the program. Since you can use logic to start such scripts,
the number running may be unknown, so StopPara would stop all threads the program started.

 This too is important because you may not know beforehand how many threads and
which ones may be running at end of program.

g1x20y60
{ if ( GlobalGet("Feedrate") < 500 ) {CallMySpindeCoolerMonitor(); }; }
...

&nbsp; If indeed CallMySpindleMonitor() started, which would only happen
if the spindle is under 500 RPM, and it had GoPara in it, then thats another
thread in the parallels list, but the designer of the program would have
no prior knowledge that it WILL run, just that it may. SO at the end, a
call
to StopParas would kill all that happen to run..

&nbsp; ( I havent given you a script command to kill Paras yet, you need to press the button.)

Art




Last edited by ArtF on Fri Jan 22, 2016 2:23 am, edited 1 time in total.
Joakim
Old Timer
Posts: 56
Joined: Mon Sep 17, 2012 5:48 am

Re: GlobalGet and var Name

Post by Joakim »

I see - things are more complex. Forgot about keeping track of thread IDs and managing them in Gcode.
Trying to get a picture of the internal architecture&nbsp; :D
Post Reply

Who is online

Users browsing this forum: No registered users and 76 guests