User Defined Function Blocks (UDFBs) are one of the power features of variable-based languages. They are a great way of turning common customer logic routines into easily reusable functions and to expand a controller’s instruction set. During this session we’ll summarise and quickly review a range of UDFBs we’ve created. You might just discover a few to use on your next project!




0:03

Good morning, everyone. Thank you for joining us on this webinar on CSCAPE 10 UDFBs.

0:09

As usual, we’ll go into the presentation. If you have any questions, you can drop them in at any point and we’ll get to them at the end.

0:15

Hello and welcome to today’s webinar. Today we will look at CSCAPE 10 UDFBs. Let’s look at our agenda for today.

0:23

We’re going to start with summarizing what user-defined function blocks are, mentioning some of the requirements needed to use UDFBs and look at some pre-made UDFBs available from Horner Automation and then we’re going to show you how you can import UDFBs into your project. So what are user-defined function blocks?

0:44

User-defined function blocks are one of the power features of variable-based logic language.

0:51

UDFBs allow you to take a section of your logic and transform it into a reusable function block with inputs and inputs, just like a regular function block in Zscape.

1:01

And then once you have created a UDFB, you can use it multiple times in your project.

1:05

You can then also export it and in the future, you can import it into a new project and use it multiple times in that project as well.

1:14

Not only can you create your own UDFBs, you can also import UDFBs that others create, including the ones that we have created here at Horner Automation. Now before you can use UGFBs you have to be using Cscape 9.9 or Cscape 10.

1:30

All of the UGFBs we are going to talk about in today’s presentation were written for a variable based advanced ladder.

1:37

Here is a summary page that tells you in one location all the different categories of UGFBs we have done as well as what some of the individual functions are within that category, the first several operates in arrays, so array type variables are only available within Variable Based Advanced Ladder in IEC, they are not available in register based languages.

1:59

We are also going to show you and talk about a drum sequencer, user defined function block as well as going to show you how you can expand your string handling capability if you have got an ASCII type application that you need to deal with.

2:14

we will talk about something that is called mass move and then we have some UDFBs for calculating tank volume and some ones for doing time math so let’s go ahead and go through these with more detail let’s start with array math so what is array math array math are user defined function blocks that are designed to perform math and statistical operations on an array or a list of data value and then we start with the median what is the median the median is the middle value in a list of values either in ascending or descending order.

2:46

So this user defined function block will report back the middle value or the median. There is a sum array math function.

2:53

It goes through the entire array of values and adds all the values together and provides you with a sum. Next we have the average of values.

3:01

It goes through the entire list of values and provides you with the average. Then you have the min and max values UDFBs.

3:08

So they will go through the entire list they will find the minimum value and the max function will find the maximum value and then we have standard deviation so we will go through the entire list and do the standard deviation calculation and present the data back to you.

3:23

This is another highly statistical function that operates on an array of data values.

3:29

The next category also works on an array type data and those are data find UDFVs so what they do they also work on an array and what they do is they search that array for specific values.

3:42

So what would that be useful for?

3:43

They can be useful for ASCII type applications.

3:47

So let’s say you got a barcode that you have scanned and you are looking for a specific character.

3:52

So you can use that by defined, or let’s say your OCS is operating in a test environment and you have performed a test and you have captured the data from the test or possibly a series of analog values and you want to look for a specific value within those test results.

4:08

Next we have data sort UDFBs.

4:11

So what these UDFBs will do is they will take an array of data and they will sort these either ascending or descending order.

4:19

And we have user defined function blocks for sort up and sort down.

4:23

And we have ones that operate on integer, double integers, are real values.

4:28

So these are data, sort UDFBs, and they use a technique called bubble sort.

4:33

Again, we will go back to the machine test environment where you may be forming a test a number of times and capturing the results.

4:41

You might want to sort the results in ascending or descending order, so that is one possibility that we can mention here, but there are plenty of applications where these can be useful.

4:51

Here is an example of data sort UGFBs on the screen with inputs on the left including input array that you can see there and then the result on the right the outputs of the UGFBs.

5:02

Here are the particular UDFBs that we have got available and the first few what they are doing is they are allowing you to extract a portion of an existing string to create a new string.

5:14

Now the first one we have got here is called left string so it is going to extract characters from the left side or start of an existing string to create a new one.

5:23

Next we have mid string which allow you to take characters out of the middle of an existing string to create a new one and then have right string which allows you to take characters extracted from the right side or the end of a string to create a new one.

