跟读练习: PLC Programming Tutorial - Ladder Logic #2: Timers and Counters - 通过YouTube学习英语口语
C1
⏸ 已暂停
What's up Automation Nation?
315 句
如果句子过短或过长,请点击 Edit 进行调整。
1
What's up Automation Nation?
2
Welcome back to LeMaster Tech and in today's video we're going to continue our tutorial series on ladder diagram basic
3
Ladder Programming for Automation and Controls Engineering.
4
Today we're going to be looking at the most common types of timers and counters used in PLC programming.
5
We're going to look at TONs, which are timer on delay, TOF, which is timer off delay,
6
TONR, which is often also abbreviated RTO or retentive timer in other platforms.
7
And then we're also going to look at counters, count up, count down, they're pretty much the same.
8
So we're going to cover all of these today.
9
We're going to the syntax is quite different, but the concept is exactly the same.
10
If you're using these in structured text or another PLC programming language, this is meant as a standalone tutorial.
11
So the concepts in here don't require prior knowledge of any of the past tutorials,
12
but we are also compounding automation and controls and ladder programming knowledge as we go through this series.
13
And as we dive into these tutorials, if you're really enjoying the content, be sure to leave a like on the video, subscribe to the channel.
14
And if you want to help me grow faster, feel free to check out my Patreon down below as well.
15
So to start as a reminder, my physical setup, which we kind of covered in the last video,
16
I have a 24 volt power supply that is powering a Siemens Symatic S7 -1200 PLC.
17
It's running TIA Portal version 17.
18
We're covering ladder diagram, not Siemens TIA portal.
19
So the instructions that we're covering in this video will work for most platforms, but that's what I'm using.
20
And then for demonstration purposes, I have a control box with two hand switches
21
and four output lights that are going to be used for the examples in this video.
22
So if you want to pause on this, my face is probably in the way.
23
If you want to pause on this wiring schematic and build some similar test bench, go ahead.
24
that I'm using in the description below the video.
25
Okay, so let's dive right into it.
26
I'm gonna go ahead and delete out everything I have in this code.
27
Okay, so I've got all functional code out of this program.
28
The only thing we're calling in main is the LadderTutorials binary function, which is what we're programming here, and it has no code in it.
29
And then if I show all the PLC tags, All I have are my four output tags for my lights and my two input tags for my hand switches.
30
I added those in the last video if you're curious.
31
But there's nothing on this PLC, so now let's dive into the timer.
32
and we're going to drop the empty box function in here, and we're just going to start with a TON.
33
The T -O -N is...
34
timer on delay, it is the most common timer.
35
And honestly, you can do almost everything you need to do in code with this.
36
So we'll call it example ton.
37
Let's do EX all caps just some crazy like that.
38
We're gonna do an example timer on delay here.
39
Okay, and it's kind of nice.
40
It populates with the four parameters you need to know about for timers.
41
There's on what condition do we want this timer to start?
42
That's this in some platforms will call that EN for enable, some platforms will have IN for input,
43
but they're sort of universally on what conditions do you want to start the timer?
44
Now, PT, process timer, preset timer, it doesn't really matter.
45
That's your set point.
46
Okay, it's called PT in almost every platform,
47
but that's your set is going to be something that starts on these input conditions,
48
counts up to a value, that's your PT, and And then when the timer finishes, that will actuate your output bit,
49
which is just true, false, has the timer finished.
50
And that's my cue.
51
If you remember most European and international standards to avoid O's that look like zeros, call outputs cues.
52
But like Rockwell Allen Bradley uses an O there.
53
They just say like, hey, you'll figure it out.
54
Um, for output, but the Q is going to be what happens when the timer is done.
55
And then the only other thing we haven't talked about here is this ET, which is our elapsed time.
56
So as the timer is counting up to that preset time value,
57
it's continuously keeping track of how much time has passed in the elapsed time field.
58
So that's everything that makes up a timer object.
59
And you might have seen when I made this TO and block, it created a database of this example timer.
60
you have to create a little pocket of memory to store these variables.
61
There has to be the input bit, the Q bit, the output bit the preset timer and the elapsed timer stored somewhere.
62
So that's living in a timer database that's called example timer.
63
So let's say what do we want to have actuate this timer to have it start.
64
Simplest thing we can do is just say when I turn hand switch one on.
65
So while hand switch one is on.
66
And if you missed the previous video on binary conditions, This means that the whole time hand switch one is on, I want the timer counting up.
67
So not just when I turn it on, which would be like this P, which would be the positive transition of it turning on,
68
but the whole time hand switch one is on I want this timer counting up.
69
Now, we're not going to put anything in elapsed time
70
because it's a purely internal thing that's keeping track of how long the timer has been active.
71
but we'll put two seconds in preset time.
72
So we'll say 2000 because the default unit is going to be milliseconds.
73
But what you see when I hit enter is that it says T pound sign 2S.
74
Okay, so the Siemens PLC is taking that value, inferring that I meant milliseconds, and it's making it
75
T pound sign to s
76
which is the Siemens PLC standard for a time parameter in
77
like Alan Bradley it's just gonna leave the millisecond value punch in there
78
if I were to say two and a half seconds if I were to type in 2500 here
79
It's going to give me this T pound sign two seconds underscore 500 milliseconds.
80
It's honestly kind of annoying, but you can even delete the S and the underscore and just say T pound sign 2500 milliseconds.
81
that part doesn't matter too much because if you want, you can always just throw a millisecond value in there and TIA portal generally is going to translate it for you.
82
Most PLC timers are expecting you to punch in a millisecond value there.
83
Let's go ahead and change it back to two seconds, 2000 milliseconds.
84
We're not going to put anything in the elapsed time.
85
And then we're just going to add when the output finishes, when the timer finishes.
86
Let's go ahead and turn on output light one.
87
Okay, so I've got my box here.
88
I think it looks pretty good last video just keeping it on screen.
89
Let's download this to the PLC.
90
We're going to hit these little glasses and play button which is live monitoring.
91
And every PLC platform generally has some form of live monitoring the logic, so just make sure to hit the button for yours and now we're going to look when i turn on
92
Hand switch 1, we should see a timer start counting and after 2 seconds the light should turn on.
93
Okay?
94
And it's beautiful when it works.
95
When I turn the hand switch off, it's going to turn off right away.
96
And what you could see when I turn this on is the timer starts counting.
97
Maybe you could see the elapsed time value starts counting up there.
98
So elapsed time is the number on top that's counting up 0, 250 milliseconds, 1 second, 2 seconds until the light turns on.
99
So that is the basic functionality of a timer on delay is conditions trigger it to start
100
you can use the output bit of that timer to turn on the light.
101
Now, an interesting derivation off of this, but super useful if you want your timers and your commands for your timers in different spots,
102
you can reference this example timer Dot done bit you can reference that bit on a separate line of code.
103
This will work exactly the same way.
104
So in a really large ladder program, you might want to create a timer based on a certain input in one spot.
105
but then use the output of that timer in another spot You can do
106
that with this sort of referencing the timer output elsewhere.
107
So if I turn the hand switch on, you'll see the timer still counts up.
108
The timer done bit will become true and then the output light will still turn on.
109
So you can reference that output light elsewhere.
110
One additional thing to mention while we're here, you can look for a, let's say, greater than block, greater than.
111
And we'll say, get rid of the X timer dot done bit here.
112
We'll say now if X timer...
113
dot elapsed time is greater than one second.
114
And now let's also say, just to get tricky with it, let's say "and the timer's not done." Okay?
115
then we want the light to turn on.
116
This is us looking at the elapsed time and saying, "Okay, the timer's been active for more than one second
117
but hasn't yet finished." That's when we want to turn on the light.
118
So we're creating a program that, if it's working correctly, should turn on when the timer gets to one second, so halfway finished, and then turns off after one second.
119
So let's take a look.
120
OK, that's kind of a cool example of using elapsed time and the done bit, and you kind of get a multi -state output out of that.
121
So that's sort of every component of the basic TON, timer on delay block.
122
Now let's look at TOF, and this is going to go really fast because it's very similar.
123
Okay, so let's go ahead and put this back just as the very simplest version, which was just when the timer finishes, we'll turn output light 1 on.
124
And now we'll start making something that instead is going to look at hand switch 2.
125
Thank you.
126
and here's where it's kinda nice to have the box we can leave all our
127
Previous timers in place and now we're gonna type in T.
128
Oh F.
129
Okay timer off delay and we'll do example Toph okay.
130
Oh F though timer off delay and And similarly, but to show that it's different, we'll make this one 3000.
131
OK, so we'll make this three seconds.
132
it has the exact same in preset time, elapsed time, and cue.
133
It is still a timer block.
134
It has all of the same values, inputs and outputs, and variables as the TON.
135
It's a timer block.
136
The main difference between the TON and the TOF is
137
that this output will become true as soon as the input conditions are true, regardless of how long the preset time is.
138
But they will stay active for a period of time after the input conditions are active, and then go away after that timer.
139
So timer off delay means
140
Outputs energize immediately when the input conditions are true and then the output is retained for a period of time afterwards.
141
So timer off delay.
142
Let's go ahead and send this one that's going to turn on output light to just
143
so you guys can see exactly what that looks like.
144
Okay, so I'm gonna go ahead and trigger output hand switch to.
145
And you can see the light turns on immediately.
146
And now I'm gonna turn hand switch to off.
147
And now you can see the elapsed time starts counting up and three seconds later output light two turns off.
148
So if we were gonna do something like we did a little bit earlier, which was...
149
use the elapsed time so if we do a greater than and we use the elapsed time on our example toff,
150
example toff dot elapsed time, and we say that when it's greater than 1500, Then we want to turn,
151
let's use output light three so we can leave output light two exactly how it is.
152
when the timer, the elapsed timer is greater than 1500, we want output light three to turn on.
153
So let's go ahead and send that.
154
So with that active, You can see the hand switch is not active right now, but output light 3 is on because the elapsed time has hit 3 seconds.
155
So the timer finished and elapsed time has hit 3 seconds.
156
Let's go ahead and cycle hand switch 2 real quick and talk about what's happening.
157
You can see elapsed time goes to zero and then when I turn the hand switch off, it starts counting up it gets above 1500 and then it stays on.
158
So what you would actually want to do in this case is rather than looking for elapsed time greater than 1500 seconds,
159
we'd want to look at it elapsed time less than 1500 seconds.
160
This is what it'll mean when the timer starts counting, which means at the point the input conditions have fallen false, after half of that countdown,
161
that's when the light will turn on.
162
and here you can see both lights turn on at the same time
163
and they're gonna stay on because elapsed time stays zero the whole time the input conditions are true.
164
And then when I trigger it off, you can see the timer starts counting up.
165
When I hit 15 seconds, the red light goes away or maybe you can't because I moved the box out of the way.
166
But you get the idea.
167
The interesting thing here is elapsed time is zero the whole time that timer is energized because it's not counting.
168
true and my elapsed time is zero.
169
And then once the sort of falling edge of the input conditions are detected, the timer starts counting up and that's when elapsed time starts trending towards preset time.
170
And once elapsed time hits preset time, it stays at or just above preset time and output stays false.
171
So TOF is kind of a count for a certain period of time after a condition has Alright,
172
so let's move on from the TOF and look at what could really be considered kind of the third type of timer, the only other kind of timer really, which is a retentive timer.
173
Alright, let's go ahead and this in Siemens is a TONR.
174
In Allen Bradley, it's RTO or retentive timer.
175
So we'll call it Toner example.
176
Thank you.
177
And there's a new bit on this one.
178
There's reset.
179
And that's because retentive timer is counting up while conditions are true, but it's not going to forget that value.
180
So if I have hand switch one true, this ton elapsed time will start counting up.
181
But if I turn hand switch one back off before it reaches the preset time, elapsed time goes back to zero.
182
It resets by default every time turn hand switch 2 off,
183
this timer is going to start counting up and elapsed time is going to start counting up.
184
But if I turn hand switch 2 back on, it's going to forget how long its elapsed time was and just go back to zero.
185
Sometimes, like if you might want over the span of a day, you want to trigger some sort of clean in place or reset cycle every time something has happened,
186
a valve has been opened for a full hour or something like that,
187
you might want to retain a trigger that's like let's say both hand switches being on...
188
No, let's say both hand switches being off are going to be what's actually going to reset the timer.
189
But both hand switches being on will be what triggers the timer, and then the timer being done.
190
Okay, so let me write this and then re explain it a little bit better.
191
It's hard to write code and explain it super well.
192
Um...
193
at the same time.
194
But let's look at how a retentive timer works by using when both hand switches are true.
195
This will count up.
196
Let's give it a higher target value like 10 ,000 milliseconds or 10 seconds.
197
And then we're going to do nothing with elapsed time.
198
We're just going to let it count up and we're going to have this be what triggers output light number four.
199
Okay.
200
And maybe, yeah, we're going to have some of the other lights triggering during this time
201
because I'm not going to delete those timers.
202
But let's talk through what this is saying again real quick.
203
This is saying when hand switch one and hand switch two are both active, count up.
204
And we'll see elapsed time counting up while both of them are active.
205
But if I turn either of those two hand switches off, this is going to remember.
206
It's going to retain the elapsed time so far.
207
And it's going to store that in elapsed time until someone comes along and resets it.
208
And the reset conditions I have are when both hand switches are off.
209
already finished
210
so basically no matter what this timer is going to hold
211
on to how long both hand switches have been active until it hits 10 seconds
212
and then I can turn both hand switches off to get it to reset let's go ahead
213
and download this and see it in practice okay so
214
Output light 4 is this one that my index finger's on right here.
215
I'm just going to keep the index finger on so you guys don't lose it amidst the other timers we already made.
216
And I turn one hand switch on, the timer's not counting up yet.
217
I turn the second hand switch on, it starts counting up, it gets to 3 seconds, and I turn one of the hand switches off.
218
And you can see just above the timer block, it's holding on to 3 seconds and 441 milliseconds.
219
Now I'm going to turn both of them back on.
220
And I'm going to turn the other hand switch off this time.
221
And you can see I got to 6 .7 seconds, but it remembers how long it was active.
222
Now I turn them both on.
223
and I'm going to let it get up to 10 seconds.
224
And now you can see it's done and output light four turned on.
225
And I'm going to turn one hand switch off.
226
That didn't reset it.
227
I'm going to turn the other hand switch off
228
that didn't reset it because my conditions to reset are both hand switches being off and the timer done.
229
So now if I turn both hand switches off, you see output light four turns off.
230
Okay, so a retentive timer is sort of like I was describing, useful for the total amount of time something was active being true.
231
If you have a heating jacket or a cooling jacket and the total heating time is the thing that matters,
232
but it could start and stop and start and stop numerous times during a batch, but you need to make sure that something is mixing for a minimum of one hour or something like that.
233
A retentive timer can be a really useful tool.
234
and delete all three of these networks and showcase one more thing that is closely related to these.
235
So I think it's super useful to cover here.
236
And I'm going to delete all these networks and we're going to do a counter.
237
Okay.
238
So a counter is not necessarily a timer
239
because you're counting up just total conditions and the number of times a condition has been met, but it's not time bound.
240
So for example, let's go ahead and say I want to count by using the positive rising edge of hand switch one.
241
I want to count the number of times I've cycled hand switch one
242
and I don't care how long it was on
243
or off in between cycles just total number of times that HandSwitch 1 has been turned on.
244
I need to make a memory bit so that I can remember the last state of HandSwitch 1.
245
We covered this in the last video.
246
If you haven't seen a rising edge like one shot trigger before, not a bad idea to go check out the Boolean logic video.
247
But basically, if I want to say, how do I keep track of the total number of times that hand switch one has turned on?
248
I want this instruction called CTU, count up.
249
Other types of counters are count down and then a CTUD, which is count up and down.
250
But we're just going to cover count up because similar to TON, TOF and RTO or TONR, they're all iterations on a theme.
251
So if we cover count up, you should have a pretty good idea what you're doing here.
252
say, let's make a counter example data block.
253
And you're going to see count up, which is actually the trigger to count something.
254
And then we see the reset bit, just like the retentive timer.
255
We see PV, which is the preset value.
256
And in this case, let's say we want this counter to be done when we get to 10 cycles.
257
OK, so 10 times oscillating that hand switch on.
258
And then when this is finished, let's just go ahead and turn all of the lights on.
259
OK, so let's just use all the lights for a cool light show.
260
And we'll say output light two, three, and four are all going to turn on when this counter finishes.
261
All right.
262
And now let's add to the reset condition.
263
What we want to have turn it off.
264
And we'll say, how about the rising edge of hand switch 2 is what's going to reset this.
265
um and let's go ahead and make a hand switch to memory bit just like we did for hand switch one
266
Boolean global memory.
267
Global memory is easier so I don't have to stick it in a database.
268
And let's go ahead and say
269
that I only want the rising edge of hand switch 2 to reset my counter if the counter has also finished, okay? So...
270
This one, totally optional.
271
You don't have to.
272
Add this bit for this to work.
273
It would work just by looking at hand switch to
274
but I'm gonna say I don't want to reset this counter
275
unless it's finished no matter what I want to keep track of how many times this has occurred.
276
So let's go ahead and download this and view it in practice.
277
Okay, so let's get our box up here.
278
Let's look at hand switch one right here and let's start cycling it.
279
Alright, I turn it on, there's the positive edge, and you can see the value of my counter turned to 1.
280
I turn it back off.
281
Doing hand switch 2 does nothing because the counter hasn't finished.
282
But now if I get to 2, three, four five, six, seven eight Nine.
283
Okay, the next high transition of this hand switch is going to complete the counter
284
because you can see it got to its target value.
285
Now it's at 10 and all four of the lights turned on.
286
What's cool about the count up block is it's actually going to keep counting even though it's already finished.
287
So you can use counters to just track total number of times something has happened
288
and not worry too much about that PV value where you're like,
289
curious how often this valve is cycling or things like that.
290
You can use a counter just to track number of strokes.
291
Okay, but now let's say even with hand switch one in the true position, which is obviously the signal to count up.
292
If I make hand switch two now, Oh, it's not going to reset it because I used the wrong bit.
293
Rather than using done, I used count up, which is a trigger...
294
that is not going to be helpful.
295
So we're going to use "QU"
296
which means "Output Count Up has finished." I used "Count Up"
297
which is only true for one cycle when the rising edge of hand switch one is true.
298
PLCs are fast enough that there's no way I was going to get that to work.
299
So this is the output bit saying count up is true
300
and you can see it's already highlighted green because we're well above the set point of 10.
301
So I'm going to go ahead and trigger...
302
hand switch to on again Where's the box?
303
There it is.
304
And you can see all my lights turn off.
305
OK, so count up is very similar to a timer, but it's not time bound.
306
It's sort of conditional bound, but it's super useful to include timers in counters.
307
OK, so I know these are action packed tutorials.
308
It's impossible to cover any of these instructions in every possible use case.
309
But I think we're building a really excellent skill set and fundamental understanding of ladder as we go through these.
310
I hope you found this useful.
311
Drop in the comments any questions that you might have and what you'd like to see next on the channel.
312
I hope you've been finding them useful.
313
If you really love the channel, consider leaving a like on the video, subscribing to the channel.
314
My Patreon is down below.
315
And as always, thank you for watching and see you next time.
下载应用
Everything you need to speak fluently
AI PronunciationScore every sentence
IPA PracticeMaster every sound
VocabularyBuild your word bank
Vocab GameLearn while playing
关于本课
在本课中,学习者将进一步探索梯形图编程中的计时器和计数器的基本概念。这一系列视频将为您介绍最常用的计时器类型,包括开延时计时器(TON)、关延时计时器(TOF)以及保留计时器(TONR),同时还将讨论计数器的使用。通过学习这些内容,您将掌握在PLC编程中如何设置和使用计时器和计数器,为您的自动化控制工程提供扎实的基础。
关键词汇和短语
- 计时器(Timer) - 在特定条件下延迟执行的一种功能。
- 开延时计时器(TON) - 计时器在启用状态下开始计时的类型。
- 关延时计时器(TOF) - 计时器在关闭状态下开始计时的类型。
- 保留计时器(TONR) - 一种能够保存状态的计时器。
- 计数器(Counter) - 用于进行加法或减法计数的工具。
- 输入条件(Input Condition) - 导致计时器或计数器激活的条件。
- 输出位(Output Bit) - 计时器或计数器完成后激活的结果。
- 过程时间(Process Time) - 计时器计数的总时间。
练习技巧
要有效提高您的英语口语技能,可以采用shadow speech技巧,特别是在观看相关的自动化控制视频时。尝试模仿视频中讲者的语速和语调,注意他们的发音和连贯性,这对于雅思口语练习尤其重要。选择速度适中的视频,进行反复练习,这样您可以在理解内容的同时提高自己的口语表达能力。在进行shadowing site练习时,试着暂停视频,并用自己的话总结讲述的内容,这将帮助您更好地内化所学知识。此外,重复说出视频中的重点短语,帮助强化记忆。最后,记得在日常学习中多利用看YouTube学英语的机会,极大地提升您的语言能力。
什么是跟读法?
跟读法 (Shadowing) 是一种有科学依据的语言学习技巧,最初开发用于专业口译员的培训,并由多语言者Alexander Arguelles博士普及。这个方法简单而强大:您在听英语母语原声的同时立即大声重复——就像是一个延迟1-2秒紧跟说话者的影子。与被动听力或语法练习不同,跟读法强迫您的大脑和口腔肌肉同时处理并模仿真实的讲话模式。研究表明它能显着提高发音准确性,语调,节奏,连读,听力理解和口语流利度——使其成为雅思口语备考和真实英语交流最有效的方法之一。
