beautypg.com

Pm designer operation manual, Timer operation – B&B Electronics WOP-2121V-N4AE - Manual User Manual

Page 437

background image

14

PM Designer Operation Manual

14-28

CHAPTER 14 USING MACROS

STOP

Format

STOP

Function

Stops the macro immediately. If the macro is a Cycle macro, it will be run again starting from the
first command when the associated window is opened again. If the macro is Main macro, it will
be run again starting from the first command when restarting the application.

This command can not be used in sub-macros.

END

Format

END

Function

Indicates the end of macro and stops the macro in the current cycle. It can be put anywhere in a
macro to stop the macro at any point. If the macro is a cyclic macro, such as the Main macro and
the Cycle macros, it is stopped just in the current cycle and will be run again starting from the
first command in the next cycle.

This command can not be used in sub-macros.

14.4.9. Timer Operation

SET_T

Format

SET_T(P1,P2)

Data Type

U

Function

Starts the timer P1 using the timer control block in P2.

P1 (C)

The ID of the timer. There are 8 timers available and the IDs are 0 to 7.

P2 (I)

The starting location of the memory block (or word array) that is used as a Timer Control Block for the
timer. The structure of the Timer Control Block is shown below:

Word No.

Data Item

Description

0

Type of operation

0: One-shot; 1: Square-wave

1 Current

timer

value

The timer increases the value of this word by 1 every
100ms.

2 Timer

limit

When the current timer value reaches the timer limit, the
timer will perform one of the following operations according
to the type of operation:
1) If the type of operation is One-shot (0), sets the time-up
flag to 1, resets the current timer value to 0, and stops itself.
2) If the type of operation is Square-wave (1), toggles the
time-up flag, resets the current timer value to 0, and
continues the timing operation.

3 Time-up

flag This word will be set to 0 or 1 when the current timer value is

equal to the timer limit.

The timer will use the associated Timer Control Block as its private memory, so do not use any words in
the block for other purposes.
A Timer Control Block requires 4 words.

Example 1

$U100

=

1

/* Type of operation is Square-wave. */

$U101

=

0

/* Initialize the current timer value to 0. */

$U102

=

5

/* Timer limit is 0.5 second (5*100ms). */

$U103

=

0

/* Initialize the time-up flag to 0. */

SET_T(

3

,

$U100

)

/* Use timer #3 to generate a 1 Hz square wave on $U103.0 */