Mission 1 Basic Instruction Application

1.1 Devices in Detail

1.I/O Relays[X,Y]

Examples of terminal names and wiring (sink input) are for the FX3U Series PLC.

(1)The PLC receives signals from external switches through input terminals.An input relay (X) connected to an input terminalinside the PLC is an electronic relay isolated optically, and has many NO contacts and NCcontacts.These contacts can be arbitrarily used inside the PLC.These input relays cannot be driven by the program,as shown in Fig.1-1-1.

Fig.1-1-1 Input and output relays

(2)The PLC outputs signals to external loads throughoutput terminals.Contacts for external output devices such as relay contacts, TRIACs andtransistors of output relays are connected to outputterminals inside the PLC.An output relay has manyelectronic NO contacts and NC contacts.These contacts can be arbitrarily used inside the PLC.

2.Auxiliary Relay [M]

There are many auxiliary relays inside the PLC.Coils of auxiliary relays are driven by contacts of variousdevices inside the PLC in the same way as output relays.

Auxiliary relays have many electronicNO contacts and NC contacts which can be used arbitrarily insidethe

PLC.However, external loads cannot be driven directly by these contacts.External loads should bedriven by output relays.

As shown in Fig.1-1-2, all of general type auxiliary relays(M0~M499) turn OFF when the PLC turns OFF.When the ON/OFF status of auxiliary relays just before power failure isrequired in control, use latched (battery backed) type auxiliary relays(M500~M1023).

Fig.1-1-2 Auxiliary relay

3.Timer [T]

Timers add and count clock pulses of 1ms, 10ms, 100ms, etc.inside the PLC.When the counted valuereaches a specified set value, the output contact of the timer turns on.

A set value can be indirectly specified by a constant (K) in the program memoryorby the contents of a data register (D).

(1)The table 1-1-1 shows timer (T) numbers(The numbers are assigned in decimal).

Table 1-1-1 Timer (T) numbers

Timer numbers not used for timers can be used as data registers for storing numeric values.Retentive type timers are protected against power failure by battery.

(2)General type.When the drive input X000 of the timer coil T200 turns ON, thecurrent value counter for T200 adds and counts clock pulses of10 ms.When the counted value becomes equivalent to the setvalue K123, the output contact of the timer turns on,as shown in Fig.1-1-3.

Fig.1-1-3 General type timer

In other words, the output contact turns on 1.23s after the coil is driven.When the drive input X000 turns OFF or when the power isturned off the timer is reset and the output contact returns.

(3)Retentive type.When the drive input X001 of the timer coil T250 turns ON, the current value counter for T250 adds and counts clock pulses of100 ms.When the counted value becomes equivalent to the setvalue K345, the output contact of the timer turns on.as shown in Fig.1-1-4.

Fig.1-1-4 Retentive type timer

Even if the drive input X001 turns OFF or the power is turned off during counting, the timer continues counting when the operationrestarts.The retentive operating time is 34.5 seconds.When the reset input X002 turns ON, the timer is reset and the output contact is returned.

4.Counter [C]

The valid set range of 16-bit binary up counter is from K1 to K32767 (decimal constant).K0 provides the same operation as K1, and the output contact turns on at the first counting.

In general type counters(C0~C99), the counter value is cleared when the PLC turns off.In latch type counters(C100~C199), however, the counter value just before power failure is stored (backed up by the battery); The counter value in the subsequent operations can be added to the last counter value,as shown in Fig.1-1-5.

Fig.1-1-5 General counter

When a coil instruction is executed 10 times, the output contact turns on.After that, the current value of the counter does not change even if the counting input X011 turns on.When the RST input X010 turns ON and then RST instruction is executed, the current value of the counter is reset to “0” and the output contact returns.

1.2 Basic Instruction

1.LD, LDI

(1)LD instruction (initial logical operation, NO contact type),as shown in Fig.1-1-6.

Fig.1-1-6 LD instruction

(2)LDI instruction (initial logical operation, NC contact type),as shown in Fig.1-1-7.

