Summary of PLC timer instruction & counter instruction & comparison assignment instruction

Summary of PLC timer instruction & counter instruction & comparison assignment instruction

1. Timer instruction

One, the storage space of the timer

Generally, there are a total of 256 timers from T0 to T255, and 16-bit storage is used for a single timer.
Insert picture description here
Timer value = time base x count value (BCD)
BCD (4 bits): 0~9;
count value: 0~999;
maximum value: 999*10s = 2h46m30s
time base:
00: 10ms
01: 100ms
10: 1s
11: 10s

Second, the classification of timer instructions

Classified by type: Coil type, block diagram type
Classified by function:
SP: Pulse timer
SE: Extended pulse timer
SD: On-delay timer
SS: Keep on timer
SF: Off-delay timer

3. Coil types of various timers

1. Pulse timer (SP): When there is a rising edge, this timer loads the timer value, and the timer value continues to decrease until it decreases to 0, which means that the timer time is up; during this period, the timer touches Point the action.
Insert picture description here
Examples and timing diagrams:

When the RLO before this kind of timer is 0, the timing stops and the timer contact is reset.
Insert picture description here
2. Extended pulse timer (SE): When there is a rising edge, this kind of timer loads the timing value, and the timing value continues to decrease until it decreases to 0, which means that the timing time is up; during this period, the timer The action of the contact.
Insert picture description here
Examples and timing diagrams:

If the timing time has not arrived, the state of the logic bit (I0.0) will change from "1" to "0". At this time, the timer will continue to run until the timing is completed. This is the difference between the SE instruction and the SP instruction.
Insert picture description here
3. On-delay timer (SD): When there is a rising edge, this timer loads the timer value, and the timer value continues to decrease until it decreases to 0. When it decreases to 0, the timer is up; after the timer is up It will cause the timer contact to switch on.
Insert picture description here
Examples and timing diagrams:

After this kind of timer delays for a period of time, if RLO is still 1, the timer output is turned on.
Insert picture description here
4. Keep on-delay timer (SS): When a rising edge arrives, this type of timer loads the timer value, and the timer value continues to decrease until it decreases to 0. When it decreases to 0, the timer time is up; the timer time is up It will cause the timer contact to be continuously connected.
Insert picture description here
Examples and timing diagrams:

After the timer value of this kind of timer arrives, the delayed connection will continue to be maintained until the reset signal arrives.
Insert picture description here
5. Turn-off delay timer (SF): When a falling edge arrives, this timer loads the timer value, and the timer value continues to decrease until it decreases to 0. When it decreases to 0, the timer is up; after the timer is up It will cause the timer contact to open.
Insert picture description here
Examples and timing diagrams:

After the timer control signal is turned off, the timer starts to count, and the timer remains on until the timer expires.
Insert picture description here
4. Block diagram types of various timers The block diagrams
Insert picture description here
of pulse timers are identified in the figure, and other timer block diagrams are replaced with corresponding names. The pulse timer has more coil types. For example, we can directly reset the timer through the R terminal, get the current value of the timer in integer format through the BI terminal, and get the current value of the timer in BCD code format through the BCD terminal.
If in the application, the timer is only used for simple timing functions, and no detailed information is needed, you can use the coil type; and if you want to perform a reset operation, especially to get the current value of the timer, we can use the block diagram type.

Second, the counter instruction

One, the storage space of the counter

Generally, there are a total of 256 counters from C0 to C255, and 16-bit storage is used for a single counter.
Insert picture description here
BCD (4 digits): 0~9;
count value: 0~999;

When the count reaches the upper and lower limits, the count value will no longer change. As long as the count value in the counter is not 0, the logic value of the counter is 1; only when the count value in the counter is 0, the logic value of the counter is 0. The logic value of the counter can also be represented by a normally open contact whose address is the counter number. The counter has a power-off hold function.

2. Classification of counter instructions
Type classification: coil type, block diagram type
Coil type: counter initial value instruction addition counter instruction subtraction counter instruction
block diagram type: reversible counter instruction addition counter instruction subtraction counter instruction

3. Coil type counter instruction
1. Counter initial value instruction: When the RLO before this instruction has a positive edge, this instruction loads the preset value into the designated counter.
Insert picture description here
2. Adding counter instruction: When the RLO before the instruction has a positive edge, the instruction will increase the value of the designated counter by 1. If no positive edge occurs, or the counter value has reached the maximum value of 999, the counter value will remain unavailable. change.
Insert picture description here
3. Subtract counter instruction: When the RLO before the instruction has a positive edge, the instruction will decrement the value of the designated counter by 1. If no positive edge occurs, or the counter value has reached the minimum value of 0, the counter value will remain unavailable. change.
Insert picture description here
Example: Use the counter instruction of the coil type to implement a reversible counter:
Insert picture description here
Insert picture description here

4. Block diagram type counter instruction
Insert picture description here
The ladder diagrams of the other two counter block diagram types are basically similar to the reversible counter. But the block diagram type is more complicated than the coil type. If in the application, the counter is only used for simple counting functions, and no detailed information is needed, you can use the coil type; and if you want to reset, especially to get the current value of the counter, we can use the block diagram type.

Three, compare assignment instructions

1. Comparison instruction
Classification by function: equal to/not equal to/greater than or equal to/less than or equal to/greater than/less than
classification by object:
integer comparison instruction (INT) 16-bit
double integer comparison instruction (DINT) 32-bit
floating - point number comparison instruction ( REAL) 32-bit

1. Integer is equal to comparison instruction
Insert picture description here
Insert picture description here
2. Double integer is greater than comparison instruction
Insert picture description here
Insert picture description here
3. Floating point number is less than or equal to comparison instruction
Insert picture description here
Insert picture description here
2. Assignment instruction
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_45252077/article/details/106647463