Categories
Articles PLC PLC Basics PLC Learning

PLC Learning Series – Programming Steps

Developing a programmable logic controller (PLC) program can be broken down into five steps. These programming steps are as follows:
Five Steps to PLC Program Development
Step 1 – Define the task
Step 2 – Define the Inputs and Outputs
Step 3 – Develop a logical sequence of operation
Step 4 – Develop the PLC program
Step 5 – Test the program
These five steps to PLC program development will help you understand, program, and troubleshoot your automated machine.
PLC Learning Series – Programming StepsWe will look at each of these steps in more detail as we discuss the PLC programming development. Let’s get started.

Categories
Articles PLC Basics PLC Learning

What are the Different PLC Programming Languages

PLC programs are typically written in a particular application on a personal computer, then downloaded to the PLC. This downloaded program is similar to compiled code to keep the program efficient. The program is stored in the PLC in battery-backed-up RAM or non-volatile flash memory.


Five Different PLC Programming Languages

Albert Einstein said, “The world as we have created it is a process of our thinking. It cannot be changed without changing our thinking” PLC programming languages have evolved to adapt and change how we program these units. We will look at all five programming languages defined by the IEC 61131-3 Standard.

  • Structured Text (ST)
  • Function Block Diagram (FBD)
  • Sequential Function Chart (SFC)
  • Instruction List (IL)
  • Ladder Diagram (LD)

Not all of these programmable controller languages are available in every PLC. Ladder logic programming is by far the most significant percentage of use in PLCs today. Fundamental concepts of PLC programming are common to all manufacturers. Differences in I/O addressing, memory organization, and instruction sets mean that PLC programs are never interchangeable between different makers. Even within the same product line of a single manufacturer, different models may not be directly compatible. This is true when looking at manufacturers that private label other controllers.

Estimates are as high as 95% of installations use ladder logic programming in the programmable logic controller.

The PLC programming language that is used can be decided when you look at the following:

  • Maintenance and troubleshooting
  • Knowledge of language
  • Acceptance of the country, location, or individual plant
  • Application of the PLC
  • Ease of changing the PLC program

The actual programming of the PLC is the second last step in developing programs. The five steps to PLC program development are an excellent method to follow before picking what programming language to use. As mentioned before, the languages supported by each PLC may differ. Please refer to the programming types available for your model and version of PLC.

Let’s quickly review some of the different programming languages for the PLC.

Structured Text (ST)

Structured Text (ST) is a high-level programming language resembling Pascale programming. Statements are used to define what to execute.
What are the Different PLC Programming Languages

Function Block Diagram (FBD)

A Function Block Diagram (FBD) is a graphical representation of that drawn that are AND, NAND, OR, NOR gates, etc. It will describe the function between input and output variables.
What are the Different PLC Programming Languages

Sequential Function Chart (SFC)

Sequential Function Chart (SFC) is like a flowchart of your program. It defines the steps through which your program moves.
What are the Different PLC Programming Languages

Instruction List (IL)

An instruction List (IL) can also be referred to as a mnemonic code and statement list. It contains simple instructions for looking at your variables.
Controller Program Language

Ladder Diagram (LD) – Widely Used

Ladder Diagram (LD) is the most popular programming language for the PLC. It was written to mimic the mechanical relays in the panel that the programmable logic controller replaced. It has two vertical rails and a series of horizontal rungs between them. Controllers will usually scan from left to right, top to bottom. The output of one rung is available for the next rung.
Controller Program Language

Note: All pictures from PLCopen IEC 61131 Basics

PLC programming methods are evolving. PLC Open is an organization defining new ways to take advantage of the latest computer innovations. They have specified the IL method of programming to XML (Extended Markup Language), which is used for web development. This, in my opinion, keeps moving the ideal method to a standard way to program PLCs.

If you have any questions or need further information, please get in touch with me.
Thank you,
Garry



If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLCs are not challenging to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, decimals, Hexadecimal, ASCII, and Floating points.

To get this free article, subscribe to my free email newsletter.


Use the information to inform other people how numbering systems work. Sign up now.

What are the Different PLC Programming Languages

The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.


Categories
Counters Do-More Do-More Designer PLC PLC Basics PLC Learning Sensors Timers

PLC Program Example – Paint Spraying

