Learn How To Program and Troubleshoot Ladder Logic

book-background-003

The book is done and free on Amazon for a very limited time starting 2/9/2015 through 2/11/2015.  The free period is over however you can still get the book on Amazon.

 

Automation is at the heart of modern industry. It is predominant in distribution, processing, manufacturing, and assembly. Behind the robots and machinery lies the Programmable Logic Controller or PLC for short. Open any modern control panel and you will find the programmable logic controller has replaced an array of relays, timers and other antiquated devices.The modern PLC dominates the world of industrial automation and Ladder Logic is the de-facto programming language in this obscure land of bits and bytes. [click to continue…]

Online PLC Training

Micro programmable logic controllers

Micro PLC’s

How To Get The Most From Online Material

This site has multiple resources to help you learn how to program. An excellent place to start is to jump in and learn ladder logic. Why Ladder Logic? The answer is easy it’s the most commonly used programming language for many reasons. It’s the easiest language to learn and for technicians to troubleshoot.

Good training can cost a lot of money. That’s why I developed this online training hub. Here you can learn how to program and configure PLC’s using the preferred programming language. This site is dedicated to Allen Bradley PLC’s. If you plan on using a different platform fear not, the principles you learn here will cross over to any platform such as Siemens or Fanuc.

Some of the most common hurdles for learning online include software and hardware, or rather the lack of it. Rockwell offers a free version of their powerful programing and configuration software and can be found here. Please note that the software is a lite version and therefore limited it what it can do. These limitations are only show stoppers if you let them be. Grab a copy of the software install and follow along with the tutorials. You won’t be able to download to a processor, however if you follow along it’s the next best thing. [click to continue…]

Ladder Logic for Dummies

No Room For Dummies in Ladder Logicbook-background-003

NOTICE!

I have written a book that will teach you how to program and troubleshoot ladder logic. It  is an excellent way to learn about PLC,s and starting 2/9/2015 it is free for a very limited time, so go ahead and grab a copy for yourself while it is free!

The free period is over, however the book is still available to buy on Amazon. It’s worth it!

Ladder Logic is a graphical based industrial programming language used to program and configure Programmable Logic Controllers, or PLC’s. Ladder programs consist of rungs that house instructions. Once compiled and downloaded to a PLC the ladder program is scanned like a book; from top-to-bottom, left-to-right.

The following illustration is a common “latching circuit” used to turn devices such as motors on and off. If you are familiar with electrical schematics you will notice the relay and coil symbols.

Ladder latch circuit

 What Makes Up a Ladder Logic Program?

Coils, relays, timers as well as other instructions can be placed on rungs. Variables store data that is checked and manipulated by instructions. How and where these instructions are placed on rungs determine the output logic of a rung. The software has a programming instruction set that covers bit instructions, timers, counters, string instructions, and file instructions just to name a few.

Ladder instructions are unique. They have built in watch windows. For example let’s take a look at the Timer On or TON instruction. Notice the three variable fields:Timer On Instruction

  1. Timer                    Name of the timer
  2. Preset                   Set time like a stop watch
  3. Accum                  How much time has accumulated?

Now let’s look at the –(EN)- and –(DN)- symbols on the right side of the instruction. If the timer is timing the –(EN)- is highlighted green. If the timer is done timing the –(DN)- symbol is highlighted green. This is atypical of programming languages. Most languages require a programmer to configure a watch-window to monitor variables at run time. Having feedback directly on the instructions makes for some quick and easy troubleshooting.

Making PLC Programs is Easy.

Most programs use a combination of just a few of the basic instructions. Master the following list of instructions and associated variables and you will have the basics mastered.

  1. XIC                        Examine If Open
  2. XIO                        Examine If Closed
  3. OTE                        Output Energize
  4. OTL & OUT          Output Latch & Unlatch
  5. MOV                      Move data into a variable
  6. COP                        Copy data into an array of variables

Online PLC Training For Dummies

This site is dedicated to teaching the novice, the dummy,  how to program. How do we accomplish that? We offer online training. Put your credit card away most of the material you will find here is completely free. Free doesn’t mean you won’t learn, quite the contrary. Take a look around the site and I think you will agree there is a bunch of useful material. Check out the main page and be sure to watch the tutorial you will learn more from this than a month of lectures.

Be sure to check out our online training videos. Here you will find a series of videos that teach you how to program. Make sure to watch them all, and if you get hung up on instructions you can get definitions and examples here.

If you’re hungry for more, check out this, and this, and this. 

Programmable Logic Controller Training

ContollogixPLC training is a broad term that includes programming, I/O configuration, and industrial networks. Modern Programmable Logic Controllers (PLC’s) can be programmed with several industrial languages with Ladder-Logic being the most popular. Individual manufacturers provide training specific to their brand. There are also books covering the basics as well as forums and websites like this one.

A Word About PLC Programming languages

