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

The text of a manual · part 7 of 11

MELSEC FX Family Programmable Logic Controllers Beginners Manual, pages 61 to 70

Pages 61 to 70 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 61

Devices in Detail

4.2

Relays

Relays In your PLC programs you will often need to store intermediate binary results (a signal state of “0” or “1”) temporarily for future reference. The PLC has special memory cells available for this purpose known as “auxiliary relays”, or “relays” for short (device identifier: "M"). You can store the binary result of an operation in a relay, for example with an OUT instruction, and then use the result in future operations. Relays help to make programs easier to read and also reduce the number of program steps: You can store the results of operations that need to be used more than once in a relay and then poll it is often as you like in the rest of the program.

M1

M1 Poll for signal state “1” (relay set)

M1 Poll for signal state “0” (has the relay been reset?)

In addition to normal relays the FX controllers also have retentive or “latched” relays. The normal unlatched relays are all reset to a signal state of “0” when the PLC power supply is switched off, and this is also their standard state when the controller is switched on. In contrast to this, latched relays retain their current states when the power is switched off and on again. Relay types

Device

Unlatched relays

Device identifier

M

Device type

Bit device

Possible values für a device

0 or 1

Device address format

Number of devices and addresses

햲 햳

4.2.1

Latched relays

Decimal FX1S

384 (M0–M383)

128 (M384–M511)

FX1N

384 (M0–M383)

1152 (M384–M1535)

FX2N FX2NC

500 (M0–M499)���

FX3U

500 (M0–M499)���

524 (M500–M1023)��� 2048 (M1024–M3071) 524 (M500–M1023)��� 6656 (M1024–M7679)

You can also configure these relays as latched relays with the PLC parameters. You can also configure these relays as unlatched relays with the PLC parameters.

Special relays In addition to the relays that you can switch on and off with the PLC program there is also another class of relays known as special or diagnostic relays. These relays use the address range starting with M8000. Some contain information on system status and others can be used to influence program execution. The following table shows a few examples of the many special relays available.

FX Beginners Manual

4–3

Page 62

Timers

4.3

Devices in Detail

Special relay

Function

Program processing options

M8000

When the PLC is in RUN mode this relay is always set to “1”.

M8001

When the PLC is in Run mode this relay is always set to “0”.

M8002

