Technical Article

Intro to Siemens S7-1200 PLC and TIA Portal Programming

February 07, 2023 by David Peterson

The S7-1200 is one of Siemens’ most popular PLC options for relatively small automation projects. Learn how to use the Totally Integrated Automation Portal to design simple ladder logic programs.

Siemens is a company well-known for its presence in nearly every field, including energy production, oil and gas, as well as automation and control.

An extensive part of the company’s product lineup is in the area of industrial automation, providing both hardware and software to meet the needs of nearly any facility or process. One of the most common platforms in the S7 series is the S7-1200, easily recognizable from its small form factor with embedded inputs and outputs and easily expandable for additional signal and communication capabilities.

 

Siemens S7-1200 PLC Platform

To begin this tutorial, we will establish the connections to this small PLC, which is an S7-1200 1214 AC/DC/Relay. The letter designation refers to the input power (AC), then the discrete input type (DC), and finally the discrete output type (relay). This model has two analog inputs, and through the use of an installed signal board, it also has an analog output; both of these will be covered in a different article. 

We will use a single input and a single output device. Since both the input and output bank are isolated from the built-in power supply, they must be supplied with power (outputs) and ground (inputs). For wiring details, check out our video tutorials for wiring of input and output devices

 

Siemens TIA Portal Programming

The Totally Integrated Automation (TIA) Portal is designed to be an application that allows a programmer to design PLC programs, HMI displays, and motion/motor control systems, all from a single software.

 

Siemens TIA Portal software for S7 1200 PLC

 

Depending on the nature of the project and the software package purchased, not all of these systems will be visible in the immediate setup. For now, we’ll focus only on the most basic target of the TIA portal which is the PLC and ladder diagram programming.

 

Starting a Project in Siemens TIA Portal

We will be using version 13 of TIA portal, which may not be the most recent update, but the application will be largely the same. Be aware that future revisions may change the interface, so this guide may not work for all versions.

When the software is first opened, the Portal View will be visible, as shown in Figure 1. 'Create new project' will allow us to give a name and optional comments to our new project, which we’ll call TIA_Test_1 for simplicity.

 

Creating a new project in Siemens TIA Portal

 

We are presented with some recommended first steps. The first step should usually be to configure the hardware and establish the proper modules, communication parameters, etc. This way, we should not meet unexpected challenges when we create tags or instructions that somehow are unsupported by the hardware we have not yet specified. Therefore, I prefer to always select the right hardware before programming.

On this next screen, that means ‘Configure a device’.

 

TIA Portal Configure a device

 

Since this is a new project and we have not yet connected to any controller, we’ll want to 'Add new device', and choose the right controller from the list.

 

Adding controller to TIA Portal

 

As specified earlier, this is a 1214 AC/DC/Relay model, and it has a specific part number visible on the front. I have removed the protective cover flaps for the I/O terminals, but you may need to fully open the lower flap to reveal the part number. 

It’s also visible on the side, but that’s not as helpful when it’s mounted to a trainer or control cabinet with modules and devices on the DIN rail adjacent.

 

PLC part number

 

connecting plc with TIA Portal

 

It should be noted that the ‘Version’ selection is important at this stage, otherwise, there may be a mismatch between the project version and the current version loaded in the existing hardware. 

If you don’t know the current version of the PLC, you should probably go directly to the next step, connect to the hardware, and then return to the setup of a new device for the project.

 

Connecting to the Siemens S7 PLC

This PLC is fairly unique for modern technology in that it only has a single Profinet port, but it can be accessed and configured regardless of your PC’s connection configuration. This allows you to connect without resetting the device, even if you have no information about the module.

To demonstrate this, I am using a PLC that I have not used in several years. I do not remember the last communication setup, so I will connect to the hardware and check the version, then return to the device setup, as discussed earlier.

From the bottom of the main screen, we can go directly to ‘Project view’. On the far left side of this view, the entire project tree is visible, including both the added devices as well as the 'Online access' to see any available devices. Find your correct network adapter and ‘Update accessible devices’ as shown below.

 

correct network adapter and update accessible devices

 

With my previously unknown PLC connected via an Ethernet cable, I can see this new device has just appeared.

 

PLC connected via an Ethernet cable

 

It should be noted that my PC is set with an IP address of 10.10.10.2 with a subnet mask that prevents these devices from being on the same subnetwork. Even so, the device is able to report back with connection information.

 

Online & Diagnostics Menu

Now click on ‘Online & diagnostics’ where we can see a bit more than just the IP address; this will be useful in setting up our new project.

I set my computer’s network adapter to the proper subnet, with a 10.10.1.x configuration, refresh the devices, and now: 

 

et my computer’s network adapter to the proper subnet, with a 10.10.1.x configuration and then refresh the devices

 

This is a version 4.0 device—good to know when setting up the device, a step which I can now accomplish.

 

Downloading a Project to a SIMATIC S7-1200

With the CPU and version chosen, added to the project, and automatically shifted to project view, all I need to do is set the target IP address. The Device view window has an image of the PLC with the network connector outlined in green. Selecting this connector allows you to enter the target address below.

I see the default address shown below, so I’ll change it to my newly-discovered 10.10.1.20 address.

 

default address shown below, change to newly-discovered 10.10.1.20 address

 

Now, I will download this entire project to the device.

 

download the entire project to the device

 

The online access window will open, allowing you to search the network and select the correct PLC. In this network, there is only one of them, so I expect the IP address to match the target, which it does. If you have a large network with many devices, you’ll need to be sure and choose the right one.

 

choose the right device

 

Writing a Basic Ladder Diagram Object Block

Once the previous steps are complete, the actual construction of a single-line sample ladder diagram is extremely easy.

The Main OB1 (object block) is where the ladder networks are stored. This is accessed from the project tree on the left sidebar.

 

access ladder networks from project tree on left sidebar

 

In typical fashion, drag down a single N.O. contact instruction and a single momentary output coil.

To reference the built-in I/O terminals, the syntax is %I0.x (such as %I0.0 in this example) for the inputs and %Q0.x for the outputs.

 

To reference the built-in I/O terminals, the syntax is %I0.x for the inputs and %Q0.x for the outputs

 

Alternatively, and probably a much better practice, is to use the PLC tag table to provide logical names to all I/O devices, and then use those in the ladder networks. I have done this using a green button and a relay as examples.

 

use the PLC tag table to provide logical names to all I/O devices and then use those in the ladder networks

 

You may now, once again, download to the device and the new project will be loaded quickly since the connection was already established.

 

Programming an S7-1200 PLC

Congratulations, you have successfully connected to and programmed an S7-1200 PLC. TIA Portal offers a lot of functionality, but it can also be a bit overwhelming for new users. Follow this simple guide to get online or even to start over with a blank slate if you run into trouble. 

The best way to learn any new PLC software is to simply jump in and get started. Now go design something awesome.

 


Want to test your knowledge of PLCs? You think you N.O. a lot about ladder logic? Are you a normally-open or normally-closed minded engineer (a couple little electrical jokes there for ya)?

Check out our PLC Programming worksheet!

 

Featured image used courtesy of Siemens