The Nippon Pulse Terminal Program includes a Repeat/Until Loop macro, which can repeat until a defined condition is met. 


These commands are micro scripts for use in the ASCII programs, and can also be used when typing in commands via the Command Entry, but you have to type in a complete Repeat/Until Loop code (start with REPEAT and end with UNTIL) all on one line separated by commas. ASCII programs loaded in from files are what it is primarily designed for though.


You can nest up to 3 levels deep of Repeat/Until Loops.


The testing loops are comprised of the following micro commands:


Command / Function

Description

BtMask

Sets the mask used for bit-wise operations

Repeat

Designates the start of the Repeat/Until Loop

Rsave

Designates a math comparison

Show

This converts and displays a reply from a command

Until

Designates the end of the Repeat/Until Loop, and defined condition to end loop


Here is an example of three REPEAT loops:


1) (nested counting) using just the default counter value for comparison:

REPEAT,
    PX=0,OK
    PY=0,OK

    PZ=0,OK
    PU=0,OK
    REPEAT,
        PX=0,OK
        PZ=0,OK
    UNTIL=3,
UNTIL=10,

The outside loop will loop 10 times. The inside loop will loop 3 times, but because the outside loop iterates 10 times it will actually run 30 times.


2) A Bit Mask comparison  

Y6400,OK

BTMASK=7,

REPEAT,

    MSTY,

    RSAVE1,

UNTILM0,

The Y axis is commanded to position 6400.  A bit mask for the first three bits is created (BTMASK=7). A loop is created that will call the MSTY command.  The reply is saved to RSAVE1. The loop will continue until the first three bits of the reply are 0 (the motor is stopped). 


3) A math comparison using a reply value would look like this:

JX-,OK
REPEAT,
    EP,
    RSAVE1,
UNTILR1000:2000,
STOP,OK

Assuming the EP values start at 0000:0000:0000:0000 the program above should loop until the first value (Encoder X) returned from EP is between 1000 and 2000 and then the loop ends and the STOP command is executed. 



Return to ASCII programs