You are on page 1of 25

Whats a PLC?

A Programmable Logic Controller (PLC) is a specialized computer designed to interact with machinery.
They are ideally suited for performing repetitive, predictable operations. Typically, PLCs are designed to
endure harsh environments, and perform instructions within tight time constraints.

Interacting with machinery


The PLC is the brain of an automated system, while its inputs and outputs are the neurological system,
connecting sensors and action oriented parts to the brain.

1. Inputs: Tell the PLC about its environment. They connect to temperature sensors, position
detectors, limit switches etc. Gathering environmental data from inputs, PLCs decide what actions to
take.

2. Outputs: Tell things what to do. Outputs may instruct motors to go to a position, a valve to open or
a door to lock.

3. Connections to Other Electronics: Many PLCs include communication ports including USB, Ethernet,
RS485 and RS232. These allow the PLC to talk to other PLCs, PCs, barcode scanners, Operator Panels
etc.

Things a PLC may do to run the cookie factory above:

1. Inputs: Connected to temperature sensors in Egg and Butter chutes, Position detectors
monitoring when the bowl has reached station, scale under bowl confirming correct amount of
ingredients have fallen from chutes.

2. Outputs: Connected to motor that moves conveyor belt, refrigeration unit in Egg chute,
warming unit in Butter chute, actuator that causes chutes to open/close, and motors that drive
the mixer.

3. PLC: Using the temperature inputs, it decides when to turn on refrigeration/warming units.
Position detectors and scale under bowl are used to determine when to advance the conveyor,
and when to lower and turn on the mixer. Along with doing the routine, the PLC will provide
error warnings when things go wrong, so an operator can investigate.
Connections to Other Electronics: An operator panel could show the operator current status of
the cookie batch, as any errors that have occurred. The PLC may also be connected to the
buildings Ethernet system, so a manager can monitor progress from a remote office.
4. Reliability: PLCs often control highly critical devices, and as a result they are built to be reliable.

5. Harsh Enviroments: They are designed to endure temperature extremes and vibration.

6. Real Time: They dont have the luxury of crashing occasionally like PCs do. Also, they must
perform operations at precise times(something that isnt standard with many PC operating
systems).

What PLCs Look Like

PLCs can physically be grouped into 3 categories.

Backplane Based: Consist of a CPU, a Backplane (also called Rack) and IO Cards that slide into the
Backplane.

Bricks (Non-Backplane Based): Have CPU and IO built into them. Often, you can connect additional IO
to their sides.

Programmable relays: Low end modules with built in screen and buttons used for programming.

Heres a Backplane close-up.

They connect a CPU to IO and are available in different sizes to accommodate IO requirements.

Backplanes add expense to a system, while often adding little additional functionality. In some cases
they allow for components to be hot swap-able. Because of the considerable expense, many PLC
manufacturers are moving away from Backplane Based systems in favor of Brick systems.
In Brick based system, like the one to the right, each brick has connectors on its left and right that allows
CPUs and IO to connect.

In this example: leftmost is a power supply, then a CPU with built in IO, followed by 6 IO units.

Wiring PLCs

1. Physical Connections

Most PLC connections involve connecting to something like the terminal block shown on the right.

Slide the wires into the slots on the bottom, and using the screws found on top, you secure the wires.
Some connectors are like the one shown, and disconnect from the PLC, while others are fixed to the the
PLC.

This kind of connection is common for Inputs, Outputs and power supplies.

2. Internal Connections

The inputs and outputs of PLCs are connected internally in 1 of 3 ways: Relays, Source or Sink. PLC
manufacturers often produce all 3 versions, so you can select the version that best fits your application.
Below are descriptions of each variety and what their advantages/disadvantages are.

Lets go over a couple symbols that will be used.


3. DC Power

Switch. It represents an input. Could be as simple as a light switch that youre monitoring to see if its
on or off.

Load. It represents something youre powering. Could be a light bulb or motor.

Juggling balls. (just kidding) Connections. They are the physical connections to the PLC discussed at the
top of this page.

PLC. This just tells you where the PLC fits into the equation. Everything inside the dashed box happens
inside the PLC.

Power Flow. Shows which direction power flows through the circuit.
Commons

In order to increase IO points on PLCs without increasing the number of connections, Commons are
used. The picture to the right shows an example of what the wiring of a PLC with 4 inputs would look
like. In the picture Without Common, the green points all lead to the same voltage source. Commons
take advantage of this frequent situation, grouping one side of connections together. In this case we go
from requiring 8 pins to requiring 5 pins, with no loss of functionality (assuming you wanted them tied to
the same sources). Commons are used in Relays, Sink and Source Circuits.

