Saturday, 24 March 2018

Using RS-232 with Ladder Logic

Posted By: PHARMACEUTICAL ENGINEERING - March 24, 2018

Share

& Comment


Using RS-232 with Ladder Logic
Now that we understand what RS-232 is/means let's see how to use it with our 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.
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:
  • 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?
  • 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!!)
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).
  • 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)
  • 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".
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.
  1. 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.
  2. 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!
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.



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.

About PHARMACEUTICAL ENGINEERING

Techism is an online Publication that complies Bizarre, Odd, Strange, Out of box facts about the stuff going around in the world which you may find hard to believe and understand. The Main Purpose of this site is to bring reality with a taste of entertainment

0 comments:

Post a Comment

Copyright © 2013 ENGINEERING TRICKS BY PRINCE T.K ™ is a registered trademark.

Designed by Templateism. Powered By Blogger | Published By PHARMACEUTICAL ENGINEERING