Arithmetic and registers – Industrial Data Systems IDS Scale Basic User Manual

Page 13

Advertising
background image

Scale Basic 4.2E

Tutorial

Use the template above to enter and test the program. The program can be extracted from the
Event and Function sections of the template. (If you are using keyboard entry, enter the data
listed in parenthesis () ).

1.

Invoke the EZ Link program.

2.

From the Event section: Set Keyboard Events / F1 key = User1

(parameter 57 = 1)

3.

From the Function section: Scale Basic / User 1 enter the following program:

(parameter 72, Fn. 1) ( 232, 72, 69, 76, 76, 79, 255)

Instruction

Operand1

Operand2

Operand3

Comment _

Prompt

HELLO Display

HELLO

End

End

of

function

4.

In EZ Link select File, Save As, then type in “test1” then click OK. This saves the program
onto disk.

5.

In EZ Link select the UP (Upload) button. Click on file “test1.sf” then click on OK. If the
upload function is not working, make sure that the indicator is in idle mode (not in configure
mode). Try pressing the CLEAR key several times then try again. If it still doesn’t work,
then do the EZ Link test procedure described in this manual.

6.

Press the F1 key on the indicator. “HELLO” should appear on the display.

7.

Press the Enter key several times. Notice how the “HELLO” message remains on the display.
Press the Clear key. The Gross weight should appear on the display.

The above program presents the programmer with a decision. The program ‘works’ but the user
of the program may get stuck, not knowing to press the Clear key. Good programming practice
assumes that the user will always do the wrong thing. To fix the above program, use the Get key
command to wait for any key press, then force the display to a known state. Use the Display
[register]
instruction to display the gross weight after the Get key instruction.

Modify the function in step 3 above:

Instruction

Operand1

Operand2

Operand3

Comment _

Prompt

HELLO Display

HELLO

Get

key Wait

for

key-press

Display Gross

Display

gross

weight.

End

End

of

function

Do steps 4 through 7 above.

Arithmetic and Registers

There are 3 types of registers: general purpose registers (Memory1…15), permanent storage
registers (Fixed43…50), and special purpose registers (Gross, Tare, Net, Id1, … ).

The general purpose registers (Memory1…15) are used for temporary storage and for
calculations. The Memory registers are stored in RAM memory, they can be read and written to.
If power is lost, the data in the registers is lost. Scale Basic instructions Add, Sub, Mul, Div,
Copy, Sign, Compare, Dp adjust, Set, and Get data can use the Memory registers.

Advertising