KNOWARE  

Software for Education and Industry


PLC Instruction List

with

CODESYS V3.5

Want to learn how to program a PLC in Instruction List, make HMIs (Human Machine Interfaces) and be able to run your programs on a simulated PLC?  PLC Instruction List with CODESYS V3.5  shows you step-by-step how to program a PLC using free CODESYS software.

Simply download the free CODESYS software at http://store.codesys.com/codesys.html?___store=en&___from_store=default then follow the exercises in PLC Instruction List with CODESYS V3.5 to learn how to program in Instruction List, build HMIs, and run your programs on a simulated PLC. You do not need an actual PLC to use PLC Instruction List with CODESYS V3.5.

PLC Instruction List with CODESYS V3.5 is written in everyday, easy to understand language that shows you step-by-step what to do.  PLC Instruction List with CODESYS V3.5 is written in .html format so you can use your favorite internet browser with hyperlinks, bookmarks, and word searches.  PLC Instruction List with CODESYS V3.5 requires no software installation on your computer.  Just  double click on the Table of Contents.html, and your Internet browser launches the program.

What is CODESYS?
CODESYS is a program written by the German company 3S-Smart Software Solutions to program various PLCs. It is written to conform to IEC 61131-3, an open international standard for PLC programming languages.  Another program similar to CODESYS called TwinCAT 3 was developed by the German company Beckhoff.  CODESYS has a built-in simulation PLC, built-in HMI capability (Human Machine Interface or Visualization), and can be programmed in various PLC languages, including:
Who uses CODESYS?
CODESYS is used by companies such as Bosch, ABB, Moeller, Wago, Eaton, Festo and others to program their PLCs.

What PLC Instruction List with CODESYS V3.5 does:
This tutorial will show you step-by-step:

What PLC Instruction List with CODESYS V3.5 does NOT do:
This tutorial does not address:

No prior knowledge of PLCs is necessary.

This tutorial is written by a Professional Engineer with 14 years industrial experience and 20 years experience teaching electrical engineering technology at the college level.

If you want to learn how to use CODESYS to program PLC Ladder Diagram and Function Block programs, you can purchase my PLC Programming with CODESYS V3.5 tutorial at http://www.knoware-online.com/codesys.html.  

Or if you want to learn how to use CODESYS to program PLC Structured Text, you can purchase my PLC Structured Text with CODESYS V3.5 tutorial at http://www.knoware-online.com/st_codesys.html.

If you want to run and solve Ladder Logic programs without using CODESYS you can purchase my PLC Simulator 10 at http://www.knoware-online.com/pc-plc.html. This simulator turns your PC into a PLC, has the "look and feel" of Allen-Bradley RSLogix Micro software (though not exact), runs and solves Ladder Logic programs that you write, and allows you to build machines with limit switches, pilot lights, selector switches, solenoids, and conveyors that move in response to the ladder programs you write.   

How to use this tutorial:
Chapters 1 though 5 of this tutorial explain how to download CODESYS, install it, program a rung, build an HMI, and run the program. Perform the tasks in these chapters verbatim until you feel comfortable navigating within CODESYS.  You can use this tutorial without using CODESYS, but then you would loose the benefit of hands-on programming.

Chapters 6 thru 14 move at a little faster pace, explain many of the more advanced instructions of CODESYS, and present example programs that you can analyze and modify if desired.



PLC Instruction Lists

with

CODESYS V3.5

(C) 2017 by Rick Miller


Table of Contents

(click on a chapter to go to it)

              Chapter

              1. Introduction
                        What is a PLC?
                        History of PLCs
                        What are Instruction Lists?
                        What is CODESYS?
                        Who uses CODESYS?
                        What this tutorial does
                        What this tutorial does not do
                        How to use this tutorial
                        What you need to use this tutorial                  

              2.  Launching CODESYS
                        Download and Install the CODESYS Software
                        Start the CODESYS Program
                        Start a New Project
                             Save the Project
                        Summary              

              3.  Programming Your First Instruction

                        Open the Project Created in Chapter 2   

                        Open PLC_PRG
                        Write the Program
                        Understand Variable Types

                        Add Comments
                        Save the Project
                              Summary
                    

              4.  Creating an HMI

                        Open the Project Saved in Chapter 3
                        Create an HMI
                        Program a Dip Switch
                        Program a Lamp
                        Save the Project
                        Summary


              5.  Running Your Program

                        Open the Project Saved in Chapter 4
                        Choose the Simulation PLC
                        Build (compile) the Program
                        Login to the Simulation PLC
                        Start the PLC

                        Close the Switch from the HMI

                        Close the Switch by Forcing It
                        Stop the PLC
                        Logout from the PLC
                        Save the Project

                        Summary                        
                       


               6. Boolean Instructions (AND, OR, XOR)
                        Start a New Project
                        Program an AND Condition
                        What if the Inputs are Numbers?
                        AND two Decimal Numbers
                       
AND two Binary Numbers
                        AND two Hex Numbers
                        AND two Octal Numbers

                        AND two Variables

                        Program an OR Condition
                        Program an XOR Condition

                        Save the Project

                        Program  Multiple Operands
                        Program Complex Operands
                        Summary  

             

              7.  Math Instructions (ADD, SUB, MUL, DIV, MOD)

                        Start a New Project
                        Program an ADD Instruction
                        Program an SUB Instruction
                        Program an MUL Instruction
                       
