Browse
(440) 299-7778
Menu
(440) 299-7778
One-year parts and labor warranty30-day money-back guaranteeContact

The text of a manual · part 5 of 11

MELSEC FX Family Programmable Logic Controllers Beginners Manual, pages 41 to 50

Pages 41 to 50 of 106

The original document is the PDF (969 KB). This is its text as extracted, unedited; tables and drawings read best in the PDF, and each page heading opens it at that page.

For the Mitsubishi FX2NC-32MT

Page 41

An Introduction to Programming

The Basic Instruction Set

Evaluating a falling signal pulse Instruction List

Ladder Diagram

M235

X010 M374

0

0 1 2

LD ANDF OUT

M235 X010 M374

1

M235 0 ON (1)

X10 OFF (0) 1

M374 0 t

If X10 is off (0) and M235 is on (1) relay M374 is switched on for the duration of a single program cycle.

With the exception of the pulse trigger characteristic the functions of the LDP, LDF, ANDP, ANDF, ORP and ORF instructions are identical to those of the LD, AND and OR instructions. This means that you can use pulse-trigger operations in your programs in exactly the same way as the conventional versions.

3.4.8

Setting and resetting devices Instruction

햲 햳

Function

Symbol

SET

Set a device���, (assign signal state “1”)

SET 첸

RST

Reset a device���, (assign signal state “0”)

RST 첸

GX Developer FX

F8 F8

The SET instruction can be used to set outputs (Y), relays (M) and state relays (S). The RST instruction can be used to reset outputs (Y), relays (M), state relays (S), timers (T), counters (C) and registers (D, V, Z).

The signal state of an OUT instruction will normally only remain “1” as long as the result of the operation connected to the OUT instruction evaluates to “1”. For example, if you connect a pushbutton to an input and a lamp to the corresponding output and connect them with an LD and an OUT instruction the lamp will only remain on while the button remains pressed. The SET instruction can be used to use a brief switching pulse to switch an output or relay on (set) and leave them on. The device will then remain on until you switch it off (reset) with a RST instruction. This enables you to implement latched functions or switch drives on and off with pushbuttons. (Outputs are generally also switched off when the PLC is stopped or the power supply is turned off. However, some relays also retain their last signal state under these conditions – for example a set relay would then remain set.) To enter a SET or RST instruction in Ladder Diagram format just click on the icon shown in the table above in GX Developer, or press the F8 key. Then enter the instruction and the name of the device you want to set or reset, for example SET Y1.

FX Beginners Manual

3 – 15

Page 42

The Basic Instruction Set

An Introduction to Programming

Instruction List

Ladder Diagram

X001 0

SET

M0

RST

M0

0 1 2 3

X002 2

LD SET LD RST

X001 M0 X002 M0

If the set and reset instructions for the same device both evaluate to “1” the last operation performed has priority. In this example that is the RST instruction, and so M0 remains off.

X1

X2

M0 t

This example is a program for controlling a pump to fill a container. The pump is controlled manually with two pushbuttons, ON and OFF. For safety reasons a break contact is used for the OFF function. When the container is full a level sensor automatically switches the pump off. Instruction List

Ladder Diagram

X001 0

SET

Y000 Pump

RST

Y000 Pump

Pump ON

0 1 2 3 4

LD SET LDI OR RST

X001 Y000 X002 X003 Y000

X002 2 Pump OFF

X003 Level sensor

3 – 16

MITSUBISHI ELECTRIC

Page 43

An Introduction to Programming

3.4.9

The Basic Instruction Set

Storing, reading and deleting operation results Instruction

Function

Symbol

GX Developer FX

MPS

Memory Point Store, stores the result of an operation, - MRD

Memory Read, reads a stored operation result, - MPP

Memory POP, reads a stored operation result and deletes it, - The MPS, MRD and MPP instructions are used to store the results of operations and intermediate values in a memory called the “stack”, and to read and delete the stored results. These instructions make it possible to program multi-level operations, which makes programs easier to read and manage. When you enter programs in Ladder Diagram format these instructions are inserted automatically by the programming software. The MPS, MRD and MPP instructions are only actually shown when you display your program in Instruction List format, and they must also be entered manually when you program in this format. Instruction List

Ladder Diagram

X000

X001

0

Y000 MPS

X002

Y001 MRD

X003

Y002 MPP

0 1 2 3 4 5 6 7 8 9

LD MPS AND OUT MRD AND OUT MPP AND OUT

X000 X001 Y000 X002 Y001 X003 Y002