5:38

Next we have contact node that allows you to take two existing strings and create one longer one that is a combination of the other two strings so that can be very useful if you are building a specific series of characters for a special purpose.

5:52

For example satellite type communications is where you have a specific series of characters that you need to add together to create a specific string.

6:01

And for building strings, CONTATENATE can be very useful.

6:05

Here is the FINE CHARACTER.

6:07

The FINE CHARACTER is very similar to the FINE BYTE function.

6:10

But with FINE CHARACTER you have to find a specific character in a string.

6:14

The current is the return signal, the start of a specific data field or a signal to the end of the string which can be a variable length.

6:22

Next we are going to talk about DRUM SEQUENCER.

6:24

This is one of the most complicated UDFBs that we have created.

6:29

So what is a drum sequencer?

6:30

A drum sequencer is an electromechanical device that is useful in controlling applications that perform a series of steps or stages in repetitive order.

6:40

So an example of a drum sequencer type control would be a dishwasher, where you have got a fill cycle, and you have got a rinse cycle, and you have also got a wash cycle, and these particular steps have different outputs on during these steps and they can last for a certain duration of time or they could be waiting for a specific sensor to trip before the specific step or sequence is complete.

7:04

So graphically this is what a drum sequencer looks like where you have a series of steps and in each step you have one or more outputs that can be on represented by those pegs and then a motor is turning your drum at a continuous speed to represent time.

7:19

You would that because there are a lot of applications that have a series of sequential steps or stages where different outputs can be on in different stages and either specific input will cause you to move from one stage to the next or a specific amount of time will cause you to move from one stage to the next or a time and an input changing will cause you to move from one step to the next so these can be useful ways of controlling sequential type machines so is why we created drum sequencer, user defined function block.

7:51

Our drum sequencer is quite capable. It can handle up to 16 steps.

7:55

It can control up to 16 outputs and it can advance from step to step based on time.

8:01

It can advance from step to step based on an event like an input change in state for instance. So it’s a very capable UTFB.

8:10

Next we have something called masked move. So what is masked move?

8:14

A masked move is a move function with a special move function.

8:18

Move functions are where we move data from one variable into another variable.

8:23

This is a move type instruction but a masked move is a move instruction where we only move parts of data from a source variable into a destination variable not the entire thing and you will find applications where they are packing in every single piece of data they can into a small number of data bytes.

8:40

Those are the sort of applications that can use packing in person and they can use MassMove as one of the tools to pack and parse the data.

8:48

So in hours like CanOpen and J1939 where they’re sending lots of data in a small amount of space to be super sufficient satellite and cellular communication examples sometimes even in mudbuzz communications and then in barcode and RFID type applications as well.

9:07

So anytime you need to pack a lot data in a small amount of space you want to use every bit the mass move is useful for that.

9:14

As you can see here with mass move you’re going to specify the source variable that you’re going to move you’re going to specify the destination variable that you are moving the data to and then you’re going to specify how many bits of the source variable are going to be moved and then the result is placed in the output.

9:32

Next we have Tang Volume UGFB so these are user defined function blocks that were customer requested that allow you to calculate the volume based on the level of the tank with either a known geometric shape or where the manufacturer has provided a data table of level versus volume for that particular tank.

9:51

So we have got those two different categories that we can handle.

9:54

Here is a graphical look at the different tank geometries that these support.

9:59

We have got an elapsed time user defined function block where we have a start time and end time are specified and then the result of that are the number of days, hours, minutes and seconds of elapsed time between start and end and you can see that both start time and end time are in the form of an array that is in seconds, minutes, hours, days, months and years.

10:21

We also got a couple of add functions one for adding days to start time another for adding hours to start time and in both cases they give you the result in terms of date and time when the end time will occur and then We have our power off time UDFB.

10:37

This is the one where you may want to react completely differently with your control algorithm, depending on how long a machine has been powered down.

10:45

That concludes our webinar for today.

10:47

Thank you so much for listening.

10:49

And the Q and A session will begin shortly.

11:01

Okay, a relatively short one this morning.

11:04

I don’t see any questions in as yet.

11:07So as usual, if you wanna go back and watch any of the webinars, they’re available on the support tab the website under webinars and you can see all the ones we’ve previously done there and there will be links to registration for the upcoming webinars okay so with that I think we can leave it there for today and we’ll see you next time thanks very much