Siemens TIA Portal & s7-1200 PLC & Inputs & Outputs [3]

In this tutorial, you will learn how to configure the inputs and outputs of your PLC and how to add them to your main program. Check out the last post, if you miss it, where we explain how to make an Online Connection between your PC and your PLC.

Parts Required

Software:

  • Siemens TIA Portal

Hardware:

  • s7-1200 1214 DC/DC/DC PLC

Data types and Memory sizes

To explain to you how to create your input and output tags you have to understand that the tags could have different types with different memory sizes:

To begin the explanation of tag types you must understand the difference between bit and byte. The bit is the smallest size on automation memory and only can keep tags that have 2 states. On and Off.

The byte memory is greater than the bit memory. Each byte of memory has 8 bit’s starting from 0 to 7. This is the reason why your inputs and outputs are written in your PLC from 0 to 7 Figure [1].

Figure [1] – Bit and Byte

The first of the 3 most usual tag types is the bool type. When you create a bool type tag it means that that tag only could be true or false, 0 or 1. A good example of that could be a lamp. That lamp could be on or off. This type of tag only uses a bit of memory. It means that when using this type of tag you must increment 0.1 in 0.1 on bit memory to create new tags.

The second usual type is the int type. When you create an int type it means that your tag could be from -32768 to 32767 only with integers values. This type of tag uses 2 bytes ( 16 bits).

The third most usual type is the real type. When you create a real type it means that your tag could be from +/-1.175495e-38 to +/-3.402823e+38. This type of tag uses 4 bytes (32 bits) and could use decimal values.

Create tags

To create your PLC tags, go to the default tag table following Figure[2].

Figure [2] – Default tag table.

The name column should be fulfilled with a suggestive name. When you start to make huge programs, if you don’t choose correctly the name of tags, at some point could be confused. To help, I personally use one simple strategy.

When I create a tag, the first character of the name tag is always the letter corresponding to the tag type. When it’s a bool type I use an “x” letter, when integer I use “i”, when it’s a real type I use “r” and so on… It means that, if I am creating a bool tag, of a button that I have connected to my first PLC input, the name I choose is “x_button1”.

So, for our tutorial, we will create an input and an output. Our input will be a button and our output will be a lamp.

To create the input we define a name of “x_button”. Because this button only could be ON or OFF, the data type is bool. Now the address should be chosen with the operand identifier “I” from “Input”, the address is 0 and the bit address is 0 as you can see in Figure [3].

Figure [3] – Address of the input

To create the output we define a name of “x_lamp”. Because this lamp only could be ON or OFF, the data type is bool too. Because the lamp is output, the operand identifier now should be “Q”, the address is 0 and the bit address is 0 too.

As these outputs and inputs are bool types, they use a bit of memory from 0 to 7. It means that if you want to create the second input must be with the address “I0.1” and so on until “I0.7”. Because bytes only have 8 bits, from 0 to 7, if you want to create one more input, must be with the address “I1.0”. This address already uses another byte starting with bit 0.

As you can see, at the right of the default tag table, you have some important columns Figure[4]:

Retain: If selected, this means that your tag saves the actual value even if the power of PLC goes OFF. This mode is very useful when we are talking about counters that couldn’t lose the count.

Accessible from HMI/OPC-UA: If selected, this means that you permit your tag could be read from HMI/OPC-UA.

Writable from HMI/OPC-UA: If selected, this means that you permit your tag could be written from HMI/OPC-UA.

Visible in HMI Engineering: If selected, this means that you permit your tag could be read from HMI Engineering.

Figure [4] – Acess Read/Write of tags

Now that, we have created one input and one output, it’s time to add them to the main program. To do that you should follow up the Figure [5].

To use the input signal, you should go to Basic instruction-Bit logic operations and choose the normally open contact. Drag and drop it on Network1 line as you can see in Figure[6].

Figure [6] – Normally open contact

Above the contact that you insert, you can write the name of the input that you create, “x_button” and you can confirm that the Address that is shown is the address “I%0.0” that you have chosen.

Now goes again to Basic instruction-Bit logic operations and choose the assignment. Drag and drop it on Network1 line as you can see in Figure[7].

Figure [7] – Assignment

Again, above the operator that you inserted, you can write the name of the output that you have created, “x_lamp” and you can confirm that the Address that is shown is the address “Q%0.0” that you have chosen.

After clicking on the download to device button shown in Figure[8] and following the process explained in Online Connection tutorial, click on “Go online” and in monitoring on/off button.

Figure [8] – Download to the device and Online connection

You can make the electrical connection between your button and the lamp. Now you can check on Tia portal software and in PLC that, when you press the button, the input 0.0 will stay green and the output Q0.0 will be green too and your lamp will light on.

This is the third post on Siemens TIA Portal. You have learned how to create inputs and outputs tags, the differences between data types of tags, and how much space they use in memory.

If you like this kind of post, if you want to know more about siemens TIA Portal or if you have some doubts about the Industrial Automation area don’t forget to leave a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
100% Free SEO Tools - Tool Kits PRO