Timer5, if/else/end if, flags – Industrial Data Systems IDS Scale Basic User Manual

Page 19

Advertising
background image

Scale Basic 4.2E

Tutorial

Scale Basic function is executed. There are 5 timer records that contain the following data:
Time interval

time interval in tenths of a second (x0.1sec). Max = 6553.0 seconds.

Scale Basic Function

the scale basic function to execute when time-out occurs.

Timers 1-4 must be reactivated with a Timer on instruction to begin again. Timer 5 is an
auto-reload timer.


Example:
As often happens when developing an application, the customer or the programmer notices that
something has been left out. In the case of the Setpoint Monitors application above, the customer
wants an automatic printout of the Gross, Tare, and Net weights of the batch. If the print
instruction is placed after the Relay off instruction in User function 2, the printout will be
inaccurate. The scale will be in motion. What we need is a time-out to allow the scale to settle.
Configure Timer 1 by clicking the Timer Events button in EZ Link.

Timer 1 Time 50 Resume

set timer 1 = 5.0 seconds, execute Resume function.

The timer activates the Resume function after a 5 second time-out. Modify User 2 function as
follows:

User 2

Relay off, 1

Turn off fill valve

Timer on, 1

Turn on timer 1

Suspend

Wait until Resume (from timer 1)

Gosub, Print2

Print page format 2

End

End

of

function


The new User 2 function uses the Suspend instruction in combination with Timer1’s Resume
function.. The purpose of the Suspend/Resume combination is to provide a suspension of a scale
basic function until an event occurs. In this case, User function 2 turns off relay 2, turns on timer
1, and then suspends processing until timer 1 times-out and executes the Resume function.

Timer5, If/Else/End if, Flags

Timer5 automatically reloads after it counts down to 0. This provides more accurate timing of
repetitive events (such as pulse outputs, speed calculations, interval timing, etc.). Timer5
continues cycling until the Timer off, 5 instruction is executed.

The If/Else/End if instructions are used to test condition codes. If the condition code is true,
then the instructions after the If instruction are executed. If the condition code in not true, then
the instructions after the If instruction are skipped until an Else or End if instruction is
encountered.

The Flags are condition codes that programmer can set or reset. The Flags are used to reflect a
user defined state or status. In this case, Flag1 is used to indicate the state of the LED (on/off).

Example Timer 5:

1.

Set Keyboard Events / F1 key = User1

2.

In Timer Events / Timer5 set time = 2, function = User2

Advertising