Relays

Relays are the simplest Connection type. They act like light switches that are turned on or off by the
PLC. They physically connect/disconnect 2 pins on the PLC.

Advantages: Use for both AC and DC connections, handle higher current than Source/Sink models.
Disadvantages: There are 2 kinds of Relays, Mechanical and Solid State. Mechanical involve moving
parts, and thus have a limited lifespan. Solid State have no moving parts, but are very expensive.

Source & Sink

Source & Sinking is used exclusively with Digital DC circuits. If the common pin is + polarity, its called a
sourcing circuit. If its polarity, its called a sinking circuit.
Advantages: No moving parts, so lifespan is long
Disadvantages: No AC support. Cant handle significant current.

Data inside PLCs

Think of PLC memory as a cabinet with drawers called Registers. Data is held in these Registers.These
Registers come in different sizes, and hold different kinds of data.

Bits: Can have values 1 or 0. 1 typically represents On while 0 represents Off. Bits are the building block
for all other types of data.

Integers: Whole numbers (no decimal points). Called: Characters (char), Integers (int), long Integers
(long int) or Words. Look for the bit size and whether they are signed or unsigned. Unsigned are
positive numbers, while signed are positive or negative.

Floating point numbers: Numbers with decimal points, and can be positive or negative.They are called
floating point numbers (Float), with their larger variety called double floats.

Type # bits Signed/Unsigned Min Value Max Value

Bit 1 0 1

Int 8 Signed -128 127

Unsigned 0 255

16 Signed -32,768 32,767


Type # bits Signed/Unsigned Min Value Max Value

Unsigned 0 65,535

32 Signed -2,147,483,648 2,147,483,647

Unsigned 0 4,294,967,295

Floating Point 32 1.175 E38 3.403 E+38

64 2.225 E308 1.798 E+308

Addresses/Tags: The Registers are all stacked side by side in the PLCs memory. Each location has an
Address that lets the PLC know what data youre talking about. Older PLC software requires the user to
refer to data by this Address (example x1023 could mean the 1023d register). Some newer software
makes the Addresses transparent. The user gives a piece of data a name (example
Oven2Temperature), and the PLC keeps track of where the register is located. If the software uses
Addresses to refer to data its called Address Based, if it uses named data its called Tag Based. Some
programming packages are Address Based, but allow Addresses to have Nicknames or something
similar. Their benefits over standard Address Based systems tend to be limited. Advantages to Tag based
systems become evident as programs grow, and remembering whats stored in x1023 becomes difficult.
If your program is going to have any complexity at all using a Tag Based System simplifies the design.

Diving Deeper

Inside the Data Types: As stated earlier, all Data Types are made of Bits (1s and 0s). An 8 bit number is
written like bbbbbbbb (where b can represent a 0 or 1), so you may have 00000000, 11111111 or
01011110. any combo will do. What these Bits mean is determined by the Data Type.

Unsigned Integers: The least valuable bit is the rightmost bit and double in value each position you move
left. The right-most bit is 1 its worth 1 next bit to the left 2 4 8 16 32 64 128 256 (this goes on
for as many bits as the Data Type calls for). Heres what is looks like for an Unsigned 8-bit Integer:

If all 8 bits are 0 (00000000) then we get 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 = 0


If all 8 bits are 1 (11111111) then we get 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255
So the range of an 8 bit unsigned Integer is 0 255
An example of something in between (00110101) 0 + 0 + 32 + 16 + 0 + 4 + 0 + 1 = 53

Signed Integers: Theyre a tad more complicated check out wikipedias article on 2s compliment for a
good explination.

Hexadecimal Format (Hex): Instead of writing every bit out, it is common to group sets of 4 bits
together. Each group can have a value of 0 15, which causes a problem since our number system goes
from 0 9, so we also use A, B, C, D, E and F to get a total of 16 values. (0, 1, 2, 3, 4, 5, 6, 7, 8, 9 , A, B, C,
D, E, F)

Example 1001 0011 1111 0010 in Hex would be 93F2


To be clear that were using Hex format we tack on a 0x the the start of the number so our last example
would be written 0x93F2

Characters: (typically 8 bit unsigned integers) are often used to reprent letter or symbols. Example: you
may use them to display text on an operator panel. Use an ASCII table to see how values are mapped to
symbols.