We will look at a PLC basic tutorial of a paint spraying station. Following the 5 steps to program development this PLC programming example should fully explain the procedure for developing the PLC program logic. Ladder logic will be our PLC programming language.


We will be using the Do-more Designer software which comes with a simulator. This fully functional program is offered free of charge at automation direct.

Define the task – PLC Paint Spraying Example

What has to happen?
Paint Station 01 - plc example paint spraying

Paint spraying system where boxes are fed by gravity through a feeder magazine one at a time onto a moving conveyor belt. Upon the start signal, boxes are pushed towards the conveyor by valve 1. This is a cylinder that extends and retracts which operates switches S1 and S2 respectfully. A spraying nozzle paints each box as it passes under the paint spray controlled by valve 2. A sensor (S3) counts each box being sprayed. When 6 boxes have been painted the valve 2 shuts off (paint spray) and valve 1 (cylinder) stops moving boxes onto the conveyor. Three seconds later the conveyor stops moving and the hopper with its load moves forward (valve 3) where it is emptied. Ten seconds later the hopper returns to the original position. The cycle is then complete and waits for a start signal again.

Define the Inputs and Outputs – PLC Paint Spraying Example

Inputs:
Start Switch – On/Off (Normally Open) – NO
Stop Switch – On/Off (Normally Closed) – NC
S1 – Valve 1 (cylinder retract) On/Off – NO
S2 – Valve 1 (cylinder extend) On/Off – NO
S3 – Box Detected- On/Off – NO
Outputs:
Motor – On/Off (Conveyor Run)
Valve 1- Cylinder to feed boxes – On/Off
Valve 2- Paint Spray – On/Off
Valve 3- Cylinder to move hopper – On/Off

Develop a logical sequence of operation – PLC Paint Spraying Example
Fully understanding the logic before starting to program can save you time and frustration.

Sequence Table: The following is a sequence table for our paint spraying application.

Sequence Table - plc example paint spraying
1 – Input / Ouput ON
0 – Input / Output OFF
x – Input / Output Does not Matter
When the power goes off and comes on the sequence will continue. This means that we must use memory retentive areas of the PLC. The stop pushbutton will stop the sequence. The start will resume until the end.

Develop the PLC program – PLC Paint Spraying Example

The best way to see the development of the programmable logic controller program is to follow the sequence table along with the following program. You will see the direct correlation between the two and get a good understanding of the process.

This is the main process to start and stop bit. V0:0 is used because it is memory retentive.
Ladder Logic Programming Sample Code

Control of the Motor (Conveyor) and the paint spray is done with the V0:0 contacts in front of the actual PLC output. The conveyor and paint spray will stop when timer 0 is done. This is the delay after the last box is detected to allow the box to be painted and loaded onto the hopper.
Ladder Logic Programming Sample Code

Control of the box movement onto the conveyor. As long as we have the process start and the hopper count is not complete this will allow the cylinder to put boxes on the conveyor.
Ladder Logic Programming Sample Code

Count the number of boxes in the hopper via S3. The counter is memory retentive.
Ladder Logic Programming Sample Code

A timer to stop the conveyor and spray after the last box is detected for the hopper. This will allow time for the box to be sprayed and loaded into the hopper.
Ladder Logic Programming Code

Hopper movement to load and unload the boxes.
plc example paint spraying

The hopper unload timer, is to unload the boxes and will then trigger the reset conveyor timer, box counter, and the process start bit (V0:0).
plc example paint spraying

Test the program – PLC Paint Spraying Example

Paint Spraying
Test the program with a simulator or actual machine. Make modifications as necessary. Remember to follow up after a time frame to see if any problems arise that need to be addressed with the program.

Watch on YouTube: PLC Programming Example – Paint Spraying

If you have any questions or need further information please contact me.
Thank you,
Garry



If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLCs are not difficult to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII, and Floating Point.

To get this free article, subscribe to my free email newsletter.


Use the information to inform other people how numbering systems work. Sign up now.

The ‘Robust Data Logging for Free’ eBook is also available as a free download. The link is included when you subscribe to ACC Automation.


Categories
Do-More Do-More Designer Outputs PLC PLC Basics PLC Learning Sensors

PLC Program Example – Shift Register (Conveyor)

