0% found this document useful (0 votes)
111 views4 pages

Virtual Axis Monitoring Motion

The document discusses using a virtual axis in motion control applications to continuously monitor the status of programmed motion. It provides two scenarios where a virtual axis executes the same moves as real axes to report the percentage of each move completed through a variable in shared memory. The first scenario adds a virtual axis move to each real move commanded by the host. The second puts the addition of virtual axis moves into motion subroutines called by G-code commands.

Uploaded by

bhageshl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
111 views4 pages

Virtual Axis Monitoring Motion

The document discusses using a virtual axis in motion control applications to continuously monitor the status of programmed motion. It provides two scenarios where a virtual axis executes the same moves as real axes to report the percentage of each move completed through a variable in shared memory. The first scenario adds a virtual axis move to each real move commanded by the host. The second puts the addition of virtual axis moves into motion subroutines called by G-code commands.

Uploaded by

bhageshl
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Application Note Nov-2004

Virtual Axis Monitoring Motion


There is a class of applications in which users desire some sort of continuous monitoring of the status of
the programmed motion. Often, this can easily be accomplished by creating a virtual axis and motor in
the Turbo PMAC that executes simultaneously with the real axes.
These examples show the use of an added virtual axis that is commanded along with the real axes to help
in monitoring the action of the motion program.
Scenario 1: Addition of a Unit Move by Host
In this scenario, the user wants to be able to easily monitor the percentage completion of each
programmed move, even if the move is sped up, slowed down, or stopped through operator intervention.
To facilitate this, we add a virtual axis V to the coordinate system, and assign it to an unused Turbo
PMAC motor. This virtual axis will do a move of unit length each programmed move, regardless of the
time for that move.
If the host adds the virtual-axis move command to each programmed move by appending a V1 onto each
programmed move command sent to Turbo PMAC, the implementation in Turbo PMAC is very simple.
The virtual axis is assigned to a motor in the same coordinate system, this motor is activated, and its
shutdown limits are disabled.
A simple PLC program continually monitors the instantaneous interpolated position of the virtual motor,
takes the remainder of this position value when divided by the length of the unit move (with the “%”
modulo operator), divides this remainder by the move length to normalize it into the 0.0 to 1.0 range, and
copies this into a floating-point register in dual-ported RAM, where the host computer can view it at will.
There are a couple of things that the user must watch out for in this approach. First, appending a V1 to
each move requires that the V-axis be in incremental mode, and the default mode for all axes is absolute
mode. Therefore, an INC(V) command must be given before the first move. In addition, if the user
desires that the real axes be changed between absolute and incremental modes, this must be done through
axis-specific commands (e.g. ABS(X,Y,Z) and INC(X,Y,Z) commands) rather than all-axis
commands (ABS and INC), which would change the V-axis as well. It is possible for these features to be
embedded into Turbo PMAC G-code subroutines; see the next scenario for an example.
Substitutions and Definitions
#define Mtr4CmdPos M461 ; Instantaneous cmd position reg
Mtr4CmdPos->D:$000208 ; Reg units of 1/(I408*32) cts
#define Mtr4YVScale M492 ; #4 V-axis scale factor
Mtr4YVScale->L:$000250
#define PercentComp M75 ; Completion reporting register
PercentComp->F:$060200 ; 32-bit float reg in DPRAM
#define Divisor P4000 ; Pre-computed operator
Coordinate System Setup
&1
#1->2000X ; Real X-axis
#2->2000Y ; Real Y-axis
#3->2000Z ; Real Z-axis
#4->100V ; Virtual axis in same C.S.
Virtual Motor Setup
I400=1 ; Activate calculations for #4
I411=0 ; Disable foll err fault for #4
I424=I424|$120000 ; Disable limits and amp fault
I480=1 ; Enabled immediately
PLC program to compute proportion of move finished and place this value in dual-ported RAM:
OPEN PLC 5 CLEAR

Virtual Axis Monitoring Motion 1


Nov-2004 Application Note

Divisor=I408*32*Mtr4YVScale ; Pre-compute for efficiency


