Tag Archives: plc programming tutorial

PLC programming tutorial – Shift and rotate

Basic PLC programming tutorial for Beginners how to work with Shift and rotate instructions in TIA V13 and how to work in TIA Portal V13/V14. Content: – Shift right (SHR) – Shift left (SHL)


Basic PLC programming tutorial for Beginners how to work with Shift and rotate instructions in TIA V13 and how to work in TIA Portal V13/V14. Content: – Rotate right (ROR) – Rotate left (ROL)


PLC programming tutorial – Word logic operations

Basic PLC programming tutorial for Beginners how to work with word logic operations in TIA V13 and how to work in TIA Portal V13/V14. Content: – AND logic operation (AND) – OR logic operation (OR) – EXCLUSIVE OR logic operation (XOR) – Create ones complement (INVERT) – Decode (DECO)


Basic PLC programming tutorial for Beginners how to work with word logic operations in TIA V13 and how to work in TIA Portal V13/V14. Content: – Encode (ENCO) – Select (SEL) – Multiplex (MUX) – Demultiplex (DEMUX)


PLC programming tutorial – Program control operations

Basic PLC programming tutotrial for Beginners how to work with program control operations in TIA V13 and ho to work in TIA Portal V13/V14. Content: – Jump if RLO = 1 (–(JMP)) – Jump if RLO = 0 (–(JMPN)) – Jump label (Label)


Basic PLC programming tutorial for Beginners how to work with program control operations in TIA V13 and how to work in TIA Portal V13/V14. Content: – Define jump list (JMP_LIST) – Jump distributor (SWITCH) – Return (–(RET))


PLC programming tutorial – Move operations

Basic PLC programming tutorial for Beginners how to work with move operations in TIA V13 and how to work in TIA Portal V13/V14. Content: – Move value (MOVE) – Deserialize – Serialize


Basic PLC programming tutorial for Beginners how to work with move operations in TIA V13 and how to work in TIA Portal V13/V14. Content: – Move block (MOVE_BLK) – Move block (MOVE_BLK_VARIANT) – Move block uninterruptible (UMOVE_BLK)

Basic PLC programming tutorial for Beginners how to work with move operation in TIA V13 and how to work in TIA Portal V13/V14.

Content: – Fill block (FILL_BLK)

– Fill block uninterruptible (UFILL_BLK)

– Swap (SWAP)


PLC programming tutorial – Math operations

Basic PLC programming tutorial for Beginners how to work with math operations in TIA V13 and how to work in TIA Portal V13/V14. Content: – Calculate (CALCULATE) – Add (ADD) – Subtract (SUB) – Multiply (MUL) – Divide (DIV)


Basic PLC programming tutorial for Beginners how to work with math operations in TIA V13 and how work in TIA Portal V13/V14. Content: – Return remainder of division(MOD) – Create twos complement (NEG) – Increment (INC) – Decrement (DEC) – Form absolute value(ABS) – Get minimum (MIN) – Get maximum (MAX) – Set limit value (LIMIT)


Basic PLC programming tutorial for Beginners how to work with math operations in TIA V13 and how to work in TIA Portal V13/V14. Content: – Form square (SQR) – Form square root (SQRT) – Form natural logarithm (LN) – Form exponential value (EXP) – Form sine value (SIN) – Form cosine value (COS)


Basic PLC programming tutorial for Beginners how to work with math operations in TIA V13 and how to work in TIA Portal V13/V14. Content: – Form tangent value (TAN) – Form arcsine value (ASIN) – Form arccosine value (ACOS) – Form arctangent value (ATAN) – Return fraction (FRAC) – Exponentiate (EXPT)


PLC ladder programming principles and programming methods

(1) Input / output relay, internal auxiliary relays, timers, counters and other devices of the contact can be used repeatedly, without complex program structure to reduce the use of contacts. (2) Each line ladder left the bus started, the coil terminates at the right bus. Contacts are not on the right side of the coil, as shown below