To make the advantage of these instructions clearer the example below shows the same program sequence programmed without MPS, MRD and MPP: Ladder Diagram

X000

X001

0

Y000 X000

X002

3

Y001 X000

6

Instruction List

X003 Y002

0 1 2 3 4 5 6 7 8

LD AND OUT LD AND OUT LD AND OUT

X000 X001 Y000 X000 X002 Y001 X000 X003 Y002

When you use this approach you must program the devices (X0 in this example) repeatedly. This results in more programming work, which can make quite a difference in longer programs and complex circuit constructions. In the last output instruction you must use MPP instead of MRD to delete the stack. You can use multiple MPS instructions to create operations with up to 11 levels. For more examples of how to use the MPS, MRD and MPP instructions see the Programming Manual for the FX Family.

FX Beginners Manual

3 – 17

Page 44

The Basic Instruction Set

3.4.10

An Introduction to Programming

Generating pulses Instruction

Function

Symbol

PLS

Pulse, sets an device* for the duration of a single program cycle on the rising edge of the switching pulse of the input condition / device

PLS 첸

PLF

Pulse Falling, sets a device* for the duration of a single program cycle on the falling edge of the switching pulse of the input condition / device

PLF 첸

GX Developer FX

F8 F8

* PLC and PLF instructions can be used to set outputs (Y) and relays (M). These instructions effectively convert a static signal into a brief pulse, the duration of which depends on the length of the program cycle. If you use PLS instead of an OUT instruction the signal state of the specified device will only be set to “1” for a single program cycle, specifically during the cycle in which the signal state of the device before the PLS instruction in the circuit switches from “0” to “1” (rising edge pulse). The PLF instruction responds to a falling edge pulse and sets the specified device to “1” for a single program cycle, during the cycle in which the signal state of the device before the PLF instruction in the circuit switches from “1” to “0” (falling edge pulse). To enter a PLS or PLF instruction in Ladder Diagram format click in the GX Developer toolbar on the tool icon shown above or press F8. Then enter the instruction and the corresponding device to be set in the dialog, e.g. PLS Y2. Instruction List

Ladder Diagram

X000 0

PLS

M0

SET

Y000

PLF

M1

RST

Y000

0 1 2 3 4 5 6 7

M0 2 X001 4

LD PLS LD SET LD PLF LD RST

X000 M0 M0 Y000 X001 M1 M1 Y000

M1 6

X0

The rising edge of the device X0 signal triggers the function.

X1

In the case of device X1 the falling edge of the signal is the trigger.

M0 Relays M0 and M1 are only switched on for the duration of a single program cycle.

M1

Y0 t

3 – 18

MITSUBISHI ELECTRIC

Page 45

An Introduction to Programming

3.4.11

The Basic Instruction Set

Master control function (MC and MCR instructions) Instruction

햲 햳

Function

Symbol

MC

Master Control, sets a master control condition, marking the beginning of a program block���

MC n 첸

MCR

Master Control Reset, resets a master control condition, marking the end of a program block���

MCR n

GX Developer FX

F8 F8

The MC instruction can be used on outputs (Y) and relays (M). n: N0 through N7 n: N0 through N7

The Master Control Set (MC) and Reset (MCR) instructions can be used to set conditions on the basis of which individual program blocks can be activated or deactivated. In Ladder Diagram format a Master Control instruction functions like a switch in the left-hand bus bar that must be closed for the following program block to be executed.

X001

Ladder Diagram

MC

0 N0 The “switch” does not have to be programmed manually and it is only actually displayed during program execution in Monitor mode.

N0

M10

M10 X002

4

Y003 X003 Y004

6 8 10

MCR

N0

X002 X004 M155

Instruction List 0 1 4 5 6 7 8 10 11 12

LD MC LD OUT LD OUT MCR LD AND OUT

X001 N0 X002 Y003 X003 Y004 N0 X002 X004 M155

M10

In the example above the program lines between the MC and MCR instructions are only executed when input X001 is on. The section of the program to be executed can be specified with the nesting address N0 through N7, which allows you to enter multiple MC instructions before the closing MCR instruction. (See the FX Programming Manual for an example of nesting.) Addressing a Y or M device specifies a make contact. This contact activates the program section when the input condition for the MC instruction evaluates true.

FX Beginners Manual

3 – 19

Page 46

The Basic Instruction Set

An Introduction to Programming

If the input condition of the MC instruction evaluates false the states of the devices between the MC and MCR instructions change as follows: –

Latched timers and counters and devices that are controlled with SET an RST instructions retain their current state.

