4 favourite function blocks for PLC programming

Home Blog 4 favourite function blocks for PLC programming Back
Blog

22/11/18 Which are the most useful function blocks for basic automation tasks? Which options do they offer you? 

Let us introduce a few useful function blocks on a practical example. We will showcase these blocks in the Mervis - the officially supported software solutions for Unipi PLC programming. 

What is a function block? 

Function blocks are based on segments of pre-defined code designed to perform a given repetitive task. It is an easy and quick way to set up behavior routines of the controller, create various logics, set up conditions, or create counters. Due to their intuitive design, the FBD method is suitable especially for beginner users. 

Following our 7 tips for PLC programming, we bring you an example of several often used function blocks for basic automation tasks. Beginners can also use these blocks to try the Mervis IDE and to understand the basics of FBD programming. 

1) Week time scheduler

This simple scheduler will allow you to create applications in which you require the option to control them according to a week time schedule. This block can be used to quickly create a heating system which will be switched on only for a given time period. You can also use the scheduler for setting up an automated lighting control; for example, you can set up a light on a stairway to turn on automatically in the evening and turn off at the time you are usually leaving for work. The screenshot below then showcases a practical usage of the scheduler - in this case, the block was used to automate a terrarium lighting. The controller turns the light on at 9:00 AM and switches it off at 9:00 PM 

2) Logic operations

Logic operators can be used to control the given technology by creating simple conditional logic and pre-defined conditions. A typical example is the kitchen light control system on the screenshot below. The project utilizes three logic operators - gt (compares two values and sets the larger one), and (combination of two values) and or (binary selection from two values). The controller is connected to a motion sensor and a manual lighting switch. In addition, it communicates with an external light intensity sensor. 

This combination of logic operators will turn the kitchen light on if any of the following conditions are met 

- a signal from the manual light switch
- the motion sensor detects a motion in the kitchen
- the exterior light intensity sensor detects night + the automatic light control is switched on

3) Blocks from reading values from energy meters

In the previous 7 tips and tricks for automation network installationwe mentioned the S0 output that should be present on practically all pulse energy meters by default. This output allows the user to monitor energy consumption through the counting of individual pulses, each of them corresponding with a certain amount of energy (i.e. 0.5 watthours per pulse). On the screenshot below, a combination of the BD30_Counter block and the mul block is used along with the T36_Power_Meter block. 

BD30_Counter serves as a pulse counter, sending the counted value to mul block; mul then calculates the cumulative energy consumption value based using the pulse count and the pre-defined value of a single pulse. This solution allows the user to monitor long-term energy consumption, but cannot be used for calculating real-time consumption. Luckily for you, Mervis features T36_Power_Meter block designed exactly for this task, generating a current energy consumption in kilowatts. The showcased combination is perfect for an overview of the energy consumption, BD30_Counter and mul can be however also used for other pulse meters (flowmeters, gas meters, etc.). 

4) Unica 1-Wire sensor block

One of the most favorite items in Unipi's inventory is the SEDtronic 1-Wire sensor series, which are compatible with the Unica wall switches. Depending on the variant, these small and simple devices can measure temperature, humidity, or light intensity. Additionally, some variants also feature digital inputs. Their low cost and simplicity makes them an excellent choice for a smart home project. For communication with these sensors, a special block is included in Mervis to read values from the sensor and transform the data into numeric values used by other function blocks. All it takes is to place the block, connect it with both inputs (sensor cables) and outputs (resulting numerical values). 

Conclusion

Showcased function blocks are among the most frequently used blocks in Mervis, they, however, represent only a fraction of the whole range of various function blocks the Mervis library contains. If you want to learn more about the Mervis, visit the comprehensible Unipi Knowledge Base, where you can find not only informative tutorials but also many other useful tips, tricks, and manuals. If your controller was just delivered and you are preparing for the first Mervis start-up, be sure to visit our First steps in the Mervis guide. 

Next step

Our parts

UniPi 1
Neuron
Axon
Patron
Gate
Mervis

Mervis

51,00 €
42,15 € excl. VAT

In stock > 50 pcs

Subscribe to our newsletter