What about the bits in Floating Point numbers, how do they break out? It gets a bit complicated, I dont
really want to get into that in this tutorial. It is unlikely as a PLC user that you will ever need to know
how their bits translate to values, so dont worry about it.

PLC Math

This page assumes you understand the principles discussed on the Data Inside PLCs page.

The Basics

Addition, Subtraction, Multiplication and Division are what youd expect. If you havent done math in a
programming language before, there are a couple of things you should be aware of.

Overflow: Integers and Floating Point Numbers have size limits. When you go beyond their size
youll cause yourself problems.
Example: 8 bit Unsigned Int with value 255 in bits looks like 11111111. If we add 1 to it we get
100000000. There isnt storage for a 9th bit, so were left with 00000000 or 0. So in this case
255 + 1 = 0
Another Example: 8 bit Unsigned Int with value 0 in bits looks like 00000000. If we subtract 1 to
it we get 11111111. So, we can get the opposite problem 0 1 = 255

Rounding: Floating Point numbers arent perfect. For this reason, you shouldnt check to see if
Floating point numbers are equal to a value, you should check to see if its within a range of
numbers.
Example: 2 * 3 performed with Floating Point numbers may not result in exactly 6.
It could be 5.9999999999998 or something similar. So instead of asking is Example = 6, ask is
Example greater than 5.9 and less than 6.1. Dont worry about how to ask these questions, well
talk about that later in the tutorial

Boolean Math
Some programming packages allow bit manipulation by using Boolean Math. The main operations are:

OR (symbol | ): A = B | C. If either B is 1 or C is 1, then A is 1. If both B and C are 0, then A is 0.

AND (symbol &): A = B & C. If both B and C are 1, then A is 1. If either B of C are 0, then A is 0.

Exclusive OR (symbol ): A = B C. If either B is 1 or C is 1, but not both, then A is 1. If both B and C


are 1, or both B and C are 0 then A is 0.

Boolean Math can be performed on Integers.


Examples using two Unsigned 8-bit Integers 229 (11100101 in binary), and 185 (10111001 in binary):

PLC Contacts & Coils

The most common PLC programming language is Ladder Logic. They consist of a series of electrical
drawings that control how the PLC functions. Well go through the basics of Ladder Logic starting with
Coils and Contacts.

Contacts stand between power and Coils, asking questions. If the answer to the question is true, then
power is allowed to flow through the contact, if not the path is blocked.

List of typical Contacts:

Normally Open asks if a bit is = 1

Normally Closed asks if a bit is = 0

Rising Edge asks if a bit just turned from 0 to 1

Falling Edge asks if a bit just turned from 1 to 0

Less Than asks if Value A is less than Value B.

Greater Than asks if Value A is greater than Value B

Less Than or Equal asks if Value A is less than or equal to Value B.

Greater Than or Equal asks if Value A is greater than or equal to Value B.


Equal asks if Value A is equal to Value B.

Not Equal asks if Value A is not equal to Value B.

Note: Were about to use the & (AND) and | (OR) symbol. They are discussed on the Math page.

Contacts placed side by side to form AND statements.

Example: Coil gets power if: Contact_A & Contact_B

Contacts placed one on top of each other to form OR statements.

Example: Coil gets power if: Contact_A | Contact_B

AND and OR statements may be combined to form complex expressions.

Example: Coil gets power if: Contact_A & (Contact_B | Contact_C)

Coils

Each Coil is tied to a specific Bit of data. Here are the standard Coil Types and what they to the specified
Bit.

Out: If the Coil is powered, the bit is assigned a 1. If not its assigned a 0.

Set: If the Coil is powered, the bit is assigned a 1. If not, the value remains whatever it was.

Reset: If a Coil is powered, the bit is assigned a 0. If not, the value remains whatever it was.

Contacts and coils are often associated with the physical Inputs & Outputs on the PLC.
If a contact is tied to an Input, then when the power at the input changes its contact value in the Ladder
Logic will Change. If a coil is tied to an output and the coil changes its value, then the voltage (or
contact state) at the output will change.
Functions: As Ladder Logic has evolved, additional functionality has been added. In many Ladder Logic
packages the Coil location can be replaced by function blocks that do specific tasks.

The Math function has already been discussed. The tutorials that follow focus on other common
functions.

Functions well go over:

Copy, Pack & Unpack

Rotate & Shift

Counter

Timer

Drum

Ramp

Filter

PID

Loop

Subroutine

PLC Copy, Pack & Unpack

Copy functions copy a value from a source register to destination register.


The source register isnt affected by the operation.