We apply the five steps of PLC development to a plc shift register example. This PLC programming example will use a shift register to reject a product on a conveyor.
When programming a PLC, you need to track what has previously happened. Shift registers allow you to do just that. We will look at a PLC basic tutorial on a conveyor belt and reject station. Following the five steps to program development, this PLC programming example should fully explain the function of shift registers. Ladder logic will be our PLC programming language.


We will be using the Do-more Designer software, which comes with a simulator. This fully functional program is offered free of charge at automation direct.

Define the task:
Shift Register – Conveyor Reject

What has to happen?
Conveyor Reject 0

A start pushbutton (NO) is used to start the conveyor, and a stop pushbutton (NC) is used to stop. Sensor B detects a product on the conveyor belt, and sensor A will see if it is too large and needs to be rejected. The product is tracked along the conveyor belt, and when under the reject station, the Reject Blow Off will expel the wrong product. The product is randomly placed on the conveyor belt, so an incremental encoder is used to track the conveyor movement. The reset pushbutton (NO) will signal that all of the product on the conveyor has been removed between the sensors and reject blow-off.

Define the Inputs and Outputs:
PLC Connections for the Shift Register Conveyor Example

Inputs: Start Switch – On/Off (Normally Open) – NO Stop Switch – On/Off (Normally Closed) – NC Reset Switch – On/Off – NO Motor Encoder – On/Off – This will give a discrete signal when the conveyor is moving. It picks up the movement of the freewheel. Sensor A (Part Reject) – On/Off – NO Sensor B (Part Present) – On/Off – NO

Outputs: Motor – On/Off (Conveyor Run) Air Blow Off – On/Off (Reject)
Inputs_Outputs

Develop a logical sequence of operations:
PLC Logic for Shift Register Conveyor Reject
Fully understanding the logic before starting to program can save you time and frustration.

Sequence Table: The following is a sequence table for our conveyor reject application.
Sequence Table

It is a simple sequence table but clarifies the following: The sequence will continue when the power goes off and comes on. This means that the shift sequencer must be memory retentive. Sensors A and B must be on to get tracked with a shift register.

Shift Registers: The Shift Register (SR) instruction shifts data through a predefined number of BIT locations. These BIT locations can be a range of BITs, a single Word or DWord, or a range of Words or DWords. The instruction has three inputs. Data, Clock, and Reset. The data input will load the beginning bit with a ‘1’ if it is on or ‘0’ if it is not. The clock input is used to shift the data through the shift register. In our example, we will use the conveyor’s encoder to track the reject container. So each pulse of the clock represents a distance on the conveyor. The last input is the reset. It will place ‘0’ in all of the bits within the shift register.
Shift Register

Develop the PLC program:
Conveyor Reject

Start and stop the conveyor motor.
Program Conveyor Reject 1

Shift register to track the rejected parts. This will move the bits with each pulse of the encoder. Note that the ‘V’ memory is used because it is memory retentive.
Program Conveyor Reject 2

This will look at the bit in front of the reject station. We can measure and count off the length (conveyor) and then determine the bit location at the reject location.Program Conveyor Reject 3

Test the PLC program:
Shift Register Conveyor Reject

Test the program with a simulator or actual machine. Make modifications as necessary. Remember to follow up after a time frame to see if any problems arise that need to be addressed with the program.

Conveyor Reject

Notes: Sometimes, you can use multiple shift registers in your program. This can be helpful if you want to track the container and the rejects. You could also use a bit shift right (BSR), and bit shift left instructions (BSR) to do the same thing as we did with the shift register instruction. The Do-more PLC rotates left (ROTL) and rotate right (ROTR) instructions. Always check the instruction set of the controller you are working with before starting the program.

Watch on YouTube: PLC Programming Example – Shift Register (Conveyor Reject)

Additional information on shift registers can be seen at the following URL:
https://accautomation.ca/plc-programming-example-sorting-station-shift-register/
This PLC programming example will sort colored tags into three different exits. The 3D simulation will use three different shift registers to trigger when to direct the correct color tag.
Watch the sequence of operation video below.
Watch on YouTube: PLC Programming Example – Sorting Station Testing

If you have any questions or need further information, please contact me.
Thank you,
Garry



If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLCs are not challenging to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII, and Floating Point.

To get this free article, subscribe to my free email newsletter.


Use the information to inform other people how numbering systems work. Sign up now.

The ‘Robust Data Logging for Free’ eBook is also available for free download. The link is included when you subscribe to ACC Automation.