(3) In addition to stepping procedure, any coils, timers, counters, and other advanced instruction can not be directly connected to the left bus bar.
(4) In the process, does not allow the same number twice coil output (dual coil output). The following ladder is not allowed.

(5) does not allow the bridge circuit.

(6)Shall be prepared by the sequential program from top to bottom, from left to right to prepare the way. To reduce the number of steps in the implementation of the program, the program should be to the left and right big small big small.

(7) as an input device with a normally open contact

(8) PLC programming experience commonly Design
In the traditional relay – contactor control diagram and typical PLC based control circuit, based on the experience accumulated translation, revised and improved to give final control procedures.

how to Learn Mitsubishi PLC ladder programming

Beginner PLC ladder programming should be to follow certain rules, and develop good habits. In this paper, Mitsubishi FX series PLC, for example, briefly explain the Mitsubishi PLC ladder programming rules to be followed, allowing users to better understand how to learn to see the Mitsubishi PLC ladder programming, we want to help. One thing to note is that although this article Mitsubishi PLC, for example, but these rules when other PLC program must also be observed.

1, PLC ladder ladder are starting left bus, and finally the right bus (usually can be omitted without painting, painting only left bus). The left side of each line is a combination of contacts, it represents the logical drive coil conditions, and represents the result of logic coil can only be connected on the right bus. Contact can not appear in the right side of the coil. The following figure (a) should read (b):

2, the contact should be plotted on the horizontal line, vertical line should be drawn on the relationship as shown in (a) contacts and other contacts between the X005 does not recognize. For such a bridge circuit should be from left to right, top to bottom, the principle of one-way, single draw all the way. FIG. (B) below:

3, parallel block series should contact many of the path on the ladder to the left (left and right light-weight principle); parallel blocks in series, parallel path should be more contacts on the top of the ladder (top heavy the rules). To do so, the program is simple, thus reducing scan time directive, which is particularly important for some large programs. As shown below:

4, not to use double-coil output. If the same ladder, more than two coils of the same component or twice, then known as the reuse or dual-coil output coil. Usually one of the dual-coil output ladder for beginners easy to commit wrong. In the double-coil output, only the last coil to be effective, and front coil is invalid. This is caused by the PLC scan feature of the decision.
PLC uses the CPU work cycle scan. Generally consists of five phases (as shown): internal diagnostics and treatment, and communication peripherals, input sample, the user program execution and output refresh. When the mode switch is in STOP, before performing only two phases: internal diagnostics and treatment, and communications peripherals.

1, the input sampling stage
PLC sequential reads the state of each input, and the input image is stored in the register we call the internal unit. When entering the program execution stage, such as the input changes state corresponding cell information input image area does not change with it, only the next input sampling phase of the scan cycle, the input image area corresponding to the cell information will change. Therefore, PLC will be overlooked pulse variation is less than the amount of the scan cycle switch input.
2, program execution stage
PLC from the program step 0, beginning with the first following the first left and right sequence scans the user program and logical operations. PLC input image by content area for logical operations, and the result is written to the output image area, rather than directly to the output terminals.
3, the output refresh period
PLC output terminal changes depending on the content of the output image area. This is the actual output of the PLC.
Above brief description of the working principle of PLC, the following examples explain why we then to write ladder program should not be repeated using a coil. As shown below, when the reset input is sampled input image area X001 = ON, X002 = OFF, Y003-ON, Y004 = ON is actually written to the output image area. But to continue down, because X002 = OFF, so Y003 = OFF, this is after the result has been written to the output image area, change the original state of Y003. Therefore, the output refresh period, the actual external output Y003 = OFF, Y004 = ON. Many newcomers to come across such a problem, why X001 has been closed, and no output Y003 it? Logic is wrong. In fact, because the use of double coil caused.