Initialisation pulse (following activation of RUN mode this relay is set to “1” for the duration of one program cycle.

M8004

PLC error

M8005

Low battery voltage

M8013

Clock signal pulse: 1 second

M8031

Clear all devices (except data registers D) that are not registered as battery-latched.

M8034

Disable outputs – the PLC outputs remain off but program execution continues.

Poll signal state

Poll signal state Set signal state.

Timers When you are controlling processes you will often want to program a specific delay before starting and stopping certain operations. In hard-wired controllers this is achieved with timer relays. In PLCs this is achieved with programmable internal timers. Timers are really just counters that count the PLCs internal clock signals (e.g. 0.1s pulses). When the counter value reaches the setpoint value the timer’s output is switched on. All timers function as make delay switches and are activated with a “1” signal. To start and reset timers you program them in the same way as outputs. You can poll the outputs of timers as often as you like in your program. Instruction List

Ladder Diagram

K123 T200

X0 0 T200 4

Y0

0 1 4 5

LD OUT LD OUT

X0 T200 T200 Y0

K123

In the above example timer T200 is started when input X0 is switched on. The setpoint value is 123 x 10ms = 1.23 s, so T200 switches on output Y0 after a delay of 1.23 s. The signal sequence generated by the following program example is as follows:

1,23 s X0

T200

The timer continues to count the internal 10ms pulses as long as X0 remains on. When the setpoint value is reached the output of T200 is switched on.

If input X0 or the power supply of the PLC are switched off the timer is reset and its output is also switched off.

Y0 You can also specify the timer setpoint value indirectly with a decimal value stored in a data register. See Chapter 4.6.1 for details.

4–4

MITSUBISHI ELECTRIC

Page 63

Devices in Detail

Timers

Retentive timers In addition to the normal timers described above the controllers of the FX1N, FX2N, FX2NC and FX3U series also have retentive timers that retain their current time counter value even if the device controlling them is switched off. The current timer counter value is stored in a memory that is retained even in the event of a power failure. Example of a program using a retentive timer: Instruction List

Ladder Diagram

X1

K345 T250

0 T250

Y1

4

0 1 4 5 6 7

LD OUT LD OUT LD RST

X0 T250 T250 Y1 X2 T250

K345

X2 6

RST T250

Timer T250 is started when input X0 is switched on. The setpoint value is 345 x 0.1 s = 34.5s. When the setpoint value is reached T250 switches output Y1 on. Input X2 resets the timer and switches its output off..

t1 X1 t2 t1 + t2 = 34,5 s When X1 is on the timer counts the internal 100ms pulses. When X1 is switched off the current time counter value is retained. The timer’s output is switched on when the current value reaches the setpoint value of the timer.

T250

Y1

A separate instruction must be programmed to reset the timer since it is not reset by switching off input X1 or the PLC’s power. Input X2 resets timer T250 and switches off its output..

X2

FX Beginners Manual

4–5

Page 64

Timers

Devices in Detail

Timers in the base units of the MELSEC FX family Timer types

Device

Normal Timers

Device identifier

T

Device type (for setting and polling)

Bit device

Retentive Timers

Possible values (timer output)

0 or 1

Device address format

Decimal

Timer setpoint value entry

As a decimal integer constant. The setpoint can be set either directly in the instruction or indirectly in a data register.

FX1S

FX1N

Number of devices and addresses FX2N FX2NC

FX3U

100 ms (Range 0.1 to 3276.7 s)

63 (T0–T62), 10 ms (Range 0.01 to 327.67 s)

31 (T32–T62)*, 1 ms (Bereich 0.001 to 32.767 s)

1 (T63), 100 ms (Range 0.1 to 3276.7 s)

200 (T0–T199)

6 (T250–T255)

10 ms (Range 0.01 to 327.67 s)

46 (T200–T245), 1 ms (Range 0.001 to 32.767 s)

4 (T246–T249), 100 ms (Range 0.1 to 3276.7 s)

200 (T0–T199)

6 (T250–T255)

10 ms (Range 0.01 to 327.67 s)

46 (T200–T245), 1 ms (Range 0.001 to 32.767 s), 4 (T246–T249)

100 ms (Range 0.1 to 3276.7 s)

200 (T0–T199)

6 (T250–T255)

10 ms (Range 0.01 to 327.67 s)

46 (T200–T245)

1 ms (Range 0.001 to 32.767 s)

256 (T256–T511)

4 (T246–T249)

* These timers are only available when special relay M8028 is set. The total number of 100ms timers is then reduced to 32 (T0 – T31).

4–6

MITSUBISHI ELECTRIC

Page 65

Devices in Detail

4.4

Counters

Counters The programmers of the FX family also have internal counters that you can use for programming counting operations. Counters count signal pulses that are applied to their inputs by the program. The counter output is switched on when the current counter value reaches the setpoint value defined by the program. Like timers, counter outputs can also be polled as often as you like in the program. Example of a program using a counter: Ladder Diagram

Instruction List

X0 RST C0

0 X1

K10 C0

3

0 1 3 4 7 8

LD RST LD OUT LD OUT

X0 C0 X1 C0 C0 Y0

K10

C0 7

Y0

Whenever input X1 is switched on the value of counter C0 is incremented by 1. Output Y0 is set when X1 has been switched on and off ten times (the counter setpoint is K10). The signal sequence generated by this program is as follows: First the counter is reset with input X0 and a RST instruction. This resets the counter value to 0 and switches off the counter output.

X0

X1

0

1

2

3

4

5

6

7

8

9

10

Once the counter value has reached the setpoint value any additional pulses on input X1 no longer have any effect on the counter.

Y0

There are two kinds of counters, 16-bit counters and 32-bit counters. As their names indicate, they can count up to either 16-bit or 32-bit values and they use 16 bits and 32 bits, respectively, to store their setpoint values. The following table shows the key features of these counters.

FX Beginners Manual

4–7

Page 66

Counters

Devices in Detail

Feature

16 Bit Counters

32 Bit Counters

Count direction

Incrementing

Incrementing and decrementing (the direction is specified by switching a special relay on or off)

Setpoint value range

1 to 32767

-2 147 483 648 to 2 147 483 647

Setpoint value entry

Directly as a decimal constant (K) in the instruction, or indirectly in a data register

Directly as a decimal constant (K) in the instruction or indirectly in a pair of data registers

Counts to a maximum of 32,767, after which the counter value no longer changes.

Ring counter: After reaching 2,147,483,647 the next incrementing value is -2,147483,648. (When counting backwards the jump is from -2,147483,648 to 2,147,483,647)

Counter output

Once the setpoint value has been reached the output remains on.

When incrementing the output remains on once the setpoint value has been reached. When decrementing the output is reset (switched off) once the value drops below the setpoint value.

Resetting

An RST instruction is used to delete the current value of the counter and turn off its output.

Counter overflow behaviour

In addition to normal counters the controllers of the MELSEC FX family also have high-speed counters. These are 32-bit counters that can process high-speed external counter signals read on inputs X0 to X7. In combination with some special instructions it is very easy to use these counters to automate positioning tasks and other functions. High-speed counters use an interrupt principle: The PLC program is interrupted and responds immediately to the counter signal. For a detailed description of high-speed counters please refer to the Programming Manual for the MELSEC FX family. Counter overview Counter types

Device

Normal counters

Device identifier Device type (for setting and polling)

Bit device

Possible device values (counter output)

0 or 1

Device address format

Decimal

Counter setpoint value entry

As a decimal integer constant. The setpoint can be set either directly in the instruction or indirectly in a data register (two data registers for 32-bit counters).

FX1S

FX1N Number of devices and addresses FX2N FX2NC

FX3U

16 bit counter

16 (C0–C15)

16 (C16–C31)

32 bit counter, - 32 bit high-speed counter, 21 (C235–C255)

16 bit counter

16 (C0–C15)

184 (C16–C199)

32 bit counter

20 (C200–C219)

15 (C220–C234)

32 bit high-speed counter, 21 (C235–C255)

16 bit counter

100 (C0–C99)���

100 (C100–C199)���

32 bit counter

20 (C200–C219)���

햲 햳

15 (C220–C234)���

���

32 bit high-speed counter

21 (C235–C255)

16 bit counter

100 (C0–C99)���

32 bit counter

20 (C200–C219)���

32 bit high-speed counter

4–8

Retentive counters

C

100 (C100–C199)��� 15 (C220–C234)���

���

21 (C235–C255)

The current counter values of retentive counters are retained when the power supply is switched off. You can set the PLC parameters to configure whether the current values of these counters should be retained when the power supply is switched off.

MITSUBISHI ELECTRIC

Page 67

Devices in Detail

4.5

Registers

Registers The PLC’s relays are used to store the results of operations temporarily. However, relays can only store values of On/Off or 1/0, which means that they are not suitable for storing measurements or the results of calculations. Values like this can be stored in the “registers” of the controllers of the FX family. Registers are 16 bits or one word wide (see Chapter 3.2). You can create “double word” registers capable of storing 32-bit values by combining two consecutive data registers.

1 sign bit

15 data bits

Register: 16 bit 2 14 2 13 2 12 2 11 2 10 2 9 2 8 2 7 2 6 2 5 2 4 2 3 2 2 2 1 2 0

0: = positive value 1: = negative value

31 data bits

1 sign bit Double word register: 32 bit ... 2 30 2 29 2 28

... 22 21 20

0: = positive value 1: = negative value

A normal register can store values from 0000H – FFFFH (-32,768 – 32,767). Double-word registers can store values from 00000000H – FFFFFFFFH (-2,147,483,648 – 2,147,483,647). The controllers of the FX family have a large number of instructions for using and manipulating registers. You can write and read values to and from registers, copy the contents of registers, compare them and perform math functions on their contents (see chapter 5).

4.5.1

Data registers Data registers can be used as memory in your PLC programs. A value that the program writes to a data register remains stored there until the program overwrites it with another value. When you use instructions for manipulating 32-bit data you only need to specify the address of a 16-bit register. The more significant part of the 32-bit data is automatically written to the next consecutive register. For example, if you specify register D0 to store a 32-bit value D0 will contain bits 0 through 15 and D1 will contain bits 16 through 31.

FX Beginners Manual

4–9

Page 68

Registers

Devices in Detail

What happens when the PLC is switched off or stopped In addition to the normal registers whose contents are lost when the PLC is stopped or the power supply is turned off, the FX PLCs also have latched registers, whose contents are retained in these situations. NOTE

When special relay M8033 is set the contents of the unlatched data registers are also not cleared when the PLC is stopped. Data register overview Data register types

Device

Normal registers

Device identifier

D

Device type (for setting and polling)

Word device (two registers can be combined to store double-word values)

Possible device values

16 bit registers: 0000H to FFFFH (-32768 to 32767) 32 bit register: 00000000H to FFFFFFFFH (-2 147 483 648 to 2 147 483 647)

Device address format

Decimal

Number of devices and addresses

햲 햳

4.5.2

Latched registers

FX1S

128 (D0–D127)

128 (D128–D255)

FX1N

128 (D0–D127)

7872 (D128–D7999)

FX2N FX2NC

200 (D0–D199)���

FX3U

200 (D0–D199)���

312 (D200–D511)��� 7488 (D512–D7999) 524 (M500–M1023)��� 6656 (M1024–M7679)

You can also configure these registers as latched registers with the PLC parameters. You can also configure these registers as unlatched registers with the PLC parameters.

Special registers Just like the special relays (Chapter 4.2.1) starting at address M8000 the FX controllers also have special or diagnostic registers, whose addresses start at D8000. Often there is also a direct connection between the special relays and special registers. For example, special relay M8005 shows that the voltage of the PLC’s battery is too low, and the corresponding voltage value is stored in special register D8005. The following table shows a small selection of the available special registers as examples. Special register

Function

D8004

Error relay address (shows which error relays are set)

D8005

Battery voltage (e.g. the value “36” means 3.6V)

D8010

Current program cycle time

D8013–D8019

Time and date of the integrated real-time clock

D8030

Value read from potentiometer VR1 (0 – 255)

D8031

Value read from potentiometer VR2 (0 – 255)

Program processing optionsm

Read register contents

Read register contents Change register contents Read register contents (FX1S and FX1N only)

Registers with externally modifiable contents The controllers of the FX1S and FX1N series have two integrated potentiometers with which you can adjust the contents of special registers D8030 and D8031 in the range from 0 to 255 (see Chapter 4.6.1). These potentiometers can be used for a variety of purposes – for example to adjust setpoint values for timers and counters without having to connect a programming unit to the controller.

4 – 10

MITSUBISHI ELECTRIC

Page 69

Devices in Detail

4.5.3

Programming Tips for Timers and Counters

File registers The contents of file registers are also not lost when the power supply is switched off. File registers can thus be used for storing values that you need to transfer to data registers when the PLC is switched on, so that they can be used by the program for calculations, comparisons or as setpoints for timers. File registers have the same structure as data registers. In fact, they are data registers – they consist of blocks of 500 addresses each in the range from D1000 to D7999. Device

File registers

Device identifier

D

Device type (for setting and polling)

Word device (two registers can be combined to store double-word values)

Possible device values

16 bit register: 0000H to FFFFH (-32768 to 32767) 32 bit register: 00000000H to FFFFFFFFH (-2 147 483 648 to 2 147 483 647)

Device address format

Decimal FX1S

Number of devices and addresses

1500 (D1000–D2499) A maximum of 3 blocks of 500 file registers each can be defined in the PLC parameters.

FX1N FX2N FX2NC

7000 (D1000–D7999) A maximum of 14 blocks of 500 file registers each can be defined in the PLC parameters.

FX3U

For a detailed description of the file registers see the Programming Manual for the MELSEC FX family.

4.6

Programming Tips for Timers and Counters

4.6.1

Specifying timer and counter setpoints indirectly The usual way to specify timer and counter setpoint values is directly, in an output instruction: Ladder Diagram

X17 0 M50 4

Instruction List

K500 T31 K34 C0

0 1 4 5

LD OUT LD OUT

X17 T31 M50 C0

K500 K34

In the example above T31 is a 100ms timer. The constant K500 sets the delay to 500 x 0.1s = 50s. The setpoint for counter C0 is also set directly, to a value of 34 with the constant K34. The advantage of specifying setpoints like this is that you don’t have to concern yourself with the setpoint value once you have set it. The values you use in the program are always valid, even after power failures and directly after switching the controller on. However, there is also a disadvantage: If you want to change the setpoint you need to edit the program. This applies particularly for timer setpoint values, which are often adjusted during controller configuration and program tests. You can also store setpoint values for timers and counters in data registers and have the program read them from the registers. It is then possible to change the values quickly with a pro-

FX Beginners Manual

4 – 11

Page 70

Programming Tips for Timers and Counters

Devices in Detail gramming unit if necessary, or to specify setpoint values with switches on a control console or a HMI control panel. The following listing shows an example of how to specify setpoint values indirectly: Instruction List

Ladder Diagram M15 0

MOV D100 D131

X17 6

D131 T31

M8002 10

MOV K34 D5

M50 16

0 1 6 7 10 11 16 17

LD MOV LD OUT LD MOV LD OUT

M15 D100 T31 M8002 K34 M50 C0

D131 X17 D131 D5 D5

D5 C0

–

When relay M15 is one the contents of data register D100 are copied to D131. This register contains the setpoint value for T131. You could use a programming or control unit to adjust the contents of D100.

–

The special relay M8002 is only set for a single program cycle directly after the PLC is switched on. This is used to copy the constant value of 34 to data register D5, which is then used as the setpoint value for counter C0.

You don’t have to write program instructions to copy the setpoint values to the data registers. You could also use a programming unit to set them before the program is started, for example.

E

WARNING: If you use normal registers the setpoint values will be lost when the power supply is switched off and when the RUN/STOP switch is set to the STOP position. If this happens hazardous conditions may be created next time the power is switched on and/or when the PLC is started again, because all the setpoints will have a value of “0”.

If you don’t configure your program to copy the values automatically you should always use latched data registers for storing the setpoint values for timers and counters. Also, remember that even the contents of these registers will also be lost when the PLC is switched off if the backup battery is empty.

4 – 12

MITSUBISHI ELECTRIC