# of
Source Destination What Happens
Bits

= Data is copied.

< Source is copied into lower bits. Upper bits are typically left in their
previous state. Verify with PLC manual.

> Lower bits of source are copied into destination.


Pack functions copy bits from specific locations into an integer.
Why : It may be more convenient to store a set of On Off values inside an integer, instead of keeping
track of individual bits, or perhaps you need the in integer form to export them serially.

Example : Pack Bit_A into the 3rd bit of Integer_B

Unpack functions copy an integers individual bits into specific bit registers.
Why : An integer may represent many On Off values and now you need to break them out

Example : Unpack the 3rd bit of Integer_B into Bit_A

PLC Rotate & Shif

Rotate functions rotate bits within an Integer Register. There are typically 2 options:

Rotate Left or Right?

How many bits would you like rotated?

Rotate Left:

Example: 8 bit Int with a value 0xC5


11000101 = Value in binary
10001011 = Rotated Left 1 bit
00010111 = Rotated Left 2 bits

Rotate Right:

Example: 8 bit Int with a value 0xC5


11000101 = Value in binary
11100010 = Rotated Right 1 bit
01110001 = Rotated Right 2 bits
Shif works just like Rotate, except for what happens to the end bits. On one side the bits are shifted out
and the other bits are shifted in. There are typically 3 options:

Shift Left or Right?

How many bits would you like shifted?

What value would you like shifted in? This can be a fixed value (0 or 1) or may come from a
register.

Shift Left:

Example: 8 bit Int with a value 0xC5


11000101 = Value in binary
10001011 = Shifted Left 1 bit (Shifting in value 1)
00010111 = Shifted Left 2 bits (Shifting in value 1)

Shift Right:

Example: 8 bit Int with a value 0xC5


11000101 = Value in binary
01100010 = Shifted Right 1 bit (Shifting in value 0)
00110001 = Shifted Right 2 bits (Shifting in value 0)

PLC Counters
Counters keep a tally of things. They come in 3 varieties:

Up Counter: Has 1 input that increments a count.

Down Counter: Has 1 input that decrements a count.

Up Down Counter: Has 2 inputs, One input causes count to increment, the second input causes
the count to decrement.

Turnstiles found at stadiums are good examples of Up Counters. Every time a person enters a count
increases. This count may represent the number of tickets redeemed.

If an entrance turnstile was combined with an exit turnstile, they would form an Up Down Counter, and
could be used to know how many people were inside the stadium at any given time.

Counters often allow users to set targets that set specified bits when the targets are met.
Example: The fire department may only allow 10,000 people in your stadium at any given time, so you
set a target of 10,000. When the target is met, a bit controlling a light, seen by the turnstile attendants, is
set This tells the attendants that capacity has been reached and that they cannot allow additional
patrons to enter. A lower target of 0 could be set up and used at the end of the event to verify that all
patrons have exited the building.

Recapping data used in counters:

1 or 2 inputs that tell counter when to change values

Count Value (1 integer)

Target Values (0 to 2 integers)

0 to 2 bits signalling that target(s) have been reached

PLC Timers
Timers wait a set duration of time then do something. An input tells the timer when to start timing.

While timer may be explained differently depending on the PLC line youre working with, well go over a
good solution, knowing other solutions will follow similar concepts:

Data used in examples:

Enable starts the timer. (1 input)

Duration (also called time-delay) defines the amount of time to wait before doing something. (1
internal integer)

Timer Value keeps track of how much time has passed since timing began. (1 internal integer)

Timer Bit (1 output bit)

On Timer waits a Duration after an Enable input goes high before turning the Timer Bit on. The Timer
Bit goes low when the Enable input goes low.

On Timers may have a Cumulative Timer options. If so, you can specify whether you want the Timer
Value to reset when Enable goes low.

Off Timer causes Timer Bit to go high when an Enable input goes high
and keeps it high for a Duration after the Enable input goes low.

PLC Drum
Drums are a great tool when youve got a simple sequence of events that need to occur at set time
intervals or as a result of predefined events.

Time Sequenced Drums turn bits on or off for set amounts of time. Below is one such drum.
Time that bits are held for is listed on the left side of the chart.
Bits that are turned on or off are listed on the top of the chart (A, B, C, D, E & F).
The sequence starts on from the top (the 9 second interval) and works its way down.

If this Drum were turned and left on it would operate for 54 seconds (9+15+5+7+6+12).

Lets look at what happens during those 54 seconds. The * indicates that all values not mentioned are
held at the value they had in the previous time interval:

Seconds 0 9 A is turned on, everything else is turned off.

Seconds 9 24 B is turned on. *

Seconds 24 29 A & B are turned off, C & D are turned on. *

Seconds 29 36 C is turned off, E is turned on. *

Seconds 36 42 E is turned off, F is turned on. *

Seconds 42 54 D is turned off. *


Event Sequenced Drums differ from Time Sequenced Drums in 1 area. Instead
of holding states for a period of time, they hold states until an event occurs. An event is when a
specified bit transitions from low to high.

Some drums have a Continuous Mode option that causes the Drum to start over after it has reached the
end of its sequence.

PLC Ramp

A Ramp brings a Output value up or down at a set rate.

Data Used in Simple Ramp:

Output that will be raised or lowered (Integer or Float)

Acceleration/Deceleration Rate (Integer or Float). Typically measured in Units/Sec

Acceleration Input

Deceleration Input
In this example we see that:

Output Rises when Acceleration Input (Up Arrow) is high

Output Lowers when Deceleration Input (Down Arrow) is high

Output remains steady nothing when both Acceleration and Deceleration Input are low or high.

Though not obvious in this example, Acceleration/Deceleration Rate controls the steepness of
the rise & fall in output value.

Now lets look at a more sophisticated Ramp. Well add the following options:

Maximum & Minimum (Integer or Float)

Soft Start Time (Integer or Float) typically measured in ms. This is the time taken to transition
from steady state to Acceleration/Deceleration Rate. This can reduce the stress on motors.

I
n this example we see:

Once the Maximum is reached, the Output quits Rising, even when the Acceleration Input is
High. Similar behavior would occur for Minimum if it were included in the example.

Including Soft Start Time lengthens the amount of time it takes to reach a value.

PLC Filter

Filters help to clear noise from signals. They are often used to clean up Analog Inputs.
To accomplish this, they take the input signal value and average it with past values.

Lets look at the filter equation on the right:


Input is the incoming signal value

Output is the result of the filter

Weight is how much influence you want past values to hold. Higher numbers place more
importance on past values. Weight must be greater than 1.

In this example we see that as Weight increases 3 things happen:

The signal smooths out

The Maximum and Minimum values decrease.

Changes in input take longer to detect.

With Filters, its a balancing act, where these considerations must be balanced to arrive at an ideal
Weight for your situation.

One option that isnt in the equation but matters a great deal: The frequency samples are taken. This
will effect how fast the Filter responds to changes in amplitude. In this example we took 36 samples for
the single wave.

For those of you who would like to see some numbers, here they are for the example above:

Input Weight = 2 Weight = 4 Weight = 8

141 141 141 141

159 150 143.25 141.28

196 173 150.69 142.46


Input Weight = 2 Weight = 4 Weight = 8

187 180 158.02 144.4

225 202.5 169.14 147.49

221 211.75 179.79 151.53

244 227.88 191.81 156.57

260 243.94 204.84 162.6

246 244.97 214.87 169.13

248 246.48 222.78 175.84

227 236.74 226.27 182.14

254 245.37 231.04 188.26

248 246.69 234.95 194.09

231 238.84 235.93 199.32

229 233.92 235.43 203.84

211 222.46 232.18 207.38

169 195.73 223.07 209.34

183 189.37 214.64 210

165 177.18 205.28 209.41

133 155.09 192.73 207.33

105 130.05 177.06 203.54

83 106.52 159.43 198.03

64 85.26 140.88 190.89

56 70.63 123.32 182.44


Input Weight = 2 Weight = 4 Weight = 8

71 70.82 110.19 173.41

54 62.41 98.25 164.01

54 58.2 88.24 154.54

44 51.1 78.95 145.09

54 52.55 72.35 136

54 53.28 67.58 127.45

62 57.64 65.1 119.65

83 70.32 66.4 113

83 76.66 68.97 107.49

78 77.33 71.06 102.94

124 100.66 78.46 99.88

150 125.33 90.18 98.67

PLC PID

PID controls are used to bring things to a desired level. Maybe its the temperature of
a liquid or the speed of a motor. Using the PIDs 3 components (Proportional, Integral & Derivative),
users can adjust how quickly and cleanly a desired level are achieved.

Example: Lets say weve got a pot of water on a burner and want to bring it up to 90C quickly, without
overshooting the temperature by more than 1. How would you do this? Youd probably turn the burner
on high until the temperature gets within a few degrees of 90, then scale back the burner so the
temperature rises slower to prevent overheating. This scaling back the burner would likely happen in
several stages until you reach a steady 90. A PLC could do this process for you using PID. First a couple
terms:

