The commands described here are only available when writing a standalone program.


Specifies the subroutine program number in a standalone program. Subroutines are independent program snippets that can be accessed based on the needs of the programmer.  Typically, subroutines are used to perform functions that are repeated throughout the operation and can be used in conjunction with logic statements related to motor actions or the status of inputs and outputs.


Applies to: CMD-4CR, CMD-4EX-SA, PMX-4EX-SA, PMX-4ET-SA, PMX-2ED-SA, PMX-2EX-SA


Standalone                SUB #

                       ;subroutine program

       ENDSUB

Syntax:                        

Write:

SUB [#]                

Where:        [#] is the subroutine number (0 - 31)

       ENDSUB

Reply: 

Command is accepted and executed

No Reply

Example: 

Write:        

SUB 1         * Start subroutine program 1

  X1000         * Move to 1000 target position (for X axis)

  WAITX         * Wait for X axis move to complete

ENDSUB         * End subroutine program 1.


Notes:

  • Up to 32 (0-31) subroutines can be called upon. 
  • Subroutine 31 is used specifically for error handling and is executed whenever an error occurs.
  • Subroutines can be shared by both standalone programs and the ASCII command set.  Once a subroutine is written into the flash memory, it can be recalled via ASCII communication using the GS command. Standalone programs can also jump to a subroutine using the GOSUB command. 
  • If a subroutine number is not defined, the controller will return with an error.

See also:

Standalone Programming Commands


Commander Manual

2.1.1.1 Identification Number