Note: we are talking about is not (should not) use dual-coil, double coils are not absolutely prohibited, in some special occasions can also use double-coil, then you will need a more extensive programming the experience and skills. Let’s talk about this. But still do not risk it for beginners. In fact, it can be seen from the above examples, the reason will result in Reuse coil output Y003 confusion is due to the reason the program is executed sequentially from top to bottom caused. But if we can change the order of program execution, at any time to ensure that the two coils is only one logical drive occurs, you can use double-coil. The most common method is to use a jump instruction

Program Analysis: M0 closed, the program jumps to at P0 (no X001 statement), M0 normally closed off, CJ P1 does not occur, the next statement. In this case, Y003 to X002 state drive. State M0 disconnected, according to the order of execution of T003 X001 is driven M0 NC closed skip P1 state by X003 to drive on Y004, which skips the X002 drive Y003 statements. Visible at the same time, Y003 drive only one can occur. In this case, the use of double-coil is possible.
But in ladder programming, we still have to try to avoid the use of dual-coil, and the introduction of auxiliary relay is a commonly used method. As shown below:

Figure (b),, X001 and X002 contact control auxiliary relay M000, X003 ~ X005 contact control auxiliary relay M001, and then by two relays M000, M001 parallel combination of contacts to control the coil Y000. Such logic has not changed, yet the double coil into a single coil.

if you find mitsubishi plc cable can click here

STEP 7 hardware configuration tool HW Config

Select the SIMATIC manager on the left side of the station, double-click the right window of the “hardware” icon, open the hardware configuration tool HW Config

(1) hardware directory

You can use the menu command to “view”, “directory” or the button on the toolbar to open or close the hardware directory window on the right. Select a hardware directory in a hardware object, the hardware directory below the small window to see its brief information, such as the main function of the order number and module, etc..
CP hardware directory is a communication processor, FM is a function module, IM is the interface module, PS is the power module, RACK is the rack or guide rail. SM is a signal module, in which the DO, AI respectively is the digital quantity input module and the digital quantity output module, AO, DI respectively is the analog quantity input module and the analog quantity output module.

(2) hardware configuration window

Figure 2-20 the upper left window is the hardware configuration window, the window is placed in the host frame and the expansion of the rack, and use the interface module to connect them. PROFIBUS-DP network can also be generated in the window, and placed DP from the station on the network.

(3) hardware information display window

Select the hardware configuration window in a rack or DP slave station, the following hardware information display window will display the detailed information of the selected object, such as module order numbers, CPU firmware version number and in the MPI Network station address, and I / O module address and annotations. The upper left corner of the window button is used to switch the rack or DP slave station in the hardware configuration window.

Omron PLC high-speed counter reset method

Omron PLC high-speed counting the number of reset mode, choose Z signal + software reset and soft reset in two ways.
       1. Z signal + software reset mode

       High-speed counter reset flag is ON state, Z-phase signal and reset input OFF → ON time by the high-speed counter current value is reset. The case of addition, since the reset flag is ON, 1 cycle 1, can be determined only in the common process, and therefore occur in the ladder program OFF → ON from the beginning of the next cycle Z-phase signal is active again.

       2. Soft reset mode

       When high-speed counter reset flag from OFF to ON, the high-speed counter current value is reset. In addition, the reset flag OFF to ON determination 1 cycle 1, carried out in the common process, the reset process is also the time. However, in the middle of a cycle period when ON to OFF change, reset flag is Dhamma track.

Omron PLC programming software to use the function block