Fig.1-1-7 LDI instruction

2.OUT

(1)Parallel OUT instructions can be used consecutively as many times as necessary.In the program example shown in Fig.1-1-8.OUT M100 and OUT M101 are parallel.If two or more OUT instructions are executed for a same device number, however, the double output (double coil) operation is resulted.

Fig.1-1-8 Output using bit device

(2)When a timer or counter is used.The set value is required after OUT instruction for the counting coil of a timer or counter.The set value can be specified directly by a decimal number (K),as shown in Fig.1-1-9.

Fig.1-1-9  Directly specifying set value by a decimal number (K)

3.AND, ANI

AND and ANI instructions connect one contact in series.The number of contacts connected in series is not limited, so AND and ANI instructions can be usedconsecutively as many times as necessary.Output to another coil by way of a contact after OUT instruction is called cascadeoutput.Such cascade output can be repeated as many times as necessary as long as the order is correct.

(1)AND instruction [serial connection of NO (normally open) contacts], as shown in Fig.1-1-10.

Fig.1-1-10 AND instruction

(2)ANI instruction [serial connection of NC (normally closed) contacts], as shown in Fig.1-1-11.

Fig.1-1-11 ANI instruction

(3)Program examples, as shown in Fig.1-1-12.

Fig.1-1-12 AND/ANI instruction examples

4.OR, ORI

OR and ORI instructions are used to connect one contact in parallel.A step containing OR or ORI instruction is connected in parallel to a preceding step containing LD or LDIinstruction.There is no limitation in the number of times of parallel connection.

(1)OR instruction [parallel connection of NO (normally open) contacts], as shown in Fig.1-1-13.

Fig.1-1-13 OR instruction

(2)ORI instruction (parallel connection of NC (normally closed) contacts), as shown in Fig.1-1-14.

Fig.1-1-14 ORI instruction

5.LDP, LDF, ANDP, ANDF, ORP, ORF

LDP, ANDP, and ORP instructions for contacts detect the rising edge, and become active during oneoperation cycle only at the rising edge of a specified bit device (that is, when the bit device turns ON fromOFF).

Contact instructions LDF, ANDF and ORF detect the falling edge, and become active during one operationcycle only at the falling edge of a specified bit device (that is, when the bit device turns OFF from ON).

(1)Instruction format, as shown in Fig.1-1-15.

Fig.1-1-15 Formats of LDP, LDF, ANDP, ANDF, ORP and ORF instructions

(2)LDP, ANDP, and ORP instructions (initial logical operation of rising edge pulse, serialconnection of rising edge pulse, and parallel connection of rising edge pulse).

In the figure Fig.1-1-16, M0 or M1 is ON during only one operation cycle when X000 to X002 turns ONfrom OFF.

Fig.1-1-16 LDP, ANDP and ORP instructions

6.SET, RST

SET instruction drives the coil for an output relay (Y), auxiliary relay (M), state relay (S) and bit specification of data register (D).In addition, even if the output of the instruction is OFF, the devices set to ON with SET instruction can keep ON.

RST instruction resets an output relay (Y), auxiliary relay (M), state relay (S), timer (T), counter (C) and bit specification of data register (D).It can be used to reset (set to OFF) the devices that are set to ON with SET instruction.

RST instruction also clears the current data of timer (T), counter ©, data register (D), extension register (R), and modifier register (V) and (Z).

(1)When using a bit device

SET instructions located in parallel can be used consecutively as many times as necessary.as shown in Fig.1-1-17.

Fig.1-1-17 Set and Reset of bit device

In the program example shown below, “RST Y000” after “SET Y000” correspondsto this usage.

(2)Use RST instruction to reset a counter

As shown in Fig.1-1-18, C0 up-counts the number of turning ON from OFF at X011.When the counting result reaches the set value K10, the output contact C0 is activated.Even if X011 changes from OFF to ON after that, the current value of the counter remains unchangedand the output contact remains activated.For clearing the counter and returning the output contact, X010is set to ON.It is necessary to specify a constant K or data register numberfor indirect specification after OUT C instruction.