Program an DIV Instruction
                        Program an MOD Instruction
                        Change the REAL Variables

                        Save the Project
                        Summary


             8.  Compare Instructions (EQ, NE, LT, LE, GT, GE)

                       Start a New Project
                       Program a EQ Instruction
                       Program a NE Instruction
                       Program a LT Instruction
                      
Program a LE Instruction
                       Program a GT Instruction
                       Program a GE Instruction

                       Save the Project
                       Summary

               9.   Jump Instructions (JMP, JMPC, JMPCN, RET, Label)
                        Start a New Project
                        Program a JMP Instruction and Label
                        Program a JMPC Instruction and Label

                        Program a JMPCN Instruction and Label

                        Save the Project
                        Summary


              10.   Bit Shift Instructions (SHL, SHR, ROL, ROR)
                        Start a New Project
                        Program a SHL Instruction
                        Program a SHR Instruction

                        Program a ROL Instruction
                        Program a ROR Instruction
                        Program a Bit Capture

                        Save the Project
                        Summary



            11.  Selection Instructions (SEL, MUX, MIN, MAX, LIMIT)

                      Start a New Project
                       Program an SEL Instruction
                       Program a MUX Instruction
                       Program a MIN Instruction
                      
Program a MAX Instruction
                       Program a LIMIT Instruction
                       Save the Project
                       Summary


            12.  Timers (TON, TOF, TP)

                        Start a New Project
                        Program a TON Timer
                        Program a TOF Timer
                        Program a TP Timer
                        Save the Project
                        Summary

              

            13.  Counters (CTU, CTD, CTUD)

                        Start a New Project
                        Program a CTU Counter
                        Program a CTD Counter
                        Program a CTUD Counter
                        Save the Project
                        Summary

            14.  Examples
                        Example - Warning Light                       

                        Example - Reversing Motor Starter
                        Example - Washing Machine with TON
                        Example - Washing Machine with MUX                         

             

            Index          

 

Sample excerpt from... 

 Chapter 14.  Examples


Step 4) Example - Washing Machine with MUX

The MUX (multiplexer) instruction introduced in Chapter 11 can be used as a sequencer.   Sequencers are much like the old drum controllers that rotated and closed various contacts at each position of rotation.  They are also something like a player piano, where at each beat a different set of keys are depressed to produce a song. 

The clothes washing machine of Step 3) above can be controlled with a MUX instead of timers by sending the output of the MUX to a new variable named Output.  Each valve or motor will be assigned to one bit of the variable Output as shown in Figure 13 below.  A pulse timer is used to drive a counter that in turn drives the MUX.

Figure 13  Washing Machine Cycle with Motors and Valves Assigned to Bits of the variable Output

Washing Machine sequence for MUX

Open  CODESYS and start a new, standard, Instruction Lists project.  Name the project Washing Machine with MUX. See Chapter 2 if you need a refresher on how to do this.  If CODESYS is already open, click on File>>New Project... to start a new project.

Program the variables shown in Figure 14a below.

Figure 14a  Example - Washing Machine with MUX variables

Washing machine with MUX variables


Program the instructions shown in Figure 14b below. Then we will discuss the instructions with red boxes around them.

Figure 14b  Example - Washing Machine with MUX instructions

Washing machine with MUX instructions


The general scheme behind this program is as follows:

The essence of the program is the MUX instruction.  Figure 15 below illustrates the MUX and ST instructions in the first red box of Figure 14b above.  The numbers (0, 1, 2, 20, etc.) being selected by the MUX are the numbers necessary to turn on the proper bits of Output for each step of the washing machine.

Figure 15  MUX and ST Instructions of the Figure 14b program

Pictorial of
            MUX instuction

The instructions in the second red box of Figure 14b above energize various valves and motors by interrogating specific bits of the variable Output.  For instance, the instruction LD Output.0 followed by ST fill_valve energizes the fill valve if bit 0 of the Output variable is 1 (True), and de-energizes the fill valve if bit 0 is 0 (False).  Similarly, the instruction LD Output.1 followed by ST agitate_mtr energizes the agitate motor if bit 1 of the Output variable is 1 (True), and de-energizes the agitate motor if bit 1 is 0 (False), and so on.

Build a Visualization (HMI) as show in Figure 16 below.  See See Chapter 4 if you need a refresher on how to do this. This is the same Visualization used in step 3) above where we programmed the washing machine with timers (TONs).  Assign the switch and lights to the same variables as you did in step 3) above.

Figure 16  Visualization of Washing Machine with MUX

Washing machine with MUX visualization


The large lamps on the left are what would appear on the front of the washing machine for the user.  The small lamps on the right are there just so we can see what outputs are being energized inside of the washing machine during the various steps of the washer. 

Run the program while viewing the Visualization tab.  See Chapter 5 if you need a refresher on running a program.  Click on the Start switch twice to simulate a momentary push button.   The washer should go through its sequence of operations and then stop.

Click on Online>Logout to stop the program, then save the program for future reference.


Hardware/Software Requirements:

Return to home page.
Go to order form.