plc上的rs232接口是哪几根线(PLC基本知识--7.4)
plc上的rs232接口是哪几根线(PLC基本知识--7.4)If you know the above then the rest is easy. If you don't know the above then make something up and now the rest is easy. Huh??? Simple pick a memory area to work with and figure out if we can choose the internal relays to use to send and receive data or if the plc has ones that are dedicated to this purpose. Sounds too simple?? (No way it is simple!!)要通过RS-232通信,我们必须设置一些东西。问自己以下几个问题:What
Using RS-232 with Ladder Logic / RS-232在梯形图中的应用Now that we understand what RS-232 is/means let's see how to use it with our plc.
现在我们了解了RS-232是什么意思,让我们看看如何在PLC中使用它。
We should start out as always remembering that a plc is a plc is a plc... In other words understand the theory first and then figure out how our manufacturer of choice "makes it work". Some manufacturers include RS-232 communication capability in the main processor. Some use the "programming port" for this. Others require you to purchase (i.e. spend extra $'s) a module to "talk RS-232" with an external device.
我们应该像往常一样开始,记住PLC是一个PLC是一个PLC……换句话说,首先要理解理论,然后弄清楚我们选择的制造商是如何“使其工作”的。有些品牌的PLC在其主处理器中包括RS-232通信能力,有些品牌使用“编程口”来实现这一点,还有一些品牌则要求你购买(即额外花费)一个模块来实现RS-232与外部设备通讯。
What is an external device you maybe asking? The answer is difficult because there are so many external devices. It may be an operator interface an external computer a motor controller a robot a vision system a ... get the point??
你可能会问,什么是外部设备?答案是很难的,因为有太多的外部设备,它可能是操作界面、外部计算机、电机控制器、机器人、视觉系统、……
To communicate via RS-232 we have to setup a few things. Ask yourself the following questions:
要通过RS-232通信,我们必须设置一些东西。问自己以下几个问题:
- Where in data memory will we store the data to be sent? Essentially we have to store the data we will send... somewhere. Where else but in our data memory!
- 在数据存储器中,我们将把要发送的数据存储在哪里呢?本质上,我们必须存储将要发送的数据,在某处,除了在我们的数据内存中!
- Where in data memory will we put the data we receive from the external device?
- 在数据存储器中,我们将把从外部设备接收到的数据放在哪里呢?
- How will we tell the plc when it's time to send our data (the data we stored in data memory) out the serial port?
- 当是时候发送我们的数据(数据存储在数据存储器)出串口时,我们将如何告诉PLC呢?
- How will we know when we have received data from our external device?
- 我们如何知道何时从外部设备接收到数据?
If you know the above then the rest is easy. If you don't know the above then make something up and now the rest is easy. Huh??? Simple pick a memory area to work with and figure out if we can choose the internal relays to use to send and receive data or if the plc has ones that are dedicated to this purpose. Sounds too simple?? (No way it is simple!!)
如果你知道上面的这些疑问,那么剩下的就简单了;如果你不知道上面的这些疑问,那就编造一些,剩下的就容易了。嗯???很简单,选择一个存储区域来工作,并弄清楚我们是否可以选择内部继电器来用于发送和接收数据,或者如果PLC有专门用于此目的的继电器。听起来太简单了??(一点也不,它就是很简单!!)
Before we do it let's get some more technical terms out of the way so we're on the same playing field.
在我们开始之前,让我们先讲一些不常见的专业术语,这样我们就能在同一个领域。
- Buffer - A buffer is a fancy technical word that means a plastic bag. In other words it's a temporary storage location where the plc or external device stores data it has received (or is waiting to send) via RS-232. When I go to the supermarket to buy my favorite tv dinners I carry them home in a plastic bag. The plastic bag is not a permanent place for my food (are tv dinners really food??) but rather a temporary storage place for them until I get home. When I get home I take them out of the bag and cook them. The supermarket was the external device where I got the data (tv dinners) from and my microwave is the plc. The plastic bag was the buffer (temporary storage place) that was holding my data (tv dinner) until I took them out to use (i.e cook).
- 缓冲区 - Buffer是一个花哨的技术词,意思是塑料袋。换句话说,它是PLC或外部设备通过RS-232口存储已接收或者等待发送的数据的临时存储位置。当我去超市买我最喜欢的冷冻快餐时,我把它们装在塑料袋里带回家。塑料袋并不是一个永久存放食物的地方(冷冻快餐真的是食物吗??),而只是一个在我回家之前临时存放食物的地方。当我回到家,我把它们从袋子里拿出来煮。超市是我获取数据(冷冻快餐)的外部设备,而我的微波炉是PLC,塑料袋是缓冲区(临时存储的地方)用来存放我的数据(冷冻快餐),直到我把它们拿出来使用(比如煮食)。
- String - A string is a cool way of saying "a bunch of characters". The word "hello" is a string. It's a bunch of characters (i.e. h-e-l-l-o) that are connected (strung) together to mean something useful. "43770" is also a string. Although it makes no sense to us it may mean something valuable to your plc or external device. It could be a command that tells your robot to send out its current coordinates. (or it could simply be the word "hello" upside down)
- 字符串 - 字符串是“一串字符”的一种很酷的表达方式。单词“hello”是一个字符串,它是一组字符(即h – e – l – l - o),它们连接在一起就表示某个有用的东西。“43770”也是一个字符串,虽然它对我们没有任何意义,但它可能意味着一些对你的PLC或外部设备有价值的东西。它可以是一个命令,用于告诉你的机器人发送它当前的坐标(也可能它只是上下颠倒的“Hello”)。
- Concatenate - This word is a mouthfull. Simply put it means to combine 2 strings together to make one string. An example is combining the 2 strings "laser" and "jet" together to make one string... "laserjet".
- 串联 - 这个词很拗口。简单地说,它的意思是把两个字符串组合在一起成为一个字符串。一个例子是把两个字符串“laser”和“jet”组合在一起,组成一个字符串……LaserJet“激光打印机”。
With the mumbo-jumbo out of the way let's see it in action. Again the memory locations and relays vary by manufacturer but the theory is universal.
言归正传让我们看看它的实际行动。同样,存储器的位置和继电器会依不同的品牌而不同,但理论是通用的。
- We assign memory locations DM100 through DM102 to be where we'll put our data before we send it out the serial port. Note- Many plcs have dedicated areas of memory for this and only this purpose.
我们通过DM102分配内存位置DM100,以便在将数据发送到串口之前放置数据。注意:许多PLC都有专门的内存区域用于此目的,而且仅用于此目的。
- We'll assign internal relay 1000 to be our send relay. In other words when we turn on 1000 the plc will send the data in DM100-DM102 out the serial port to our external device. Note again- Many plcs have dedicated relays (special utility relays) for this and only this purpose. It's great when the manufacturer makes our life easy!
我们将分配内部继电器1000作为我们的发送继电器。换句话说,当我们合上1000时,PLC会将内存DM100-DM102里的数据从串口发送到我们的外部设备。再次注意:许多PLC有专门的继电器(特殊用途的继电器)为此目的,而且仅此目的。制造商让我们的生活变得轻松,这太棒了!
We'll send the string "alr" out the plc serial port to an operator interface when our temp sensor input turns on. This means our oven has become too hot. When the operator interface receives this string it will displayed an alarm message for the operator to see. Look back on the ASCII chart and you'll see that "alr" is hexadecimal 61 6C 72. (a=61 l=6C r=72) We'll write these ASCII characters (in hexadecimal form) into the individual data memory locations. We'll use DM100-102. How? Remember the LDA or MOV instruction? We'll turn on our send relay (1000) when our temperature sensor (0000) turns on. The ladder is shown below.
当我们的温度传感器输入合上时,我们将把字符串“alr”从PLC串口发送到操作员接口,这意味着我们的烤箱太热了。当操作员接口接收到此字符串时,它将显示一条警报消息供操作员查看。回头看看ASCII表,你会发现“alr”是十六进制61、6C、72(a = 61 l = 6C r = 72),我们将把这些ASCII字符(以十六进制形式)写入各个数据内存位置,我们将使用内存DM100-DM102。还记得LDA或MOV指令吗?当温度传感器(0000)合上时,我们将打开发送继电器((1000)。梯形图如下所示。
Some plcs may not have dedicated internal relays that send out our data through the RS-232 port. We may have to assign them manually. Further some plcs will have a special instruction to tell us where the data is stored and when to send the data. This instruction is commonly called AWT (ASCII Write) or RS. The theory is always the same though. Put the data in a memory location and then turn on a relay to send the data.
一些PLC可能没有专用的内部继电器来通过RS-232端口发送我们的数据。我们可能不得不手动分配它们。此外,一些PLC会有一个特殊的指令,告诉我们数据存储在哪里和何时发送数据。这条指令通常被称为AWT (ASCIIWrite)或RS。理论总是一样的,把数据放在一个内存位置,然后打开一个继电器发送数据。