Global Variable Access within mapp Robotics / NC interpreted .st files

I am working in Automation Studio 4.12 and using an .st file to define robot movements (similar to G-Code/Motion programs).

The Problem: I need to modify a variable inside this robot program from a separate cyclic PLC task (e.g., a background logic task). I have declared a variable in the Global.var table, but when I try to reference it inside the robotics .st file, I get a compiler error stating the variable is not recognized.

Context:

  • The .st file is assigned to a Motion Group (mapp Robotics), not a standard Cyclic Task.

  • I want to be able to pass dynamic values (like speed overrides or target coordinates) from my main HMI/Logic tasks into the robot sequence.

  • Currently, the robot program only seems to recognize variables declared locally or specific motion parameters.

Questions:

  1. How do I correctly reference Global Variables within an interpreted Motion/Robot script?

  2. Is there a specific configuration required in the “Software Configuration” or “Program Package” to make these variables visible to the motion interpreter?

  3. Should I be using a specific structure (like a PV alias) to bridge the gap between the PLC cyclic world and the Motion world?

Hello,

By searching through the help this link could help you.

1 Like

@pavel.vavra I didn’t use .st so far but normally in my cnc application with mapp Motion I configure all variables in a axesgroup feature “CNC & robotics program“:

Can we do the same with .st?
Thanks
Ciao
Valerio

@valerio.manenti
There is no need to configure the variables in “Feature_Programs”. When using Structured Text, you can read them directly in the Motion Program.

In my case, it is a local variable:

Note: The file extension is .txt because .st files containing VAR / END_VAR are not allowed in the project structure.

2 Likes

This is interesting @simon.buschor , I see in the help the same way to define plc variable inside the cnc program and no link to the Axesgroup feature:

So why R&D developed that Axesgroup feature for the variable declaration?
Maybe some customers prefer to declare all variables in one single point inside the axesgroup feature and not redefine them in each cnc program…I guess.

Thanks
Ciao
Valerio

1 Like

Thanks, this exactly what I was looking for.

but, The variable value inside the motion program only updates once when the program starts. If I change the Global Variable via a Watch Window or another PLC task while the robot is running a loop, the value inside the robot script remains at its initial state.
How do I force the motion interpreter to read the “live” value of a PLC variable during every cycle or movement command?

Thanks
Regards
Hasan

Hi @Hasan_Dzulfadli
there are few pages in the help with examples for the Synchronization
Ciao
Valerio

Hello Hasan,

The Motion-Programs which are executed by the Interpreter have two execution Pointers.

Interpreter Pointer → This is the execution which reads the file ahead and prepares the Movement Planing. In this context the Variable will normaly be resolved with its value and put in the Puffer to Plan the Movement. This Pointer can be several lines ahead and if you have a loop, it can be also some loop rounds ahead.

Path Generator Pointer → This is the execution of the interpolation and takes time due to the movement. It executes the movement in real time and uses the Data from the Planing Puffer. (it looks like its old variable data)

If you wait long enought you should recognice that the new Variable value is used. If all the Pufferdata went throught.
Having these two execution mechanisms is a major difference to how normal ST in PLC will be executed.

The access to the Data in the Interpreter is like a Pointer access, immediat to the memory.
To have a immediate change to the system, you have to stop the interpreter to not have data in the Buffer. Because the Data in the Buffer will not change.

This is were the Synchronisations Commands Valerio pointet to come into place.

Example:

  • “WaitEndMove” This will Stop the Interpreter until all previous movements are done
  • The Buffer will run empty and does not have further old variables in it.
  • Movement Stops because there is no Geometry data in Buffer
  • Interpreter gets released and continues to fill data now
  • Variable gets modified
  • Next movement uses modified Value
  • Movement continues
WaitEndMove
P1.Pos.X := PLCVariable
MoveLR(P1);

Currently (Mapp6.5) you can not delete Data which is in the Motion-Buffer. Which makes this updating a tricky one. It basicaly leads to the point that you can only interpret data as long as you know the data is valid. If you expect a value to change you should wait and not put it jet in the buffer. This makes synchronisation bit tricky.

There are more advanced posibilities like WaitALAP…

Greetings
Michael

2 Likes