Elmo HARSFEN0602, HARmonica Initiating a Program, Halting and resuming a program, XQ##TASK1

Models: HARmonica HARSFEN0602

1 220
Download 220 pages 51.63 Kb
Page 65
Image 65

HARSFEN0602ElmoHARmonicaSoftwareManual

PRELIMINARYDRAFT

6.4.1Initiating a Program

program is initiated by the XQ command. The XQ command states at which label the execution shall start.

The XQ command resets all the program variables. In particular, it clears the call stack (refer the chapter the Functions and the Call Stack), it kills any pending automatic routines, and it clears the interrupt mask.

The description and syntax of the XQ command see at the chapter Debugging: running, breaking and resuming

6.4.2Halting and resuming a program

A program may be halted using the HP Interpreter command.

The HP command stops the execution of the user program and the automatic routines. The HP command freezes the status of the program, and does not reset it.

A later XC command will resume the program from the instruction where the program was halted. Pending interrupts will remain pending.

The command XC restarts execution from the point where the program has been halted.

Example:

Consider the program

MO=1;

**Start motor

JV=2000;

**Set jog speed

##LOOP;

**Repetitive task

BG;

 

wait(1000)

**Wait & switch direction

JV=-JV;

 

goto##LOOP;

**Repeat

This program makes the motor travel at 2000 counts/sec for one second, then reverses the direction for one second, continuing to travel back and forth forever.

Suppose the HP command is applied when the program waits (executing the wait(1000) instruction). The motor will continue to travel at the same direction, for unlimited time.

An XC command shall reverse the direction immediately, since the waiting time already elapsed.

Example:

A servo axis in a machine has two different tasks to do, in two different machine modes. The following routine implements the two tasks.

##TASK1;

 

##LOOP;

**Repetitive task 1

**Task 1 body

goto##LOOP;

**Repeat task 1

##TASK2;

 

##REP;

**Repetitive task 2

**Task 2 body

goto##REP;

**Repeat task 2

The first task is invoked by

XQ##TASK1

In order to switch to the second task, the first task has to be killed before:

63

Page 65
Image 65
Elmo HARSFEN0602, HARmonica software manual Initiating a Program, Halting and resuming a program, XQ##TASK1