Home / Plc

Procedure for Designing a PLC Control Program


Input Output


&

>=1

Block diagram of the function Negative input Negative output


OR plus AND plus


From basic logic blocks when programming, we can combine blocks together to create commands with different functions according to digital circuit logic thinking.

1.3.6.2. Procedure for designing a PLC control program

PLC programming has become increasingly popular in Vietnam today thanks to the popularity of PLCs for many applications. Programmers can program on computers and write programs according to specific requirements and then load them into PLCs to control a certain system. Systematic design techniques include the following steps:

1 - Study the control requirements of the device

First we must decide what device or system we want to control. The main purpose of a programmable controller is to

control an external system. This controlled system can be a device, machine, or process and is often referred to as the control system.

2 - Determine the requirements for inputs and outputs

All external input and output devices connected to the PLC controllers must be identified. Input devices are switches, sensors, etc. Output devices are magnetic devices, valves, etc.

solenoid, motor and indicator lights...

3 - Determine the algorithm to be used

An algorithm is a sequence of steps that defines a method for solving a problem. This is usually done using a flowchart or written in a decoding algorithm. This is a very important step and is the content of the control program.


4 - Write control program


Next, write the program in the form of a ladder diagram through the order of operation of the control system as determined, step by step. From the ladder diagram can be translated into other forms to make it easier to follow the program.

5 - Load the program into memory

From the written program and the defined inputs and outputs. We access the program in memory or programming keyboard or by computer with the help of programming software tools. After completing the programming, we check for any coding errors using a tool that is a diagnostic function that, if possible, simulates the entire operation to see that it is as desired.

6 - Test the control program

To ensure that the program structure and the installed parameters are correct before entering the control system, we need to test run the control program. If there are errors or are not reasonable, fix them when running the control program. It is best to pair with

object and complete the program according to the machine's operation.

1.3.6.3. S7 – 200 command syntax

The S7 - 200 command system is divided into three groups as shown below:

+ Instructions that when executed work independently of the stack value.

+ Instructions can only be executed when the logical value of the first bit in the stack is 1.

+ Command labels mark positions in the script.

- I: Used to indicate the physical input directly connected to the PLC

- Q: Used to indicate the physical output directly connected to the PLC

- T: Used to identify the timing element in the PLC

- C: Used to determine the counting element in the PLC

- M and S: Used as memory flags operating inside the PLC

* All the above elements (operands) have two states ON or OFF (0 or 1)


CPU Operand Limit Table 224


How to access

Baby

CPU 226

Operand limit


V

0.0 - 5119.7


I

0.0 - 15.7

Bit access

Q

0.0 - 15.7


M

0.0 - 31.7


SM

0.0 - 299.7



0.0 - 31.7


T

0 – 255


C

0 - 255


L

0.0 - 59.7


VB

0 – 5119


IB

0 – 15

Access

QB

0 - 15

byte

MB

0 - 31


SMB

0 - 299


SB

0 - 31


LB

0 - 59


AC

0 – 3



Constant


VW

0 - 5118


IW

0 – 14

Access to

QW

0 - 14


MW

0 - 30


SMW

0 - 298


SW

0 - 30


T

0 – 255


C

0 - 255


LW

0 - 58


AC

0 - 3


AIW

0 - 62


AQW

0 – 62



Constant


Example

0 - 5116


ID

0 - 12

Access

QD

0 - 12

double word

MD

0 - 28


SMD

0 - 296


LD

0 - 56


AC

0 - 3


HC

0 - 5



Constant

Maybe you are interested!

Procedure for Designing a PLC Control Program

** Basic commands


1 – Input/Output Commands

+ Load (LD): The LD instruction loads the logical value of a contact into the top bit of the stack, the remaining old values ​​in the stack are pushed back one bit.

+ Load Not (LDN): The LDN instruction loads the inverse logic value of a contact into the first bit of the stack, the remaining values ​​in the stack are pushed back one bit.

The different forms of LD, LDN instructions for LAD are as follows:


LAD

Describe

Operand

n

Normal contact

is closed if n=1 .