All the major PLC manufactures adhere to the IEC 61131-3 standard which defines programmable logic controller standards. The IEC standard details such things as Data Types, Variables, Tasks, and Programs. [click to continue…]

Do I need a PLC Programming Certification?

certification

PLC programming is a broad term that usually incorporates PLC programming, network configuration, SCADA and HMI programming as well as peripheral programming and configuration of devices such as stepper motors, linear drives, pick and place automation, robotics, etc.

Programming certifications may be required for specialty fields such as programming amusement park rides, refrigeration systems, oil and gas processing, mining operations, food processing, and health care. The certifications and requirements vary from company to company and depend on local and national laws and regulations.

As a general rule of thumb proper certifications are always good to have and can give you an advantage over those who hold no certifications. For instance millions of people use MS Excel yet most hold no related certifications.

Purse certifications that are related to the platforms you will be working with. If you are interested in working for a company that works with Allen Bradley PLC’s you should pursue certifications that are AB certified and model specific. [click to continue…]

JSR, SBR, RET Jump To Subroutine, Subroutine, & Return Ladder Logic Instructions

JSR Definition

The JSR instruction is a ladder logic rung output instruction.  When the instruction is scanned program execution jumps to the subroutine named in the JSR instruction. After the called subroutine is executed the logic execution continues from the rung the subroutine was called from. The instruction is enabled when the preceding logic is true and disabled otherwise.

The JSR instruction can be used alone or with the SBR and/or RET instructions. At minimum the JSR instruction must contain the “Routine Name” that is to be called. In other words parameters and their associated instructions are not required.

SBR or Subroutine Instruction

 

SBR

      
                 

 

RET or Return From Subroutine Instruction

RET

 

 

 

To pass a parameter to a subroutine:

Parameters may be passed to subroutines called out by a JSR instruction. To do this the JSR instruction must contain an Input Parameter (Tag or Constant) and an SBR instruction with an Input Parameter (Tag) must be in the called subroutine.

The Input Parameter data from the JSR instruction is copied to the Input Parameter of the SBR instruction.

For instance it you call a subroutine named “Conveyor_01” with a JSR containing an Input Parameter (Tag or Constant), the first rung in the subroutine “Conveyor_01” must contain an SBR instruction with an Input Parameter (Tag) to receive the parameter.

       Note: The SBR instruction must be the first instruction of the first rung in the called subroutine.

INPUT PARAMETERS can be any combination of the following data types.  They are optional and multiple input parameters can be used.

  • CONSTANT When used as an Input Parameter on a JSR
  • BOOL
  • SINT
  • INT
  • DINT
  • REAL
  • STRUCTURE

To return a parameter to a subroutine:

Data can be passed back to the JSR instruction that called the subroutine. To do this the JSR instruction must contain a Return Parameter (Tag) and a RET instruction with a Return Parameter (Tag or Constant) must be in the called subroutine.

The Return Parameter data from the RET instruction is copied to the Return Parameter referenced in the calling JSR instruction.

For instance it you were to call a subroutine named “Conveyor_01” with a JSR  containing a Return Parameter (Tag), the subroutine “Conveyor_01” must contain a RET instruction with a Return Parameter (Tag or Constant).

Note: The RET instruction can be anywhere in the called routine. When enabled the RET instruction jumps back to the JSR that called the instruction.

RETURN PARAMETER can be any combination of the following data types. They are optional and multiple return parameters can be used.

  • CONSTANT             When used as a Return Parameter on a RET
  • BOOL
  • SINT
  • INT
  • DINT
  • REAL
  • STRUCTURE

Do not use the JSR instruction to call the main routine as it already runs unconditionally. Do not use the RET instruction in a main routine as a fault will occur.

The JSR, RET and SBR instructions can show or hide parameters. There is more than one way to do this, however only one will be covered here.

To add an input Parameter or Return Parameter to a JSR instruction: Right click on the Routine Name variable. From the pop up menu choose “Add Input Parameter” or “Add    Return Parameter”. Curiously enough if one or more Input or Return parameters are already visible you have to Right click on the visible parameter to display all the     selections. To remove a parameter right click on the parameter and choose “Remove Instruction Parameter” from the pop up window.

Note: Arithmetic status flags are affected (S:V, S:Z, S:N, S:C). Overflow, Zero, Negative, and Carry.

 

FSC(File Search & Compare) Ladder Logic Instruction

Definition

The FSC instruction is a ladder logic rung output instruction that compares data in an array, element by element. The instruction uses a Control data type in conjunction with a user defined expression.  The instruction is enabled when the preceding logic is true and disabled otherwise.

Insure the Length and Position does not travel outside the array boundaries.

List of possible arguments

