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?
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".
- 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.
- 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!
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.
0 comments:
Post a Comment