Omron PLC programming software also increases the function block function block preparation software features to IEC61131-3
A function block call a ladder example
The main purpose is to promote good function block structured programming, function calls; allow complex programs to create less code, more manageable process.
A block from the block header and block body composition
Physique – to be used in the function block program data: as a variable input and output connections, the function block variables, parameters are defined locally within a block – parameters.
Blocks may contain instructions algorithm – this is the actual code for each function block execution. Call, the corresponding input and output variables corresponding to the actual variable substitution. Not all PLC function blocks can be created.
The function block can be established Omron PLC: CJ1M, CJ, CS, CP1H / L, etc;
The number of each type of PLC function blocks that can be created is different. You can define up to 64 function blocks in the PLC, up to 30,000 write statements.
Steps for creating and using function blocks
A, PLC must be a valid PLC type.
Second, the definition of the function block is created. Select the appropriate function block type: ladder or structured text; the new block is created, its name will default to ‘block’.
Third, it is to open the block for editing, including setting a variable using function blocks in the block header; block the use of written algorithms function block ladder structured editor or a text editor to write.
Fourth, created after the function block can be called in the main program using the ladder diagram editor.
If a specific function block already exists, from ‘FB list’ option. If not, the function block is created only need to enter a new name, select the appropriate ‘FB list’ definition. The function block is created automatically in the global symbol table selection (including the allocation of memory for each variable in the function block header is defined); calling function block will be displayed in the ladder.Executive function block calls can be connected to the function block EN input pin through execution conditions. When the execution condition is satisfied (equivalent to True), energy flow reaches the EN pin, the function block is executed. Function Block ENO output pin optional. It is optional; you can connect to perform coil or execution conditions, but the right-most elements must be terminated with a coil or instructions.
V. The function block input and output pins.
These pins must use the [ENTER] key or from [insert] [function block parameters] menu option to select the parameters of the connection; rather than using the contact or coil connection. Left function block input pin; the right side of the function block output pin. Input and output pins connected to the function block is entirely optional.
Sixth, after the setup is complete, CX -P program can compile, download and run.
Establish ways
Select the tree menu [block], right insertOr select the tree menu [block], and then from the drop-down menu [Insert], select the [block]
There are several forms to create
First, the direct import (suffix .CXF) existing function blocks from the file;Second, create your own: structural way to write text; or a ladder to write.
Select the appropriate cell programming area, right call, or use the [Insert] menu [function block call] option.

Frequency measurement for Omron PLC high-speed counter

By PRV instruction, you can read the frequency of the input pulse, high-speed counter frequency measurement, frequency is measured in Hz, hexadecimal 8-bit output, and can be used only in high-speed counter 0. In addition, also during high-speed counter 0 comparison operation at the same time, measurement frequency. Even in the frequency measurement, nor will feature high-speed counter, pulse output function has been affected.

      1. High-speed counter frequency measurement step