CONTROL Must be a Control Data Type

  • Control.EN     High when the instruction is enabled.
  • Control.DN     When the .POS is equal to the .LEN
  • Control.ER      Error bit
  • Control.IN      Inhibit bit is set when a true comparison is detected. Clear the bit to continue the search operation.
  • Control.FD      Set when a true comparison is found. Similar to the Inhibit bit.
  • Cotnrol.LEN   The number of elements in an array to search.
  • Contol.POS     The current element the instruction is comparing.

LENGTH Number of elements in the array to be compared. Constant type no tags.

POSITION The current element in the array. Is an element of the control tag and can be used in the expression to step through arrays.

MODE Can be ALL or INCREMENTAL. Selecting ALL will enable the instruction to execute from the first element in an array to the last element in an array on a false to true transition. INCREMENTAL will enable the instruction to execute one element in an array for every false to true transition.

EXPRESSION can contain one or more of the following data types

  • SINT
  • INT
  • DINT
  • REAL
  • CONSTANT
  • STRING

Note: The REAL data type is supported for safety routines on the 1756-L7xS series of controllers.

The expression is defined using tags, math operators, and constants. Parentheses () are used to give priority to sections of an expression. Here is a list of logical operands.

Expressions are executed in a predetermined order of operation, not the order they are written in. The operation order may be changed by placing sections of the expression in parentheses as an expression enclosed in parentheses will execute first.

 

Order                                           Operation

  • 1                                            () Parentheses
  • 2                                            ABS, ACS, ASN, ATN, COS, DEG, FRD, LN, LOG, RAD,                                                                                                       SIN, SQR, TAN, TOD, TRN
  • 3                                            **
  • 4                                            –(negate), NOT
  • 5                                            *, /, MOD
  • 6                                            –(subtract), +(add)
  • 7                                            AND
  • 8                                            XOR
  • 9                                            OR

If the Position or Length is less than zero a major fault will occur. Make sure the length is less than or equal to the actual array size. If the Length value is set higher than the length of the array the destination value will be wrong.

Note: Arithmetic status flags are affected (S:V, S:Z, S:N, S:C). Overflow, Zero, Negative, and Carry.

 

SRT(Sort File) Ladder Logic Instruction

Definition

The Sort File instruction is a ladder logic rung instruction that sorts data in an array into ascending order.  The instruction is enabled when the preceding logic is true and disabled otherwise.

The Sort File instruction uses the Control data type to sort the data.

Insure the Length and Position does not travel outside the array boundaries.

List of possible arguments

ARRAY TAG & DIMENSION TO VARY must be an array and the dimension of the array must be pointed out.

ARRAY can be one of the following data types

  • SINT              
  • INT
  • DINT
  • REAL
  • DIM TO VARY Must be a Constant with one of these values 0,1,2
  • CONTROL Must be a Control Data Type
  • LENGTH The amount of elements in the array to average
  • POSITION Is the beginning position in the array to average

If the Position or Length is less than zero a major fault will occur. Make sure the length is less than or equal to the actual array size. If the Length value is set higher than the length of the array the destination value will be wrong.

Note: Arithmetic status flags are affected (S:V, S:Z, S:N, S:C). Overflow, Zero, Negative, and Carry.

 

STD (Standard Deviation) Ladder Logic Instruction

Definition

The Standard Deviation instruction is a ladder logic rung instruction that calculates the standard deviation of values in an array and places the calculated value in the Destination tag. The instruction is enabled when the preceding logic is true and disabled otherwise. Wikipedia has an excellent article detailing the theory and standard deviation formula.

The STD ladder instruction uses the Control data type to calculate the standard deviation.

Insure the Length and Position does not travel outside the array boundaries.

List of possible arguments

ARRAY TAG & DIMENSION TO VARY must be an array and the dimension of the array must be pointed out.

ARRAY can be one of the following data types

SINT              
INT
DINT
REAL

  • DIM TO VARY Must be a Constant with one of these values 0,1,2
  • DESTINATION can be one of the following data types
  • REAL
  • CONTROL Must be a Control Data Type
  • LENGTH The amount of elements in the array to average
  • POSITION Is the beginning position in the array to average

If the Position or Length is less than zero a major fault will occur. Make sure the length is less than or equal to the actual array size. If the Length value is set higher than the length of the array the destination value will be wrong.

Note: Arithmetic status flags are affected (S:V, S:Z, S:N, S:C). Overflow, Zero, Negative, and Carry.

 

TRN (Truncate) Ladder Logic Instruction

Definition

The Truncate instruction removes the fractional part of a number stored in a Real data type and places the truncated value in the destination. The Source data remains unchanged.

Example

  •             Source data =              357.06
  •             Destination data =      357      (After truncate)

List of possible arguments

SOURCE can be one of the following data types.

  • CONSTANT
  • REAL

DESTINATION can be any combination of the following data types.

  • SINT
  • INT
  • DINT
  • REAL

Note: Arithmetic status flags are affected (S:V, S:Z, S:N, S:C). Overflow, Zero, Negative, and Carry.