قدرتی به نام برق
قدرتی به نام برق 
آخرین مطالب
ذکر ایام هفته

آموزش plc s7 به صورت لاتین

counter & timer


Timers are devices that count increments of time. Traffic lights are one example where timers are used. In this example timers are used to control the length of time between signal changes.

Hard-Wired Timing Circuit

Timers used with PLCs can be compared to timing circuits used in hard-wired control line diagrams. In the following example, a normally open (NO) switch (S1) is used with a timer (TR1). For this example the timer has been set for 5 seconds. When S1 is closed, TR1 begins timing. When 5 seconds have elapsed, TR1 will close its associated normally open TR1 contacts, illuminating pilot light PL1. When S1 is open, deenergizing TR1, the TR1 contacts open, immediately extinguishing PL1. This type of timer is referred to as ON delay. ON delay indicates that once a timer receives an enable signal, a predetermined amount of time (set by the timer) must pass before the timer’s contacts change state.

S7-200 Timers

Timers are represented by boxes in ladder logic. When a timer receives an enable, the timer starts to time. The timer compares its current time with the preset time. The output of the timer is a logic 0 as long as the current time is less than the preset time. When the current time is greater than the preset time the timer output is a logic 1. S7-200 uses three types of timers: On- Delay (TON), Retentive On-Delay (TONR), and Off-Delay (TOF).

S7-200 timers are provided with resolutions of 1 millisecond, 10 milliseconds, and 100 milliseconds. The maximum value of these timers is 32.767 seconds, 327.67 seconds, and 3276.7 seconds, respectively. By adding program elements, logic can be programmed for much greater time intervals.

On-Delay (TON)

When the On-Delay timer (TON) receives an enable (logic 1) at its input (IN), a predetermined amount of time (preset time - PT) passes before the timer bit (T-bit) turns on. The T-bit is a logic function internal to the timer and is not shown on the symbol. The timer resets to the starting time when the enabling input goes to a logic 0.

Example Ladder Logic

In the following simple timer example, a switch is connected to input I0.3, and a light is connected to output Q0.1. When the switch is closed input 4 becomes a logic 1, which is loaded into timer T37. T37 has a time base of 100 ms (.100 seconds). The preset time (PT) value has been set to 150. This is equivalent to 15 seconds (.100 x 150 ). The light will turn on 15 seconds after the input switch is closed. If the switch were opened before 15 seconds had passed, then reclosed, the timer would again begin timing at 0.

A small sample of the flexibility of PLCs is shown in the following program logic. By reprogramming the T37 contact as a normally closed contact, the function of the circuit is changed to cause the indicator light to turn off only when the timer times out. This function change was accomplished without changing or rewiring I/O devices.

Retentive On-Delay (TONR)

The Retentive On-Delay timer (TONR) functions in a similar manner to the On-Delay timer (TON). There is one difference. The Retentive On-Delay timer times as long as the enabling input is on, but does not reset when the input goes off. The timer must be reset with a RESET (R) instruction.

The same example used with the On-Delay timer will be used with the Retentive On-Delay timer. When the switch is closed at input I0.3, timer T5 (Retentive timer) begins timing. If, for example, after 10 seconds input I0.3 is opened the timer stops. When input I0.3 is closed the timer will begin timing at 10 seconds. The light will turn on 5 seconds after input I0.3 has been closed the second time. A RESET (R) instruction can be added. Here a pushbutton is connected to input I0.2. If after 10 seconds input I0.3 were opened, T5 can be reset by momentarily closing input I0.2. T5 will be reset to 0 and begin timing from 0 when input I0.3 is closed again.

Off-Delay (TOF)

The Off-Delay timer is used to delay an output off for a fixed period of time after the input turns off. When the enabling bit turns on the timer bit turns on immediately and the value is set to 0. When the input turns off, the timer counts until the preset time has elapsed before the timer bit turns off.

Timers Specifications

The S7-200s have 256 timers. The specific T number chosen for the timer determines its time base and whether it is TON, TONR, or TOF.

Timer Example

In the following example a tank will be filled with two chemicals, mixed, and then drained. When the Start Button is pressed at input I0.0, the program starts pump 1 controlled by output Q0.0. Pump 1 runs for 5 seconds, filling the tank with the first chemical, then shuts off. The program then starts pump 2, controlled by output Q0.1. Pump 2 runs for 3 seconds filling the tank with the second chemical. After 3 seconds pump 2 shuts off. The program starts the mixer motor, connected to output Q0.2 and mixes the two chemicals for 60 seconds. The program then opens the drain valve controlled by output Q0.3, and starts pump 3 controlled by output Q0.4. Pump 3 shuts off after 8 seconds and the process stops. A manual Stop switch is also provided at input I0.1.