Categories
Do-More Do-More Designer PLC PLC Basics PLC Learning

PLC Programming Example – Process Mixer

We will apply the five steps to PLC Program development to our following programming example of a process mixer.
The process mixer will be programmed using ladder logic. We will discuss each step of the PLC program development.

1 – Define the task:
How does the process mixer work?

PLC Prgramming Example - Process Mixer



A normally open start and normally closed stop pushbuttons are used to start and stop the process. When the start button is pressed, solenoid A energizes to begin filling the tank. As the tank fills, the empty level sensor switch closes. When the tank is complete, the full-level sensor switch closes. Solenoid A is de-energized. The mixer motor starts and runs for 3 minutes to mix the liquid.  When the agitate motor stops, solenoid B is energized to empty the tank. The empty sensor switch opens to de-energize solenoid B when the tank is empty. The start button is pressed to repeat the sequence.

2 – Define the Inputs and Outputs:
What sensors will be used in the PLC program?

Inputs:
Start Pushbutton – Normally Open – On/Off
Stop Pushbutton – Normally Closed – On/Off
Empty Sensor Switch – On/Off
Full Sensor Switch – On/Off
Timer 3 minutes done bit – On/Off (Internal)

Outputs:
Mixer Motor – On/Off
Solenoid A – Fill – On/Off
Solenoid B – Empty – On/Off
Timer 3 minutes – (Internal)

3 – Develop a logical sequence of operation:
How the PLC example program is to solve the logic.

A flow chart or sequence table is used to understand the process entirely.  It will also prompt questions like the following.

What happens when electrical power and/or pneumatic air is lost? What happens when the input / output devices fail? Do we need redundancy?

Knowing all of these answers upfront is vital in developing the PLC program. This is the step where you can save yourself a lot of work by understanding everything about the operation. It will help prevent you from continuously re-writing the PLC logic.

Process Mixer - Sequence Table

4 – Develop the PLC program
Writing the PLC sample ladder logic program for the process mixer.

Since we need to continue the sequence when the power goes off, memory retentive locations in the PLC must be used. In our example, we will use the ‘V Memory’ areas.

The first thing in our program is to control the start and stop functions. This is done through a latching circuit. From the sequence table, we know that we need to have the timer done and the empty sensor off to reset the sequence.Process Mixer Program 1

The filling of the tank is done through Solenoid A. It is turned on by the start signal and off by the full sensor switch. (Sequence Table) You will notice that we have a memory retentive output and the actual output to activate the solenoid.Process Mixer Program 2

The retentive memory timer will start timing when we have the start sequence signal and when the empty and fill sensors are on. The timer will reset when the empty and fill sensors are off. The mixing motor will be on when the timer is timing and when the timer is not done.Process Mixer Program 3

Solenoid B turns on to empty the tank when the timer is done, and the full and empty sensors are on. It will reset when the empty sensor switch goes off.Process Mixer Program 4

5- Test the program
Simulate the PLC program of the Process Mixer

 

PLC Programming Example - Process Mixer

Test the program under many conditions. Check to see what happens when power is removed.

Using this five-step program development technique will shorten your programming time. The result will be a better-defined logic and easier to understand the program because it has within the documentation the logic flow chart or sequence table.

Watch on YouTube: PLC Programming Example – Process Mixer

Testing of the program is essential and should be done in various ways. Factory IO provides a 3D simulation of the process. Factory IO provides a straightforward method of seeing your program in action before you wire your application.

We will be using the BRX PLC Modbus TCP Server (Slave). Factory IO will be the Modbus TCP Client (Master). When the tank fills up, we will start a dwell time instead of the mixer time for the simulation.
Here is the mapping of the inputs and outputs using Factory IO.

Factory IO Website is at the following URL:
https://factoryio.com/
Documentation is well done. Start at the ‘Getting Started’ at the following URL:
https://factoryio.com/docs/

You can download the PLC program and Factory IO scene here.

Watch the following video to see this simulation in action.

Watch on YouTube: Process Mixer Test Simulation

If you have any questions or need further information, please contact me.
Thank you,
Garry



If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLCs are not challenging to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII, and Floating Point.

To get this free article, subscribe to my free email newsletter.


Use the information to inform other people how numbering systems work. Sign up now.

The ‘Robust Data Logging for Free’ eBook is also available for free download. The link is included when you subscribe to ACC Automation.