(1) the use of high-speed counter settings without using the /: the PLC Setup High-speed counter [O / without] is set to “use.”

      (2) counter selection: Setting PLC Setup High-speed counter in the [] / [] pulse input mode.

      Sampling (3) Value range mode: select System Settings in the PLC high-speed counter [O] / [] mode range of values, the value range mode to ring mode, the selection PLC Setup High-speed counter 0 [ ] / [] ring counter maximum value.

      (4) Select the reset method of high-speed counter current value: Select PLC Setup High-speed counter [0] / [Reset] mode.

      Execution (5) PRV instruction: Operands N is the number of high-speed counter [high-speed counter input 0: # OO1O]; C is the frequency of the operand read is # 0003; operand D is a frequency to save channel.

Omron PLC equipment disassembly sequence and method

(1) downtime must be two or more people care operations;
(2) The front panel of the CPU mode selector switch from “Run” to “stop” position;

(3) off the main power supply of the PLC, and then close the other to die Sakamoto power supply;

(4) The power supply shelf connected to the power line wire number and remember clearly after connecting position, and then remove the screws power racks and cabinets connected to the power rack can be removed;

(5) CPU board and I / 0 board may, upon rotating the screw template underneath removed;

(6) When installing in reverse order.

Hardware interrupt (OB40) – Siemens S7-300PLC organization block OB

Response process from different modules (eg I / O modules, CP or FM module module) issued a warning or a hardware interrupt request signal.

OB 40 runs, the operating system does not receive the other hardware interrupt requests.
You can modify the parameters for analog or digital module with a programming tool which is set by the start signal OB 40. For CP and FM, the software must also provide supporting module settings. By calling SFC, also set online is interrupted by a hardware module in the program is running.

OB40 Application

When the system is configured analog input module, the user can set the allowable range of measured values, if the measured value exceeds this limit, OB40 is called. This feature is similar to the OB1 the comparison logic, but it is omitted in OB1 control program, saving the scan cycle time.

PLC programming elements timer

Timer is equivalent to relay time relay in the circuit may delay control in your program. FX2 series programmable controller has the following four types of timer.
100ms timer: T0~T199 200 timing ranges: 0.1~3276.7 s
T200~T245 46 10ms timer timing range: 0.01~327.67 s
1ms totalizer timers T246~T249 4 (interrupt) time range 0.001~32.767 s
100ms totalizer timer T250~T255 6 timer range 0.1~3276.7s
Timer programmable controller based on cumulative timing clock pulse, clock pulse 1ms, 10ms, 100ms in different specifications. (Process timer job is actually the clock pulse counts) because of work, outside of own numbered memory, timer, also played a set value registers (Word), a current values of registers (Word). Setting register (Word) store when programming timings set value of an assignment. Current values of registers recording timer to the current value. These registers as a 16-bit binary storage. The maximum value multiplied by the time timer value is the maximum timed range of timer values. The timer starts timing conditions are met, current values of registers is counted when the timer actions when the current value is equal to the set value, normally open contacts connected normally closed contacts disconnect, and procedures used to control the object, achieve the purpose of time control.
Figure 6 timer used in the ladder diagram. Figure 6 (a) as a normal non-totalizing timer. Figure 6 (b) integrating the timer. Figure 6 (a) in the X1 time condition, when X1 is switched on t-10 times of the timer begins. K20 as the set value. Decimal number 20 for the timer time unit values of multiples. T 10 to 100ms timer, when set value is K20, its time time of 2s. Y10 for timer objects in the picture. When time is up, timer t 10 normally open connecting, Y10 set to 1. T10 is the non-accumulation-type timer. At the beginning of its time and not when the set value is reached, disconnect timing conditions X1 or PLC power power failure, time to abort and the current values of registers reset (set to 0). Disconnect if X1 or PLC power power failure occurs in the timing process is complete and the contact of the timer action, contact action cannot be maintained.
T 10 timer replace timer T250 product formula, the situation is different. Plot formula of timer in timed conditions or PLC lost lose the power, the current values of registers contents and contact status can be maintained, cumulative timings. So called accumulation. Figure 6 (b) ladder diagram for timer t 250 product formula work. Timer product formula current values of registers and contact with memory function, you must join in a program dedicated to reset reset instructions. X2 is a reset condition. When X2 connected to perform RST T250 instruction, t 250 the current values of registers and contacts at the same time set to 0.

Figure 6 timer using
Timer you can use the number k as the set value at once, such as in Figure 3-5 K20 and K345, also can be used after the data content of the register as a set value. Set timer value is D10 and D10 content is 100, the timer value is 100. When using the data set timer value registers. General use has the power to keep the data register. Even so, if battery voltage decreases, the timer may malfunction.

Mitsubishi FX series PLC multiple output directives (MPS and the MRD, and MPP)

Precautions for use:
(1) the MPS order multiple circuit or circuits of electric shock can be stored up to back multiple branches out.
(2) the 1th MPS stack instruction before the branch, multiple branches using MRD stack before the branch instruction in the middle and last branch of multiple circuits using MPP out of the warehouse instruction.
(3) finally slip MPP instruction must be used, and MPS with MPP‘s use without much 11 times, and occur in pairs.

Mitsubishi FX series PLC instructions

1. take rising edge/falling edge of LDP/LDF——directive
Features: take a single normally open the rising edge/falling edge and bus (bus bar and branch bus left) connected when a rising edge when specifying operating units through to 1 scan cycle.
2. ANDP/ANDF—–with rising edge/falling edge command
Features: series a single normally open the rising edge/falling edge.
3. the ORP/ORF——–or rising edge/falling edge instructions
Features: series a single normally open the rising edge/falling edge.