쉐도잉 연습: PLC Programming #5: User-Defined Data Types (UDTs) Explained - 영상으로 영어 말하기 배우기

레슨 만드는 중...
1
Hello and welcome back to the channel.
2
In today's video, we'll be continuing our PLC tutorial series.
3
And today we'll be looking at user -defined data types, UDTs, which are a super important concept in PLC programming.
4
Okay, so today's tutorial is going to be a little bit different
5
because I've been doing a lot of code along tutorials in this series, but today's video is going to need to feature a fair bit of structured text,
6
which I haven't gone super deep into on the channel. And
7
so I think what would be more valuable than sharing the
8
writing of this code line by line is talk about the concept and show it in a practical use environment.
9
And then I'll explain to you the code I generated for this.
10
start very high level with the concept,
11
a user defined data type is essentially a grouping of tags that you want associated with a shared type of device.
12
So a very common example is in a big chemical plant, you'd make a user defined data type for every valve, every pump and motor.
13
And sometimes you go even more generic and you say every two state device is going to have auto manual commands,
14
it'll have alarms, overrides, and a whole bunch more features.
15
Every single device of this type is going to have these things.
16
So you bunch a bunch of features together for shared objects in a data type.
17
The example that I'm going to show with you guys today is going to be alarms.
18
This is very common, regardless of the size of your system, to want a bunch of shared alarms in your factory.
19
So if you're building a little standalone system, there still could be 15, 20 things that go wrong with it.
20
And if you're controlling an entire factory from this PLC, there could be hundreds or thousands of things that could go wrong with it.
21
So in TIA Portal, there's a folder called PLC data types over on the left in the system tree.
22
In Rockwell, I think there's a section called UDTs, user -defined data types.
23
And most other PLC platforms, it'll be pretty clear.
24
It'll be something that says data types.
25
And when you make a new one, you go to add new data type.
26
I've already generated the base code for alarm.
27
And here's where I think it's really clear what's going on.
28
You're saying, what does every alarm have?
29
that's going to trigger it initially
30
and then it's going to need to give me the option to acknowledge
31
that alarm and say yep i've seen it because
32
when you trigger an alarm the most normal response case is
33
that a light would turn on to say hey i'm in
34
alarm state you would shut down the logic until someone had come over
35
and said i see the alarm it's okay to resume
36
So then there will be this bit tracking if that alarm is active, if it has not yet been acknowledged.
37
And then when someone does try to acknowledge it, we need to retain that bit because there's a chance someone hits acknowledge, but the trigger condition is still active.
38
In that case, we need to see that it's been acknowledged, but not yet cleared.
39
sort of SCADA software so you can track alarms over time
40
and then we'll just give a couple identifying things so id
41
and message could just be like enumerated one through 20
42
and message could be like here's the thing that just happened
43
so you put that information again on an HMI
44
and we'll say every alarm in our system we want to share these
45
and you can see we have booleans we have long date say no matter how many alarms we make,
46
we want to keep track of all of these alarms.
47
And then to show where this gets really useful, we make a data block, we make a global database apologies.
48
And we say, hey, we're going to store all the information about all these alarms inside of this database.
49
So I go and make an array of 20 alarms.
50
And right off the bat, I get 20 individual Initially,
51
I have one of these tied to a physical push button.
52
I have another one tied to a PLC bit.
53
I could come right in here and I could say this is actually my third alarm.
54
It doesn't matter.
55
And then we'll say and this ID is two.
56
And you can see this is the default timestamp it loads in at.
57
So this has never been triggered.
58
OK, but I get all of this information for 20 objects, 21, really, just by making an array from zero to 20 of alarm.
59
I can make infinite numbers of that data type and I get all of those tags populated every time.
60
And then I made one individual outside of the array to say current alarm
61
because a really common thing in big systems in particular is alarm fatigue
62
and so many alarms go off when something shuts down
63
that you lose sight of what has happened most recently or what the most critical one is.
64
So I made a separate one and for the sake of this demonstration today this will be really valuable whatever triggered last.
65
So you can see the last alarm that I triggered was the button trigger, the one that's tied to the button.
66
So I'm going to drag that off to the side, we'll pull that back up later.
67
But now we've created a bunch of these objects, right, they live in this DB alarms, but we're not doing anything with them yet.
68
And this is where the structured text is going to come in.
69
So buckle up.
70
An important thing to understand is for loops are not super easy to
71
something kind of brute force with like counter variables and move blocks.
72
But almost the whole reason structured text became a thing.
73
And in Siemens, it's called SCL structured command language.
74
It is Siemens version of structured text, all the syntax people can calm down.
75
The reason structured text kind of emerged as a viable PLC programming language is
76
because loops and other sort of more advanced programming concepts are really tricky to do in ladder.
77
Rockwell does have a four block, but honestly, if you can pick up a little bit of structured text, you're going to be a better PLC programmer anyways.
78
And I'll talk you through what's happening here.
79
And let's talk through how you would want alarms in your factory to work.
80
Any alarm goes off in my system and I want it to activate the alarm light, the, hey, you have an alarm and it hasn't been acknowledged light.
81
So that's my light zero right here.
82
last alarm that occurred is into my current alarm field.
83
Okay, this is partly for me for this tutorial.
84
So I can keep it up over here on the right and show you how this code works.
85
But this is also a very real world scenario where you'd want to keep track of whatever the last alarm
86
that went off was and show that on the HMI
87
or you might want to do it where the first right the oldest unacknowledged alarm was
88
that might be more useful if you're doing like root cause analysis.
89
pretty easily in structured text.
90
And what we're going to do here is we're going to talk through the code
91
that I have set up in my alarm processing routine.
92
And then if you're doing this in kind of a follow along fashion, feel free to pause and copy it.
93
Um, and then But anyways, the first thing we're going to do is we're just going to check the local time.
94
This is useful when we're doing time comparisons later.
95
And then we're going to reset the light to zero.
96
So the way functions work, and this is in a function, not a function block, the way functions work is they don't have memory.
97
So we're going to start every scan of the alarm logic as if there is no alarm active.
98
And so we're going to turn the light off unless we find
99
that one of the alarms is active as we iterate through on our for loop.
100
that's when we'll turn the light back on as we'll see in a bit.
101
Okay.
102
And then latest time and latest index are just going to be, they're going to be checkers for us to see if we've iterated through the whole loop.
103
And if we found alarms that have gone off more recently than the kind of initial time, right?
104
The default time when you first set up a new tag.
105
Okay.
106
So hopefully that or Python programming, Arduino.
107
Hopefully this looks pretty familiar to you at the beginning.
108
Now, the meat of what the alarm handler is doing for us is it's iterating from zero to 20, right?
109
Because we made an array of zero to 20 alarms.
110
So important to note, If you made a new array with 50 new alarms and you call them something different, you do need to make a new version of this
111
or at least update this counter with your new array size and you need to point it at the right input tags.
112
Okay.
113
But anyways, for zero to 20, which is going to iterate through all of our alarms in our database of alarms.
114
First, we're going to check if the trigger is active.
115
So if it's actively having the alarm condition trigger it, and it hasn't already been active so if the triggers on
116
but we've already seen
117
that it's active on past cycles doesn't make sense to do all this initial stuff again
118
but what we'll do then is we'll say okay active is true we'll reset acknowledged
119
because even if for some reason it had been previously acknowledged the alarm is still occurring
120
so we'll make that false and then we'll set the time stamp
121
that this alarm has last gone off at as temp time so this will give us a snapshot of the triggered.
122
Then we'll also say if acknowledge is true, or this is something I forgot to mention, acknowledge all.
123
So what I have physically is two push buttons, one I'm going to use to trigger one of the alarms.
124
The other one I want to use as an acknowledge all button.
125
Okay, if you've been in an industrial environment, it's very normal for a cabinet to have like an alarm acknowledge push button on the outside.
126
So I have an acknowledge all push button here.
127
So if I acknowledge just or I press acknowledge all,
128
then I want acknowledged acknowledged past tense to go equal to true and then I can reset acknowledge equal to false.
129
Again, acknowledged is that intermediate value that's checking to see if acknowledged has been true, then I should reset the thing.
130
If trigger is not currently active and acknowledged is true, then we want to set active back equal to false.
131
And we don't really need an and if active check here
132
because there's no harm in setting a value that's already false equal to false again.
133
So And then again, if we get any alarm that is currently active, let's have our active alarm light just be on.
134
And then this little bit here is just for us to be able to track the most recently triggered
135
and active alarm and move it into our global alarm.
136
So that's this line down here, whatever our latest time and latest alarm indexes, let's go ahead and copy that whole thing into the current alarm.
137
And then the last thing we'll do is we'll assume ACK all is equal to false, right?
138
So if we detect that it's true, we'll go ahead and reset it at the end.
139
This we could actually delete most likely now that I'm reading it to you, but we're going to leave it as is because I know this is working.
140
So I put all that logic in a function I called alarm handler.
141
And then in main, I call two things, I call the alarm handler, and then I call another function called alarm setup.
142
And this one I made purely for the sake of demonstrating how this works.
143
Okay.
144
So like I I'm the first one tied to zero on my PLC.
145
I'm going to use it to simulate the trigger for alarm zero.
146
And then I made a memory tag called trigger one, I'll use that to simulate triggering alarm one.
147
And then my other push button tied to input one, I'll use that as the acknowledge all signal.
148
Okay, again, I hope this is making sense in terms of why to use it, I set up alarm zero and alarm one to be a button trigger and a PLC bit trigger.
149
I trigger them here on the left, you'll see them populate this current alarm on the right, and you'll get a good sense of the benefit of a UDT.
150
So if I push the start push button, you can see on the left side there that activates alarm zero in the field, my output, my light is on now.
151
And if I go ahead and press stop, all that'll trigger acknowledge all the light is off.
152
And what you can see in current alarm here in the bottom right, is we got an updated timestamp and it says, hey, the button trigger was the last alarm to go off.
153
Now, if I modify to one, what's cool is the light just turned on in the field.
154
So the same output triggered, that's my, hey, an alarm is active and hasn't been acknowledged yet.
155
And here you can see PLC bit trigger is the last alarm that got triggered.
156
And the ID is one, and I got an updated timestamp.
157
So again, I'll press acknowledge, but it's not going to actually trigger condition is still true.
158
If I modify to zero, the trigger condition goes away.
159
Now I can clear the thing.
160
So I'm able to generate a lot of alarms with shared logic very quickly
161
and they all have a trigger and acknowledge and active acknowledge timestamp.
162
They have all these shared conditions
163
and I know they're going to work the same way thanks to the UDT that I generate.
164
But I can still reference the individual tags under each of those alarms and use them to program unique functionality.
165
So if only one or two of these alarms need to open up a vent valve or stop a certain pump, I could still do that with these UDTs.
166
Hopefully that's a useful practical tutorial for you.
167
Apologies, this is a little bit of a chaotic tutorial, but this is honestly a pretty tricky one to teach
168
because I didn't want to get super in the weeds on structured text with you
169
and the lines and the use cases between UDTs and function blocks and instance data blocks do get a little bit blurry.
170
that you want every device of a certain type to have access to, to one master data type tag,
171
like an alarm that needs a trigger, acknowledge, active, and timestamp.
172
It's also totally common practice to create UDTs, data types for devices like alarms, pumps, motors, valves, analog sensors,
173
and combine that with function blocks.
174
So it's not either or user defined data types or function
175
be combined and that's how you can make some really powerful clean well -structured code okay
176
so i still hope this practical tutorial was useful for you as always
177
if you have questions
178
or there are things i forgot to cover in this feel
179
free to ask them in the comments below i'll get back
180
to you as soon as i can let me know what
181
you want to see next on the channel in the comments
182
and please don't forget to leave a like on the video subscribe to the channel
183
if you're finding this content useful thanks for watching good luck with your projects and see you next time Bye.

