ISPSoft User Manual 13.4 Example of a Structured Text 13.4.1 Explanation The example is about the control of a tower light. A tricolor light and a buzzer are used. The control mechanisms for various device statuses are listed below. If more than one device status appears, the device status which is given precedence over the others is displayed. 13.4.2 Planning Hardware In this example, the AH500 series CPU module AHCPU530-EN , the digital I/O module AH16AP11R-5A , and the four-slot main backplane AHBP04M1-5A are used. The table below is an I/O allocation table. 13.4.3 Planning a Program (1) If the flag ERROR is ON, and the flag BUZZER_OFF is OFF, the state code will be 4.
(2) If the flag ERROR is ON, and the flag BUZZER_OFF is ON, the state code will be 3. (3) If the flag ERROR is OFF, and the flag RUNNING is ON, the state code will be 2. (4) If the flags ERROR and RUNNING are OFF, and the flag COMPLETE is ON, the state code will be 1. (5) If the flags ERROR, RUNNING, and COMPLETE are OFF, the state code will be 0. (6) Every state code corresponds to a light. The control of the tricolor light has many practical applications, and the tricolor light can be displayed in various ways. Considering that a program can be expanded and reused, a function block is created.
13-32 State code Device status Light Precedence Red Yellow Green Buzzer light light light 4 The device is malfunctions. ON OFF OFF Flash Highest 3 The device malfunctions. (The buzzer is turned off.) Flash OFF OFF OFF 2 The device is operating. OFF OFF ON OFF 1 The work is done. OFF Flash OFF OFF 0 The device is idling. OFF ON OFF OFF Lowest Type ID Description Digital output Y0.0 Red light Digital output Y0.1 Yellow light Digital output Y0.2 Green light Digital output Y0.3 Buzzer