0:01
on this webinar on advanced data logging using structures.
0:05
It’s roughly about 15 minutes but if you have any questions just put them in and we’ll get them at the end.
0:11
Hello and welcome to today’s webinar. In this webinar we will look at advanced data logging using structures.
0:19
Here is the agenda for today. We will start with two quick reviews.
0:25
First of the data logging feature and then of the removable media function blocks.
0:31
After those quick reviews we will then look at the right structure removable media function block.
0:38
Then we will discuss Excel and the numeric date and time formats.
0:43
There will be demonstrations of everything throughout and we will finish with a Q &A session at the end. Let’s begin. What is data logging in Horner controllers?
0:53
This is a feature which allows controller to record machine data as described by the system designer.
1:00
This machine data is recorded to a.csv file, making it compatible with a wide range of spreadsheets and other data analysis tools, including Microsoft Excel.
1:12
Configuration is straightforward and only requires a few steps to set up. Why use this data logging feature?
1:19
In the modern age of automation, machine data is increasingly important.
1:24
Data logging allows you to extract more information than ever from your machines, including process validation, machine efficiency, historic operations, diagnostic information, and more.
1:39
How do we use the data logging feature?
1:42
Data logging files can be recorded to either microSD card or USB drive on your controller.
1:49
Data logging files are configured as groups of variables. You can have up to 30 variables per group and up to 100 variables total per application.
2:03
Each variable in a group will be recorded at the same time.
2:08
Data logging readings can be taken on a configured in Cscape.
2:15
These readings are saved to data logging files which can be created daily or hourly depending on the sample rate.
2:23
This restriction is built into all controllers with the data logging feature in order to keep file sizes reasonable.
2:30
In today’s webinar however we are going to demonstrate how to get around this restriction if instead you want to save your data logging files once per month, once per year, or at any other time interval.
2:44
The way we are going to do this is by building a custom data logging function using the write removable media function block.
2:52
These are very powerful but can be quite complicated and a bit intimidating at a first glance.
2:58
These function blocks write data from OCS variables to a file and are quite useful for a range of applications, but can be a bit complex to first set up.
3:09
One limitation of the WriteRemovableMedia function block is that they can only write one data type at a time.
3:16
If multiple data types need to be written, you must cascade multiple function blocks in sequence.
3:23
When dealing with a large dataset, however, this can quickly get overwhelming, so we will not be using this method today.
3:30
Instead, we will look at the WriteRemovableMediaStructure function blocks.
3:37
These write data from OCS variables to a file, but they do so from a structured variable and without type restrictions.
3:48
These function blocks can support multiple data types in a single write without any problems.
3:55
They also require much less setup and are easier to work with.
3:59
Here, in the top right corner, we can see an example of a group of variables.
4:04
This group is named parameters, and features a selection of fairly common variables that might be used in automation control today.
4:13
There is also a range of data types used by these variables, including integers, real numbers, booleans, and so on.
4:23
Below this, we can see a row of data from Microsoft Excel.
4:26
with all our variables in the parameter group recorded within it.
4:31
And we can see that despite there being different data types, all the variables got recorded and stored correctly.
4:39
This was done using a right removable media structure function block.
4:44
The only limitation, which you might have noticed, is the lack of ASCII support.
4:49
And this raises a question.
4:52
Without ASCII support, how do we handle date and time?
4:55
The standard data logging feature creates and writes the ASCII date and time formats automatically.
5:02
By contrast, the Write Removable Media function block only handles ASCII date and time if you build a custom string.
5:10
But to do this, you need to string together multiple function blocks, which is more complex than some users are able to work with.
5:17
The right removable media structure function blocks, however, that we’ve just looked at, do not handle the ASCII data type at all.
5:27
However, all hope is not lost, as Excel and similar database programs don’t require date and time functions to be stored exclusively in ASCII format.
5:39
Here we have the numeric date and time formats available to most database programs.
5:45
In general, computer programs often store date and time in numeric form rather than in ASCII form.
5:52
This is because it’s easier to work with date and time mathematically when they’re stored numerically.
5:58
Excel specifically has two alternative formats that we will look at today.
6:03
Date can be stored as a double integer, and this counts the number of days since January 1st, 1900.
6:11
And time can be as a floating point number, which counts the fraction of seconds past midnight.
6:18
These two together allow us to deal with date and time much more easily.
6:23
However, they do require some extra function blocks to convert them to an Excel readable format.
6:29
To make this easier, we have created some user-defined function blocks for you that convert the real-time clock date and time value in a Hornet controller into a date and time value in the Excel format. So with all that covered, let’s put everything together.
6:45
In the following demonstration, we are going to show you how to use writeRemovableMediaStructure function blocks to data log data at custom intervals.
6:56
To do this, we will create a structure containing the variables you want to data log.
7:01
Then we will create a variable instance of that structure.
7:06
Then, to ensure our date and time variables are stored correctly, we are going to use the custom Excel user defined function blocks to convert the values of our date and time variables that we created in our structure.
7:21
Then, we will use a single write removable media structure function block to handle creating and writing our data log file.
7:30
Finally, we a bit of logic to trigger all of our function blocks.
7:34
With that covered, let’s get into our demonstration of data logging with the write removable media structure function blocks. Here we are in Cscape with our demo program loaded up.
7:49
To start, navigate to the program variables window using the button at the top.
7:54
Here we can see several structures that already exist, some of them by default in Cscape 10.
8:01
To create a new structure, right-click somewhere in the Program Variables window and select Add Structure.
8:09
This will create a new structure.
8:11
If we right-click on it, we can give it a name.
8:13
After that, we would go ahead and create all the variables we want to log and place them into this structure.
8:21
However, for this demonstration, we have already created and populated a structure.
8:26
Here, we have oven, which is the structure we are going to use for this demonstration.
8:32
Inside, we can see a wide range of variables in our structure, with a few different data types.
8:38
To use this structure, we first need to create an instance of it as a variable.
8:43
This lets us call our structure more easily in our logic.
8:48
We have created ours as a retained variable named process, with a data type of oven, which is an available option because oven is a structure.
8:59
So when we are writing our logic, we will be able to reference parts of our structure.
9:04
For instance, process dot date underscore double integer will return the date value to us. Process dot time underscore real will return the time value.
9:16
Process dot temp underscore set will return the set temperature and so on.
9:21
We planned ahead and We created these variables for our machine with the knowledge that we would use write removable media structure function blocks for data logging.
9:32
This means that they are already directly referenced, so when they are populated with data at runtime, our function blocks will be updated directly.
9:40
If you are adding on this type of data logging functionality to an existing program, you will need to create a bit of logic to write the values of existing variables to these variables in your new structure. This is all that is required for most of our variables.
9:57
However, for date and time we need to do some extra work.
10:02
To correctly convert our date and time values to an Excel-ready format, we are going to utilize these custom user-defined function blocks.
10:10
We imported these by right-clicking on Logic Modules and selecting Import Logic Module.
10:17
This will open a File Explorer window and there we can navigate to the UDFB file locations.
10:24
Once imported, your user-defined function blocks will appear under UDFB modules.
10:29
Then, simply navigate to the project toolbox, which should now have a UDFB tab, and you can drag each module into the programming area.
10:40
These user-defined function blocks are very simple.
10:43
For the date underscore now UDFB, it only requires your date variable in your structure to be assigned. We can do this by using the drop down provided.
10:53
Then for the time underscore now user defined function block it only requires your time variable in your structure to be assigned, again using the drop down provided.
11:05
With those assigned we can now start working with our write removable media structure function blocks. This is located under the removable media tab in the toolbox.
11:16
Specifically write to ORM structure is the block we are looking for.
11:21
Once it’s in our programming area, we can start configuring.
11:24
First, we need to assign a filename.
11:26
This is also how we would assign the file’s location.
11:30
In our demonstration, we have decided to store our files in the root directory, so we can simply enter our filename.
11:38
If you want your files to be stored in a specific location, simply add the address before the filename.
11:44
Our file is named log underscore dollar sign y underscore dollar sign m.
11:52
The dollar sign y and m stand for dollar sign year and month.
11:57
These are wildcard characters which will change into the current year and month when the file is created.
12:04
Then we choose.csv as we want to use this file for data logging.
12:09
Then for source address this should link to the structure we want to record.
12:13
so in our case we have chosen process which is the name of our structure.
12:19
Then we have to assign a status variable to ensure everything is working correctly.
12:25
For mode we can select create slash append which means a new file will be created if one doesn’t already exist with the same name and if one does exist with the same name it will simply append it.
12:37
Finally, we will check this box at the bottom for Write Column Headers on Create.
12:44
This creates the first row in our recorded data as a list of all the names of our recorded variables.
12:51
This is very useful in keeping everything organized.
12:54
And that is everything we need to do to set up the Write Removable Media Structure function blocks.
13:01
Before we move to the bench, we just need to assign a trigger bit.
13:04
This trigger bit will depend on how you want your data to be recorded.
13:09
If you want your data to be recorded monthly, then this trigger should occur on a monthly basis.
13:14
If you want your data to be recorded yearly, then this trigger should occur on a yearly basis.
13:19
The choice of how and when to trigger this function block is entirely up to you.
13:23
But once that is completed, we are ready to see if our data logging works at runtime.
13:30
Here we are on the bench, with a screen that is displaying all our variables.
13:35
We have also included a real-time clock on this screen for demonstration purposes.
13:40
We have set up our trigger bit to trigger every 10 minutes, so when we open the resulting .csv file, we should see a reading from all of these variables every 10 minutes.
13:53
We have also included a Log Now button, which will trigger our data logging when pressed.
14:00
Let’s now move back to our computer and take a look at the resulting.csv file that our program creates.
14:08
Here we are in Microsoft Excel, and this is the.csv file our program has created.
14:15
As you can see, all our data has been recorded, many times over.
14:19
This all looks to be correct, however our date and time seem unreadable.
14:25
To fix this we simply need to select each row and change the data type in Excel.
14:31
First we select our date column and under format we select short date.
14:38
As we can see, the numbers that were there previously have become dates, which seem to be accurate.
14:44
Then, we select our Time column, and under Format, we choose Time.
14:50
Once again, the unreadable numbers that were there before have now turned into accurate times.
14:57
Despite their initial appearance, we hope it is now clear just how simple it can be to use write removable media structure function blocks to create advanced data logging in Cscape 10.
15:10
That concludes our webinar for today.
15:12
Thank you so much for listening and the Q &A session will begin shortly.