맥락 및 배경

이 강의에서는 PLC 프로그래밍의 중요한 개념 중 하나인 사용자 정의 데이터 타입(UDT)에 대해 다루고 있습니다. PLC 프로그래밍은 산업 자동화에서 필수적인 기술로, 특히 화학 공장과 같은 대규모 시스템에서 자주 사용됩니다. UDT는 관련된 여러 태그를 그룹화하여 장치의 공통적인 특성을 정의하는데 사용됩니다. 이 강의에서는 UDT의 개념을 깊이 이해하기 위해 실제 예제를 통해 설명하고 있습니다.

일상적인 의사소통을 위한 5가지 주요 문구

  • 사용자 정의 데이터 타입은 장치의 공동 특성을 그룹화하는 것입니다.
  • 알람은 시스템 내 다양한 문제를 모니터링하는 데 사용됩니다.
  • 비상 상황이 발생했을 때 알람을 인식해야 합니다.
  • 각 알람은 식별 ID와 메시지를 포함해야 합니다.
  • PLC 데이터 타입에서 새 유형을 추가하여 데이터베이스를 만들 수 있습니다.

단계별 쉐도잉 가이드

이 강의를 통해 shadowspeak와 같은 기술을 연습하면, 영어 발음과 억양을 자연스럽게 향상시킬 수 있습니다. 아래는 이 강의를 효과적으로 활용하는 단계별 가이드입니다:

  1. 비디오 시청: 처음에는 비디오를 한번 보고 전체적인 흐름을 파악하세요.
  2. 반복 듣기: 강의를 여러 번 들으면서 중요한 개념과 문구에 집중하세요.
  3. 쉐도잉 연습: 다 듣고 난 후, 각 문장을 따라 하면서 발음과 억양을 연습하세요. 이때 영어 쉐도잉 기법을 활용하세요.
  4. 식별된 문구 연습: 앞서 추린 5가지 문구를 사용하여 다양한 문장으로 확장하여 연습하세요.
  5. 일상 대화에 적용: 학습한 내용을 실제 상황에서 사용해 보세요. IELTS 스피킹 수업에서도 활용할 수 있는 표현들입니다.

이 과정을 통해 여러분은 shadow speech 능력을 키우고, 영어 말하기 실력을 극대화할 수 있습니다. 연습하면서 자신감을 더욱 키워보세요!

쉐도잉이란? 영어 실력을 빠르게 키우는 과학적 방법

쉐도잉(Shadowing)은 원래 전문 통역사 훈련을 위해 개발된 언어 학습 기법으로, 다언어 학자인 Dr. Alexander Arguelles에 의해 대중화된 방법입니다. 핵심 원리는 간단하지만 매우 강력합니다: 원어민의 영어를 들으면서 1~2초의 짧은 지연으로 즉시 소리 내어 따라 말하는 것——마치 '그림자(shadow)'처럼 화자를 따라가는 것입니다. 문법 공부나 수동적인 청취와 달리, 쉐도잉은 뇌와 입 근육이 동시에 실시간으로 영어를 처리하고 재현하도록 훈련합니다. 연구에 따르면 이 방법은 발음 정확도, 억양, 리듬, 연음, 청취력, 말하기 유창성을 크게 향상시킵니다. IELTS 스피킹 준비와 자연스러운 영어 소통을 원하는 분들에게 특히 효과적입니다.

섀도잉 방법: 단계별 전체 가이드 읽기 →