WHILE (1<2) ; Loop indefinitely
PercentComp=(Mtr4CmdPos%Divisor)/Divisor
ENDWHILE
CLOSE
The following setup can be used to copy the commanded position of the virtual motor into the actual
position by reading the command position register like an absolute encoder. This is not necessary for the
functionality, but is useful to be able to monitor the virtual motor position in the Executive program. This
setup assumes that the first four lines of the conversion table (I8000 to I8003) are used for real feedback.
I408=1 ; So reg units are 1/32 count
I8004=$280208 ; Read #4 cmd pos reg as encoder
I8005=$018000 ; Use all 24 bits
I403=@I8005 ; Use result for #4 act pos
Scenario 2: Addition of a Unit Move by Turbo PMAC
In this scenario, the host computer does not append a V1 command to the end of each programmed move,
so Turbo PMAC does this itself. This makes the feature invisible to the algorithms creating and sending
the part program.
In this example, the addition of the virtual axis move is done within the context of G-code subroutines;
other approaches are possible. This example uses the setup of the previous scenario and adds the
following motion subroutines built into PROG 1000, so they are call-able by G-codes.
This example treats each move command as a subroutine call by the use of the PRELUDE statement,
which creates a subroutine call before each subsequent move command. The subroutine then reads the
move command as arguments. With this method, the move command must be either at the beginning of a
line, or immediately following a numeric line label.
An alternative strategy would be to precede each move command with the move-mode code G00, G01,
G02, or G03, and have the G-code subroutine itself read the move command as arguments.
Substitutions and Definitions
#define CS1XtargPos M5147 ; X-axis move-end position
CS1XTargPos->L:$002047
#define CS1YtargPos M5148 ; Y-axis move-end position
CS1XTargPos->L:$002048
#define CS1ZtargPos M5149 ; Z-axis move-end position
CS1XTargPos->L:$002049
#define CS1XaxisInc M5177 ; X-axis incremental mode
CS1XAxisInc->X:$002040,18,1 ; CS1 status bit
#define CS1YaxisInc M5178 ; Y-axis incremental mode
CS1YAxisInc->X:$002040,20,1 ; CS1 status bit
#define CS1ZaxisInc M5179 ; Z-axis incremental mode
CS1ZAxisInc->X:$002040,22,1 ; CS1 status bit
#define PassBits Q100 ; Bit mask for READ
#define Iarg Q109 ; Variable for I-argument
#define Jarg Q110 ; Variable for J-argument
#define Karg Q111 ; Variable for K-argument
#define Xarg Q124 ; Variable for X-argument
#define Yarg Q125 ; Variable for Y-argument
#define Zarg Q126 ; Variable for Z-argument
#define Ival 256 ; Value for passed I-argument
#define Jval 512 ; Value for passed J-argument
#define Kval 1024 ; Value for passed K-argument
#define Xval 16777216 ; Value for passed X-argument
#define Yval 33554332 ; Value for passed Y-argument
#define Zval 67108864 ; Value for passed Z-argument

2 Virtual Axis Monitoring Motion


Application Note Nov-2004

G-code Subroutine Program


