LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using shift registers within a sub vi to record one instance of value.

I have created a sub vi to record a boolean value to an SQL database. The problem I have is that the value is constantly being written to the database. I have used shift registers before on stand alone VIs to record a new numeric value once only when it has changed. I have attached the simple VI to help explain. I'm not sure if I have to use some sort of single dimension array in this case using a Array Size vi and Index Array vi as was used in previous standalone VI. Anyone who can help much appreciated.

Antoni University of Dundee
0 Kudos
Message 1 of 11
(3,803 Views)

Hello Antoni

the main part of your program is missing. attach subvi so we can look at it.

i dont understand what you are trying to do: if you want to record only when the value change, you will get an array of alternating true-false. if you need a time stamp, you actually dont need the boolean value itself. to do that, a shared variable might be of use to you, as you can poll it to check if data has change (the shared variable includes a time stamp), on a standalone external application (or other vi).

 

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 2 of 11
(3,795 Views)

In order to use a shift register, you have to have a loop. The simple example below shows how you would compare the current value with the previous value. Note that using the Equal function on floating point numbers is still going to give you a lot of writes to the databaes. You'll want to decide on a how many digits of precision you want to use. Then, instead of the Equal, you could use something like the In Range/Coerce function.

 

p.s. Also note that I cleaned up your wiring. Try to keep a neater diagram.

Message Edited by Dennis Knutson on 07-27-2007 11:58 AM

0 Kudos
Message 3 of 11
(3,788 Views)
What I am trying to do is create a sub vi to register to a database table called sensorlog. I have a InfraRed thermal scanner looking at a cooker. When the temperature rises above a predetermined value i.e. 30 I want it to write a 1 and when it falls below i.e. 30 then it has to write a 0. At the moment it does this perfectly well only, it keeps on writing this value every 1.5 to 2 secs and will fill my db with a lot of uneeded data. I have now included the full .llb file.

0 Kudos
Message 4 of 11
(3,778 Views)
If you just want to log when the result of the Less or Equal changes, wire the Boolean to the shift register and compare the current comparison to the previous.
0 Kudos
Message 5 of 11
(3,775 Views)
How can I put in a while loop on a sub vi? Or can you?

I've not been using Labview for long hence my inexperience.
0 Kudos
Message 6 of 11
(3,769 Views)
To insert a while loop, go to the Structures palette, select the while loop and drag it until it surrounds your existing code. Notice that in the example I showed, the termination terminal has a true constant wired to it. That means that the while loop will execute only one time. You code will execute just like it did before. The while loop is only there to hold the shift register.
0 Kudos
Message 7 of 11
(3,766 Views)
In addition to your 1s and 0s, you should also write a timestamp to your database.  Just use the Date/Time function.  This will give you a record of when the temperature threshold was crossed.
- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 11
(3,746 Views)
If you have a look inside the vi in the case structure I have a timestamper and table lables built into the DBWrite.vi Thanks all the same.
0 Kudos
Message 9 of 11
(3,730 Views)
Thanks for all your help guys. I'm confident I'll get this sorted now. Going on holiday now. If I have any more probs I know where to come.
0 Kudos
Message 10 of 11
(3,724 Views)