Skip to main content

Create User-Defined Data Types and Function Blocks in Studio 5000

 In this post, we will see how to create user-defined data types and function blocks in Studio 5000 software.

As we know, user-derived data types and function blocks play a very important role in PLC software. A programmer finds it easier to develop the logic faster and more efficiently if there is a repeated type of logic in the whole program.


That means, suppose there are 10 motors and each motor should start by pressing the start button and stop by pressing the stop button.

Instead of writing the same logic for all the 10 motors every time, he can just create his own library or data type which will contain a common logic; and it can be used in multiple instances within the whole logic.


User-defined types are available in almost every PLC software. In this post, we will see one such software of Rockwell Automation – Studio 5000. This software is used to program Rockwell PLCs like Compact Logix, Control Logix, and Flex Logix series. It is a very high-end one and has many advanced features available to make the task easier for the programmer.


User-Defined Data Types in Studio 5000

So, what is a data type? A Boolean, integer, real, etc.; the terms which a programmer has faced while creating a variable is called data type. It defines the type of data or variable used.

User-defined data type means a programmer can manually create his own data type and give it any name according to his convenience. Refer to the below steps to create a user-defined data type in Studio 5000.


As shown in the image, expand the assets category. Expand the data types category and in that, right-click the user-defined option as shown to create a new data type.


On clicking it, the following window will appear. Here, you have to click add a member as shown; to add variables of the data type you want; and give a name for the data type.

For example, as discussed earlier, two variables have been created – start and stop. Both these variables are of Boolean type.


Clicking Ok will create a data type of the name motor. Now, understand the logic. If you are creating a variable named M1 of type Boolean; you can create it as type motor also.


This means, if created, then the M1 variable will have two members accordingly – M1. Start and M1. Stop.


Add-On Instructions (User Defined Function Blocks)

A user-defined function block is a library created by the programmer himself. For example, as the timer is a predefined library that comes inbuilt with the PLC software, a user-defined library is the one that will be customized by the programmer according to his requirements accordingly.


Refer to the below steps to create a user-defined function block in Studio 5000.


As shown in the image, expand the assets category. Right-click the Add-on Instructions option as shown to create a new function block.


On clicking it, the following window will appear. Name the library according to you and define the programming language.


Here, I have named the function block as Motor_Logic and chosen the ladder diagram as the programming language.


On clicking Ok, the following window will appear.

Develop the logic according to you, as shown in the figure. When you create, you will be asked to create variables first; if undeclared.

As shown, I have not created variables initially; that is why it is showing as the red cross mark on the left side. This is because the rung has errors.

Here, create start and stop as input parameters; and create motor as output variable.

When you right-click any undeclared or undefined variable to create a new parameter, the following popup will appear.

Select the Input parameter for the input variable and the output parameter for the output variable. Choose the data type and click ok.

The variable will be created.

When the whole rung is now clear without any error, it will appear as follows:
Create the Program
Now that your data type and function block is created, you can use them in your main program. Refer to the below image.

In the add-on option, choose Motor_Logic library.

An undeclared library will be added. Type M1_Logic and create it with type – Motor_Library.
Right-click the newly created library and select open instruction definition.

The following window will appear. Tick Req (Required) option for the variables required to be pinned in the library outside, for linking external variables to it.

Click ok and you can now link external variables in your library pins; as shown in the figure.

Now, I have created two instances of the motor library and created two variables (M1 and M2) of data type – motor. And, it has been linked to start and stop pins of the library.

That means, whenever the variable – M1. Start turns on, the motor will turn on according to the logic written inside before; and stop when the variable – M1. Stop turns on.

The same logic will work for motor 2.


In this way, we saw how to create user-defined function blocks and libraries in this software.

Comments

Popular posts from this blog

PLC Program for Mixing Tank

 Create a ladder diagram for controlling a batch mixing process. Implement a PLC program for mixing tank or Mixing Process using PLC Ladder Logic. PLC Program for Mixing Tank Fig : Mixing tank A tank is used to mix two liquids. The required control circuit operates as follows: A. When the START button is pressed, solenoids A and B energize. This permits the two liquids to begin filling the tank. B. When the tank is filled, the float switch trips. This de-energizes solenoids A and B and starts the motor used to mix the liquids together. C. The motor is permitted to run for 1 minute. After 1 minute has elapsed, the motor turns off and solenoid C energizes to drain the tank. D. When the tank is empty, the float switch de- energizes solenoid C. E. A STOP button can be used to stop the process at any point. F. If the motor becomes overloaded, the action of the entire circuit will stop. G. Once the circuit has been energized, it will continue to operate until it is manually stopped. Solution...

What is Relay? How it Works? Types, Applications, Testing

 We use relays for a wide range of applications such as home automation, cars and bikes (automobiles), industrial applications, DIY Projects, test and measurement equipment, and many more. But what is Relay? How a Relay Works? What are the Applications of Relays? Let us explore more about relays in this guide. What is a Relay? A Relay is a simple electromechanical switch. While we use normal switches to close or open a circuit manually, a Relay is also a switch that connects or disconnects two circuits. But instead of a manual operation, a relay uses an electrical signal to control an electromagnet, which in turn connects or disconnects another circuit. Relays can be of different types like electromechanical, solid state. Electromechanical relays are frequently used. Let us see the internal parts of this relay before knowing about it working. Although many different types of relay were present, their working is same. Every electromechanical relay consists of an consists of an Elect...

Chlorine dioxide Analyzer Principle

 Chlorine dioxide measurement Chlorine dioxide (ClO2) is an instable, non-storable, toxic gas with a characteristic scent. The molecule consists of one chlorine atom and two oxygen atoms – represented in the chemical formula ClO2. It is very reactive. To avoid the risk of spontaneous explosions of gaseous chlorine dioxide or concentrated solutions, it is generally handled in dilution with low concentrations. ClO2 is soluble in water, but tends to evaporate quickly. Typically it is prepared on site, for example from hydrochloric acid and sodium chlorite. The procedure provides solutions with approx. 2 g/l ClO2 that can be safely handled and stored for several days. Image Credits : krohne Sensor Parts : Reference electrode Applied chlorine dioxide specific potential Current needed to maintain the constant potential Counter electrode Measuring electrode The disinfection effect of ClO2 is due to the transfer of oxygen instead of chlorine, so that no chlorinated byproducts are formed. C...