Friday, May 15, 2015

Database with LabView


Today the exercise is to do a simple program that can interface with a database, we can insert data on LabView and it will comunnicate with the database and save that data and also read it to make a graphic of those values. Probably I’m not being so clear here and probably the next video will show you how it works.



In order to make this happen I have created three (3) subVi that are for Creating the database, Inserting data on it and last reading the data on the database.

Those SubVi will talk to the data base in SQL programming language giving commands to do a specific task.

The next picture shows how the create table diagram is and you can notice we use the command:

- CREATE TABLE NameOfTheTable (ID CHAR(12), HOUR CHAR(12), MINUTES CHAR(12), TEMPERATURE CHAR(12)) –

It will create a table with the name given for the user.

Create_tabla

This other picture shows the SubVi for inserting the data on the table we just create or even other table that already exist, but since this is a SubVi I will use the same table we just created with the following command:

-INSERT INTO NameOfTheTable (ID, HOUR, MINUTES, TEMPERATURE) VALUES(HOUR, MINUTES, TEMPERATURE)-

This is other command in SQL, and it will insert into the table on each column each values that are given by the user.

insert_into_table

Once we have inserted the data on the table we wan to read and then make a graphic with that data, so for that I also created another SubVi for reading those values (as you can see in the next picture).

In this SubVi I used the command:

- SELECT HOUR, MINUTES, TEMPERATURE FROM NameOfTheTable -

Read_table

Now you’re probably wondering how all this happened, well the answer is simple, I used all these SubVi in a main Vi that work in a loop until it finishes all processes it has to do.

That is a While loop that inside has a case loop for each button state, the first one (as you can see below) is the one I never erase which is the timeout case.

Base_datos1

In the next picture you see how we have the create table case that uses the “create table” SubVi.

Base_datos2

In the next case which is the insert data case using the “insert data” SubVi

Base_datos5

In the picture below you’ll see how in the “read table” case we use the Read table SubVi

Base_datos3

And last we have the case to make the graphic or to plot the values on the graphic.

Base_datos4

It is very simple to do and it doesn’t take that much time for doing it.Also as you saw in the video the data is transfer almost immediately.

You can download the files in this link:
File name: Data_base.zip
Version of Proteus 8.1







No comments:

Post a Comment