Fig.1-1-18 Set and Reset of a counter

7.MOV/Move

16-bit operation (MOV and MOVP).The contents of the transfer source are transferred to the transfer destination.

While the command input is OFF, the transfer destination does not change.

When a constant (K) is specified as the transfer source, contents of at most 16 (multiple of 4) bit devices can be transferred if it is automatically converted into bit number (K1X000~K1Y000) of the bit device specified by BIN, as shown in Fig.1-1-19.

Fig.1-1-19 16-bit operation

As shown in Fig.1-1-20, contents of at most 16 (multiple of 4) bit devices can be transferred if bit number (K1X000~K1Y000) of the bit device is specified.

Fig.1-1-20 Example of MOV instruction

8.SFTL/Bit Shift Left

(1)16-bit operation (SFTL and SFTLP)

For “n1” bits (shift register length) starting fromD, “n2” bits are shifted leftward ([1] and [2] shown below).After shift, “n2” bits from S are transferred to “n2” bits from D ([3] shown below), as shown in Fig.1-1-21.

Fig.1-1-21 16-bit operation (SFTL and SFTLP)

(2)Program example (conditional stepping of 1-bit data)

As shown in Fig.1-1-22, by setting X000 to X007 to ON in turn, Y000 to Y007 are activated in turn.If the order is wrong, activation is disabled.

Fig.1-1-22 Program example of SFTL instruction

9.SFTR/Bit Shift Right

16-bit operation (SFTR and SFTRP).For “n1” bits (shift register length) starting from D,“n2” bits are shifted rightward ([1] and [2] shownbelow).After shift, “n2” bits from S are transferred to “n2” bits from D+n1-n2 ([3] shown below), as shown in Fig.1-1-23.

Fig.1-1-23 16-bit operation (SFTR and SFTRP)

10.LD =, >, <, <>, <=,>=/Data Comparison

(1)Contact comparison instructions

As shown in Fig.1-1-24, these instructions compare numeric values, and set a contact to ON when the condition agrees so that an operation is started.

Fig.1-1-24 Contact comparison instructions

(2) The input procedure is described below

Operating procedure:

a.Display the circuit program edit window, and put the cursor in a position where a data comparisoninstruction is to be used.

b.Choose symbol [-[]-].

c.Input “Instruction”→“space”→“value or device”→“space”→“value or device”.For an input example, refer to “Instruction input window in GX Developer” shown in Fig.1-1-25.

Fig.1-1-25 Input of contact comparison instruction

d.Click the [OK] button.

e.Input other contacts and coil drive units consecutively.

(3) Program example, as shown in Fig.1-1-26

Fig.1-1-26 Program example of contact comparison instruction

When the current value of the counter C10 is “200”, Y010is driven.When the contents of D200 are “-29” or more and X001 isON, Y011 is set.When the contents of the counter C200 are less than “K678,493” or when M3 turns ON, M50 is driven.

【Exercise】

Exercise 1 write the program of PLC, press running button X1, pushing cylinder Y30 is pushed out; after 2s, pushing cylinder Y32 is pushed out; after 2s, pushing cylinder Y34 is pushed out; after 2s, pushing cylinder Y36 is pushed out; after 2s, pushing cylinders Y30, Y32, Y34 and Y36 all retract.

Exercise 2 write the program of PLC, press running button X1, pushing cylinder Y30 is pushed out; after 2s, pushing cylinder Y30 retracts; after 2s, pushing cylinder Y30 is pushed out again; after 3 times repeatedly, it stops the work.

Exercise 3 write the program of PLC, use MOV instruction to control pushing cylinders Y30, Y32, Y34 and Y36 to be pushed out at the same time; after 2s, they retract at the same time.

Exercise 4 write the program of PLC, use SFL/SFR instruction to control one of pushing cylinders Y30, Y32, Y34 and Y36 to be pushed out every two seconds successively; wait for 2s after they are all pushed out, then in the sequence of Y36, Y34Y32 and Y30, retract one every two seconds; after they all retract, stop the work.