–

Unlatched timers and devices that are controlled with OUT instructions are reset.

(See chapter 4 for details on these timers and counters.)

3.4.12

Inversion of an Operation Result Instruction INV

Function

Symbol

GX Developer FX

Invert, reverses the result of an operation

An INV instruction inverts the operation result up to just before the INV instruction, and does not require device number specification. –

If the result of an operation is "1", it becomes "0" after execution of the INV instruction.

–

If the result of an operation is "0", it becomes "1" after execution of the INV instruction. Instruction List

Ladder Diagram

X001

X002 Y000

0

INV instruction

0 1 2 3

LD AND INV OUT

X001 X002 Y000

The above example produces the following signal sequence: 1

X001 0 1

X002 0 1

Operation result before the INV instruction

0

Operation result after the INV instruction

1

Y000 0 t

The INV instruction can be used when you need to invert the result of a complex operation. It can be used in the same position as the AND and ANI instructions. The INV instruction cannot be used at the beginning of an operation (circuit) like an LD, LDI, LDP or LDF instruction.

3 – 20

MITSUBISHI ELECTRIC

Page 47

An Introduction to Programming

3.5

Safety First!

Safety First! PLCs have many advantages over hard-wired controllers. However, when it comes to safety it is important to understand that you cannot trust a PLC blindly. Emergency OFF devices It is essential to ensure that errors in the control system or program cannot cause hazards for staff or machines. Emergency OFF devices must remain fully functional even when the PLC is not working properly – for example to switch off the power to the PLC outputs if necessary. Never implement an Emergency OFF switch solely as an input that is processed by the PLC, with the PLC program activating the shutdown. This would be much too risky. Safety precautions for cable breaks You must also take steps to ensure safety in the event that the transmission of signals from the switches to the PLC are interrupted by cable breaks. When switching equipment on and off via the PLC always use switches or pushbuttons with make contacts for switching on and with break contacts for switching off. +24 V ON EMERG. OFF

OFF

In this example the contactor for a drive system can also be switched off manually with an Emergency OFF switch.

X000 X001 X002

COM Y000 Y001

0V

X001 0

SET

Y000 Motor ON

Motor ON

X002 2

RST Motor OFF

Y000 Motor ON

In the program for this installation the make contact of the ON switch is polled with an LD instruction, the break contact of the OFF switch with an LDI instruction. The output, and thus also the drive, is switched off when the input X002 has a signal state of “0”. This is the case when the OFF switch is operated or when the connection between the switch and input X002 is interrupted.

This ensures that if there is a cable break the drive is switched off automatically and it is not possible to activate the drive. In addition to this, switching off has priority because it is processed by the program after the switch on instruction. Interlock contacts If you have two outputs that should never both be switched on at the same time – for example outputs for selecting forward or reverse operation for a motor – the interlock for the outputs must also be implemented with physical contacts in the contactors controlled by the PLC. This is necessary because only an internal interlock is possible in the program and an error in the PLC could cause both outputs to be activated at the same time.

FX Beginners Manual

3 – 21

Page 48

Safety First!

An Introduction to Programming

The example on the right shows such an interlock with contactor contacts. Here it is physically impossible for contactors K1 and K2 to be switched on at the same time.

X000 X001 X002

COM Y000 Y001 K2

K1

K1

K2

Automatic shutdown When a PLC is used to control motion sequences in which hazards can arise when components move past certain points additional limit switches must be installed to interrupt the movement automatically. These switches must function directly and independently of the PLC. See Chapter 3.6.2. for an example of such an automatic shutdown facility. Output signal feedback Generally, the outputs of PLCs are not monitored. When an output is activated the program assumes that the correct response has taken place outside the PLC. In most cases no additional facilities are required. However, in critical applications you should also monitor the output signals with the PLC – for example when errors in the output circuit (wire breaks, seized contacts) could have serious consequences for safety or system functioning. In the example on the right a make contact in contactor K1 switches input X002 on when output Y000 is switched on. This allows the program to monitor whether the output and the connected contactor are functioning properly. Note that this simple solution does not check whether the switched equipment is functioning properly (for example if a motor is really turning). Additional functions would be necessary to check this, for example a speed sensor or a voltage load monitor.

3 – 22

X000 X001 X002

COM Y000 Y001

+24 V

K1

MITSUBISHI ELECTRIC

Page 49

An Introduction to Programming

3.6

Programming PLC Applications

