How to pause and restart a BASIC program
BASIC programs run best when left to run continuously with functions controlled by setting values in the global VR varables. However sometimes it is necessary to put a program in a "paused" state while another program takes control of something. The commands to put a process on hold and then run again are the ones usually used by Motion Perfect. They are STEPLINE and TROFF.
STEPLINE puts the program in step-by-step mode
TROFF turns off the "trace" mode and allows the program to continue on from the current line number.
Here is a short example that controls a program called PROGRAM_1.
' pause and restart another process
' PROC_STATUS values
' 0 stopped: no program OR task is running ON the PROCESS
' 1 running: a task OR program is running
' 2 stepping: PROCESS is stepping line by line
RUN "PROGRAM_1", 4 ' running on process 4
PRINT PROC_STATUS PROC(4)
WA(133)
STEPLINE "PROGRAM_1"
PRINT PROC_STATUS PROC(4), PROC_LINE PROC(4)
WA(200)
TROFF "PROGRAM_1"
PRINT PROC_STATUS PROC(4)
The example uses PRINT to confirm the state of PROGRAM_1. PROC_STATUS can be used in a program to confirm that the named program is running or not, and then some decision can be made based on that. e.g. restarting the program or showing an alarm to the operator if the status is not as expected.
Related Articles
Could not restart CANIO with CANIO_STATUS
CAN IO modules went into error and could not be reset by CANIO_STATUS.4 = 1. After some tests, the customer found the issue was as follows: It was solved by providing isolation for Trio and Can IO module from the panel. Also used separate 24V supply ...
ladder program process
Why is the IEC process showing "Sleeping" most of the time? ========================================================================== The PLC has a scan cycle. Probably it is set to 10 msecs. The ladder may take only one or two msecs to run and then ...
DRIVE_STATUS issue (EtherCAT CoE status word)
DRIVE_STATUS is the value of the CoE status word. Object number 0x6041. If bit 11 is set in the status in the drive then we must see the same in DRIVE_STATUS. If not then the drive is not setting the bit in Object 0x6041. You can check the object ...
CPU Processing time
You can make things more efficient if you make sure a BASIC program never waits on WAIT UNTIL. WAIT UNTIL a=0 AND b=2 AND c=3 will keep the process runing in its slot. REPEAT WA(10) UNTIL a=0 AND b=2 AND c=3 will put the process to sleep while ...
Axis Status Error
Just picked up my Flex-6 Nano again to do some testing with movelink, for some reason my FLEX-3AX is throwing errors. pressing the error reset button is not changing anything. All 3 axis are the same: Answer: The Fault bit in the CoE status will be ...