Relays / 继电器
Now that we understand how the PLC processes inputs, outputs, and the actual program we are almost ready to start writing a program. But first lets see how a relay actually works. After all, the main purpose of a PLC is to replace "real-world" relays.
现在我们了解了PLC如何处理输入、输出和实际程序,我们几乎可以开始编写程序了。但首先让我们看看继电器是如何工作的。毕竟,PLC的主要用途是取代“现实世界”中的继电器。
We can think of a relay as an electromagnetic switch. Apply a voltage to the coil and a magnetic field is generated. This magnetic field sucks the contacts of the relay in, causing them to make a connection. These contacts can be considered to be a switch. They allow current to flow between 2 points thereby closing the circuit.
我们可以把继电器想象成一个电磁开关。对线圈施加电压,就会产生磁场。这个磁场把继电器的触点机构吸进去,使两个触点连接起来。这些接触可以被认为是一个开关。它们允许电流在两点之间流动,从而闭合电路。
Let's consider the following example. Here we simply turn ON a bell (Lunch time!) whenever a switch is closed. We have 3 real-world parts. A switch, a relay and a bell. Whenever the switch closes we apply a current to a bell causing it to sound.
让我们考虑下面的例子。在这里,只要开关一闭合,我们就会铃铛(BELL)响起(午餐时间!)。我们有3个真实的零件,一个开关,一个继电器和一个铃铛。每当开关闭合时,继电器吸合,这时电铃被施加电流就发出了声音。

Notice in the picture that we have 2 separate circuits. The bottom (blue) indicates the DC part. The top (red) indicates the AC part.
注意在图中我们有两个独立的电路。下面的(蓝色)表示直流部分。上面的(红色)表示交流部分。
Here we are using a DC relay to control an AC circuit. That's the fun of relays! When the switch is open no current can flow through the coil of the relay. As soon as the switch is closed, however, current runs through the coil causing a magnetic field to build up. This magnetic field causes the contacts of the relay to close. Now AC current flows through the bell and we hear it. Lunch time!
这里我们使用直流继电器来控制交流电路。这就是继电器的乐趣所在!当开关断开时,没有电流可以通过继电器的线圈。然而,一旦开关闭合,电流就会通过线圈,形成磁场。这个磁场使继电器的触点闭合。现在交流电流流过电铃,我们听到了它的声音。午餐时间到了!

A typical industrial relay / 典型的工业继电器