You are on page 1of 10

PLC Laboratory

Fourth Year

Experiment no.3

Word Switch
(ADD, SUB, Digit ADD, Digit SUB, and Script)

Prepared by:
Prof. Dr. Mofeed T. Rashid
Prof. Dr. Ammar A. Aldair
Dr. Abdul-Basset A. Al-Hussein

PLC Lab – Fourth Year Page 1


Objective
Designing an interactive visual interface using HMI to control PLC by Word Switch (ADD, SUB, Digit
ADD, Digit SUB, and Script).

Introduction
The previous experiment dealt with a word switch, which includes the implementation
of set mode experiments. In this experiment, the other modes in the word switch will be
implementing. These are ADD, SUB, Digit ADD, Digit SUB, and Script.

ADD mode:
Pressing the word switch add the direct or indirect set value to the PLC relevant address. With direct set
value, each time the switch is pressed, the relevant PLC address's value is increased by constant
increment whereas with indirect one the increase amount is function of the indirect address value at the
pressing time.

SUB mode:
Pressing the word switch subtract the direct or indirect set value from the PLC relevant address. With
direct set value, each time the switch is pressed, the relevant, PLC address's value is decreased by
constant decrement whereas with indirect one the decrement amount is function of the indirect address
value at the pressing time.

Example: In this example, we will design a Timer value adjustment panel, which is used to increment
and decrement the value of the PLC timer manually by the HMI panel. There are two buttons in the HMI
panel, the first one employs a word switch in add mode to increase timer value while another one is
employed the word switch in sub-mode to decrease the time value; further lamp has been used for
observing the changing in the value of PLC timing.

Solution:

PLC Lab – Fourth Year Page 2


Device Caption Mode Set value Address Display
Word Switch ADD 10 MW2 Visible
Word Switch SUB 10 MW2 Visible
Bit Switch Momentary MW1.0 Transparent
Lamp QX0.0.0 Default
(a) Device Characteristics

(b) Interface HMI page

Hint: Over each WORD SWITCH, a transparent BIT SWITCH is placed.

PLC Lab – Fourth Year Page 3


%MW1.0 %QX0.0.0

%MW2

(c) PLC Ladder Diagram.

The Execution of Example

PLC Lab – Fourth Year Page 4


Digit ADD:
Pressing the word switch increments the PLC relevant address value. The increment amount is function
of the selected number system (HEX or BCD) and the position of the digit to be incremented by 1. For
example selecting BCD as the number system and 2 as the digit position, each press increments the tenth
position by one until reaching 9 after which the tenth position returns to zero and new increment cycle
start again.

Digit SUB:
Pressing the word switch decrements the PLC relevant address value. The decrement amount is function
of the selected number system (HEX or BCD) and the position of the digit to be decremented by 1. For
example selecting BCD as the number system and 2 as the digit position, each press increments the tenth
position by one until reaching 9 after which the tenth position returns to zero and new increment cycle
start again.

Example: Design HMI page such that the operator can set the PLC memory word %MW4 in thumb wheel
like manner.

Solution: Hint: In Connection property, make (use PLC simulator) passive.

PLC Lab – Fourth Year Page 5


Device Type Operation Mode Data Type Address
Numeric Display 16 bit, BCD %MW4

Word Switch Digit ADD 4 %MW4

Word Switch Digit ADD 3 %MW4

Word Switch Digit ADD 2 %MW4

Word Switch Digit ADD 1 %MW4

Word Switch Digit SUB 4 %MW4

Word Switch Digit SUB 3 %MW4

Word Switch Digit SUB 2 %MW4

Word Switch Digit SUB 1 %MW4

(a) Device Characteristics

(b) Interface HMI page

PLC Lab – Fourth Year Page 6


The Execution of Example

Script:
Pressing the Word switch executes the assigned C language program segment like script.

Example: Give HMI Utility that inverts the state of %MW1.0 each time the word switch ¾MW4 is Pressed.

Solution:

Hint: Steps of adding script as follow:

1. Open the script editor by insert script as shown in figure

PLC Lab – Fourth Year Page 7


2. Write the c-code as shown in figure

3. Back to design window as shown in figure

(a) Interface HMI page

PLC Lab – Fourth Year Page 8


Device Type Operation Mode Script_No. Address
Bit Lamp %MW1.0
Word Switch Script Script_0000 %HW4
(b) Device Characteristics

The Execution of Example

PLC Lab – Fourth Year Page 9


Exercises:
Q1: Design Automatic liquid mixing machine by HMI and PLC, which the mixing time can
be increased or decreased. Use ADD, SUB modes.

Q2) Design an electronic lock for the big money treasury by HMI and PLC as shown in
the figure. Use Digit ADD, Digit SUB mode.

When the code


is correct

Open Lock

PLC Lab – Fourth Year Page 10

You might also like