Hello friends, I hope you are doing very well! In today's tutorial, we will set up a simulation environment for Ladder Logic Programming. It's our second tutorial in Ladder Logic Programming Series. In our previous tutorial, we have seen a detailed Introduction to Ladder Logic Programming and we have seen that this programming language is used for PLC controllers.
As PLC is an Industrial Controller, it comes with built-in relays/transistors(with protection circuitry) and thus is quite expensive as compared to microcontrollers/microprocessors i.e. Arduino, Raspberry Pi etc. Moreover, if you are working on a real PLC, you need to do some wiring in order to operate it. So, in order to avoid these PLC issues at the beginning, instead of buying a PLC one should work on a PLC Simulator. Using PLC Simulator, we can program our PLC controller and imitate its real behavior without having the hardware, saving both time and money as now we don't need to buy a new PLC and can start right away.
To sum up, by completing this article you will have a complete lab that includes the software you are going to use, the simulator that plays as the hardware, and certainly, you will be familiar with installing a PLC programming environment by which you can program, configure, moving the program to the PLC hardware, retrieving the program from the PLC to the software environment, and testing your program on the simulator. In addition, we are going to test our environment setup with a very basic program and take the chance to show you how to program, configure, upload, and test your program on the simulator.
Setup PLC Simulator
As I mentioned in the last tutorial, we are going to work on Siemens PLC throughout this tutorial, as it's one of the most common PLC controllers. So, we are going to install PLC Environment designed by Siemens and is called Total integrated automation (TIA). Along with this software, we will also need to install a PLC Simulator called S7 PLCSIM, again designed by Siemens. At the time of this writing, their most stable versions are 15.1, so download these two applications from below links:
Installing TIA Software
After downloading the TIA and the simulator, we extract the package by double click on the file we downloaded, and then it will be self-extracted and initiate the setup wizard as shown in the below figure. The image shows many steps. Moving our eyes from left to right, on the first part, the downloaded package has been extracted. In the next part of the picture in the middle, the setup wizard gets started by general settings in which you can set the preferred language and select the preferred installation location. The third part shows the setup goes on progressively and takes you to the end of the installation of the software IDE. Congratulation! You know have the programming software IDE installed on your computer and the good news is, all packages of Siemens go with the same scenario, you download the software package files. Click them to be extracted. And then, the installation wizard is launched by the end of file extraction which is a very systematic and easy way.
Figure 2: TIA portal version 15.1 setup wizard
Installing the PLC simulator
Well done so far! After having the programming software IDE completed, the next step is to install the simulator package which is PLCSIM version 15.1. Download PLCSim from the above link and then double-click the downloaded file of the simulator package as shown in Figure 3 to start extracting the packed file. You will be asked for the language and the location you prefer to have the installation folder. So you can leave it as the default or go with your preferences.
Figure 3: PLC simulator PLCSIM version 15.1 package extraction
After file extraction has been completed, the setup wizard will start automatically as shown in Figure 4 with the general setting screen by which you can set the preferred language and the location to install the simulator software. So you can use the default setting or update with your preferred choices.
Figure 4: the simulator setup general settings
Figure 5 shows the simulator setup configurations screen which helps you to configure and customize your installation. In this configuration screen, you can go with the typical options of installation in which all software components are selected to be installed or you can customize your installation to select or deselect components of the package. And by hitting the next button of this window, the installation will go on as shown in figure 6 until the end of the installation. During the installation progress, Siemens show off the features you may find in the software and the facilities you will enjoy by using this software. At the end of the installation, the wizard will request you to restart your computer now or later for completing the setup wizard by saving settings and registry values related to the installed software as shown in figure 7. That’s great! As for now, you have everything is ready and you are all set to get started and enjoy practice and learning the ladder logic programming and simulating your work.
Figure 5: the simulator setup configurations
Figure 6: the simulator installation screen
Figure 7: Simulator setup completion screen
Checking the setup environment
Before going any further let us check the successfulness of the installation process of the software and PLC simulator. Simply go to start and open TIA portal 15 and S7-PLCSIM you will see the software opening with no problem as shown in Figures 8 and 9. In figure 8, you can see options to create a new project or open an existing project. Also, there is an option to migrate projects from one version to another version by upgrading or downgrading the version of the projects. In addition, you can enjoy the welcome tour to know about the software programming tools and be familiar with its components. In addition, there is an option to check the installed software to validate the packages you select to include within your installation. for any further information you can click help to search and inquiry about any doubts.
Figure 8: Opening the TIA 15 software for testing installation successfulness
Moving to the S7 PLCSIM simulator software, as you can see in Figure 9, it is a very smart and simple interface. It shows a power button by clicking it you can shutdown the PLC controller or turn it on. Also, all indicators like the real PLC controller are included. You can see the RUN/STOP indicator. In addition, the ERROR indicator blinks red for any faults with the CPU of the PLC. In addition, you can see the run and stop buttons to start and stop the controller. Also, the MRES button to reset the PLC to the default values at any time. In addition, there is a detailed interface of the S7 PLCSIM simulator as shown in Figure 10. You can launch the detailed or maximized interface of the simulator by hitting the top-right icon on the shortcut window version of the simulator.
Figure 9: Opening the PLC simulator PLCSIM 15 for testing installation successfulness
The shortcut or the small version of the simulator shows the basic functions of the simulator like starting and stopping the controller or resetting the PLC and showing the status of the controller i.e. Run, stop, in fault status. But, the maximized or the detailed window simulator interface shows more options and facilities of the simulator. For example, you can create a simulation project to link it with a PLC project. Showing status of all input and output channels on the Input and output modules. In addition, it enables you to set and reset any of the inputs as we will elaborate in detail later in the next articles.
Figure 10: Opening the PLC simulator PLCSIM 15 in detail mode
Validating the PLC Simulator
After completing the installation successfully of the programming tools software TIA version 15.1 and the simulator PLCSIM version 15.1, it should be validated to make sure all components are installed and working properly. Let us validate by going through the functions and wizard. You now get in the Lab by opening the TIA portal and hitting create a new project as shown in Figure 11. On the right, you just need to name your project like for example let it be “first_ladder_prog” and you may leave the default location of projects or alter the data to the project file location as you prefer.
Figure 11: Creating a new project on the TIA portal
By hitting create, the creating project wizard comes out as shown in figure 12. As you can see you have many options to do on this screen like configuring the hardware, designing visualizations by designing and programming a human-machine interface (HMI) screen, motion control, or writing a ladder logic program. As for now do not worry about all these options as they are all not our scope in this series except those are relating to ladder logic programming like writing program option and configuring PLC device and network which we will come to them later in the next articles. For testing the installed software, you can simply select write a plc program for now.
Figure 12: creating project wizard
By choosing to write a PLC program, the wizard takes us to add the controller on which we are going to run the designed program as shown in Figure 13. If you are not familiar with the type of PLC controller models and hardware for now. That is not an issue because we are here to learn Ladder logic programming which is general for most PLC controllers of all brands i.e. Siemens, Schneider, Rockwell Automation, Allen Bradley, Beckhoff, WAGO, et cetera. So, for now, let us for testing purposes select S7-1200 which is one of Siemens PLC controllers to use in our project. By hitting the yellow small cross icon to add a device. You will see the list of the Siemens controllers that have appeared. For each controller, you can see many versions. Each version represents firmware for example, by selecting S7-1200 CPU 1211C AC/DC/RLY, you will see three versions. Each version represents a specific controller CPU in the market i.e. the selected one if of firmware ver 4.2 as shown in figure 14. By seeing this long list of CPUs and models, that means the software has been installed successfully and is ready to be used in our projects. So congratulation for successfully setting up the working environment for our Lab of ladder logic programming and being ready for utilizing this environment including programming software TIA 15.1 and simulator S7 PLCSIM version 15.1 in our learning and practice.
Figure 13: adding PLC controller wizard
Figure 14: selecting S7-1200 CPU v4.2