open

will

n: I, Q, M, SM, T, C, V

(bits)

n

The normally correct contact will open when n=1.

n

Normal contact

instantaneous close when n=1

open

will

n: I

n

The contact is normally open instantly when n=1.

close

will


Different forms of LD, LDN instructions for STL are as follows:


Luong

Describe

Operand

LD n

The instruction loads the logical value of point n into the first bit of the bin.

n (bits): I, Q, M, SM, T, C, V

LDN n

The instruction loads the logical inverse of point n into the first bit of the stack .

LDI n

The instruction loads the immediate logic value of point n into the first bit of the stack .

n: I

LDNI n

The instruction loads the immediate inverse logic value of

point n to the top bit of the stack.


+ OUTPUT (=)

The instruction copies the contents of the first bit in the stack to the specified bit.

specified in the instruction, the contents of the stack are not changed .

The LAD command is described as follows:


LAD

Describe

Operand

n

( )

The output coil is in the excited state when the control current passes through it.

n: I, Q, M, SM, T, C,

V

(bits)

n

( I )

The output coil is in the excited state instantly when the control current passes through.

n: Q (bits)


The command description in STL is as follows:


STL

Describe

Operand


= n

Copy the value of the top of the stack to the n-point

as specified in the command.

n: I, Q, M, SM, T, C, V

(bits)


= In

Immediately copy the value of the top of the stack to the next

point n is specified in the command.

n: Q (bits)


2 – Commands to write/clear values ​​to contacts

SET (S) ; RESET (R):


The instructions used to close and open the interrupt points have been designed. In LAD, the logic controls the current that turns the output coils on or off. When the current

control to the coils then the coils close or open the contacts (or a series of contacts).

In STL, the instruction transfers the top bit state of the stack to the design contacts. If this bit has a logic value of 1, the R and S instructions will close or open the contact or a series of contacts (limited from 1 to 255). The contents of the stack are not changed, below is the instruction description.


LAD command description


LAD

Describe

Operand



Close an array of n contacts starting from S BIT.

S BIT: I, Q, M, SM,

S BIT

n

T, C, V


(S)

n(bytes): IB, QB,

MB, SMB, VB,



AC, Constant, *VD,


S BIT


n

( R )

Interrupts an array of n contacts starting from S BIT. If S BIT points to a timer or counter again, the instruction clears the bit.

Timer and counter output

already

*AC



Instantly close an array

S BIT: Q

S BIT

n

( SI )

consists of n contacts starting from S BIT.


N(byte): IB, QB, MB, SMB, VB,AC, Constant




se, *VD, *AC


S BIT


n

( RI )

Instantly interrupts an array of n contacts starting at S BIT.


Command description in STL


STL

Describe

Operand

SS BIT n

Write a logical value to an array of n bits starting from address S BIT.

S BIT: I, Q, M, SM,


T, C, V


(bits)

RS BIT n

Delete an array of n consecutive elements

points from S BIT. If S BIT points to a timer or counter again, the instruction clears the bit.

Timer and counter output

already


n: IB, QB, MB,

SMB, VB

(byte) AC, Constant,

*Example, *AC

SIS BIT n

Writes a logical value to an array of n bits starting at address S BIT.

S BIT: Q


(bits)


n: IB, QB, MB,

RIS BIT n

Instantly clears an array of n contacts starting at S BIT.

SMB, VB (bytes)

(byte) AC, Constant,

*Example, *AC


3 - Boolean algebraic logic instructions

These are instructions that execute independently of the logic value of the stack. Boolean algebra contact instructions allow the creation of logic circuits (without storage). When executing Boolean algebra contact instructions in LAD, these instructions are represented through a circuit structure, connecting normally closed contacts and normally open contacts in series or parallel. In STL, the contacts

The stack is replaced by A ( And ) and O ( or ) instructions for open functions or AN ( And not ), ON ( or not ) instructions for closed functions. The value of the stack changes depending on the instruction.

In addition to the commands that work directly with contacts, the S7-200 also has 5 special commands.

Comment


Agree Privacy Policy *