Counters used in PLCs serve the same function as mechanical counters. Counters compare an accumulated value to a preset value to control circuit functions. Control applications that commonly use counters include the following:

Count to a preset value and cause an event to occur

Cause an event to occur until the count reaches a preset value

A bottling machine, for example, may use a counter to count bottles into groups of six for packaging.

Ladder Logic

Counters are represented by boxes in ladder logic. Counters increment/decrement one count each time the input transitions from off (logic 0) to on (logic 1). The counters are reset when a RESET instruction is executed. S7-200 uses three types of counters: up counter (CTU), down counter (CTD), and up/downcounter (CTUD).

There are 256 counters in the S7-200, numbered C0 through C255. The same number cannot be assigned to more than one counter. For example, if an up counter is assigned number 45, a down counter cannot also be assigned number 45. The maximum count value of a counter is ±32,767.

S7- 200 Up Counter

The up counter counts up from a current value to a preset value (PV). Input CU is the count input. Each time CU transitions from a logic 0 to a logic 1 the counter increments by a count of 1. Input R is the reset. A preset count value is stored in PV input. If the current count is equal to or greater than the preset value stored in PV, the output bit (Q) turns on (not shown).

S7-200 Down Counter

The down counter counts down from the preset value (PV) each time CD transitions from a logic 0 to a logic 1. When the current value is equal to zero the counter output bit (Q) turns on (not shown). The counter resets and loads the current value with the preset value (PV) when the load input (LD) is enabled.

S7-200 Up/Down Counter

The up/down counter counts up or down from the preset value each time either CD or CU transitions from a logic 0 to a logic 1. When the current value is equal to the preset value, the output QU turns on. When the current value (CV) is equal to zero, the output QD turns on. The counter loads the current value (CV) with the preset value (PV) when the load input (LD) is enabled. Similarly, the counter resets and loads the current value (CV) with zero when the reset (R) is enabled. The counter stops counting when it reaches preset or zero.

Counter Example

A counter might be used to keep track of the number of vehicles in a parking lot. As vehicles enter the lot through an entrance gate, the counter counts up. As vehicles exit the lot through an exit gate, the counter counts down. When the lot is full a sign at the entrance gate turns on indicating the lot is full.

Up/down counter C48 is used in this example. A switch, connected to the entrance gate, has been wired to input I0.0. A switch, connected to the exit gate, has been wired to input I0.1. A reset switch, located at the collection booth, has been wired to input I0.2. The parking lot has 150 parking spaces. This value has been stored in the preset value (PV). The counter output has been directed to output Q0.1. Output 2 is connected to a “Parking Lot Full” sign. As cars enter the lot the entrance gate opens. Input I0.0 transitions from a logic 0 to a logic 1, incrementing the count by one. As cars leave the lot the exit gate opens. Input I0.1 transitions from a logic 0 to a logic 1, decrementing the count by 1. When the count has reached 150 output Q0.1 transitions from a logic 0 to a logic 1. The “Parking Lot Full” sign illuminates. When a car exits, decrementing the count to 149, the sign turns off.

[ چهارشنبه 5 اسفند‌ماه سال 1388 ] [ 11:18 ب.ظ ] [ سیدمحمدصادق میرمحمدی ]
.: Weblog Themes By Iran Skin :.

درباره وبلاگ

سید محمد صادق میرمحمدی.مهندس برق قدرت.عضو انجمن مهندسین برق و الکترونیک ایران.عضو انجمن انرژی خورشیدی ایران.عضو انجمن روشنایی.عضو انجمن آموزش مهندسی.عضو انجمن مهندسی برق ایران.دارای مدرک بین المللی ماکروسافت.نویسنده 5 مقاله چاپ شده در زمینه انرژی های نو.و یک مقاله isc در کنفرانس روشنایی ایران.حوزه فعالیت در زمینه روشنایی ،انرژی های نو و مهندسی برق.طراح چراغهای led.مسلط به رایانه.طراح سایت جهت ارتباط با sadegh4@gmail.com در تماس باشید.
نظر سنجی
امکانات وب


تعداد بازدید ها: 235922