OPEN PROG 1000 CLEAR ; G-code subprogram
N0 RAPID ; G00 is RAPID mode
INC(V) ; Make sure V is incremental
PRELUDE1 G00.1 ; Make moves a subroutine call
RETURN
N100 ; G00.1 subroutine
READ(X,Y,Z) ; End points into Q124,125,126
GOSUB 200 ; Check for end points sent
X(XArg)Y(YArg)Z(ZArg)V1 ; Append V-axis move
RETURN
N200 ; Check for end points passed
IF(PassBits&XVal=0) ; X argument not passed?
IF(CS1XAxisInc=1) XArg=0 ; No dest = zero incr distance
ELSE XArg=XTargPos ; No dest = same abs pos
ENDIF
IF(PassBits&YVal=0) ; Y argument not passed?
IF(CS1YAxisInc=1) YArg=0 ; No dest = zero incr distance
ELSE YArg=YTargPos ; No dest = same abs pos
ENDIF
IF(PassBits&ZVal=0) ; Z argument not passed?
IF(CS1ZAxisInc=1) ZArg=0 ; No dest = zero incr distance
ELSE ZArg=ZTargPos ; No dest = same abs pos
ENDIF
RETURN
Subroutine for Calculations on LINEAR and RAPID Moves
N1000 LINEAR ; G01 is LINEAR mode
INC(V) ; Make sure V is incremental
PRELUDE1 G00.1 ; Make moves a subroutine call
RETURN
N2000 CIRCLE1 ; G02 is CIRCLE1 (CW) mode
INC(V) ; Make sure V is incremental
PRELUDE1 G02.1 ; Make moves a subroutine call
RETURN
; Subroutine for calculations on CIRCLE1&2 moves
N2100 ; G02.1 subroutine
READ(X,Y,Z,I,J,K) ; End point into Q124,125,126
; Vector into Q109,110,111
GOSUB 200 ; Check for end points sent
IF(PassBits&IVal=0) IArg=0 ; No I-component set
IF(PassBits&JVal=0) JArg=0 ; No J-component set
IF(PassBits&KVal=0) KArg=0 ; No K-component set
X(XArg)Y(YArg)Z(ZArg)I(IArg)J(JArg)K(KArg)V1 ; Append V-axis move
RETURN
N3000 CIRCLE2 ; G03 is CIRCLE2 (CCW) mode
INC(V) ; Make sure V is incremental
PRELUDE1 G02.1 ; Make moves a subroutine call
RETURN
N90000 ABS(X,Y,Z) ; G90 is absolute real moves
RETURN
N91000 INC(X,Y,Z) ; G91 is incremental real moves
RETURN
CLOSE
Scenario 3: Addition of a Proportional-Length Move by Turbo PMAC
In this scenario, the added virtual-axis move is proportional in length to the vector distance of the real
programmed move. In this case, the velocity of the virtual axis will be constant if the program is executing

Virtual Axis Monitoring Motion 3


Nov-2004 Application Note

at the programmed speed, but the velocity will be proportional to the override of the coordinate system,
whether due to time-base control or lookahead. This permits another action to be slaved to the position of
the virtual axis.
To create a move proportional to the vector length of the programmed move, this length must be calculated.
Turbo PMAC does this by looking at the move parameters passed as arguments into the subroutine call
through the READ statement.
This example computes the length for linear and rapid moves only. This computation is possible for
circle moves as well, but the calculations are much more involved.
Substitutions and Definitions
#define DXSqrd P4001 ; Square of X distance
#define DYSqrd P4002 ; Square of Y distance
#define DZSqrd P4003 ; Square of Z distance
#define Vdist P4004 ; Virtual axis distance
G-code Subroutine Program
OPEN PROG 1000 CLEAR ; G-code subprogram
N0 RAPID ; G00 is RAPID mode
INC(V) ; Make sure V is incremental
PRELUDE1 G00.1 ; Make moves a subroutine call
RETURN
Subroutine for Calculations on LINEAR and RAPID Moves
N100 ; G00.1 subroutine
READ(X,Y,Z) ; Destinations into Q124,5,6
IF(AbsMode=1) ; ABS, subtract last destination
DXSqrd=(XArg-CS1XTargPos)*(XArg-CS1XTargPos)
DYSqrd=(YArg-CS1YTargPos)*(YArg-CS1YTargPos)
DZSqrd=(ZArg-CS1ZTargPos)*(ZArg-CS1ZTargPos)
ELSE ; INC, use new distances
DXSqrd=XArg*XArg
DYSqrd=YArg*YArg
DZSqrd=ZArg*ZArg
ENDIF
VDist=SQRT(DXSqrd+DYSqrd+DZSqrd)
X(XArg)Y(YArg)Z(ZArg)V(VDist) ; Append V-axis move
RETURN
N1000 LINEAR ; G01 is LINEAR mode
INC(V) ; Make sure V is incremental
PRELUDE1 G00.1 ; Make moves a subroutine call
RETURN
N90000 ABS(X,Y,Z) ; G90 is absolute real moves
AbsMode=1 ; Internal flag
RETURN
N91000 INC(X,Y,Z) ; G91 is incremental real moves
AbsMode=0 ; Internal flag
RETURN
CLOSE
To use the V-axis position as the time-base master for CS2 on Turbo PMAC, use the following setup:
I8006=$403506 ; Use result of I8005 as master
I8007=128 ; Scale factor (app. dependent)
I5293=@I8007 ; CS2 use this for time base
The virtual motor can be used also to output a pulse frequency proportional to its speed. See the Virtual
Motor with Synthesized Encoder example for details.

4 Virtual Axis Monitoring Motion

You might also like