Set Point: 90C. The value were trying to reach and hold
Input (also called Process Variable): the water temperature. What were trying to get to the Set
Point.

Output (also called Control Variable): the Burner. What we adjust to reach our Set Point.

Error: the difference between the Output and the Set Point.

So, PIDs watch Inputs to decide how to change their Output to reach the Set Point.

Proportional: Looks at the present. It uses the current error to determine Input. Typically it is in charge
of most of the error reduction.

Integral: Looks at the past. It uses a sum of past errors to eliminate long term error.

Derivative: Looks at the future. Trying to predict where the signal is going, it can be used to prevent
both overshooting Set Points and output ringing.

Instead of going into detail on this subject, we point you to a great article written by Tim Wescott on the
subject: PID without a PHD.

PLC Loop

Loops repeat a section of a Ladder Logic program a specified number of times.

There are 3 instructions associated with Loops

Loop specifies the number of times a section of Ladder Logic should be performed. It is placed
just above the section you would like repeated.

Next does one of 2 things.

o If the loop hasnt been performed as many times as specified in the loop instruction, it
will jump to the first rung inside the loop.

o If it has performed the maximum number of times, the loop will end and the program
will jump to the first statement after the loop.

Break forces the loop to end. The program will jump to the first statement after the loop.
Loops must always have 1 Loop statement and 1 Next statement. They dont need to have a break
statement, but may have several if desired.

PLC Subroutine

Subroutines improve Ladder Logic code re-usability and readability. They do this by allowing you to
break apart your code into manageable pieces. Subroutines can then be used multiple times inside a
program and easily brought into new programs.

2 routines envolved:

Calling Routine: the routine requesting a Subroutine to run. It can be the main program, or
another subroutine.

Subroutine: the routine being called

Subroutines act as a separate Ladder Logic that can be called whenever needed. Many times youll need
to provide it data from the calling routine. To do this, you setup input Tags for the Subroutine that will
receive data from the Calling Routine. Wherever you call the Subroutine you match up the Tags you
want to pass from the Calling Routine to the Tags in the Subroutine that will receive the data. Passing a
Tag can be done in 1 of 2 ways.

Pass by Value: is a 1 way street for data to go From the Calling Tag to the Subroutine Tag. The Calling Tag
will be unaffected by the pass.

Pass by Reference: is a 2 way street. The Calling Tag passes the Subroutine Tag its value. When the
Subroutine Returns, the Subroutine Tag passes the Calling Tag its value.

Example:
Heres the order what happens in a subroutine:

1. The Rungs of a Calling Routine run until it reaches a Subroutine Call

2. Data is passed from Calling Routine Tags to Subroutine Tags (optional)

3. Subroutine runs until it reaches a Return statement

4. Data passed by reference is passed from Subroutine Tags to Calling Routine Tags (optional)

5. The Calling Routine continues with the rung that follows the Subroutine Call.

Inside the Subroutine you must have at least 1 Return statement. This tells the Subroutine to return to
the Calling Routine. It is possible to have more than one Return statement, if you need more than one
thing to trigger a return.

Often it is possible to use Tags inside the Subroutine that come from the Main Program without passing
them. This is using Global Tags. While this is allowed, they will make your Subroutine less re-usable. If
you want to bring the Subroutine into another project it will be necessarily that the project has all the
Global Tags used in your Subroutine(s).

A word of caution: PLC makers describe a range of functionality as Subroutines, while often missing key
elements. On our sister site PLCCompare.com you can find our assessments of which PLC lines provide
true Subroutines.

Continue?
So, youve finished this tutorial and want more. Here are a few suggestions on where to go next.

Check out our sister site PLCCompare.com to get a feel for differences between PLC Lines. Each product
has its own page where you can find further information including free software downloads (if they
exist), brochures and online vendors to purchase from.

You could pick up an inexpensive PLC to get started. You can find a high quality, cheap PLC from
Velocio.net. Otherwise, Automationdirect.com offers some decent, inexpensive PLCs. If you need to
stick with Rockwell or Siemens, you can easily pick one up form PLCCenter.com, PLCHardware.com or
EBay without the hassle of dealing with a local rep.

There are some good forums out there. PLCTalk and MrPLC are 2 of the best.

Tim Young has some nice product specific walk-throughs at PLC Dev

Be sure to sign up for our Newsletter!

You might also like