Data Logging and Monitoring LabVIEW Project

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi in this video I will give an overview of the data logging and monitoring application I have made with the lab you I will show the LabVIEW cold which is behind the application and go through the larva code in details let's open the lab you code in this application I having a used LabVIEW project sign and I just open the lab your project file how here so you see here I made a structure folder called main where how the main application so just double click on this one here you see the main application or this data logging and monitoring application and under starry eyes I put all the surveys that are created for this application on the resources I put different resources like any files or configuration files a database file about user guide have some icons that I use when I create an executable application of the lab u code etc I also as part of this application I have made a web service which you find here in order to create new folders you can just right click on my computer I'm select new and then you can easily add new folders etc in order to have a good structure of your code so let's open our main application the data logging dot V I so here you see a front panel of this application it consists of a top folder with different tabs one for one of the tabs the first tab showing a chart of the values so in this app this application or used to load data from different duct devices from National Instruments in this example I'm in just show whole you can use and the USB system doesn't hate the long game data into this application on the data folder and created two-dimensional table where I will show all the data from the different channels connected to the dr. Weiss channel settings here I have created different input fields or for the device a device type device name etc and here you have information or settings about the different channels so in this application you can have up till 32 channels and then you can just browse through the channels clicking on these buttons and you have this logging tab very high settings about the logging the long interval can use a low pass filter you can also choose to log to a to a file etc so then you have you to all or set all the settings you want to keep and you can save with this save configuration data and then all these settings will be saved in a configuration file and then you are ready to to start logging you can just click start the DAC and the logging will start and then you can choose and just showing the values in this chart and in this array where you come log to a file but you can also log to a database or a cloud service so let's take a closer look at the code behind this application so and then I can just click ctrl e to throw the code and here you see how I loop here at the top and also have a value pair at the bottom so in this application I have made two while loops that is running in parallel this upper while loop is handling all the graphical user interface interaction with the user so when you click some buttons etc this this loop handle all this interaction so we have here in the mate I have this even structure that handle all interaction with the users in the lowest while loop is while loop Andals in parallel that the data logging from the dock device so the good thing and by having two wire loops in parallel and these two loops don't interact with each other because then when they use to click some buttons etc this logging loop is doesn't influence on that one because then and the user can click buttons set some settings while logging is running in parallel without interruption I'm using a technique called the state machine so you see here in this while loop inside the while loop I have what you call a case structure it's happening all the cases in this case and also I use shift register you can create shift registers on the value just I click on the border and select add shift register so the way this state machine is working and first we have an initialize state so when the program starts the program goes into the wire loop select the proper case in this case initialize and then the contents of this state is executed and then when all this has been executed it goes to the next state which is open configuration data which we find here so here I am select or get all the configuration settings from the configuration file which is stored on the hard drive so let's open the configuration file just go to the file browser and all the configuration is stored in this configuration file so let's just open it so here information about the device is stored here the information about the logging is stored here here are also information about the database and the different channels you can hold up till of 32 channels so you start from channel 0 1 2 3 1 and then you come and store here the measurement name if the channel is active physical Channel and the minimum voltage and maximum voltage of the different channels and also the engineering unit used in this case Celsius etc so you can set up till 32 channels this is where I get all the settings from the file next I set some measurement names in this case I update update the information here based on the name of the different channels I update measurement name and from this file this information is stored in file but you can also change it here in your channel settings here in addition the column headers are also including the temperature also read the measurement name and units like this that's not happening in this case so as you see in this case I used a for loop so since we how can have multiple channels and you need to go into for loop for each channel and do this and this coding here I used a variable a local variable here I've used what we called a cluster which you find here the cluster Alette and here this is what we call a property node so each control or indicator on the front panel I can have one more more property nodes you create a property node by just clicking on the control and then right-click and create property node and then you can select the properties that is available for the different controls and indicators like this then I can this can just select key focus and then a computed wherever I like within my code here I've used different if I click ctrl H you can see different functions built-in functions are used in this case and just convert number the decimal string here our use the constant and conjugate string in order to to build a total string based on these sub strings also used it here here so here I've used to string a subset function just in this case since there are limited space on the front panel here I just give you choosing our long measurement name I just show the first 11 characters on the front panel like this so so far I'll use different loops I use the for loop here I use the case structure and how used by loops all these things you find it in a structural palette so here you have the for loop the while loop and the case structure and next and this code is finished it goes to the weight case the weight event and let's see what's happening there so wait here I have used what we call our event structure you find the M structure in the same place as the for loop while loop acceptance we find it there even structure and so this even structure is used to handle interactions from user so when I use the clicker button etc you won't typically want something to happen for instance in this case if you click the save configuration data button then I have created an event for that one so then you click the person click this button the cold goes into this event structure and then do the code which is inside here in this case I haven't put so much cold inside here instead I have set here which case the code should go to next so in this case the program should go into the save configuration data event sorry the case so it comes into this one and here it's the opposite of opening all the settings from from the file in this case are just all the information that is stored here in the channel settings on the loading setting and then saved to your text file in this case and this duct settings 5 let's see how these files are work and working so this these are Serbia's that I have made all these Savi eyes and then placed in this API folder in the project Explorer so let's open one of these surveys so here the left side are the inputs on the right side there are outputs of this survey and then you see the connection pane inputs and outputs so that's open block diagram for this this one so as you probably say I also use the state machine and principle in many of the study is in this case and the surveyor starts to execute it goes into the image lies in a case which is here in this case it just opened the configuration file and using the build path function I'll use there I've used the application directory function in order to file the folder which is this application is located and then just select or right here in a string constant the name of the file and then I'm just build a total path to the file using this wheel path function and then I use the open config data and function in order to open the file and then and this is Tom it goes to the next case device configuration which is here so here adjust input to this file ask is device settings which is this is what we call a structure I'm sorry what we call cluster so a cluster I can contain different controls like this then using a cluster it's then you can just then you just need one input to the survey I instead of in this case 1 2 3 4 input so we just I collect different controls into one cluster like this and then you can get information about different controls within the cluster using this I'm bummed by name function you see here yeah device type device name dark M mix name and the terminal wiring and again get out the data inside here using this unbundling function in this case I just save all the data or the value stored in this cluster cluster using the right key and VI cell VI in order to store information in the configuration file and then this T system it comes to the XE case and then it just close the configuration data and then I see here I'll put this to true which means a while loop is stopped running and this survey also stops running and then it goes back to the main program undo the next part in the main program and it let it happen it has saved all the information into the configuration file it go back to the wave case and just wait here until the user clicks on new button so let's assume and the user clicks a new button in this case I assume the user clicking the start back button then it goes into this even structure fine start back button event you can easily create new event in just right click on event structure and select add event case and then you can easily add new events for the different controls on your front panel in this case and music and clicks the start back button in this case I've used on my property notes and any button and used to click this button it Gray's out and disable the button because when you clicked it you don't want to click it once more so then I just disable the button and make a gray and also the stop back button I make sure this this button is enabled and not gray so you're able to stop the duck or the logging and ever you like after you all start at the login and then then hold on that I go to a new case called the check device so let's see what's happening inside that case check device here since you're going to log data from the duck device I just start by and check if the device is working properly so I just use this building function which is using or performing a self-test on the duck device and check if the device is working properly and is if it's connected problem if that's okay and this function gives no error you see here are connected error in our out of this function so if our out gives no error M it goes into this no error case you can see i connected the error cluster you see if I open this it is something error cluster if this error cluster contains no error it goes into the no error case and I can't connect and a cluster there and directly into this question mark on the case for the case selector on the case of structure like this and then if there are no error it goes to in each load a in each slice duck case which we find here but if there are some error it just do nothing and go back and to wait it pops up some error message let us assume there are no error and then you're going to initialize the duck device so here in this in case based on the logging interval you set here on the front panel I just use this multiplier in order to make sure the X scale or the time scale is a correct or according to the proper logging interval so you can also do this by right click on the chart component and select properties and then you can set the properties here on scales on this multiplier and it seems in this case you can change the logging in twelve at run time and you need to use a property node in order to change this information while the code is running so I can just in order to create that I just right click on short select create property node and then I select the proper property node to find it here on the X scale next based on the information that device settings each user enter here I want to initialize the dark device and also the channel information then I have created a Sophia called duck in initialize let's open this serviette so input to this Sevilla is the device settings and shadow settings and also how error in an error cluster and then let's go to the block diagram for this one so in this survey I based on the device settings and the channel settings and then I have used here I come just right click on the cluster to create this unbundle by name function inside here I can select all the controls that are inside the cluster same here in the channel settings to see here in the channel setting this is an array of clusters you see how this I right here you can create an array like this you find array this is just an empty array and then you compute whatever you like within this array you can also pick two clusters or whatever but since this is an array I need to have a for loop so I can go through all the elements within the array then inside the for-loop I can use this on Donald function get information about the controls within the cluster for each iteration in the for loop in this case I just used the doc MX create virtual channel in order to initialize the channels that are setup in this channel cluster and then I just set the minimum voltage and the maximum voltage and the physical channel name based on the information that the user is entering so I'll set this information on using this disability in function if the channel is not active I just do nothing in false case in this case that's this function just close it yeah if the in each slice of the duck device is working without any error and I just have a local variable that I set to true that is starting the logging and then since the logging is true and the logging is handled in the lower while loop here so in the program here starts it goes to initialize and then it goes to check and here it's just checking at this intervals so every here I have the logging interval um this one is waiting for the next logging interval and then it checks if this logging variable is set to true if there are no error in the arrow cluster then it starts reading value from the duck then I use this clever function this select operator based on the input if it's true or false with it's true I go to the red duck case if not it's set to true I just go into the check case once more I'm just checking until this is true let's see no this is should be true so then the next case should be read duck so let's open this one so here I get the values from the duck device so if the logging is true it goes into this case if not I just do nothing in the false but in this case it's true and also I can choose to use some random data instead of getting the real value from the doctor wise in this case this one is false so then it goes into the false case here you see here our case structure here on our case structure here and I have a case structure here this is starting to getting a little bit complicated but in this case it goes into this false case and them are using the disputing doc MX read it just read values from the analog input of the duck device and if I have configured to read from more than one channel where I can configure that to read from more dimensional the output here is some array you see this is an array of data that contains values from the different channels so I just store this information in in in this control that contains the values from the back device and then next I want to scale the values from the duct device so then I go to the scaling here so in the scaling case I also used a for loop since the input is an array of values from the different channels so then have you created the VI that is doing the scaling from from raw data to your engineering unit let's take a look at this code here it's quite easy I just use this linear formula known from mathematics and input to this function is the voltage minimum and a voltage maximum and an engineering unit minimum an engineering unit maximum and then use this form formula and to find this linear relationship between the voltage input on the engineering unit output here in this case I used what we call a formula mode and this formula node is handy to use and you want to create more advanced formulas like this here it's just an humble in order to get the proper values from this cluster if you are choose to use a low-pass filter which you can set on the front panel use low-pass filter if this is true em use low-pass filter is true and then this part of application is executed and then I just made survey I that is implementing an ordinary low-pass filter no so in this case and use this formula lo it is a formula for the low-pass filter then out here and scaled and the filtered signal is stored in two and new array and then next I go to the plotting case which is here so here I just plot and engineering unit unit values into this this chart on the front panel next I go to the data list case in this case I just update and this is two dimensional array with the data from the dr. ones here I have used some different building functions in LabVIEW here I have used a form at a time string in order to to set the date time or the values in this column I use the pinned array and here I'll convert from a number text string here I also use some property notes in order to fill this two-dimensional array with the data actually it's not a - it's a two-dimensional array but find it here on on the front panel on using the controls you find it here in the list table down 3 and set the palette so it's a list box like this I also made some logic here in the bottom so if the list here contains more than thousand data points I just emptied the list and start all over because if I store too much data in this list it takes to memory and too much memory next and I want to log data to the file I go to this case so if this logging data file is set to true I go into this cell VI so the input to this one is the channel settings an actual value this arrow cluster in a note here I've used this this is built in right to measurement file function which we find here and rest right click file i/o and then you have this white two measurement file refine it and then you can set a lot of information within this file file name on property so this this file should look like your concept headers if you want a column with the time series etc let me just do the settings here and click OK and also I'm use these set dynamic data attributes in order to set columns within this logging file so on the measurement name which accept English Channel setting I'll use that's the column name and within the file and since you can have multiple channels this one is running inside afforded next and when I say the information to to a file the data to a file and then I come next I want to log the data to the database so assuming you have turn on this logging data to SQL Server database and you can also save information to the SQL Server database so if this know being is set to true and this database connection string with the server name database name username password is correct and then I'll click connect in order to connect to the database if everything here is true then I start saving the data to the database and then I made a survey of that let's open this subject so the input to this survey is the connection to the database which is just our random shadow settings data set so let's open of block diagram since there are can be multiple channels this information goes into a for loop and then I have used my own SQL tool kit in order to save data to the SQL Server you can just in order to use this toolkit you can find the functions palette and then you can go to SQL and then you see the different functions within this sk8er kit so you have a function for open a connection to the database you have a function for inserting data to the database called SQL execute so here you can insert statement or using stored procedures which I have used in this case if you want to get data from the database you can use SQL select function when you're finished you can use the SQL close function Octus and this one this toolkit you can download it for free from my web page then I go through all the channels and if the channels are active then I just get the measurement name from the channel settings and I get the values from this array and then this is input to this format into string and then I build up the string query string that I insert into this SQL execute function it has a connection in and this SQL query which is the query that is executed on the SQL server not storing information to the database next you can also store information into a cloud service like this I'm not going to details here but if you turn on this and this feature and information can be stored on this web service and then you store information into this web service you come later use on your web browser or an application called data that sorry and date gap you and this application is called the data - pork lab you which is an application that you can use for free and you can download it either on iPad or on Android devices so either you can download it from the Apple App Store or the Google Play and then you can start using that application together with this logging application in order to get data on your iPad and then you can get sharks etc using this this application and next in in the executing execution here and go to the next case called error so if there are some error I just store the information in an error cluster and then next I go to the check case now then I wait for the next logging interval and then checking if the logging is still true and then I go all through all the cases once more I get this that's a basic implementation of this application so you can create quite an advanced application using these and basic features in LabVIEW your while loop case structures you have shift registers your Serbia's and you have local variables on your property nodes etc and you how so this event structure that is handy to use and you want to to handle information that is happening on the user interface and the user clicks buttons etc so here I have all these events force and user click the start but dock button the stop back button if it changes this logging interval etc here if you click these buttons in order to go through the different channel settings then the code goes into this this event structure if you connect to the database and clicking this connect button it goes into this event and then connect to the database and do the cold inside here and then it goes back to eight an eight run new user interaction here I have different buttons here on help save the user click on this Help button and I just open also right click on this this home button and it just opened a web page in this case open URL in default browser this is a hand if Soviet use which is built into lab Europe here and help I click this Help button it opens and the user guide which is a PDF file which is stored in the same location at the last application which you find here and energy just use this open Acrobat document VI and this function is also built into LabVIEW here clicking video not just open a web page in a link to the YouTube video I made which is explaining this application so now when I have gone through the cold in detail let's start application so just clicking the Run button an application is starting and I can go to the channel setting and set up a proper device settings in this case I just want below a temperature value from my USB six thousand eight dollar device and then I set a unique name here I select the proper duct MX named and also setup and the wiring in this case I just used referential single-ended I have this and in this case I'm just using channel number 1 or 0 analog input 0 I set a name in this case temperature I set up a voltage in v the minimum and the maximum and a unit and then in this case and it should be scaled from 0 to 30 degrees Celsius when I set up all this I can just click Save in order to save it do this this this find here so then next time I open this application this information should be getting should this application should get this information from the file so I don't need to enter all this information on smoke or every time I open application and and are setting the logging information I want to discuss just for demo log every second just want to link it to a file I come along the database file is here and I click this show database settings I just show one new folder in the tub folder here and then I can click here the data to SQL Server and then I can setup the database connection and I can connect to the database and then it turns green I'm connected to the database I now Don all these settings I can just click start back and the values from the doctor wise is starting to shown in the plot here so also I can scale it the the y-axis come since this is just logging the room temperature using a temperature sensor I can put it from 20 to 1055 or something this is in temperature Celsius and I can see also data in this this array you see the latest value is always on the top pair on the historical data is stored here in this array then I've finished logging I can just click the stop to that button so let's open this folder to see the information that is stored on the file I just locate the folder on here you see here is the measurement file it is storing some information on top here in the header and then the data points are stored here in these different columns here and times time value on the x-axis on here I have the temperature value in this column I can also open my SQL Server see here are my database with the necessary tables and then I just select all from measurement data which is the table that all the values are stored so I can just run this query and then you see here the values are stored in in the database entities so basically that's the basic features in is data logging and monitoring application next I will show you how you can create an executable file or even make a a setter package for this application so then here under build specification you can if you are right click here you have different options you can make a next executable application you can make an installer package etc run also make a seed file if you want to distribute a source code to other users let's start with the executable file so then I have open this configuration so here you can set different settings for the executable file you can set the name you can include startup file additional files etc here is destination where you are building the executable file you can also include an icon and you have some other settings as well and then you can just click build in order to build the executable file and then also next you can create an setup package which means that you don't need to have a lab you in order to run the application if you just use the executable file you need you don't need to lobby on your computer but you need to have or install they'll have your runtime engine if you make unexcusable it's right in make up a setter package and you can also want to include the runtime engine within this setup package so then you can just run the setup exa in a setter package lobby runtime will be installed and also your executable application will be installed and you can setup shortcuts etc that is appearing I don't own the desktop or in the Start menu in Windows so here you see the results of this an applic build on the executable and then here is the executable file here our additional file that is it that are included setting files or the configuration files they use the ride is here etc so then I can just click on the data loading exam and here I start in application without LabVIEW so this is using the LabVIEW runtime engine in in the bottom and also see here I got a new icon which I have included in in my set package and I can use the application start the doc start logging etc and then I can then distribute this application to two users that want our LabVIEW on their computer so that's all you can download this application and also the lab you code for free on my home page and you can use it as it is or you can make any changes that you want so good luck with your data logging and monitoring applications
Info
Channel: Industrial IT and Automation
Views: 40,990
Rating: undefined out of 5
Keywords: LabVIEW, Datalogging, Monitoring, Database Systems
Id: FFnvYu7jjeI
Channel Id: undefined
Length: 52min 7sec (3127 seconds)
Published: Wed Oct 04 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.