Categories
Do-More Do-More Designer PLC PLC Basics PLC Learning

Five Steps to PLC Program Development

Programming a PLC can sometimes be a daunting task. The best method is to break the task into some smaller steps. These are the steps that I have used for years to develop PLC programs. We will apply them to a die stamping application.


Step 1 – Define the task:

What has to happen? This is written down and summarized. You may have to ask several different people how the machine operates—going back to individuals when there is a conflict on specific aspects of the operation. This step is number one for a reason with PLC program development.
steps plc program development

Two sensors: an upper limit switch that indicates when the piston is fully retracted and a lower limit switch that indicates when the piston is fully extended. A master switch is used to start the process and shut it down. When the master switch is turned on, the piston reciprocates between the extended and retracted positions. This is achieved with an up and down solenoid. When the master switch is turned off, the piston returns to the retracted position, and all solenoids are off.

Step 2 – Define the Inputs and Outputs:

Based on the information in step 1, you determine the inputs and outputs to the PLC required to develop what has to happen.

Inputs:
Master Switch – On/Off
Upper Limit Switch – On/Off
Lower Limit Switch – On/Off

Outputs:
Down Solenoid – On/Off
Up Solenoid – On/Off

Step 3 – Develop a logical sequence of operation:

This is where the majority of time is spent in PLC program development. Steps 1 and 2 allow you to express what has to happen in the PLC program systematically. Based on the logic, you may have to modify the program’s inputs/outputs or sequence. This is the most accessible place to make changes.

You can use anything to fully understand the logic of the operation before programming. This can be done using a flow chart or sequence table. Many people do not use this step and jump straight to programming.

Fully understanding the logic before starting to program can save you time and frustration.

Sequence Table: The following is a sequence table for our die stamping application. I usually review this sequence with the person with the most knowledge of the machine. This can be the designer or the machine operator.
steps plc program development

Read the Sequence Table: Follow the steps from left to right, top to bottom. Inputs and outputs are labeled as 1 (ON), 0 (OFF) or X (Does not Matter). Step 1 indicates that it does not matter the upper and lower limit switch positions. The master switch is off, so the up and down solenoids are off. Steps 3 and 4 repeat themselves as long as the master switch is on.

Note: You will notice that at step 2 after the master switch turns on the up solenoid will be activated. So the piston always retracts when the master switch is first turned on.  This operation was picked up in the development of our logical sequence.

Step 4 – Develop the PLC program:

Utilizing the above steps, we will now actually write the plc program. This can be in several different languages. In our case, ladder logic will be used.

Look at the sequence table for the following logic. I have used Set and Reset conditions, so the sequence table quickly follows it. When the master switch turns on the up solenoid is activated. Notice the first rung is a direct correlation. Follow the rest of the sequence table with this ladder logic.

steps plc program development
Document, Document, Document This is a vital part of every program, saving you time and money when you have to return to the program years later.

Step 5 – Test the program:

Test the logic that you have developed. Once again, the previous steps are helpful in this process. PLC program development testing is an important step to test for all logic conditions. (Power Cycle, Sensors Fail, Safety, etc.)

steps plc program development
Test the program with a simulator or actual machine. Make modifications as necessary. Check with the people most knowledgeable on the device to see if it is doing what they expect. Do they need anything else? Follow up after a time frame to see if any problems arise that need to be addressed.

These five steps will help you in your PLC program development.

  1. Define the task
  2. Define the inputs and outputs
  3. Develop a logical sequence of operation
  4. Develop the PLC program
  5. Test the program

The five steps form the basis of all PLC development. You will notice that the actual programming does not occur until the second last step. Usually, more time is spent understanding the task and sequence of operation.

Watch on YouTube: Five Steps to PLC Program Development

If you have any questions or need further information, don’t hesitate to contact me.
Thank you,
Garry



If you’re like most of my readers, you’re committed to learning about technology. Numbering systems used in PLC’s are not difficult to learn and understand. We will walk through the numbering systems used in PLCs. This includes Bits, Decimal, Hexadecimal, ASCII, and Floating Point.

To get this free article, subscribe to my free email newsletter.


Use the information to inform other people how numbering systems work. Sign up now.

The ‘Robust Data Logging for Free’ eBook is also available for free download. The link is included when you subscribe to ACC Automation.