Programming PLC Applications Programmable logic controllers provide an almost unlimited number of ways to link inputs with outputs. Your task is to choose the right instructions from the many supported by the controllers of the MELSEC FX family to program a suitable solution for your application. This chapter provides two simple examples that demonstrate the development of a PLC application from the definition of the task to the finished program,.

3.6.1

An alarm system The first step is to have a clear concept of what you want to do. This means that you need to take a “bottom-up” approach and write a clear description of what it is you want the PLC to do. Task description The objective is to create an alarm system with several alarm circuits and a delay function for arming and disarming the system. –

The system will be armed with a key switch, with a 20-second delay between turning the switch and activation. This provides enough time for the user to leave the house without tripping the alarm. During this delay period a display will show whether the alarm circuits are closed.

–

An alarm will be triggered when one of the circuits is interrupted (closed-circuit system, also triggers an alarm when a circuit is sabotaged). In addition to this we want to show which circuit triggered the alarm.

–

When an alarm is triggered a siren and a blinking alarm lamp are activated after a delay of 10 seconds. (The acoustic and visual alarms are activated after a delay to make it possible to disarm the system after entering the house. This is also why we want to use a special lamp to show that the system is armed.)

–

The siren will only be sounded for 30 seconds, but the alarm lamp will remain activated until the system is disarmed.

–

A key-operated switch will also be used to deactivate the alarm system.

Assignment of the input and output signals The next step is to define the input and output signals we need to process. On the basis of the specifications we know that we are going to need 1 key-operated switch and 4 alarm lamps. In addition to this we need at least 3 inputs for the alarm circuits and 2 outputs for the siren and the blinking alarm lamp. This makes a total of 4 inputs and 6 outputs. Then we assign these signals to the inputs and outputs of the PLC: Function

Input

Output

FX Beginners Manual

Name

Adress

Arm system

S1

X1

Alarm circuit 1

S11, S12

X2

Alarm circuit 2

S21, S22

X3

Alarm circuit 3

S31, S32

X4

Display “system armed”

H0

Y0

Acoustic alarm (siren)

E1

Y1

Optical alarm (rotating beacon)

H1

Y2

Alarm circuit 1 display

H2

Y3

Alarm circuit 2 display

H3

Y4

Alarm circuit 3 display

H4

Y5

Remarks Make contact (key-operated switch) Break contacts (an alarm is triggered when the input has the signal state “0”)

The outputs functions are activated when the corresponding outputs are switched on (set). For example, if Y1 is set the acoustic alarm will sound.

3 – 23

Page 50

Programming PLC Applications

An Introduction to Programming

Programming Now we can start writing the program. Whether relay devices are going to be needed and if so how many usually only becomes clear once you actually start programming. What is certain in this project is that we are going to need three timers for important functions. If we were using a hard-wired controller we would use timer relays for this. In a PLC you have programmable electronic timers (see Chapter 4.3). These timers can also be defined before we start programming: Function

Timer

Adress

Remarks

Arming delay

T0

Time: 20 seconds

Alarm triggering delay

T1

Time: 10 seconds

Siren activation duration

T2

Time: 30 seconds

Next we can program the individual control tasks: 쎲 Delayed arming of the alarm system Ladder Diagram

Instruction List

X001

K200 T0

0 T0 4

Y000

0 1 4 5

LD OUT LD OUT

X001 T0 T0 Y000

K200

When the key-operated switch is turned to ON the delay implemented with timer T0 starts to run. After 20 seconds (K200 = 200 x 0.1s = 20s) the indicator lamp connected to output Y000 lights up, indicating that the system is armed. 쎲 Monitor alarm circuits and trigger alarm signal Ladder Diagram

Instruction List

X002 Y000 6

SET

M1

SET

Y003

SET

M1

SET

Y004

SET

M1

SET

Y005

X003 Y000 10

X004 Y000 14

6 7 8 9 10 11 12 13 14 15 16 17

LDI AND SET SET LDI AND SET SET LDI AND SET SET

X002 Y000 M1 Y003 X003 Y000 M1 Y004 X004 Y000 M1 Y005

Output Y000 is polled in this routine to check whether the alarm system is armed. You could also use a relay here that would then be set and reset together with Y000. An interruption of an alarm circuit will only set relay M1 (indicating that an alarm has been triggered) if the alarm system is actually armed. In addition to this outputs Y003 through Y005 are used to indicate which alarm circuit triggered the alarm. Relay M1 and the corresponding alarm circuit output will remain set even when the alarm circuit is closed again.

3 – 24

MITSUBISHI ELECTRIC