Jump to content
  • PLC programming technology and HMI interface design English database

    PLC, DCS, HMI and SCADA product application technical articles

    leikang
    In a previous article, we discussed what is a function block FB, how it works in a PLC program, and how to create and use one. In this article, we will talk about data block instances of different function block types in Siemens Tia Portal and when to use each type.
    Contents:
    What is a function block FB? Different options of data instances. Single Instance. Parameter Instance. Multi-instance. What is a Function Block?
    A function block or an FB is simply a block that contains code logic. You use this FB to achieve specific functionality through the pieces of code written inside.
    When calling a function block into your code you will be asked to assign a data block also called data instance to be associated with this FB, to save the values of the FB parameters. Not all parameters inside an FB are saved in the data instance, but we will get to that later.
    When calling a function block, you have 3 different options for associating a data block instance with this function call. These different options will depend on where you are calling your FB.
    So, in a nutshell. A function block FB is basically a function FC with a dedicated data block DB, this data block is used to store the values of the function block parameters.
    Different Options for Data Instances
    We have 3 different options for a data instance of a function block, these options are:
    Single Instance. Parameter Instance. Multi-Instance. The three different call data instances come from the 3 different call methods:
    You can call a function block FB inside the main OB1 which will give you the option of: Single instance. You can call the function block FB inside a function FC, which will give you two options Single instance Parameter instance You can call the function block inside another function block, which will give you the three available options for creating a data instance Single instance Parameter instance Multiple instances Single Data Instance
    First, let’s start by creating a function block FB, as we mentioned before, we create a function block by clicking add a new block and choosing the type of block we want. See picture 1.

    Picture 1 – Creating a function block FB
    Now, let’s call the ReusableFB that we created inside our main OB1. See picture 2.

    Picture 2 – Calling the FB inside the main OB1
    As you see from the previous picture, when calling an FB inside the main OB1 you will be asked to assign a data instance to be associated with this FB call. In this case, there will be only one option, which is the single instance.
    After choosing a single instance option, a data block will be created and associated with the FB call. See picture 3.

    Picture 3 – Single instance created
    The created single instance will be used to store the values of some of the FB parameters. Like the inputs, outputs, In Out, and static parameters.
    Other parameters of the FB will not be stored, like temp and constants. See pictures 4 and 5.

    Picture 4 – Data is saved inside the data instance

    Picture 5 – Data saved from the FB into the data instance.
    Now, let’s create a simple logic inside the FB to help us understand the data instances better. This logic will add a constant value of 15 to a static variable and then move the result to the output. See picture 6.

    Picture 6 – Create a simple logic
    Now, go back to the main OB1 and notice how your FB call is now. See picture 7.

    Picture 7 – Update the FB call after each change
    Any change you make to the logic inside the FB, will result in the need for updating the Function block call, so that the changes you made can be applied.
    You can update the block call by right click the FB call and pressing the update block call option or by recompiling your PLC code. See picture 8.

    Picture 8 – Updating the FB call
    After updating the block call, the changes you made in the FB code will be applied and employed in the block call. As you see in picture 9.
    The FB now expects an input signal of type bool to be provided and the FB will give an output of type int.

    Picture 9 – Inputs and outputs are now associated with the FB call
    Let’s simulate our code and see how the PLC will behave. See the next animation showing a simple simulation of the PLC logic so far.

    As you see from the animation, whenever the start signal is TRUE, the function will be executed and the output keeps changing. And once the start signal is no longer available the Output will remain at the last value recorded.
    The use of the data instance here is that the values of the static variable and the output variable are saved inside the single instance, so when the start signal comes back again, the function will continue from the last recorded values.
    Very Important Note
    You should never use the same single instance for two different calls of an FB. See the next animation.

    As you see from the animation, we have two different FB calls, but both calls are associated with the same single instance, which is why even when the start2 signal was FALSE, the Output2 value was changing with Output1.
    As you would expect the change in the data instance of the 1st call will also be affected in the 2nd call because they have the same memory block. See picture 10.

    Picture 10 – Never use the same data instance with different FB calls
    If you used the same data instance with different FB calls, then your function block is no longer reusable. Even if the inputs/outputs parameters are different for each different FB call. As you saw from the last video (animation) both calls had the same results even though 2nd call doesn’t even have an enable input signal.
    Another very important note
    We said before that if you call your FB from a higher-level FC, you will have two options for the associated data instance; these options are the single instance and the parameter instance. See picture 11.

    Picture 11 – Using a single instance with an FB called from an FC
    If that happened, and you will call an FB inside an FC, You should never use a single instance for your FBs. To know why that is. See picture 12

    Picture 12 – Calling the higher-level FC more than once
    As you see from picture 12, when you call the higher-level FC in your logic more than one time, you will not be asked to assign a data block, because FCs don’t need one.
    But you know that there is a called FB inside the FC, this FB has a single instance associated with it. So now the 3 FC calls have the same data instance for the FB call. So, your function FC is no longer reusable.
    What to do?  The best option for when you need to call an FB inside an FC is to use the parameter instance.
    Parameter Instance
    As we said before, if you called an FB inside an FC you shouldn’t choose the single instance but rather the parameter instance is better for your reusability purposes.
    A parameter instance will save the data instance of the FB called into the In Out area of the FC block interface. Allowing you to enter a new data instance for each FC call. See pictures 13 and 14.

    Picture 13 – Assign parameter instance when calling an FB inside an FC

    Picture 14 – Each FC call will need a new data instance
    As you see from the previous picture, whenever you call the FC inside your program, it will ask for a data instance for the reusable FB inside the FC.
    But, using this way you will have to create the data instance yourself. See picture 15.

    Picture 15 – Create a new data instance
    To create a new data instance, you do the same as creating an FC or an FB, but this time you choose the DB option. And make sure that you select the DB type to be the same as the FB called.
    Now, your FC can be reused as many times as you want, you just have to create an instance for each call. See picture 16.

    Picture 16 – Assign the DB to the FC call
    Multi-instance Database
    A multi-instance DB simply means that the DB of the called FB will be stored inside the DB of the higher-level calling FB.  This option is only available if you call an FB from another FB.
    Let’s create another FB to use it as a higher-level FB.
    After creating this HigherLevelFB, call it from the main OB1, and off-course the only option of calling will be a single instance as shown before. See picture17.

    Picture 17 – Call the HigherLevelFB from the main OB1
    Now, call the ReusableFB from the HigherLevelFB. And choose the Multi-instance option. See picture 18.

    Picture 18 – Assign multi-instance DB
    When you choose the Multi-instance option, the created DB will be stored inside the static parameters of the calling FB. See picture 19.

    Picture 19 – Instances are saved inside static parameters
    You can call the ReusableFB many times, each time you call it the multi-instance will be stored inside the static parameter. See picture 20.

    Picture 20 – Calling the ReusableFB many times
    As you can see the data instance of the lower-level FB will be saved inside the data instance of the higher-level FB. It is best for better program structure and easy-to-read logic.
    Conclusion
    Creating function blocks inside your code will require associating a data block with each FB call you to make in your logic. This data block or also called data instance has different options depending on the type of block that is calling your FB.
    Be careful when choosing the type of data instance, as some options may not be suitable for your case as we showed before. And sometimes this can lead to problems in your logic and your function can no longer be reusable.
    Using multi-instance can help better organize your program structure, as all called FBs will store their DBs inside the main calling FB.

    leigehong
    In the previous article, we talked about data blocks, and we discussed the two different types of data blocks, the global data block and the data instances of function blocks FBs.
    In this article, we are going to discuss what is meant by optimized data block access and standard data block access in Siemens Tia Portal.
    Contents:
    What are optimized and standard data blocks? Simple program example. What are Standard DBs? What is the offset? What are optimized DBs? Advantages of using optimized DBs. Conclusions. What is optimized and standard data block access?
    First, these are not new types of data blocks; we said we only have two different types, the global DB and the instance DB. Optimized data block access is a feature for the data block. You can activate or disable this feature from the properties of the data block you have created.
    The optimized data block feature is only available for S7-1200 and S7-1500 PLCs not for s7-300 or s7-400
    The standard setting for data blocks when working with S7-1200 or S7-1500 PLCs is that they are optimized, if you want a standard data block you will have to set that yourself.
    So, what is optimized and standard blocks? To understand the difference, we will make a simple program and try to show how an optimized block differs from a standard block.
    Simple Program Example:
    In this example we will not create any PLC logic or code any instructions, we will just create 2 global data blocks, DB1 will be called OptimizedDB and DB2 will be called StandardDB.
    Inside both data blocks, we will declare 4 variables of data types Bool, Int, Real, and Word respectively. See picture 1.

    Picture 1 – Create two global DBs
    The first thing you will notice is that both data blocks are exactly the same, that is because as we said the default setting when creating a data block is that it will be optimized, so we need to change the setting of DB2 to make it a standard block, to see if something will change.
    We do that from the properties of that DB2. You access the properties of DB2 by right click the data block and press properties. See picture 2.

    Picture 2 – Change DB2 to standard block access
    Once you de-select the optimized block access attributes that you see in picture 2 and press OK, a warning message will pop up, see picture 3.

    Picture 3 –  Change block access Pop-up
     Once you press OK, your DB2 will have been converted to standard block access. See picture 4. To see what difference did that make.

    Picture 4 – DB2 is now a standard block
    What we can directly see is that DB1 and DB2 are not the same anymore. The standard block access option represented in DB2 has an additional column called offset.
    In front of each variable in the offset box, there is a … written, this will change once you compile your program.
    Let’s compile and see what happens, see picture 5.

    Picture 5 – Compile your program to reload the offset
    Now, the offset is filled in with as you can see 0.0, 2.0, 4.0, and 8.0 respectively.
    So, what is that offset? What does it mean? We will get to that later, but now, Let’s create another STANDARD block and declare the same 4 variables, but this time we will change the order of the variable data types, see picture 6.

    Picture 6 – Create another standard block DB3
    You see from the last picture the offset of DB2 and DB3 is different, why the offset values are different when we changed the order of data types? They are the same data types but in different order.
    Let’s create another standard DB, and declare the same 4 variables but again in a different order. Compile your PLC code and now compare the offset of the 3 DBs. See picture 7.

    Picture 7 – Three different DBs with three different offsets
    The same thing happened again.
    What are Standard DBs? What is the offset?
    Data blocks with standard access have a fixed structure. When you declare a variable inside a standard DB this variable will be assigned a fixed address within this DB.
    The address of this variable is shown in the “Offset” column. So, what we were seeing inside the offset in previous pictures was the address assigned for each variable.
    Because the structure of standard DBs is fixed, you can only work inside the DBs with fixed memory capacity, this is 16 bits area or 2 bytes. This is the reason for the different addressing of the same variables when we changed the order of declaration. For more explanation see picture 8.

    Picture 8 – Simple representation of DB2
    Picture 8 shows a simple representation of the standard data block DB2. As we said before a standard DB has fixed memory blocks of 16 bits, so, when we declare Variable_1 to be of data type BOOL, this Variable will occupy the whole 16 bits even though it only needs a 1-bit memory. That is why you see the rest of the area marked red because it is not used but can no longer be used. So it is a lost memory.
    With Variable_2 the data type INT needs 16 bits, so it is using 2 whole bytes. Same with Variable_4 which is of data type WORD.
    With Variable_3 we occupied 4 bytes because it is of data type REAL. This is why the offset for DB2 is 0.0, 2.0, 4.0, and 8.0 respectively.
    The same concept is executed for DB3 and DB4. But because the data type order of the variables is different the memory representation will be different and hence the offset will be different. See pictures 9 and 10 for DB3 and DB4. See if you can understand the representation based on the previous explanation.

    Picture 9 – Memory representation of DB3

    Picture 10 – Memory representation of DB4
    So, when you work with a standard DB you have to be careful when declaring your variables, knowing that there would be a loss of memory each time you define a new BOOL variable.
    If you declare the new variable at the end of your DB list, the offset will extend to include your new variable. But if you declare the new variable between your old or at the start of the DB something else will happen. See picture 11.

    Picture 11 – Declare a new variable
    The first thing you will notice is that your offset is now lost, and you have to compile your code to re-establish the new offset. See picture 12.

    Picture 12 – Re-establish your offset by recompiling your code
    Did you notice how the addressing of the Variables (OFFSET) has now changed?
    For example, the offset of the REAL tag was 2.0 but after we added the new TestVariable the addressing of the same REAL tag (OFFSET) is now 4.0, see picture 13.

    Picture 13 – Offset change after adding TestVariable
    So, when adding a new variable the addressing of all old variables was changed. That means any instruction in your program that need to write of read the value of a certain variable will now be looking at the assigned address in the instruction but now the address has different data than expected.
    So simply put, your whole logic is now messed up. That will lead to a lot of trouble. Not to mention now you have extra lost memory after you added the new variable.  See picture 14.

    Picture 14 – Add a MOVE instruction
    Let’s add a MOVE instruction to move a value of 1 into the Variable_2 tag. See how the address of the MOVE output is %DB2.DBW2.
    Now, let’s add a new variable of type INT to DB2. See picture 15.

    Picture 15 – Add new INT variable
    When you add the new variable, the offset is lost and the PLC no longer knows where the destination of the OUT1 of the MOVE instruction is.
    We need to compile the program to reload the new offset. See picture 16.

    Picture 16 –  New address of OUT1
    Do you see how the OUT1 address is now different? It is now %DB2.DBW4 instead of %DB2.DBW2. This is a very big disadvantage of using standard data blocks.
    What are Optimized DBs?
    The difference between optimized data blocks and standard data blocks is that variables inside an optimized data block are not assigned to a fixed address, but rather a symbolic name is given for the variables, plus the structure of the data block is not fixed as the standard data blocks, so there is no memory loss and no change in the addresses when declaring new tags. See picture 17.

    Picture 17 – Declaring new tag in optimized blocks
    So, declaring new tags in optimized data blocks will not affect the rest of the tags, as they are defined by symbolic names rather than absolute addressing.
    An optimized data block will not allow you to use addresses when working with the tags defined inside of it. See picture 18.

    Picture 18 – Absolute addressing with optimized blocks
    As you see in the last picture, absolute addressing is not allowed with an optimized data block and only symbolic names are allowed. See picture 19.

    Picture 19 – Using symbolic names with optimized DBs
    Advantages of Data blocks with Optimized Access
    Data blocks with optimized access have no fixed defined structure. The data elements (tags) are assigned only a symbolic name and no fixed address within the block is used.
    The elements are saved automatically in the available memory area of the block so that there are no gaps in the memory. This makes for optimal use of the memory capacity and avoids lost memory compared to standard DBs.
    This provides the following advantages:
    You can create data blocks with any structure without paying attention to the physical arrangement of the individual tags. Quick access to the optimized data is always available because the data storage is optimized and managed by the system. Access errors, as with indirect addressing or from the HMI, for example, are not possible. Because there are now addresses, just unique symbolic names for each tag. You can define specific individual tags as retentive. In standard DBs you can only define the whole block as retentive. Conclusion
    Optimized data blocks have a lot of advantages compared to standard DBs. Using symbolic names helps avoid any address changes of tags when adding new variables to your block.
    With optimized blocks, no memory area is lost. Opposite of what happens when using standard DBs.

    leikang
    In a previous article, we discussed what an organization block is, and we talked about one very important organization block, which is the main OB1.
    In this article, we will continue discussing the different OBs and this time we are talking about the time of day interrupt organization blocks or OB10.
    Contents:
    What is time of day Interrupt OB10? How to create and use OB10? Simple program example. Important Rules for the time of day interrupts. Conclusions. What is a Time of Day Interrupt (OB10)?
    As the name suggests, a time of day interrupt is an organization block that will interrupt the execution of the main cycle of your PLC program at a certain time of the day. This interrupt time (date and time) can be specified to occur once at a specified time or to occur periodically at specified time intervals, for example, every minute, hour, day, week, and some other options.
    You can have more than one time-of-day interrupt in the same program, they don’t have to have the same logic or code, each one can have its own functionality and also each one can be configured separately to occur at a specified time.
    How to Create and Use OB10?
    To create a time of day interrupt you follow the same steps you would do if you need to add any new block into your logic. See picture 1.

    Picture 1 – Add a time of day interrupt
    Press the Add new block option in the project tree on the left, choose organization block, and then choose a time of day interrupt as shown in the previous picture.
    Now you can open the OB10 and add whatever PLC logic you want to execute when this block is called, by called we mean that the interrupt event or time has occurred and so the operating system will interrupt the main cycle and execute the OB10.
    We will write a very simple code into the OB10 to help us better understand how this OB10 block works. In this logic, we used add instruction to add a value of 1 to a memory area that we called TimeOfDayInterruptCounter and then put the result of the summation back in the same area. That way we can have a counter for the execution of the OB10.
    Each time the OB10 will be called and executed, the value of TimeOfDayInterruptCounter will increase by 1. See picture 2.

    Picture 2 – Add your logic to the OB10
    Now that we have created the OB10 and written some logic inside, we need to configure the set time of the OB10 and how many times we want it to interrupt our main cycle.
    To configure the time and interval setting of the OB10 we need to go to the properties page of the OB10. See picture 3.

    Picture 3 – Properties of OB10
    In the properties of the OB10, you will find a lot of settings and attributes that you can configure.
    What we need now is the time of day interrupt page so we can set up when the OB10 will be called and how many times. See picture 4.

    Picture 4 – Time of day interrupt setting
    As you see from the last picture, you can set the execution of OB10, the start date, and the time of day at which the OB10 should be executed.
    For the sake of simulation, we made the execution interval to be every minute so that every minute the OB10 will be called and executed. That means starting from the date of 3/23/2023 and time 09:25 AM the value of TimeOfDayInterruptCounter will increase by 1 every minute.
    You have the option of setting the time according to the PLC system time or local time as you see from the last picture. In a previous article, we talked about the system and local time of the PLC, what each time mean, and how to configure and use them.
    As we said before the local time is the time you see now on your PC.  So it is the actual time of the region where the PLC will be used.
    You have to configure the local time for the PLC, depending on where it will be used. See picture 5.

    Picture 5 – Setting the local time for the PLC
    Simple PLC Program Example
    We added a time of day interrupt OB10 to our PLC program and we have set it so it will be executed every minute. We also have configured the local time of the PLC.
    We created a simple logic of an ADD instruction to accumulate the value of the TimeOfDayInterruptCounter by 1 each time the OB10 is executed.
    We will add another instruction, but in the main OB1, this instruction is RD_LOC_T or read local time, so we can see how the local time is progressing and compare it with the execution of OB10. See picture 6.

    Picture 6 – Simple program example
    Compile your PLC program and start a new simulation.
    Notice that we will set the time of day interrupt occurrence so that the OB10 can be called and executed while we are simulation the PLC logic. See the following simulation.

    As you see from the animation, the value of TimeOfDayInterruptCounter is zero at the start and then it will be increased by 1 every minute starting from time 09:25 AM indicating that the OB10 is being executed every minute.
    Important Rules for the Time of Day Interrupts
    If you set a time interrupt in such a way that the corresponding OB is to be processed once, the start time must not be in the past (relative to the real-time clock of the CPU). If you set a time interrupt in such a way that the corresponding OB is to be processed periodically, but the start time is in the past, then the time interrupt OB is processed the next time it is due according to the current time. The date of periodic time interrupts must correspond to a real date. For example, the monthly repetition of a time interrupt OB with a start date of 1/31 is therefore not possible. In this case, an OB is only started in the months that have 31 days. A time interrupt activated during startup is not executed until the startup has been completed. A startup deletes all time interrupts that were set and activated by an instruction in the user program. Conclusion
    OB10 is an organization block that can be configured to interrupt the cycle of your program at a certain day and time. This interrupt can either occur once or periodically every certain amount of time.
    No specific reason why would you need an OB10, as it depends on your process and your logic. And yes, you can achieve the same functionality using your personal code, but it is an available and easy-to-use built-in function. And you know how to use it.

    leikang
    In previous articles, we discussed what an organization block is, and we talked about the main cyclic interrupt OB1 and the time of day interrupt OB10.
    In this article, we will continue discussing the different OBs, and this time we are talking about the Time Delay Interrupt organization block or OB20.
    Contents:
    What is OB20? How to call OB20? Parameters of SRT_DINT instruction. Example Program. Conclusion. What is Time Delay Interrupt (OB20)?
    OB20 is an organization block that is called and executed by the operating system, but we have to tell the operating system when to call this OB20.
    The operating system gets the information from the user PLC program to call this OB20, it will wait for the delay time configured then it will call and execute whatever logic is inside the OB20.
    We create an OB20 block from Add a new block in the project tree. See picture 1.

    Picture 1 – Create a new OB20 block
    Now that I have created a time delay interrupt, when will it be executed? And how to configure the time delay of the block execution?
     Again, OB20 is an organization block, which means you don’t call the block to be executed, but you tell the operating system when it can call it and execute whatever functionality is written inside.
    How to Tell the Operating System to Call the OB20?
    To tell the operating system that we want to call the OB20, we use the SRT_DINT or start time delay interrupt, see picture 2.

    Picture 2 – Start time delay instruction
    Parameters of SRT_DINT instruction
    As you see from the last picture, you can use the SRT_DINT instruction to call the OB20. but you need to configure some parameters, for the instruction to work.
    EN: the instruction will not be executed until a negative edge signal is presented at the EN input. That means you have to assign a condition of the set of conditions to enable signal and the instruction will only work when this condition is true then false again.
    OB_NR: you assign the number of the delay interrupt that you need to call, in our case 20 as we created OB20, but we can create more than one delay interrupt and then we will have to call each one with a separate SRT_DINT instruction.
    DTIME: that is the delay time you want to wait before executing the OB20, we will set this time to 5 seconds for the sake of simulation.
    SIGN: Identifier that appears when the time-delay interrupt OB is called in the start event information of the OB.
    Example PLC Program
    To better understand the OB20, we will create a simple logic to see how an OB20 can be called and executed. We will build this PLC example on the previous logic we made for the OB1 and OB10 in previous articles.
    Inside the OB20 we will create a logic that counts how many OB1 cycles have been called and executed within the 5 seconds delay time that we have configured for the OB20. See picture 3.

    Picture 3 – Logic inside OB20
    In the last picture, you see that we used MOVE instruction to push information on cycle counts at the start of the OB20 call and after it has been executed.
    See picture 4 for the rest of the logic.

    Picture 4 – Calculate how many cycles count inside 5 sec
    After that, we will subtract the two values of cycle counts to get how many cycles have been executed within the five seconds delay.
    Now that we have created the logic we want, how can we call the OB20? As explained before we have to use the SRT_DINT instruction. We will use this instruction inside the OB10 which we have configured before to be executed every minute. That means the OB20 will also be called and executed every minute but with a delay time of 5 seconds.
    In the previous article we built a logic that calls how many times the OB1 is being called and executed, we also built another logic that will call the OB10 every minute.
    In this example, we will use the call of the OB10 to call the OB20. See picture 5.

    Picture 5 – Calling the OB20 through OB10
    We said before that the SRT_DINT needs a negative edge signal at the EN for the call to start. That is why we used the TimeOfDayInterruptEnabled signal which we know it will be true when OB10 is executed and then go back to false giving us the edge signal we need.
    Now that all PLC logic is complete, let’s compile and run a new simulation. See the following simulation of our project.

    You see in the animation at first the values of cycle counts are zeros but when the OB10 is called and the TimeOfDayInterruptEnabled is true logic will wait 5 seconds then the count values will be updated with cycle counts.
    Conclusion
    OB20 is an organization block called and executed by the operating system. We can tell the operating system to call the OB20 with the SRT_DINT instruction.

    leikang
    In previous articles, we discussed different types of organization blocks, like the main OB1 which is the main cyclic program block, in this article we will take about another cyclic organization block. The OB30 or cyclic interrupt OB.
    Contents:
    What is cyclic interrupt OB30? What is the main OB1 cycle? Why do I need OB30? How to configure cyclic interrupts? What if I have more than one cyclic Interrupt? Conclusion. What is Cyclic Interrupt OB30?
    A cyclic interrupt OB30 is an organization block that gets called and executed at specified and exact time intervals, unlike the main cyclic OB1 which is continuously called and executed the cyclic interrupt will be called at time intervals which you should configure when creating a cyclic interrupt OB.
    For example, if I created an OB30 with a time interval _also called cycle time_ of 20ms, that means the operating system will interrupt the main cycle OB1 and calls the OB30 each 20ms.
    You have to make sure that the runtime of a cyclic interrupt OB must be smaller than its time interval. Otherwise, it could still happen that the next call of the OB30 will arrive while this call of the OB30 is still being executed. In this case, the operating system generates a time error that might lead to PLC going to STOP mode.
    What is the Main Cycle OB1?
    The main cyclic OB1 is the organization block which is responsible for cyclically executing your logic by the PLC. Whenever you create a new project and add a PLC, the Main OB1 will be automatically created by the software.
    The essential basis of your PLC code is the cyclic behavior, meaning you need your code to be executed continuously. When the processing of your logic has been completed, the operating system starts processing it again. That is done through the use of the main OB1, you put and call all of your logic and code inside this OB1 and the operating system will make sure to continuously execute it.
    Main OB1 cycle time refers to the runtime of the cyclic program, including the runtime of all nested program parts like FCs, FBs, and higher-priority OBs. If you have created several program cycle OBs, each program cycle OB contributes to the cycle time.
    The operating system monitors whether the cycle time remains smaller than the configured maximum cycle time. If it exceeds the maximum cycle time, PLC will either go to STOP mode or call OB80 depending on your programming.
    Why do I need OB30?
    Someone could argue that I can put whatever functionality inside the OB30 in the main OB1 and try to get away with it depending on the very fast performance of most PLCs nowadays. This can be OK sometimes, but not every time.
    Depending on the performance of your PLC, the main cycle time could be something between 1 to 150ms; it can be different but this is the standard configuration, this cycle time depends on so many factors, like the size of your PLC program, and interrupts inside your logic and other factors that will most likely make the run time of your cycle not stable.
    Now, if you need to do certain functionality exactly each 10ms, not 9ms and not 11ms. Now you can’t depend on the main OB1, as the result might not be as desired. In this case, you use the cyclic interrupt OB30, you configure it to the 10ms you want and the operating system will make sure to call and execute this function every 10ms exactly. That is why it is called interrupt; because it will interrupt the execution of the main OB1 to call and execute your OB30.
    Examples of Functionality that Needs OB30
    PID controller processing. Safety circuits monitoring. Monitoring communication between machines. All previous examples have the need to continuously monitor and check your parameters at certain times, as they relate to real physical quantities or to machine safety. The execution of such functions shouldn’t be delayed as they affect the safety and continuity of your process.
     How to Configure Cyclic Interrupts?
    When you create a cyclic interrupt, there are some parameters you need to configure. See picture 1 for adding a new OB30.

    Picture 1 – Add new cyclic interrupt OB30
    When creating a cyclic interrupt, you can find many parameters you can set in the properties of the block see picture 2.

    Picture 2 – Properties of OB30
    The most important parameters that you need to consider are as follows:
    Cycle time Use the parameter “Cycle time” to set the period of time between two calls of the cyclic interrupt OB. It is an integer multiple of 1 µs.
    Phase offset Here, you set the time period by which the start times are shifted as compared to the multiple of the cycle time.
    See picture 3 for cycle time and phase offset configuration.

    Picture 3 – Setting the cycle time and offset of OB30
    Priority of the cyclic interrupt OB This is another important parameter you have to consider when configuring a cyclic interrupt, as you might have more than one cyclic block, if in case two different OBs need to be called at the same time, the operating system will call and execute the block with a higher priority number.
    You should know that the PLC main program cycle OB1 has priority number 1 which is the lowest priority level a block can have. That is why OB1 can be interrupted by any other block call. See picture 4.

    Picture 4 – Setting the priority of OB30
    What if I have more than one Cyclic Interrupt?
    It is not uncommon that you would have more than one cyclic interrupt in your logic. If you have two PID controllers in your PLC logic then you might need two cyclic interrupts to handle each PID. In that case, you need to make sure that the calling and execution of different cyclic interrupts will not be overlapped.
    For example, if you have OB30 with an interval cycle time of 5ms and OB31 with a cycle interval of 10ms, that means the second call of the OB30 will also be the time for calling OB31. This might lead to logic errors, even if you set the priority of one of them to be higher than the other, it will mess up your cycle time for the lower priority block. See picture 5.

    Picture 5 – Overlapping of calling different cyclic interrupts
    In that case, a phase offset may be advisable when you are using multiple cyclic interrupt OBs.
    If their cycle times have common multiples, you can use a phase offset to prevent simultaneous start times. See picture 6.

    Picture 6 – Offset between different OB calls
    So, to avoid this overlapping, we will set the offset time of OB31 to be 1 ms.
    That means the counting for the OB31 time interval will be offset by 1ms than the starting time of OB30. See picture 7.

    Picture 7 – Offset setting of OB31
    Conclusion
    Cyclic interrupts are very useful for time-critical tasks that shouldn’t face any delays. You can have more than one cyclic interrupt in your logic. Use the offset setting of the cyclic interrupts to avoid simultaneous start times. Use priority setting to control the order of executing different cyclic interrupts.

    leigehong
    In previous articles we started discussing different Organization blocks of TIA Portal PLCs, we talked about what OBs are, and we discussed some of the OBs like OB1- Main cyclic, OB10, and OB20 the time of day delay and time delay interrupts respectively. In this article, we will talk about the OB100 or the startup organization block in Siemens Tia Portal.
    Contents:
    What is OB100? Why need OB100? Important notes during startup. Simple program example. What is Start-up Organization Block (OB100)?
    OB100 or the startup OB is an organization block that is called and executed by the operating system once at the startup of the PLC, meaning once each transition from STOP to RUN mode.
    The main cycle OB1 will not be called and executed until all startup functions inside OB100 are executed.
    You can have more than one start-up OB in your PLC logic if that happens then the operating system will call and execute all of them one by one starting from a lower OB number to a higher number. I.e. if you have OB100 and OB123, then OB100 will be called and executed first then OB123.
    After the OB100 is executed the operating system will read the input modules into the PII and starts the main cycle program OB1.
    Why need OB100?
    You use OB100 for a lot of tasks that you might want or need to perform before you start your cyclic logic, for these reasons are:
    Initialize variables. Reset system modules. Recalibrate sensors/actuators. Check for alarms and safety conditions before starting your process. Even if you haven’t created a startup OB for your logic, the operating system still has many tasks that it needs to execute before starting your main logic, some of these tasks are:
    Clear non-retentive memories Clear the PIQ Call and execute startup OBs, if any. Update PII Enable outputs after changing to RUN mode. Did you notice that the last task of a startup routine is to enable the outputs? That is why the first step of executing the main cycle program OB1 is to write the PIQ into the output module.
    Important Notes during Start-Up
    Note the following points regarding the “STARTUP” mode:
    The outputs on the modules are disabled. The process image is initialized. The process image is not updated. In order to read the current state from inputs during “STARTUP”, you can access inputs via direct I/O access. In order to initialize outputs during STARTUP, values can be written via the process image or via direct I/O access. The values are output at the outputs during the transition to the “RUN” mode. The non-retentive bit memories, timers, and counters are initialized. The non-retentive tags in data blocks are initialized. During startup, no cycle time monitoring is running yet. Simple Program Example
    In this example, we will add a start-up OB100 to our PLC logic and see how many times the OB100 is executed. See picture 1 for adding a new OB100.

    Picture 1 – Add an OB100
    As you see from the last picture, you add startup organization blocks the same way we add a function of a function block.
    Inside the OB100 we just created we will add a simple ADD instruction, to accumulate how many times the OB100 is called and executed. See picture 2.

    Picture 2 – Accumulate execution times of OB100
    Now, compile and run your program and see what will happen. See the following animation for a simulation of the PLC program.

    Animation 1
    As you can see from the above animation, the OB100CycleCounter is 1 and it doesn’t change when the PLC mode transitions from STOP to RUN.
    Well, it does change but you don’t see this change. Each time the PLC goes into STOP mode and then to RUN mode again. The counter will be reset to zero and then to 1 again after the OB100 is executed. You can also see the main OB1 cycle counter changing, and the PLC stops and then runs again the OB1CycleCounter will start accumulating again.
    To see the change in the startup counter, we need to retain the value of the tag memory. See picture 3.

    Picture 3 – Retain the OB100CycleCounter tag memory
    After we retain the OB100CycleCounter tag, now run the PLC simulation again and see what will happen. See simulation animation 2.

    Animation 2
    You see now from the above animation, that the startup counter increases each time I stop the PLC and then start it again. As the tag memory is now retained, the value will not be reset to zero, and that is why you see the value of the OB100CycleCounter accumulates.
    Now, I need to add extra functionality to my startup PLC logic, which is to know when the last startup of the PLC was. We will achieve that through a simple logic where I read the local time of the PLC at startup and move the date and time to a certain memory area. See picture 4.

    Picture 4 – Reading local time at start-up
    After you add your logic, compile and run the simulation again. See the PLC simulation animation 3.

    Animation 3
    You can see from the above animation, that each time the PLC starts the startup date and time will be recorded in the memory area we assigned. So now I have the information regarding how many times my PLC started and when was the last start-up time.
    Conclusion
    Startup OBs are very important if you want to evaluate some functionality before you can run your cyclic process. You can use start-up OBs to initialize parameters, calibrate sensors and even check for safety conditions before allowing your process to run.

    leikang
    In this article, we continue our discussion about different types of organization blocks in Siemens PLC. This time we will take about the OB121 or the programming errors interrupt in the Tia portal.
    Contents:
    What are programming errors interrupt OB121? Examples of programming errors. What will happen if a programming error is detected? Simulating a programming error in TIA Portal. How can the OB121 be useful against programming errors? Conclusions. What are Programming Errors Interrupt (OB121)?
    OB121 is an organization block that will get called by the PLC’s operating system if a programming error occurs while running your logic. Note that we are not talking about a programming error that will be caught by the compiler when trying to download your logic into your PLC. See picture 1.

    Picture 1 – Some programming errors will get caught by the compiler
    As you see from the last picture, there is a programming error in my PLC logic; some operands are missing in the input and output of Network 1. But, this error was caught by the compiler before even downloading the logic into the PLC. The error in picture 1 is not the programming error type that can trigger the need to call OB121.
    Errors in your PLC program that can’t be found by the compiler, but still can cause troubles in your logic while PLC is running are the programming errors we mean. These errors will trigger a call to the OB121 by the operating system.
    Examples of Programming Errors
    Here are some examples of mistakes in your PLC logic that can cause programming errors:
    Maximum nesting depth of block calls exceeded. You have used a NULL pointer to address an operand. Unknown instruction. The addressed string has incorrect length information. Area length error when reading. Area length error when writing. Error in timer no. Access to a DB that is not loaded; the DB number is located in the permitted area. DB does not exist. These errors and many more can cause programming errors in your PLC. You can check the Help section of the TIA Portal to find out what other reasons can cause PLC programming errors.
    What will happen if a Programming Error is Detected?
    When your PLC detects a programming error, one of three events can occur.
    Your PLC will show an error and go to STOP mode. Your PLC will show an error but keep running your logic. Your PLC will show an error then try to solve this error. These three events will depend basically on your PLC programming. Meaning your code will decide how the operating system will behave when detecting a programming error.
     Simulating a programming error in TIA Portal
    To better understand how the PLC will behave, we will create a simple program where we cause a programming error, and then we will see what will happen. See picture 2.

    Picture 2 – Simple program logic
    The logic we created is very simple, when the InitiateProgError has been enabled the value of 126 will be moved into DB52.DBW16 area. Note that we haven’t created DB52. so, that will be our programming error. Note that this error will not be caught during compiling or downloading into the PLC. See pictures 3 and 4.

    Picture 3 – Error not caught by the compiler
    See how the block was successfully compiled, while including a programming error.

    Picture 4 – Block downloaded into PLC
    Again, the block was downloaded into PLC with a programming error.
    Now, let’s simulate our PLC program and see what will happen. See animation 1 for the simulation of the PLC code.

    Animation 1
    As you see from the above animation, the PLC ERROR LED will flash red for a few seconds then the PLC will go into STOP mode.
    Go to PLC online diagnostics to see what happened. See picture 5.

    Picture 5 – Online and diagnostics of the PLC
    What you saw in the animation is exactly what you see in the previous picture. They can be mentioned into 3 steps:
    The PLC detects the programming error which is OB52 not loaded. The operating system will trigger the call for the OB121, but there is no OB121 created in our logic. When the PLC finds out that there is no OB121 created in our logic, the operating system will initiate a request STOP. And the PLC will go into STOP mode. How can the OB121 be useful against Programming Errors?
    Let’s add an OB121 to our PLC code and see how things will change. See picture 6.

    Picture 6 – Adding an OB121
    After creating and adding the OB121 into our PLC logic, let’s see what will happen in the simulation.
    Keep in mind that we haven’t written any PLC logic inside the OB121. See animation 2.

    Animation 2
    As you see from animation 2, when InitiateProgError is triggered, the PLC ERROR led will flash red but the PLC will keep running.
    Meaning that the PLC will not go into STOP mode. Let’s check the online diagnostics to see what actually happened. See picture 7.

    Picture 7 – Error didn’t cause PLC stop
    You see from the picture that the PLC detects the error but doesn’t go into STOP mode. It will skip this error, continue the cycle and start all over again from the beginning.
    When it arrives at the error again, it will detect the error again, giving an alarm in the diagnostics. Skip the error and continue. That means the PLC will give the same alarm every scan cycle. And that is why in the picture you see the event keeps triggered and the alarm is repeating each scan cycle.
    So, just having an empty OB121 will give you the benefit of keeping the PLC running and y extension, keeping your process running.
    But, there is more we can do, we can try to catch this error and eliminate it. Also, we can try to show the type of programming error detected.
    Determine the Error Type
    The OB121 has an internal fault ID identifier that we can use to show the type of fault, maybe as an alarm on an HMI. Inside the OB121 we will create a simple MOVE instruction, where we will push the Fault_ID input of the OB121 to a defined memory area inside our global DB. See picture 8.

    Picture 8 – Identifying the error type
    As you see from the previous picture, when the programming error occurs, the Fault_ID will be pushed into the Data.ProgErrorID. See picture 9.

    Picture 9 – Programming Error Fault_ID
    You can see the fault ID is 3A. if you check the TIA Portal help you can find the meaning of this fault. 
    3A: Access to a DB that is not loaded; the DB number is located in the permitted area.
    Catching the Error
    This simply means, trying to solve the PLC programming error after you have identified the reason. This will depend mainly on what is the error and how you want to handle it. We will just simulate a solution to the error, to see how the PLC will behave.
    The actual solution for the error we created will be to just create the DB52 or use a data block that is already created.
    But for the sake of simulation, we will just add a simple contact that will open when the programming error occurs to catch this error. See pictures 10 and 11.

    Picture 10 – Catching the error
    Whenever OB121 is called, the CatchError will be set.

    Picture 11 – Eliminate the error
    Whenever OB121 is called, the CatchError will be set, and it will be used to catch the programming error in Network 1. See animation 3 for the PLC simulation.

    Animation 3
    From the above animation, you can see that when the InitiateProgError is triggered, the PLC will go into error for a moment then the error will be cleared and the PLC is in RUN mode all the time.
    Conclusion
    Just having an empty OB121 in your logic will ensure that your PLC will not go into STOP mode if there was a programming error in your code. You can later use the OB121 to also identify the error and solve it.

    leigehong
    This article is about a T-junction traffic control system with the help of a PLC ladder logic using a comparator for lights operation.
    T-Junction Traffic Control System
    The function of the T-junction traffic control system consists of three groups of segments. By the logic of comparator operation, we control the Traffic lights system.

    First segment: In the first segment, lane 1 traffic is allowed and lane 2 and lane 3 are stopped. Here in this segment, the green light (Green 1) of lane 1 glows, and red lights (Red 2) of lane 2 and (Red 3) of lane 3 glow. This period continues for fifteen seconds.
    Second segment: In the second segment, lane 2 traffic is allowed and lane 1 and lane 3 are stopped. Here in this segment, the green light (Green 2) of Lane 2 glows, and the red lights (Red 1) of Lane 1 and (Red 3) of Lane 3 glows. This period continues for fifteen seconds.
    Third segment: In the third segment, lane 3 traffic is allowed and lane 1 and lane 2 are stopped. Here in this segment, the green light (Green 3) of Lane 3 glows, and the red lights (Red 1) of Lane 1 and (Red 2) of Lane 2 glow. This period continues for fifteen seconds.
    After the execution of all three segments, the sequence of operations again starts and repeats continuously.
    Description of Inputs and Outputs
    In this PLC project, we used 2 Inputs, 6 Outputs, 2 Memory, and 1 On Delay Timer.
    S.No Symbol Description 1 I 0.0 START 2 I 0.1 STOP 3 M 0.0 MEMORY 4 M 0.1 MEMORY 1 5 Q 0.0 GREEN 1 6 Q 0.1 RED 1 7 Q 0.2 GREEN 2 8 Q 0.3 RED 2 9 Q 0.4 GREEN 3 10 Q 0.5 RED 3 11 DB1 ON DELAY TIMER PLC Programming and its Explanation
    1. When the START (I 0.0) Button is pressed, MEMORY (M 0.0) is energized. This M 0.0 is the main memory used to execute all the processes in the program. Since it is latched, it will be in energized state only. If  STOP ( I 0.1) is pressed whole process will get stopped at any time.

    2. Once MEMORY is energized, it will switch on the TIMER DB1 which controls the timing of the Traffic Junction. In this timer, we set the Pre-set time of 45 seconds. Once the timer achieves the pre-set time which energizes the MEMORY 1 (M 0.1) and this M 0.1 also resets the timer as per the logic and runs the cycle continuously.
    3. Next, the comparator plays a major role in controlling the traffic junction. Firstly, the Output GREEN 1 (Q 0.0) is turned on as per the logic. Here we used Less than or Equal to the comparator. In this logic, Q0.0 will be in the ON state from 0 seconds to 15 seconds. After that, it will be going to OFF state
    4. Next for output RED 1 (Q0.1), we used Greater than or Equal to function. Q0.1 will be in the ON state from 15 seconds to 45 seconds. It will be in the OFF state when Q0.0 is in the ON state.
    5. Then for output GREEN 2 (Q0.2), we used both Less than or Equal to and Greater than or Equal to for this output. Both the comparator functions were connected in series logic connection with the output. In this Q0.2 will be in the ON state from 16 seconds to 30 seconds as per the condition.
    6. Next for output RED 2 (Q0.3), we also used both Less than or Equal to and Greater than or Equal to function for performing the operation. Comparators were connected in parallel connection with the output. This output will be in the ON state from 0 seconds to 15 seconds and 30 seconds to 45 seconds. In between 15 seconds, it will be in the OFF state only since at that time Q0.2 is in the ON state.
    7. Then for the last GREEN 3 output (Q0.4), we used Greater than or Equal to function. As per the conditional logic, it will be in an ON state from 30 seconds to 45 seconds. Before this timing, it will be in an OFF state.
    8. Finally, the RED 3 output (Q0.5). Here we used Less than or Equal to function for executing the PLC logic. It will be in the ON state from 0 seconds to 30 seconds after that it will be in the OFF state.
    Conclusion
    So, in this way, the given T-Junction Traffic control is executed by the comparator function with the PLC logic. We can control the traffic logic with the help of PLC logic in many ways & this is also one of the ways in that.

    leikang
    When you are working with PLC, you need to know what types of voltages are generally available in it; so that you can do the wiring accordingly. Not just power supply, but we must also be related to the input and output voltage required.
    Every PLC manufacturer has their own set of voltage and current ranges according to the module and CPU they provide. In this article, we will learn the PLC operating voltages generally available everywhere.
    PLC Power Supply
    In standard, PLC operates in four types of voltages – 24V DC, 24V AC, 110V AC, and 240V AC. In some PLCs, only the CPU requires a power supply and the IO modules get supply from the CPU backplane, whereas in some PLCs, all the modules including CPU, inputs, and outputs require a power supply.

    In any case, you will require a SMPS or transformer in the PLC panel, for converting raw power voltage. In AC supply voltage, some PLC’s offer a range of voltage from 110-240V AC.
    Every power supply point in the PLC has an earthing point, for providing safety to the PLC in case of any surge or short circuit. When an AC supply is used, it is mostly equipped with a protective fuse inside.
    DC supply too has a fuse inside, but for AC supply, it is compulsory to use it for the high amount of voltage involved. When the rated voltage is given in the CPU, it means that the voltage you are providing has been stabilized properly and controlled to a great extent.
    But, it is not practical for voltage to remain constant at 24V or 240V. So, a range of rated voltage comes for a PLC like 20-28V DC or 220V-245V AC. This range is predefined in every PLC so that you get an area of power supply for working with them efficiently, without any problem.
    Power Supply for IO Modules
    Now, let us come to our next topic for the power supply required for IO modules. As discussed earlier, two types of power supplies are available – one where the module is powered by the CPU backplane itself and one where the module requires an external power supply.
    When using the backplane, every CPU has a rating for mA that it will provide as a load to the modules connected.
    For example, if a CPU has a rating of 24VDC – 450mA, then it will also specify that the CPU backplane can provide this much of current to the IO modules and you can connect only that amount of modules with the CPU rack.
    Also, each module will specify how much current it will take when connected on a backplane bus. This can help you select the appropriate modules and CPU for a specific application.
    Coming to the second type of power supply, there are some modules that require an external power supply. So, in that case, you have to choose an SMPS or transformer with a higher current and load rating accordingly. This can, in turn, power up both the CPU and modules properly and also power up other components of the panel which require the same supply.
    Power Supply for Field Instruments
    Field wiring for a PLC also mostly requires DC voltage for instruments and AC voltage for high-power devices. So, the above four voltages mentioned earlier work the same for IO module common supply wiring.
    Also, remember that there is mostly a battery backup inside the PLC apart from the standard power supply. This ensures that the program inside the memory of the PLC remains intact in case of any power outage.
    Power Supply Selection for PLC
    When selecting the power supply, it is thus necessary to consider the following parameters generally – rated voltage, rated current, rated power, ripple and noise, voltage adjustable range, voltage tolerance, line regulation, and load regulation.
    Once you have selected the right power supply, you can then wire the CPU and modules to power it up properly.  
    In this way, we understand the concept of PLC operating voltages.

    leikang
    Programmable logic controllers (PLC) and programmable automation controllers (PAC) are two types of industrial controllers used to automate processes and machines in manufacturing, processing, and other industrial applications. Both types of controllers have similar functions, but there are also significant differences between them.
    In this article, we will take about the differences, similarities, and examples of PLC and PAC.
    Contents:
    What are PLCs? What are PACs? Similarities between PLC and PAC. Differences between PLC and PAC. Examples of PLC models from various vendors. Examples of PAC models from various vendors. When is a PLC best fit? And when is a PAC? Conclusion What is a PLC?
    PLC stands for Programmable Logic Controller, which is a specialized industrial computer used for automation control systems. PLC is designed to operate in harsh environments and are used to control machinery in manufacturing plants, assembly lines, and other industrial settings.
    PLC can be programmed using 5 different languages such as ladder logic, function block diagrams, structure text, instruction list, and sequential charts. These 5 languages are approved and applied as per the IEC 61131-3 standards.
    What is a PAC?
    PAC stands for Programmable Automation Controller, which is similar to a PLC but has more advanced functionality. PAC combines the capabilities of a traditional PLC with the ability to perform much more complicated tasks and communicate with other devices and systems, making them more flexible and powerful than PLC.
    PAC is typically used for more complex automation and control applications in industries such as automotive, aerospace, and power generation. PAC can be programmed using the same 5 languages as PLC but also they can be programmed using C and C++, giving them the ability to handle coding more complex algorithms.
    Similarities between PLC and PAC
    The similarities between PLC are PAC are too many that it is difficult sometimes to tell if they are even different. Although there is still some difference between them.
    The similarities they share can be even more. Here are some of the common points between PLC and PAC:
    Core Functionality
    Both PLC and PAC are designed to provide reliable and accurate control of industrial automation systems. They are used to monitor inputs from sensors and other devices, process the information, and then output control signals to actuators and other equipment.
    Programming
    Both PLC and PAC use programming languages to create control logic that determines the behavior of the automation system. They share the 5 programming languages defined in the IEC 61131-3 standards, but PAC offer more programming language options including C and C++.
    Durability
    Both PLC and PAC are built to withstand harsh industrial environments, such as temperature extremes, humidity, and vibration. They are designed to be rugged and reliable, with long lifetimes and lower maintenance requirements.
    Modular Design
    Both PLC and PAC have a modular design, which allows for easy expansion and customization. Modules can be added or removed to meet specific requirements.
    Industry Standards
    Both PLC and PAC are built to meet industry standards for automation and control systems, such as IEC 61131. These standards ensure interoperability between devices and systems from different manufacturers.
    Differences between PLC and PAC
    The distinction between PAC and PLC can be somewhat blurry. While there is no definition of what constitutes a PAC, there are some common characteristics that differentiate PAC from PLC:
    Functionality
    While both PLC and PAC are used for automation and control applications, PAC have more advanced functionality such as motion control, process control, and data acquisition. PAC also typically have more processing power and memory than PLC.
    Connectivity
    PAC have more advanced connectivity options than PLC, including Ethernet, USB, and wireless. This makes it easier to integrate them into larger automation systems and to communicate with other devices and systems.
    Cost
    Because of their more advanced functionality and flexibility, PAC are generally more expensive than PLC.
    More Advanced Features
    PAC often have more advanced software features than PLC, such as integrated motion control, data logging, and advanced diagnostic tools. These features make it easier for engineers and technicians to monitor and troubleshoot the control system.
    Examples of PLC Models from various Vendors
    Siemens S7-1500 PLC:
    This is a high-performance PLC from Siemens, one of the leading automation vendors. It is designed for demanding applications and offers advanced functions such as motion control, safety, and security. See picture 1.

    Picture 1 – SIEMENS S7-1500 PLC
    Allen-Bradley CompactLogix 5370 PLC:
    This is a versatile PLC from Rockwell Automation that offers a wide range of I/O options and communication protocols. It is suitable for a variety of applications, including machine control and process automation. See picture 2.

    Picture 2 – Allen-Bradley CompactLogix 5370 PLC
    Mitsubishi Electric Q Series PLC:
    This is a reliable PLC from Mitsubishi Electric that offers high-speed processing, flexible I/O options, and advanced programming capabilities. It is suitable for a variety of applications, including automotive, food and beverage, and pharmaceuticals. See picture 3.

    Picture 3 – Mitsubishi Electric Q Series PLC
    Omron NJ Series PLC:
    This is a high-speed, high-performance PLC from Omron that offers advanced motion control and network capabilities. It is suitable for a variety of applications, including packaging, printing, and semiconductor manufacturing. See picture 4.

    Picture 4 – Omron NJ Series PLC
    Beckhoff TwinCAT PLC:
    This is a software-based PLC from Beckhoff that runs on a PC-based platform. It offers advanced functions such as motion control, CNC, and robotics, and is suitable for a variety of applications, including machine control and process automation. See picture 5.

    Picture 5 – Beckhoff TwinCAT CX9240 PC-based PLC
    Examples of PAC Models from various Vendors
    Emerson DeltaV DCS PAC:
    This is a distributed control system (DCS) PAC from Emerson. It is designed for complex continuous control applications and offers advanced functions such as process modeling, batch management, and advanced control. See picture 6.

    Picture 6 – Emerson DeltaV DCS PAC
    Schneider Electric Modicon M340 PAC:
    This is a high-performance PAC from Schneider Electric that offers advanced functions such as motion control, safety, and cybersecurity. It is suitable for a variety of applications, including energy, water treatment, and mining. See picture 7.

    Picture 7 – Modicon M340 PAC
    Some other examples of PAC are as follows:
    ABB AC 800M PAC Yokogawa ProSafe-RS PAC Phoenix Contact PLCnext Technology PAC Bosch Rexroth IndraMotion MLC PAC When is a PLC best fit? And when is a PAC?
    PLC and PAC are used in different types of automation applications depending on the specific requirements of that application. Here are some general guidelines on where a PLC is best fit and where a PAC is the best fit:
    PLCs are the best fit at:
    Discrete control applications:
    PLCs are best suited for applications that involve discrete control, such as controlling the operation of a conveyor, sorting equipment, or packaging machinery.
    Simple control systems:
    PLCs are ideal for applications that have a relatively simple control system that can be programmed using ladder logic or other similar programming languages.
    Cost-sensitive applications:
    PLCs are generally less expensive than PACs, which makes them a good choice for applications where cost is a significant factor.
    Small to medium-sized systems:
    PLCs are suitable for small to medium-sized control systems, where the number of inputs and outputs is relatively low.
    A conveyor system in a manufacturing plant is a good example of an automation system where a PLC is the best fit. In this application, the PLC is responsible for controlling the speed and direction of the conveyor, as well as monitoring the status of sensors and other equipment along the conveyor line. The PLC can also be programmed to handle specific production tasks such as sorting, counting, or packing.
    A conveyor system typically has a fixed structure and a well-defined set of operations that need to be executed in a sequential manner. PLC are well-suited for this type of application because they are designed to handle discrete control tasks and are very reliable in their operation. PLC can be easily programmed and configured to handle different types of sensors, actuators, and communication protocols.
    PACs are best fit at:
    Process control applications:
    PAC best suited for applications that involve process control, such as controlling the operation of a chemical plant, water treatment plant, or power plant.
    Complex control systems:
    PAC ideal for applications that have a complex control system that requires advanced algorithms and optimization functions.
    Large-scale systems:
    PAC suitable for large-scale control systems, where the number of inputs and outputs is high and the system is distributed over a large area.
    High-performance applications:
    PAC capable of handling high-performance applications that require fast data processing, real-time control, and high reliability.
    A power plant control system is a good example of an automation system where a PAC is the best fit. In this application, the PAC is responsible for controlling and monitoring a large number of complex processes and equipment, such as turbines, generators, boilers, and pumps. The PAC is also responsible for collecting and analyzing data from various sensors and other sources and making decisions based on that data to optimize the plant’s performance.
    A power plant control system is a very complex and dynamic environment, with many different processes and equipment operating simultaneously. PAC are well-suited for this type of application because they offer advanced functions such as distributed control, redundancy, and fault tolerance, which are essential for ensuring the reliability and safety of the plant. PAC can handle large amounts of data and can be programmed to perform complex algorithms and optimization tasks.
    Conclusion
    PLC and PAC are both used in industrial automation applications. They have different capabilities and are best suited for different types of applications. When selecting between PLC and PAC, it is essential to consider the specific requirements of the application. PLC typically used in discrete control applications that have a relatively simple control system. PAC used in process control applications that have a complex control system and require advanced algorithms and optimization functions.

    caixiaofeng
    S7-1200 PLC is a compact, modular, and cost-effective solution that offers a wide range of features and flexibility for small to mid-sized automation applications. These features include communication options, memory, CPU performance, and IOs configuration. When you have a process that you need to control, you should choose the PLC and configure it to best fit your process requirements.
    In this article, we will discuss the hardware configuration of S7-1200 PLC and we will give an example of how to configure it in the Siemens Tia portal.
    Contents:
    What is the hardware configuration of a PLC? Importance of hardware configuration. Simple project example. How to configure our PLC with the given example? Hardware configuration of CPU. IOs hardware configuration. HMI configuration. Conclusion. What is the hardware configuration of a PLC?
    The hardware configuration refers to the specific components of the PLC, such as the CPU, memory, input/output (I/O) modules, communication ports, power supply, and any additional modules or accessories that may be needed and added to the system.
    The hardware configuration of a PLC also includes enabling or disabling some of the CPU features, depending on the device, its capabilities, and the requirements of your process.
    The hardware configuration steps for a PLC typically involve the following:
    Select the appropriate PLC model based on the application requirements. Identify the input/output requirements for the system, which include the type and number of sensors, actuators, and other devices that will be connected to the PLC. Choose the communication protocol and network topology that will be used to connect the PLC to other devices and systems. Determine the power supply requirements for the PLC and its peripherals. Mount the PLC in an appropriate location and connect all the necessary cables and wires. Configure the PLC software to communicate with the hardware components and set up the appropriate logic and control functions. The specific steps for hardware configuration may vary depending on the PLC model and the application requirements, but these are the basic steps that are typically involved in the process.
    In this article, we will talk about the hardware configuration that is done in the TIA Portal platform. That means we will assume that you know your application and that you have already chosen your PLC model and the Power supply to feed it. You can refer back to previous articles where we discuss how to choose the PLC and power supply that best fits your application.
    Importance of Hardware Configuration in PLC
    Proper hardware configuration ensures the system is reliable and robust. If the hardware components are not configured correctly, they may not work as intended, resulting in system failures or errors
    Hardware configuration affects the performance of the system. By choosing the right hardware components and configuring them appropriately, the system can operate at maximum efficiency and speed and can handle a high volume of inputs and outputs.
    Hardware configuration impacts the scalability and flexibility of the system. The choice of hardware components and their configuration should take into consideration future expansion or modifications to the system, to ensure that the system can easily accommodate changes or upgrades.
    Hardware configuration affects the cost of the system. By selecting the appropriate hardware components and configuration, unnecessary costs can be avoided, and the overall cost of the system can be minimized.
    S7-1200 Hardware Configuration
    We will assume a simple PLC project and see how we can configure the PLC into our project before we start writing our code.
    Temperature Control System for a Reactor using PLC
    The project involves controlling the temperature of a reactor using a PLC. The system should measure the temperature of the reactor and adjust the temperature by controlling the flow of a cooling fluid.
    The project uses four thermocouples to measure the temperature, two solenoid valves to control the flow of the cooling fluid, and a motor to drive the impeller of the reactor.
    I/O Configuration
    Inputs:
    Thermocouples 1 – 4: these are 4 analog inputs that measure the temperature at different locations inside the reactor.
    Emergency Stop Pushbutton: This is a digital input that is used to stop the system in case of an emergency.
    Temperature Set Point Potentiometer: This is an analog input that allows the operator to set the desired temperature setpoint.
    Outputs:
    Solenoid Valve 1 and 2: these are 2 digital outputs that control the flow of the cooling fluid through the reactor pipes.
    Motor Control: This is a digital output that controls the speed and direction of the motor that drives the impeller.
    Heater Control: This is a digital output that controls the heating system of the reactor.
    System Operation:
    The system waits for the operator to set the temperature setpoint using the potentiometer. The PLC reads the temperature setpoint and compares it to the current temperature of the reactor, which is measured by the four thermocouples. If the reactor temperature is below the setpoint, the PLC activates the heater control output to increase the temperature. If the reactor temperature is above the setpoint, the PLC activates one of the solenoid valve outputs to increase the flow of the cooling fluid and decrease the temperature. The PLC continuously monitors the temperature and adjusts the heater and cooling systems to maintain the desired setpoint. The PLC also controls the motor that drives the impeller to mix the contents of the reactor. If the emergency stop pushbutton is pressed, the PLC deactivates all the outputs and stops the system. The PLC project can be further expanded and modified to include additional functionality, such as alarms, data logging, or remote monitoring, depending on the specific requirements of the project. However, we will not care about coding the PLC logic of this system, rather we will use this example to explain how to hardware configure the PLC to fit our project.
    This includes:
    Selecting the PLC CPU. Selecting the IO modules. Assigning the input and output tags to the hardware modules. Assigning an IP to the PLC for communication. Assigning a protection password. Configuring the local time of the PLC. Configuration the HMI and set the connection with PLC. How to configure PLC with the given example?
    Below we will discuss the basic PLC project creation with the required hardware.
    The hardware configuration of the CPU:
    Selecting the CPU:
    When you start a new project in TIA Portal, you should configure a new device and add it to your project. See picture 1.

    Picture 1. Configure a device for your project
    As you can see from the previous picture, the TIA portal already shows you that the first step should be configuring a new device.
    In the previous article, we discussed how to choose the PLC that fits your process, so we will not mention that here again, for our project as it is a simple project we will choose the CPU 1214C AC/DC/RLY. See picture 2.

    Picture 2. Add a new controller to the project
    CPU Properties:
    Depending on the CPU that you have selected for your project, different CPU features and properties will be available.
    You can enable or disable these features depending on your needs. Some of the features will need extra configuration to be made. See picture 3.

    Picture 3 – Properties of CPU
    As you can see in the previous picture there are many properties that you can set for your CPU in the project.
    We will mention some of these properties which you will need to configure in each project you make, some other properties are used only in special cases.
    Communication:
    This is a very important configuration for any PLC project; your project will most probably have different modules and devices that need to talk to each other. Setting up the communication between your PLC and these devices is important for your project.
    By selecting the CPU you already have defined how the communication will be. Some CPU only works with Profinet, some only work with Profibus and some have the ability to use both. The selected PLC for this example only works with Profinet.
    From the Profinet interface you will set the IP address for your PLC, this IP should be unique in the project; you can’t use the same IP for two different modules. See picture 4.

    Picture 4 – Profinet interface
    Cycle time:
    This is another important property for your PLC, as you know; the cycle time of your program will depend on how much code you have written and how long it will take the PLC to execute this code.
    In the cycle time properties, you can set the cycle monitoring time, if the PLC takes longer than this set time to execute the program, then the PLC will give an error. See picture 5.
    From this property you can also determine the minimum cycle time for your CPU, you can do that if you triggered the “Enable minimum cycle time for cyclic OBs”.
    You then can write the minimum cycle time that you want, and the PLC will adjust its performance to match this time. Off course this time is limited by the CPU performance capability, so you can’t lower this time below a certain limit.

    Picture 5 – Cycle time Property
    System and clock memory bits:
    System memory bits and clock memory bits are built-in bits inside the CPU that the operating system used to indicate certain events in the PLC.
    For example, there is a memory bit that will change to TRUE only at first scan or a memory bit that will be TRUE if diagnostic status changes, there are also some dedicated clock memory bits like a bit representing a clock of 10Hz or a bit representing a clock of 2Hz.
    These bits can be very useful in some applications and can save a lot of programming code to obtain the same functionality. See picture 6.

    picture 6 – Enable system and clock memory bits
    You can enable the use of one or both memory bytes; you can also determine the address of these bytes as you can see from the picture.
    Time of Day:
    Another very important property of your PLC is setting the time inside your PLC. In almost any project you make, you will need to know the real-time to be able to assign certain actions with different dates.
    In the previous article, we talked about local and system times inside the PLC and how to use them. This property of the CPU allows you to set the local time to the time zone that you want. See picture 7.

    Picture 7 – Local time property
    Protection and security:
    From this property, you can determine the access level and password protection for your PLC.  See picture 8.

    Picture 8 – Protection and security property
    The previously mentioned properties are the most commonly configured properties with almost any PLC project you would do. There are some other properties that are less likely to be used with simple programs such as Web servers and OPC UA.
    The next step in the Hardware configuration of your project is configuring the IOs.
    IOs hardware configuration:
    Another important step of your project is the configuration of your IOs, which means deciding how many IO modules you need and what kind of IO modules you need.
    When deciding about your IOs, you should consider some key points like having some spare IO points and choosing the IO modules that fit the input sensors and output actuators inside your project. See picture 9.

    Picture 9 – Adding analog input module
    As we mentioned in our example project, we have 4 thermocouples used as analog inputs to my PLC, so I need to add an analog input module with at least 4 input channels because the selected PLC only has 2 analog input channels.
    Another thing is that the thermocouple is a special type of analog input that requires a dedicated input module. That is why we chose the AI 8xTC module, which has 8 input channels dedicated to being used with thermocouples; we choose the 8-channel module and the 4 to have spare channels for future use in case we need to expand our project.
    If you go to the properties of the AI 8xTC module you will see that you can configure each input channel individually, you can choose the type of thermocouple, scale of measurement, and other properties. See picture 10.

    Picture 10 – Configuring input module
    Next, you will need to define your IOs tags and assign each input or output you have to a proper IO point in your PLC or in the IO modules. See picture 11.

    Picture 11 – Assign input tags
    Then you continue to assign the rest of the inputs and outputs tags, see pictures 12 and 13.

    Picture 12 – Assign input tags for the PLC

    Picture 13 – Assign output tags to your project
    HMI Configuration
    Your PLC project will probably need an HMI, after selecting your HMI there are different configurations you can make.
    In this article, we will only show how to configure the communication between the HMI and the PLC. As you see from the previous picture, you select an HMI by adding a new device and then select an HMI. See picture 14.

    Picture 14 – Selecting an HMI
    There are different ways to set the communication between the HMI and the PLC, but the easiest way is through the network view page. See picture 15.

    Picture 15 – Setting HMI connection
    Inside the network view page, you can set the connection between the HMI and the PLC by simply clicking on the small green square representing Profinet from the HMI and dragging it to the PLC.
    TIA Portal will then draw a green line between the two modules and it will automatically give the HMI an IP address to set the communication between them.
    Conclusion
    Hardware configuration is a very critical step of any PLC project. The proper hardware configuration of your PLC will ensure that the needed functionalities of the project are met. Hardware configurations include selecting IO modules, enabling or disabling certain CPU properties, and configuring different devices like HMI with your PLC.

    xiangjinjiao
    This is a PLC program for pneumatic valve operation in sequence mode.
    Sequential PLC Programming for the Pneumatic Valves
    Write a ladder logic for sequential PLC programming for the pneumatic valves to operate cylinders in sequential mode.

    Solution:
    Here in this system, there are two cylinders and two push buttons that are connected to the PLC.
     The push buttons are connected to the PLC inputs and the cylinders are connected to the Outputs of the PLC.
    There are the following condition for the system to work which are as follows: –
    When START PB is pushed, cylinder A should start, and Cylinder B should start after 5 seconds of Cylinder A.
    When STOP PB is pushed, both cylinders A & B are to be stopped.
    Now to meet the following conditions, we must use a timer which delays the operation of cylinder B.
    List of inputs/outputs
    Inputs:
     X1 -START PB  X2 -STOP PB Outputs:
     Y0 -Cylinder A  Y1 -Cylinder B Ladder Diagram for the Sequential Operation of Cylinders

    Program Explanation:
    In rung 1, we used STRAT PB (X1) to start Cylinder A (Y0). Here we used NC contact of STOP PB (X2) to stop cylinder A (Y0). In parallel with X1 contact, we used NO contact of Y0 to latch the output.
    In rung 2, we used Timer T0 to count the delay for cylinder B (Y1).
    In rung 3, we used NO contact of T0 so once time delay over the Cylinder B (Y1) will ON.

    leizuofa
    In this article we are going to talk about a major problem that happens a lot when you start programming your PLC, this is the firmware version’s common errors and how to handle them.
    Contents:
    What is the firmware version of a PLC? Why firmware version can cause trouble? How to know the firmware version of hardware PLC? How to handle firmware version errors? Conclusions. What is the firmware version of a PLC?
    The firmware of a PLC or a PLC module (IOs, Communication modules, etc) is simply the internal software installed in the PLC which is responsible for what the hardware can actually do.
    A firmware version will determine what internal feature your PLC has, like the safety protocols, internal optimizing functions, better time handling, and other different features and capabilities.
    A PLC with an older firmware version will have fewer features and internal capabilities than a newer firmware version PLC.
    Pictures 1 and 2 show you how the same hardware PLC will have different features and performance capabilities with different firmware versions installed.

    Picture 1 – Firmware version V4.0

    Picture 2 – Firmware version V4.4
    Did you notice how the same CPU is now having more features added just by updating to a higher firmware version? With the higher firmware V4.4, the CPU now has OPC UA among other features added to its performance capabilities.
    Why firmware version can cause trouble?
    Look, you usually start your PLC project by selecting the PLC then you start programming.
    You will select your PLC in TIA Portal according to one of two points:
    You already have purchased the hardware PLC, so you will select the same PLC that you actually have in the TIA Portal project. You still haven’t purchased a PLC, so you will select a PLC in TIA Portal that meets your requirement then you will buy it later. In either of the two cases, if the firmware version of the PLC selected in the TIA Portal project is different from the firmware version of the actual hardware you will have a problem. And your program won’t even be downloaded to the hardware PLC.
    So, you should always make sure that the firmware version of the actual PLC matches the PLC selected in TIA Portal.
    It is worth mentioning to know that if the firmware version selected in TIA Portal is older than the actual PLC, you won’t face any troubles with your program, you will lose some of the PLC features and capabilities, but your program will work fine.
    Troubles will appear if the opposite is true, if the firmware version selected in TIA Portal is newer than the actual PLC, then you will have a problem.
    That is why if you don’t know the firmware version of your hardware, you should select the older version in the TIA Portal project.
    How to know the firmware version of hardware PLC?
    We can know the firmware version of the hardware PLC that we have by one f two methods:
    From the PLC itself
    The firmware version of any PLC module is always written somewhere on the hardware device. See the next pictures.

    Picture 3 – Firmware version FS:04

    Picture 4 – Firmware version is V7.0.5
    From the TIA Portal software
    Using the TIA Portal software you can connect your PLC to your TIA Portal and search for the device then you can find the firmware version of the hardware device, see the following steps.
    You don’t even have to create a new project; just the project view of the TIA Portal is enough, see picture 5.

    Picture 5 – Project view of TIA Portal without creating a project.
    From online access search for your PLC. As the connection between TIA Portal and the PLC is through an Ethernet cable, then we will use the Ethernet connection option. Double-click on update accessible devices to start searching for your PLC. See picture 6.

    Picture 6 – Update accessible devices to search for your PLC.
    If there is a connection between the PLC and the TIA Portal then the software should find your PLC. See picture 7.

    Picture 7 – Your PLC was found by the software.
    Now, double-click on Online & diagnostics to show your PLC’s information. See picture 8.

    Picture 8 – Online information of the PLC.
    From the General attribute, you can find the firmware version of your PLC as shown in the previous picture.
     You can also find the firmware version from the Functions attribute. See picture 9.

    Picture 9 – Firmware version from the functions attribute.
    How to handle firmware version errors?
    First, let’s create a firmware version error scenario then we will see how to handle and fix this error.
    We will start by simply create a new project and then add a new device, in this PLC example we will intentionally choose a newer firmware version than the actual hardware PLC. We know that our plc firmware is V4.0, but in TIA Portal we will choose V4.4 firmware version. See picture 10.

    Picture 10 – Add a new PLC with a higher firmware version.
    Press OK to add your device and that is it, you have created a situation that will cause a firmware error. To see that let’s try to download the project to our PLC.
    Note that we haven’t even written any code. Just download it to the PLC. See picture 11.

    Picture 11 – Download to PLC failed, incompatible firmware.
    As you see from the previous picture, once you try to download the project to the PLC, an error will appear stating that the firmware versions of the PLC and TIA Portal are not matching.
    You can even see it if you try to go online. See picture 12.

    Picture 12 – The PLC is in an error state.
    To solve this error, we simply need to change the firmware version of the PLC selected in the TIA Portal project to older or the same firmware as the actual hardware PLC.
    To do that we go to the properties page of the PLC and select Change firmware version from the General attribute. See picture 13.

    Picture 13 – Change the firmware version option.
    Once you press the Change firmware version button, a change device window will appear; in this window, you’ll be able to change the firmware version. See picture 14.

    Picture 14 – Change the device window.
    In the change device window, you will see the current device which you have selected before and the new device which you need to match its firmware with what you actually have.
    Note that, when choosing a lower firmware for example V4.3 the information at the bottom of the window will show you what features you have lost when moving down to a lower firmware as you see in the previous picture.
    Now, change the firmware of the new device to the V4.0 version of the hardware PLC. And notice how many features and capabilities the PLC has lost just by choosing a lower firmware. See picture 15.

    Picture 15 – Matching the firmware between hardware PLC and Software.
    Press OK to confirm changes and now try to download your project once again to the PLC. You will notice that now the project will be loaded to the PLC without any errors. See picture 16.

    Picture 16 – The project is loaded into the PLC.
    A successful load of the project to the PLC indicates that the firmware version error is now fixed. You can also go online and check that from the online view of the PLC project. See picture 17.

    Picture 17 – Online view of the project.
    The green checks and circles you see in the previous picture indicate that all configurations of the software and the hardware are matching and are compatible with one another.
    Conclusion
    Firmware version errors are very common trouble to face when creating a new project in TIA Portal.
    A best practice is to know the firmware version of the hardware device you have and match the firmware of it to the selected device in TIA Portal.
    If you don’t know the firmware of the hardware device, then you should choose the oldest version of the selected module inside the TIA Portal. To avoid any firmware issues with your project.

    caixiaofeng
    In this article, we will talk about analog input signals processing in PLC and how can we handle these signals in the automation process.
    Contents:
    What are analog input signals? Input analog processing in S7-1200 and 1500. Input analog processing in S7-300 and 400. Which are best for control? – analog or digital signals Conclusion. What are Analog Input Signals?
    Before we dive into how to handle analog input signals in TIA Portal, let’s start by understanding analog inputs first.
    Any automation system needs input signals to understand the status of the process to be able to take decisions that will keep the process running and stable. These input signals are either discrete or digital input signals which are in the form of 0 or 1 values. The other type of input is the analog signals.
    An Analog signal is simply a continuous representation of a physical quantity in your system, so if you need to monitor temperature or pressure in your process, an analog signal will give you continuous and instantaneous values that correspond to the real changes in the physical quantity.
    Analog signals are provided in many standard forms, but most commonly the 0-10V or the 4-20mA. It will depend on the type of analog sensor you are using, and it will also dictate the type of PLC analog module that you can use.
    Assume an analog pressure sensor that has a measuring range of 0-10 bar and an output in the form of 4-20mA. Usually, an analog signal will have a linear relationship between the measured physical quantity and the corresponding output.
    That means if the sensor is measuring a 0 bar it will give a 4mA signal and if it is measuring a 10 bar it will give a 20mA signal and the same in between will also be linear. See picture 1.

    Picture 1 – Analog signal representation.
    The PLC still can’t understand the 4-20mA of the physical quantity, and here comes the use of the analog module of the PLC. The analog module will make another transformation to this representation so the PLC can actually understand it.
    The analog module will convert the analog mA measurements into digital values that depend on the type of the module, but for Siemens PLC, these values are always in the range of 0 – 27648. So if the sensor is mearing 0 bar the output will be 4mA and it will be converted to 0 value inside the PLC. See picture 2.

    Picture 2 – Analog to digital conversion of the input signal
    The PLC will then convert the 0-27648 values into the equivalent physical measurement depending on your programming which we will get to later. See picture 3.

    Picture 3 – The scaled measured value inside the PLC.
    The analog processing of temperatures is quite different because the temperature sensor behavior with the physical changes is not linear as would a level or a pressure sensor do. That is why there are standardized tables for the different types of temperature sensors that tell which temperature corresponds to which sensor value.
    That is why with temperature measurement you would select special types of input modules of your PLC where these standard tables are internally defined and you directly get the temperature value corresponding to the sensor measurement.
    That is why you can’t find a temperature sensor that has a voltage or current measurement range written on it. You will only find the sensor type written, for example, PT100, PT1000, KTY84, PTC, and so on.
    Analog Input Processing in S7-1200 and 1500
    To see how we handle analog signals in modern S7 family PLC, let’s start by creating a new project and adding an S7-1200 CPU. We will also add an analog input/output module. See picture 4.

    Picture 4 – Adding an analog input module.
    Now, let’s define our input signal tag, we will assume a pressure sensor that can measure pressure between 0 and 10 bars and gives a corresponding signal between 4 and 20mA.
    We will define that input signal in the first tags of the input module. See picture 5.

    Picture 5 – Define the input signal tag.
    As we said before, the input module can work with different input signals, whether it is 0-10V or 4-20mA, so we need to assign the right configuration for our sensor.
    As we said the pressure signal is given in the form of 4-20mA so we will configure our input channel to that. See picture 6.

    Picture 6 – Configure the input channel
    Now that we finished the hardware configuration part, we will start programming our handling code. To do so, we will create a function FC so we can reuse it each time we have an analog signal to process. Inside this FC we will create the logic which will handle the analog signal and convert it into the physical measured value.
    In TIA Portal there are predefined instructions that we can use to do just that, these instructions are the NORM_X and the SCALE_X instructions. See picture 7.

    Picture 7 – NORM_X and SCALE_X instructions
    As you can see, the NORM_X will normalize the analog input into a value between 0 and 1, and then the SCALE_X will be used to scale this normalized value to the range of the measured physical value, which in our sensor case between 0 and 10 bars.
    We used a function FC instead of writing our code directly in the main OB1 to make our code reusable with any analog signal. Each time I have a new analog input signal I will just drag and drop the FC block into our main OB1 and just write the associated parameters of the required input. See picture 8.

    Picture 8 – Drag and drop your FC.
    When you drag and drop the FC into your main OB1, you will be asked to provide the associated parameter of this function call.
    In our case, the input signal is the pressure sensor and the ScaledMIN and ScaledMAX are the measurement value range of 0-10 bars. See picture 9.

    Picture 9 – Assigning the function parameters to our pressure sensor.
    If I have a new analog input, then I won’t have to recreate the PLC logic again, I will just drag and drop the FC into the main OB1 and assign the new sensor parameters.
    Let’s assume that we now have a new analog sensor for measuring the level inside a water tank between 0 and 100 % of the tank. We will do the same steps as we did before, starting with defining the new input tag. See picture 10.

    Picture 10 – Define new level sensor
    Next, we will configure the input channel for the level sensor as we did in picture 6. We will assume the same configuration.
    Next, we will just drag and drop the FC we created and just assign the parameters of the level sensor. See picture 11.

    Picture 11 – Reusing the FC with the level sensor.
    As you can see from the previous picture, this is one of the many advantages of using functions FCs in your logic as it helped reduce the amount of programming we made.
    Now you have a generic code that can be reused many times with any input analog signal you can need in your PLC project.
     See the next simulation for input signals processing in Siemens PLC.

    Analog Inputs in S7-300 and S7-400
    To see how we handle analog signals in older S7 family PLCs like S7-300, let’s start by creating a new project and adding an S7-300 CPU.
    The PLC chosen already have enough analog input channels, so we won’t add any analog modules. See picture 12.

    Picture 12 – Add an S7-300 PLC.
    Then we will define the new analog sensor tag, we will assume a pressure sensor that has a measuring range between 0 and 100 bar and an output of 4-20mA.
    We will configure the PLC input channel as we did before with the S7-1200 to fit our analog input sensor. See picture 13.

    Picture 13 – Configure the input channel.
    Now to the PLC coding part, the instruction in s7-300 that is used to handle analog processing is different from the s7-1200.
    In the S7-1200 PLCs, we have to use NORM_X and SCALE_X. but with the S7-300 we don’t have the normalized instruction, only a SCALE instruction is used. See picture 14.

    Picture 14 – SCALE instruction in S7-300
    As you can see from the previous picture, the SCALE instruction in S7-300 is kind of similar to the NORM_X and SCALE_X instructions combined together. There is one more clear difference which is the BIPOLAR input.  
    The BIPOLAR input is used to indicate if the value at the IN parameter is to be interpreted as bipolar or unipolar. The parameter can assume the following values:
    BIPOLAR = 1 then the input integer value is assumed to be between -27648 and +27648. For example, when the analog sensor gives us an output in the range of -10V to +10V BIPOLAR =0 then the input integer value is assumed to be between 0 and 27648. For example, when the sensor gives us an output in the range of 0-10V  And this is simply how to handle analog input signals in both S7-1200 and S7-300 PLCs.
    Which are Best for Control? – Analog or Digital Signals
    Look, both signals are critical and useful for any automation system, but I personally prefer to use the analog signals if I can, because having analog signals measurements for the process’s physical quantities will give me continuous monitoring of process parameters which will enable me to better track and control my process.
    Also, having continuous monitoring of the parameters will enable me to set different control logic for different signal values, it will make it easier to have a value range for controlling the process and another value ranges for alarms and warnings of the process deviating from normal operation.
    Conclusion
    An Analog signal is a continuous representation of a physical quantity in your system. Analog inputs are most commonly provided in the 0-10V or 4-20mA range. Analog signal processing means converting the analog 4-20mA signal into a range of values that corresponds to the real physical quantity and that the PLC can understand. In the modern S7 family of PLCs like S7-1200, handling analog signals is done using the NORM_X and the SCALE_X instructions. In the older S7 family of PLCs like S7-300, handling the analog signals is done using the SCALE instruction, which is basically a combination between the NORM_X and the SCALE_X instructions.

Apply for friendship links:WhatsApp or E-mail: admin@plchmis.com
×
×
  • Create New...