SlideShare a Scribd company logo
1 of 67
Download to read offline
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Coding, Simulating & Testing Programmable Logic Controller
With Examples
About The Authors
is a PLC Control programmer. With over 20 years of experience in the
industrial automation field. With deep appreciation for his friend who introduced him
to this in 1997 after finishing his diploma program in Electrical & Electronics.
Farouk Idris
Over the years, he has engaged with many system integrators and companies in
Singapore. Utilizing self-taught skills, networking, and leverage mentality, he works
with the industry's best tools, people, and companies.
By joint venture between him , who possesses a similar capacity,
they are taking up a key role in teaching PLC programming to as many people as
possible, cutting short the learning curves and fears.
and Michael Blake
All rights reserved and Disclaimer.
No part of this publication shall be reproduced or stored in any retrieval system
mechanical or electronic, or transmitted in any form or by any means; electronic,
mechanical, recording, or otherwise, without the author's prior written permission.
Hacks to Crush Plc Program Fast & Efficiently Everytime…
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Although the author has made every effort to ensure that the information in this
book is correct at present, the authors and publisher do not assume and hereby
disclaim any type of liability to any party for any loss, damage, or disruption caused
by any errors or omissions, whether such errors or omissions resulting from
negligence, accident, or any other possible cause. This book cannot assume any
responsibility whatsoever. All contents are original contents by Michael Blake and
Farouk Idris. CoDeSys is the Copyright of 3S - Smart Software Solution GmbH. This
book is not authorized or endorsed by 3S - Smart Software Solution GmbH.
This book serves as a best practices guide. The results are unique. Our track record
has shown those who contribute effort follow the best practices guide shown here
and continue to work on it, achieving sustainable and long-term results.
It is essential that you have the PLC programming App in your PC. Click the link below
to download it.
https://plcguide.com/funnel/view/AppDownload
Table of Content
About The Authors
All rights reserved and Disclaimer.
Preparation before Inputting Contacts in LD (Ladder Diagram)
Insert New Rung before in LD.
Insert New Rung after in LD.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Variables Declaration in LD
Input a Normally Open Contact in LD
Input a Normally Closed Contact (negated) in LD
Input a Parallel Contact' in LD
Input a Parallel Contact (negated) in LD
Moving all the contact elements in the LD-Editor
Input an Output Coil in LD
Input a Set coil in LD.
Input a Reset coil in LD.
Input a Function Block instruction in LD.
Input a Rising edge detect Instruction in LD.
Input a Falling edge detect instruction LD.
Changing the SET/RESET output with S/R in LD
Input Box with EN instruction in LD
Input MOVE instruction in LD
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Input a POU Block in LD
Input AND contact in LD
Input OR contact in LD
Ladder Diagram in the Online Mode
Input GT instruction in LD
Input EQ instruction in LD
Input SR instruction (Flip Flop) in LD
Input RS instruction (Flip Flop) in LD
Input CTU instruction in LD
Input TOF instruction in LD
Input CTUD instruction in LD
Controlling a Traffic Light Signal Example
Create a POU (Program Organization Unit)
TRAFFIC_LIGHT.pro Simulation
TRAFFIC_LIGHT.pro variable declaration
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
The result
PLC_PRG
Visualization for a Traffic Signal
Summary
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
This command on the toolbar inserts a rung or network in the Ladder editor. If there
are rung already then, the new one will be inserted before the currently selected.
Insert New Rung after in LD.
Network (after):
Network (before):
Insert New Rung before in LD.
Preparation before Inputting
Contacts in LD (Ladder Diagram)
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Click this button in the LD editor to insert a contact.
The contact now shows "???". You can click on this text and change it to the desired
variable shown at “Declared Variable Image.”
Normally open contact:
Input a Normally Open Contact in LD
Variables Declaration in LD
Declare variables.
This command on the toolbar inserts a rung or network in the Ladder editor. If there
are rung already then, the new one will be inserted after the currently selected.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Parallel (OR) Normally open contact:
Use this command in the LD Editor to insert a contact parallel to the marked position
in the network.
Input a Parallel Contact' in LD
This command inserts a negated contact. The same is true for the commands' Insert'
'Contact' and 'Extras' 'Negate,' which in combination also could be used to insert a
negated contact.
Input a Normally Closed Contact (negated)
in LD
Normally Closed Contact:
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
This command inserts a negated parallel contact. The same is true for the
commands' Insert 'Parallel Contact' and 'Extras' 'Negate,' which in combination also
could be used to insert a negated parallel contact.
Moving all the contact elements in the LD-
Editor
Input a Parallel Contact (negated) in LD
Parallel (OR) Normally close contact:
The contact is preset with the text "???". This means you can change the text and
desired variable name.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Move the element to one of these positions and let off the mouse key: the element
will be inserted at the new position. If you, however, move the element to the name
(variable name) of another element, the name field will be shaded green. If you then
let off the mouse key, the previous name will be replaced by the "dragged" one. If
additional addresses and comments are displayed (options), the copying also will
apply to those. Here we’ll demonstrate that. First, click on the contact that you wish
to move.
All elements in the editor can be moved around to a different position within an LD
POU by "drag&drop."
To do this, just select the any elements that is, contacts, coils, function blocks and
drag it – remember to keep pressing the mouse select key button – and move it away
from the current position. Thereupon all possible positions within all networks in the
editor, to which the element can be moved, will be indicated by a mirage of grey-
filled rectangles.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Input a Set coil in LD.
Input an Output Coil in LD
Output Coil:
Use this command in the LD Editor to insert a coil in a run. If clicked again, a new coil
will be inserted in parallel to the previous coils.
All the small boxes indicated by the BLUE arrow will be highlighted when dragging the
contact. Thus, you can drop it anywhere indicated by the small box.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
This command will insert a Set coil. Another way is to go through the Insert 'Coil' and
in Extras 'Set/Reset,' which could also get a Set coil.
Input a Function Block instruction in LD.
Input a Reset coil in LD.
Change output coil to Reset:
This command will insert a Reset coil. Another way is to go through the Insert 'Coil'
and in Extras 'Set/Reset' could be used to get a Reset coil.
Change output coil to Set:
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
For this example, choose TON.
In this example, we will add a Timer Function Block (TON):
After clicking on it:
Adding a Function Block.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Write the name Timer1 then click OK.
Finally, put in the timer input count to T#5s which means 5 seconds.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
This command inserts a R_TRIG function block, which will detect a rising edge (FALSE
-> TRUE) by the incoming signal. You can do the same through the command 'Insert'
'Function Block,' which can be used to insert any available function block.
Input a Rising edge detect Instruction in
LD.
Rising Up detect Instruction:
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Input a Falling edge detect instruction LD.
Falling Down detect Instruction:
Input the variable name, then click OK.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
This command inserts a F_TRIG function block, which detects a rising edge (TRUE ->
FALSE) at the incoming signal. You can do the same by the command 'Insert'
'Function Block,' which can be used to insert any available function block.
Input the variable name, then click OK.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Changing the SET/RESET output with S/R in
LD
Click this command repeatedly. The coil will alternate between set, reset, and normal
coil.
Input Box with EN instruction in LD
Use this command to insert a function block, an operator, a function, or a program
with EN input into an LD network.
The EN Box is inserted parallel to the coils that are underneath them. Initially, it
contains the instruction "AND." Then, after that, just rename it to instructions to
your liking.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Input MOVE instruction in LD
Declare the variables beforehand. We have assigned Source with 15. So, when we run
the code 15 will be loaded to the Source variable.
Insert a box with EN.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Rename the default AND instruction to MOVE instruction.
Another way is to right-click and click the “Box with EN.”
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Rename the default AND instruction to MOVE instruction or any other instruction
based on your code design
Input a POU Block in LD
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Here we will input the Demo_Ladder_Diagram program to the PLC_PRG program,
which is the main program in this project. But you may ask, why is that? If you don’t
do that, then the Demo_Ladder_Diagram program will not run. Meaning all the codes
in Demo_Ladder_Diagram will be idle or no operation.
This is another way to input the Demo_Ladder_Diagram program here.
Just delete the word AND in the box, then enter in the period (.) then, you can scroll
to find the program you want to input here. But you need to make sure you rebuild
the programs by going to Project -> Rebuild all.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
We don’t need the output for this box, so delete the output line.
The final looks like this.
Rebuild all the programs.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Input AND contact in LD
Click this button to add in a normally open contact in series.
Clicking again will place another normally open contact in front of it (in series). This is
an AND logic. Meaning input1 AND input2 must be ON for the output coil to be ON.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Input OR contact in LD
This button will add in contact in parallel. Let the cursor or selector be at input1
normally open contact, then just click on the Parallel Contact button.
Once a new parallel contact (OR) appears, then rename the variable. This is OR logic.
Output7 will be On if either input1 OR input3 is ON.
Ladder Diagram in the Online Mode
It is necessary now that we show how to go in the online mode. The upcoming
example will showcase why this is the better option.
All the contacts and coils in the Ladder Diagram (LD) in the "ON" state are colored
blue. And all the lines over which the "ON" state is carried are also colored blue. At
the inputs and outputs of function blocks, the values of the corresponding variables
are indicated in the LD diagram and at the variable fields.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
To start to simulate, just go Online and log in.
It is essential that you have the PLC programming App in your PC. Click the link below
to download it.
https://plcguide.com/funnel/view/AppDownload
Other books Special Offers
https://plcguide.com/funnel/view/paperbackboxset
Next is to click the Run or press F5.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Now double click the Demo_Ladder_Diagram program to allow it to appear on the
screen. Next, click the boolean you want to update the value as shown by the arrow
in the below picture.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
When double-clicked, you can see what next is going to happen to the variable. This
means you can turn this variable ON (TRUE). Clicking on it again will change it to
FALSE.
If Write Values (Ctrl+F7) is selected, the value will be updated to the variable.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Input GT instruction in LD
This is a Greater than comparing instruction. Click the Box with EN.
A new AND box will be inserted. First, delete the AND and rename the GT. Then,
start to put in a number on the instruction input and a boolean variable at the
output.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
The input we put in a 10 (Top input) & a 9 (Bottom input), then the output variable is
Level_Up.
It will return the value TRUE when the value of the first (top ones) operand is greater
(this case is 10) than that of the second (bottom ones, which is now 9). The Level_Up
boolean will be TRUE (Turned ON) when input1 contact is ON.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Input EQ instruction in LD
This is equal to comparing instruction. This instruction will return the value TRUE
when the operands are equal.
Input new box with EN with either right-click on a rung or clicking the icon on the
toolbar.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
A new AND instruction BOX with EN is inserted
Edit and change the AND to EQ. instruction
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Add in the variable Source and the value 15 on the EQ instruction inputs. The output
of EQ is the variable name Same_Level. A normally open contact has been added in
the next rung.
Now, let us simulate it. First, as in the previous example, update the value of the
variable input1 to 1 (ON).
The variable Destination will be updated with a value 15. The variable Same_Level is
turned ON now because it is equal to the value 15.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Input SR instruction (Flip Flop) in LD
This instruction is provided by standard.lib. Making a Bistable Function Block.
The SR truth table:
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
No S R Q Description
1 1 0 1 Q is set to ON
2 1 1 1 No change
3 0 1 0 Q is set to OFF
4 1 0 1 Q is set to ON
5 0 0 1 No change
Input SR instruction
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Declare it as
Another way is to click.
Then choose the bistable function.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Then click OK.
Declare variable to
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Notice here there are two types of SR instructions. Next, we will plug in all the
variables and simulate them.
All variables have been added.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Right after running the simulation, the SR_Demo2 output with Q1 is turned ON. This
is because the SET1 input is already ON
If SrInp3 is turned ON, the output Q1 is still not OFF, as shown by the truth table.
Therefore, we suggest you test the logic as shown by the truth table.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
The SrInp1 is turned ON for SR_Demo, but the Q1 (SrOut1) is OFF. This is because the
EN input is not ON.
Now when input3 turns ON, the Q1 (SrOut1) is ON. So, all the behavior of this SR
instruction can be demonstrated as shown by the truth table.
Overall, the SET1 input will make Q1, ON regardless if RESET input is On or OFF
Input RS instruction (Flip Flop) in LD
Provided by the standard.lib. Resetting Bistable Function Blocks
The RS truth table:
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
No S R Q Description
1 1 0 1 Q is set to ON
2 1 1 0 Q is set to OFF
3 0 1 0 No change
4 1 0 1 Q is set to ON
5 0 0 1 No change
We have created the two types of RS instructions here
Let us start to simulate it. First, it would appear that the RS instruction is the
opposite of SR instruction. Why is that?
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
This is because whenever the RESET1 input is ON, the output will be OFF. Try it
yourself.
Input CTU instruction in LD
This is provided by standard.lib. Counter Up Function block Incrementor:
Type BOOL is input variables CU, RESET and the output variable Q. Whereas, type
WORD is input variable PV, and the output variable CV.
If RESET is TRUE the counter variable CV will be set to 0. If CU input detect a
transition from 0 to 1 Or from FALSE to TRUE, CV value will be incremented by 1. Q
will return TRUE when CV is greater than or equal to the upper limit PV.
Below in the example, we have added a 1-second clock represented by Clock1 and
Clock2 TON timers. Each TON timer's PT parameters are set to 0.5 seconds.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
The R_TRIG detects the rising edge of Clock2.Q output and feeds the input CTU
counter instruction.
The counter PV is set to 10, and RESET input is set to input3.
Below shows the CV value at 8 now.
Now you can see the CV is over the value of 10, and the output of the counter is ON.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
The input3 is ON now, which reset CV to zero. The Counter1 output is also OFF now.
Input TOF instruction in LD
This is provided by standard.lib. TOF function block implements a turn-off delay.
When input1 is ON, the TOF_Demo output is ON as well.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
When the variable input1 is OFF, the TOF starts to count.
Now the TOF timer output is OFF now.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Input CTUD instruction in LD
Provided by the standard.lib. Function Block of a Counter Up and Down
(Incrementor/Decrementer)
For this example, the previous clock has been reduced to 0.2 seconds (Combining
Clock1 & Clock2)
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Create a new set of timers for this. You can see here Clk_Short is at 3 seconds, and
Clk_Long is at 5 seconds. Use the Clk_Short output AND with Clock_Pulse.Q to drive
Up_Count output.
One this Normally-Close Clk_Long with Clock_Pulse.Q to drive Down_Count output.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Below is the Trend plotting on CTUD_Demo.CV. You can see the value of
CTUD_Demo.CV going up and down but eventually trending up.
Controlling a Traffic Light Signal
Example
Now we will write our own version of traffic light signal unit controlling the two
traffic light signals at a traffic intersection.
The red/green phases of both traffic signals must be alternate to avoid accidents.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
In this example, we will see how time-dependent programs can be shown with the
language resources of the IEC1131-3 standard. But for now, we only focus on Ladder
Logic (LD) with the help of CoDeSys, and how one can easily connect them while
becoming familiar with the simulation of CoDeSys.
Create a POU (Program Organization Unit)
Starting is always easy by just Start CoDeSys and choose 'File' 'New.'
In the dialog box which appears, the first POU has already been given the default
name PLC_PRG. Keep this name, and the type of POU should be a program. Each
project needs a program with this name. In this case, we choose as the language of
this POU the Ladder Logic (LD)
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
TRAFFIC_LIGHT.pro Simulation
Now we will check and test the program in simulation mode. Compile ('Project'
'Build') and load ('Online' 'Login'). Then click ('Online' 'Run'). This will set the virtual
PLC to run and execute the code we wrote in PLC_PRG.
TRAFFIC_LIGHT.pro variable declaration
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
There are two declarations made in the program. One in the PLC_PRG POU, and the
other is in the Global_Variables.
In the declaration editor, we will declare inputs, outputs, and local variables (between
the keywords VAR and END_VAR in the POU) and (between the keywords
VAR_GLOBAL and END_VAR in the Global_Variables) in the resource tab.
In the Global_Variables we have put all the lights output variables in it. Whereas in
PLC_PRG POU will have all the local variables used for the logic. The declaration will
look like these:
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
The result
In our hypothetical situation, the traffic signal cycle starts upon running the virtual
PLC in simulation mode.
Light 1 will start from the green light, whereas Light 2 will start from the red light.
After the cycles are completed, the traffic light unit turns itself on, and the entire
process starts again from the beginning.
We do a test of the current version of your program in simulation mode before we go
on to create the POU PLC_PRG.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
PLC_PRG
The Ladder Logic program for Controlling a Traffic Signal.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
To start, we have added an NC boolean contact. This contact is not being triggered
anywhere in the program. When the simulation is run, a pulse trigger will be available
at POWER_UP_PLS, Q output which will latch variable INIT. This will start the Traffic
Signal lighting sequence. Remember, there are many ways you can program this
logic. But in this book, we have specifically used Ladder Diagram (LD) or Ladder
Logic. We have a great plan to teach you all the five programming languages
available in IEC 61131-3 standard. Michael and I have committed to teaching you
what we have learned for 20 years in customizing automation machines and
systems.
Just follow what we have written below. This is the beginning of the code where
initialization takes place.
L1, L2 & L3 are for Light 1, where L1 is for the Green, L2 is for the Yellow, and L3 is for
the Red.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
L1DONE means the Light 1 sequence is done. The TON timer L3DELAY1.Q will initiate
the start for the Light 2 sequence.
L11, L21 & L31 are for Light 2, where L11 is for the Green, L21 is for the Yellow, and
L31 is for the Red.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
MASTER_RESET TON timer is used to reset the if both light sequences are done.
Output LIGHT1RED (For Light 1) is the start of the output I/O’s.
Output LIGHT2RED (For Light 2) is the start of the output I/O’s.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Visualization for a Traffic Signal
With the visualization in CoDeSys, you can quickly and easily bring projects to life.
We will now draw two traffic signals which will illustrate the switching process. Here
we have made it quite simple for you.
You just have to put in the global variable with a logical NOT in front of it. This means
in the normal case, the lights will be invisible. However, when it is triggered or
latched, then it will be visible.
The below image shows how we do the variable setup in the visualization tab.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
This is how it looks when the simulating starts. First, the green light of Light 1 will
light up.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
After a few seconds, then the yellow of Light 1 will light up.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Then later, the red of Light 1 will light up.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
At this time Light 1 sequence is done. Then after a few seconds, the green light of
Light 2 starts to light up.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Then later, the yellow of Light 2.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Then finally, the Light 2 sequence is done where the red light will be on.
After this, the MASTER_RESET TON timer will restart the whole process again.
HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME
https://freeplcbook.plcguide.com/
Summary
This was not meant to be an exhaustive guide, but we hope it becomes a great
baseline. Additionally, you can use the quick references and other information to
build on as you become more adept in this programming language and functionality.
Other books Special Offers
https://plcguide.com/funnel/view/paperbackboxset
HACKS TOCRUSH PLC PROGRAM
FAST &EFFICIENTLY
EVERYTIME... :CODING,
SIMULATING &TESTING
PROGRAMMABLE LOGIC
CONTROLLERWITH EXAMPLES
★ Hacks To Crush PLC Programs From Beginning. Start Designing,
Building, Simulating and Testing Programs in IEC Languange (This book
guides only on LD (Ladder Diagram)★ This book will get you crushing
PLC-HMI programming environment as well as familiarize you with
(LD) ladder logic programming. You'll gain a deeper understanding of
the LD programming and the editing interface, the practical methods
used to build a PLC program, and how to . We also cover the basics of
ladder logic programming that every beginner should know, and
provide ample practical examples to help you gain a better
understanding. By the end of this book you will be able to create a
PLC-HMI program from start to finish, that can take on any real-world
task. If you know how to write & test the PLC-HMI codes then you're
on your way to work on any PLC environment.

More Related Content

Similar to HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME... : CODING, SIMULATING & TESTING PROGRAMMABLE LOGIC CONTROLLER WITH EXAMPLES

Rodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementationRodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementationFelipe Prado
 
For this phase of the course project, you will research a bank to .docx
For this phase of the course project, you will research a bank to .docxFor this phase of the course project, you will research a bank to .docx
For this phase of the course project, you will research a bank to .docxhanneloremccaffery
 
OVERVIEW OF PLC AND SCADA
OVERVIEW OF PLC AND SCADAOVERVIEW OF PLC AND SCADA
OVERVIEW OF PLC AND SCADASandeep Sahu
 
Larson and toubro
Larson and toubroLarson and toubro
Larson and toubroanoopc1998
 
Plc and scada project ppt
Plc and scada project pptPlc and scada project ppt
Plc and scada project pptPriya Hada
 
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?Pin-Ying Tu
 
How To Use IO Monads in Scala?
 How To Use IO Monads in Scala? How To Use IO Monads in Scala?
How To Use IO Monads in Scala?Knoldus Inc.
 
pdfslide.net_plc-and-scada-project-ppt.pdf
pdfslide.net_plc-and-scada-project-ppt.pdfpdfslide.net_plc-and-scada-project-ppt.pdf
pdfslide.net_plc-and-scada-project-ppt.pdfPrafulPatel54
 
Troubleshooting in plc
Troubleshooting in plcTroubleshooting in plc
Troubleshooting in plcNisarg Naik
 
Creation of derive roles with secatt
Creation of derive roles with secattCreation of derive roles with secatt
Creation of derive roles with secattRoberto B.
 
Configuring the cisco switch with the cli based setup program
Configuring the cisco switch with the cli based setup programConfiguring the cisco switch with the cli based setup program
Configuring the cisco switch with the cli based setup program3Anetwork com
 
Apex behind the scenes
Apex behind the scenesApex behind the scenes
Apex behind the scenesEnkitec
 
Control infrared remote controls receiver RS-232
Control infrared remote controls receiver RS-232Control infrared remote controls receiver RS-232
Control infrared remote controls receiver RS-232topomax
 

Similar to HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME... : CODING, SIMULATING & TESTING PROGRAMMABLE LOGIC CONTROLLER WITH EXAMPLES (20)

RamachandraParlapalli_RESUME
RamachandraParlapalli_RESUMERamachandraParlapalli_RESUME
RamachandraParlapalli_RESUME
 
Rodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementationRodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementation
 
For this phase of the course project, you will research a bank to .docx
For this phase of the course project, you will research a bank to .docxFor this phase of the course project, you will research a bank to .docx
For this phase of the course project, you will research a bank to .docx
 
OVERVIEW OF PLC AND SCADA
OVERVIEW OF PLC AND SCADAOVERVIEW OF PLC AND SCADA
OVERVIEW OF PLC AND SCADA
 
Vt training plc_1
Vt training plc_1Vt training plc_1
Vt training plc_1
 
Larson and toubro
Larson and toubroLarson and toubro
Larson and toubro
 
Telelab 2
Telelab 2Telelab 2
Telelab 2
 
Plc and scada project ppt
Plc and scada project pptPlc and scada project ppt
Plc and scada project ppt
 
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
超級全能危樓改造王 - 增建、改建、打掉重建你的軟體架構?
 
How To Use IO Monads in Scala?
 How To Use IO Monads in Scala? How To Use IO Monads in Scala?
How To Use IO Monads in Scala?
 
pdfslide.net_plc-and-scada-project-ppt.pdf
pdfslide.net_plc-and-scada-project-ppt.pdfpdfslide.net_plc-and-scada-project-ppt.pdf
pdfslide.net_plc-and-scada-project-ppt.pdf
 
Troubleshooting in plc
Troubleshooting in plcTroubleshooting in plc
Troubleshooting in plc
 
Creation of derive roles with secatt
Creation of derive roles with secattCreation of derive roles with secatt
Creation of derive roles with secatt
 
Modul PLC Programming.pdf
Modul PLC Programming.pdfModul PLC Programming.pdf
Modul PLC Programming.pdf
 
PLC TRAINING IN NOIDA
PLC TRAINING IN NOIDAPLC TRAINING IN NOIDA
PLC TRAINING IN NOIDA
 
Abap proxy
Abap proxyAbap proxy
Abap proxy
 
Pic microcontroller step by step your complete guide
Pic microcontroller step by step your complete guidePic microcontroller step by step your complete guide
Pic microcontroller step by step your complete guide
 
Configuring the cisco switch with the cli based setup program
Configuring the cisco switch with the cli based setup programConfiguring the cisco switch with the cli based setup program
Configuring the cisco switch with the cli based setup program
 
Apex behind the scenes
Apex behind the scenesApex behind the scenes
Apex behind the scenes
 
Control infrared remote controls receiver RS-232
Control infrared remote controls receiver RS-232Control infrared remote controls receiver RS-232
Control infrared remote controls receiver RS-232
 

Recently uploaded

Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?Watsoo Telematics
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 

Recently uploaded (20)

Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 

HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME... : CODING, SIMULATING & TESTING PROGRAMMABLE LOGIC CONTROLLER WITH EXAMPLES

  • 1.
  • 2. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Coding, Simulating & Testing Programmable Logic Controller With Examples About The Authors is a PLC Control programmer. With over 20 years of experience in the industrial automation field. With deep appreciation for his friend who introduced him to this in 1997 after finishing his diploma program in Electrical & Electronics. Farouk Idris Over the years, he has engaged with many system integrators and companies in Singapore. Utilizing self-taught skills, networking, and leverage mentality, he works with the industry's best tools, people, and companies. By joint venture between him , who possesses a similar capacity, they are taking up a key role in teaching PLC programming to as many people as possible, cutting short the learning curves and fears. and Michael Blake All rights reserved and Disclaimer. No part of this publication shall be reproduced or stored in any retrieval system mechanical or electronic, or transmitted in any form or by any means; electronic, mechanical, recording, or otherwise, without the author's prior written permission. Hacks to Crush Plc Program Fast & Efficiently Everytime…
  • 3. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Although the author has made every effort to ensure that the information in this book is correct at present, the authors and publisher do not assume and hereby disclaim any type of liability to any party for any loss, damage, or disruption caused by any errors or omissions, whether such errors or omissions resulting from negligence, accident, or any other possible cause. This book cannot assume any responsibility whatsoever. All contents are original contents by Michael Blake and Farouk Idris. CoDeSys is the Copyright of 3S - Smart Software Solution GmbH. This book is not authorized or endorsed by 3S - Smart Software Solution GmbH. This book serves as a best practices guide. The results are unique. Our track record has shown those who contribute effort follow the best practices guide shown here and continue to work on it, achieving sustainable and long-term results. It is essential that you have the PLC programming App in your PC. Click the link below to download it. https://plcguide.com/funnel/view/AppDownload Table of Content About The Authors All rights reserved and Disclaimer. Preparation before Inputting Contacts in LD (Ladder Diagram) Insert New Rung before in LD. Insert New Rung after in LD.
  • 4. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Variables Declaration in LD Input a Normally Open Contact in LD Input a Normally Closed Contact (negated) in LD Input a Parallel Contact' in LD Input a Parallel Contact (negated) in LD Moving all the contact elements in the LD-Editor Input an Output Coil in LD Input a Set coil in LD. Input a Reset coil in LD. Input a Function Block instruction in LD. Input a Rising edge detect Instruction in LD. Input a Falling edge detect instruction LD. Changing the SET/RESET output with S/R in LD Input Box with EN instruction in LD Input MOVE instruction in LD
  • 5. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Input a POU Block in LD Input AND contact in LD Input OR contact in LD Ladder Diagram in the Online Mode Input GT instruction in LD Input EQ instruction in LD Input SR instruction (Flip Flop) in LD Input RS instruction (Flip Flop) in LD Input CTU instruction in LD Input TOF instruction in LD Input CTUD instruction in LD Controlling a Traffic Light Signal Example Create a POU (Program Organization Unit) TRAFFIC_LIGHT.pro Simulation TRAFFIC_LIGHT.pro variable declaration
  • 6. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ The result PLC_PRG Visualization for a Traffic Signal Summary
  • 7. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ This command on the toolbar inserts a rung or network in the Ladder editor. If there are rung already then, the new one will be inserted before the currently selected. Insert New Rung after in LD. Network (after): Network (before): Insert New Rung before in LD. Preparation before Inputting Contacts in LD (Ladder Diagram)
  • 8. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Click this button in the LD editor to insert a contact. The contact now shows "???". You can click on this text and change it to the desired variable shown at “Declared Variable Image.” Normally open contact: Input a Normally Open Contact in LD Variables Declaration in LD Declare variables. This command on the toolbar inserts a rung or network in the Ladder editor. If there are rung already then, the new one will be inserted after the currently selected.
  • 9. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Parallel (OR) Normally open contact: Use this command in the LD Editor to insert a contact parallel to the marked position in the network. Input a Parallel Contact' in LD This command inserts a negated contact. The same is true for the commands' Insert' 'Contact' and 'Extras' 'Negate,' which in combination also could be used to insert a negated contact. Input a Normally Closed Contact (negated) in LD Normally Closed Contact:
  • 10. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ This command inserts a negated parallel contact. The same is true for the commands' Insert 'Parallel Contact' and 'Extras' 'Negate,' which in combination also could be used to insert a negated parallel contact. Moving all the contact elements in the LD- Editor Input a Parallel Contact (negated) in LD Parallel (OR) Normally close contact: The contact is preset with the text "???". This means you can change the text and desired variable name.
  • 11. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Move the element to one of these positions and let off the mouse key: the element will be inserted at the new position. If you, however, move the element to the name (variable name) of another element, the name field will be shaded green. If you then let off the mouse key, the previous name will be replaced by the "dragged" one. If additional addresses and comments are displayed (options), the copying also will apply to those. Here we’ll demonstrate that. First, click on the contact that you wish to move. All elements in the editor can be moved around to a different position within an LD POU by "drag&drop." To do this, just select the any elements that is, contacts, coils, function blocks and drag it – remember to keep pressing the mouse select key button – and move it away from the current position. Thereupon all possible positions within all networks in the editor, to which the element can be moved, will be indicated by a mirage of grey- filled rectangles.
  • 12. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Input a Set coil in LD. Input an Output Coil in LD Output Coil: Use this command in the LD Editor to insert a coil in a run. If clicked again, a new coil will be inserted in parallel to the previous coils. All the small boxes indicated by the BLUE arrow will be highlighted when dragging the contact. Thus, you can drop it anywhere indicated by the small box.
  • 13. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ This command will insert a Set coil. Another way is to go through the Insert 'Coil' and in Extras 'Set/Reset,' which could also get a Set coil. Input a Function Block instruction in LD. Input a Reset coil in LD. Change output coil to Reset: This command will insert a Reset coil. Another way is to go through the Insert 'Coil' and in Extras 'Set/Reset' could be used to get a Reset coil. Change output coil to Set:
  • 14. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ For this example, choose TON. In this example, we will add a Timer Function Block (TON): After clicking on it: Adding a Function Block.
  • 15. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Write the name Timer1 then click OK. Finally, put in the timer input count to T#5s which means 5 seconds.
  • 16. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ This command inserts a R_TRIG function block, which will detect a rising edge (FALSE -> TRUE) by the incoming signal. You can do the same through the command 'Insert' 'Function Block,' which can be used to insert any available function block. Input a Rising edge detect Instruction in LD. Rising Up detect Instruction:
  • 17. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Input a Falling edge detect instruction LD. Falling Down detect Instruction: Input the variable name, then click OK.
  • 18. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ This command inserts a F_TRIG function block, which detects a rising edge (TRUE -> FALSE) at the incoming signal. You can do the same by the command 'Insert' 'Function Block,' which can be used to insert any available function block. Input the variable name, then click OK.
  • 19. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Changing the SET/RESET output with S/R in LD Click this command repeatedly. The coil will alternate between set, reset, and normal coil. Input Box with EN instruction in LD Use this command to insert a function block, an operator, a function, or a program with EN input into an LD network. The EN Box is inserted parallel to the coils that are underneath them. Initially, it contains the instruction "AND." Then, after that, just rename it to instructions to your liking.
  • 20. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Input MOVE instruction in LD Declare the variables beforehand. We have assigned Source with 15. So, when we run the code 15 will be loaded to the Source variable. Insert a box with EN.
  • 21. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Rename the default AND instruction to MOVE instruction. Another way is to right-click and click the “Box with EN.”
  • 22. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Rename the default AND instruction to MOVE instruction or any other instruction based on your code design Input a POU Block in LD
  • 23. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Here we will input the Demo_Ladder_Diagram program to the PLC_PRG program, which is the main program in this project. But you may ask, why is that? If you don’t do that, then the Demo_Ladder_Diagram program will not run. Meaning all the codes in Demo_Ladder_Diagram will be idle or no operation. This is another way to input the Demo_Ladder_Diagram program here. Just delete the word AND in the box, then enter in the period (.) then, you can scroll to find the program you want to input here. But you need to make sure you rebuild the programs by going to Project -> Rebuild all.
  • 24. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ We don’t need the output for this box, so delete the output line. The final looks like this. Rebuild all the programs.
  • 25. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Input AND contact in LD Click this button to add in a normally open contact in series. Clicking again will place another normally open contact in front of it (in series). This is an AND logic. Meaning input1 AND input2 must be ON for the output coil to be ON.
  • 26. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Input OR contact in LD This button will add in contact in parallel. Let the cursor or selector be at input1 normally open contact, then just click on the Parallel Contact button. Once a new parallel contact (OR) appears, then rename the variable. This is OR logic. Output7 will be On if either input1 OR input3 is ON. Ladder Diagram in the Online Mode It is necessary now that we show how to go in the online mode. The upcoming example will showcase why this is the better option. All the contacts and coils in the Ladder Diagram (LD) in the "ON" state are colored blue. And all the lines over which the "ON" state is carried are also colored blue. At the inputs and outputs of function blocks, the values of the corresponding variables are indicated in the LD diagram and at the variable fields.
  • 27. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ To start to simulate, just go Online and log in. It is essential that you have the PLC programming App in your PC. Click the link below to download it. https://plcguide.com/funnel/view/AppDownload Other books Special Offers https://plcguide.com/funnel/view/paperbackboxset Next is to click the Run or press F5.
  • 28. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Now double click the Demo_Ladder_Diagram program to allow it to appear on the screen. Next, click the boolean you want to update the value as shown by the arrow in the below picture.
  • 29. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ When double-clicked, you can see what next is going to happen to the variable. This means you can turn this variable ON (TRUE). Clicking on it again will change it to FALSE. If Write Values (Ctrl+F7) is selected, the value will be updated to the variable.
  • 30. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Input GT instruction in LD This is a Greater than comparing instruction. Click the Box with EN. A new AND box will be inserted. First, delete the AND and rename the GT. Then, start to put in a number on the instruction input and a boolean variable at the output.
  • 31. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ The input we put in a 10 (Top input) & a 9 (Bottom input), then the output variable is Level_Up. It will return the value TRUE when the value of the first (top ones) operand is greater (this case is 10) than that of the second (bottom ones, which is now 9). The Level_Up boolean will be TRUE (Turned ON) when input1 contact is ON.
  • 32. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Input EQ instruction in LD This is equal to comparing instruction. This instruction will return the value TRUE when the operands are equal. Input new box with EN with either right-click on a rung or clicking the icon on the toolbar.
  • 33. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ A new AND instruction BOX with EN is inserted Edit and change the AND to EQ. instruction
  • 34. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Add in the variable Source and the value 15 on the EQ instruction inputs. The output of EQ is the variable name Same_Level. A normally open contact has been added in the next rung. Now, let us simulate it. First, as in the previous example, update the value of the variable input1 to 1 (ON). The variable Destination will be updated with a value 15. The variable Same_Level is turned ON now because it is equal to the value 15.
  • 35. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Input SR instruction (Flip Flop) in LD This instruction is provided by standard.lib. Making a Bistable Function Block. The SR truth table:
  • 36. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ No S R Q Description 1 1 0 1 Q is set to ON 2 1 1 1 No change 3 0 1 0 Q is set to OFF 4 1 0 1 Q is set to ON 5 0 0 1 No change Input SR instruction
  • 37. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Declare it as Another way is to click. Then choose the bistable function.
  • 38. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Then click OK. Declare variable to
  • 39. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Notice here there are two types of SR instructions. Next, we will plug in all the variables and simulate them. All variables have been added.
  • 40. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Right after running the simulation, the SR_Demo2 output with Q1 is turned ON. This is because the SET1 input is already ON If SrInp3 is turned ON, the output Q1 is still not OFF, as shown by the truth table. Therefore, we suggest you test the logic as shown by the truth table.
  • 41. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ The SrInp1 is turned ON for SR_Demo, but the Q1 (SrOut1) is OFF. This is because the EN input is not ON. Now when input3 turns ON, the Q1 (SrOut1) is ON. So, all the behavior of this SR instruction can be demonstrated as shown by the truth table. Overall, the SET1 input will make Q1, ON regardless if RESET input is On or OFF Input RS instruction (Flip Flop) in LD Provided by the standard.lib. Resetting Bistable Function Blocks The RS truth table:
  • 42. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ No S R Q Description 1 1 0 1 Q is set to ON 2 1 1 0 Q is set to OFF 3 0 1 0 No change 4 1 0 1 Q is set to ON 5 0 0 1 No change We have created the two types of RS instructions here Let us start to simulate it. First, it would appear that the RS instruction is the opposite of SR instruction. Why is that?
  • 43. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ This is because whenever the RESET1 input is ON, the output will be OFF. Try it yourself. Input CTU instruction in LD This is provided by standard.lib. Counter Up Function block Incrementor: Type BOOL is input variables CU, RESET and the output variable Q. Whereas, type WORD is input variable PV, and the output variable CV. If RESET is TRUE the counter variable CV will be set to 0. If CU input detect a transition from 0 to 1 Or from FALSE to TRUE, CV value will be incremented by 1. Q will return TRUE when CV is greater than or equal to the upper limit PV. Below in the example, we have added a 1-second clock represented by Clock1 and Clock2 TON timers. Each TON timer's PT parameters are set to 0.5 seconds.
  • 44. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ The R_TRIG detects the rising edge of Clock2.Q output and feeds the input CTU counter instruction. The counter PV is set to 10, and RESET input is set to input3. Below shows the CV value at 8 now. Now you can see the CV is over the value of 10, and the output of the counter is ON.
  • 45. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ The input3 is ON now, which reset CV to zero. The Counter1 output is also OFF now. Input TOF instruction in LD This is provided by standard.lib. TOF function block implements a turn-off delay. When input1 is ON, the TOF_Demo output is ON as well.
  • 46. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ When the variable input1 is OFF, the TOF starts to count. Now the TOF timer output is OFF now.
  • 47. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Input CTUD instruction in LD Provided by the standard.lib. Function Block of a Counter Up and Down (Incrementor/Decrementer) For this example, the previous clock has been reduced to 0.2 seconds (Combining Clock1 & Clock2)
  • 48. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Create a new set of timers for this. You can see here Clk_Short is at 3 seconds, and Clk_Long is at 5 seconds. Use the Clk_Short output AND with Clock_Pulse.Q to drive Up_Count output. One this Normally-Close Clk_Long with Clock_Pulse.Q to drive Down_Count output.
  • 49. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Below is the Trend plotting on CTUD_Demo.CV. You can see the value of CTUD_Demo.CV going up and down but eventually trending up. Controlling a Traffic Light Signal Example Now we will write our own version of traffic light signal unit controlling the two traffic light signals at a traffic intersection. The red/green phases of both traffic signals must be alternate to avoid accidents.
  • 50. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ In this example, we will see how time-dependent programs can be shown with the language resources of the IEC1131-3 standard. But for now, we only focus on Ladder Logic (LD) with the help of CoDeSys, and how one can easily connect them while becoming familiar with the simulation of CoDeSys. Create a POU (Program Organization Unit) Starting is always easy by just Start CoDeSys and choose 'File' 'New.' In the dialog box which appears, the first POU has already been given the default name PLC_PRG. Keep this name, and the type of POU should be a program. Each project needs a program with this name. In this case, we choose as the language of this POU the Ladder Logic (LD)
  • 51. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ TRAFFIC_LIGHT.pro Simulation Now we will check and test the program in simulation mode. Compile ('Project' 'Build') and load ('Online' 'Login'). Then click ('Online' 'Run'). This will set the virtual PLC to run and execute the code we wrote in PLC_PRG. TRAFFIC_LIGHT.pro variable declaration
  • 52. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ There are two declarations made in the program. One in the PLC_PRG POU, and the other is in the Global_Variables. In the declaration editor, we will declare inputs, outputs, and local variables (between the keywords VAR and END_VAR in the POU) and (between the keywords VAR_GLOBAL and END_VAR in the Global_Variables) in the resource tab. In the Global_Variables we have put all the lights output variables in it. Whereas in PLC_PRG POU will have all the local variables used for the logic. The declaration will look like these:
  • 53. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ The result In our hypothetical situation, the traffic signal cycle starts upon running the virtual PLC in simulation mode. Light 1 will start from the green light, whereas Light 2 will start from the red light. After the cycles are completed, the traffic light unit turns itself on, and the entire process starts again from the beginning. We do a test of the current version of your program in simulation mode before we go on to create the POU PLC_PRG.
  • 54. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ PLC_PRG The Ladder Logic program for Controlling a Traffic Signal.
  • 55. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ To start, we have added an NC boolean contact. This contact is not being triggered anywhere in the program. When the simulation is run, a pulse trigger will be available at POWER_UP_PLS, Q output which will latch variable INIT. This will start the Traffic Signal lighting sequence. Remember, there are many ways you can program this logic. But in this book, we have specifically used Ladder Diagram (LD) or Ladder Logic. We have a great plan to teach you all the five programming languages available in IEC 61131-3 standard. Michael and I have committed to teaching you what we have learned for 20 years in customizing automation machines and systems. Just follow what we have written below. This is the beginning of the code where initialization takes place. L1, L2 & L3 are for Light 1, where L1 is for the Green, L2 is for the Yellow, and L3 is for the Red.
  • 56. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ L1DONE means the Light 1 sequence is done. The TON timer L3DELAY1.Q will initiate the start for the Light 2 sequence. L11, L21 & L31 are for Light 2, where L11 is for the Green, L21 is for the Yellow, and L31 is for the Red.
  • 57. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/
  • 58. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ MASTER_RESET TON timer is used to reset the if both light sequences are done. Output LIGHT1RED (For Light 1) is the start of the output I/O’s. Output LIGHT2RED (For Light 2) is the start of the output I/O’s.
  • 59. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Visualization for a Traffic Signal With the visualization in CoDeSys, you can quickly and easily bring projects to life. We will now draw two traffic signals which will illustrate the switching process. Here we have made it quite simple for you. You just have to put in the global variable with a logical NOT in front of it. This means in the normal case, the lights will be invisible. However, when it is triggered or latched, then it will be visible. The below image shows how we do the variable setup in the visualization tab.
  • 60. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ This is how it looks when the simulating starts. First, the green light of Light 1 will light up.
  • 61. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ After a few seconds, then the yellow of Light 1 will light up.
  • 62. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Then later, the red of Light 1 will light up.
  • 63. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ At this time Light 1 sequence is done. Then after a few seconds, the green light of Light 2 starts to light up.
  • 64. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Then later, the yellow of Light 2.
  • 65. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Then finally, the Light 2 sequence is done where the red light will be on. After this, the MASTER_RESET TON timer will restart the whole process again.
  • 66. HACKS TO CRUSH PLC PROGRAM FAST & EFFICIENTLY EVERYTIME https://freeplcbook.plcguide.com/ Summary This was not meant to be an exhaustive guide, but we hope it becomes a great baseline. Additionally, you can use the quick references and other information to build on as you become more adept in this programming language and functionality. Other books Special Offers https://plcguide.com/funnel/view/paperbackboxset
  • 67. HACKS TOCRUSH PLC PROGRAM FAST &EFFICIENTLY EVERYTIME... :CODING, SIMULATING &TESTING PROGRAMMABLE LOGIC CONTROLLERWITH EXAMPLES ★ Hacks To Crush PLC Programs From Beginning. Start Designing, Building, Simulating and Testing Programs in IEC Languange (This book guides only on LD (Ladder Diagram)★ This book will get you crushing PLC-HMI programming environment as well as familiarize you with (LD) ladder logic programming. You'll gain a deeper understanding of the LD programming and the editing interface, the practical methods used to build a PLC program, and how to . We also cover the basics of ladder logic programming that every beginner should know, and provide ample practical examples to help you gain a better understanding. By the end of this book you will be able to create a PLC-HMI program from start to finish, that can take on any real-world task. If you know how to write & test the PLC-HMI codes then you're on your way to work on any PLC environment.