LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to click 'Run' button at the start of the day, and 'Stop' button at the end of the day automatically or programmatically?

Solved!
Go to solution

Also, i am using labview 8.5 (released around 2007) and i am not sure what the error line does, I am still learning i will look it up.

0 Kudos
Message 11 of 13
(392 Views)

You are making this much too hard.  Think about the LabVIEW TimeStamp.  It is a LabVIEW data type that expresses time as "seconds since 12 a.m., 1 Jan 1904 (UTC)".  [12 a.m. is time 00:00 on the 24-hour clock].

 

Suppose you want to know "How many seconds is it from now until the clock first reaches 9:00 a.m. (which might be tomorrow, if you ask in the evening, or in a few hours, if it is just before dawn)?

 

Get Date/Time in Seconds returns a TimeStamp value of "now".  If you wire it to a TimeStamp indicator, you'll see the current time.  You can also drop a TimeStamp Control on the Front Panel, and fill it in with 9:00 AM "tomorrow".  Here is a Block Diagram showing these two operations:

Seconds until 9 am BD.png

 

[Because I named my TimeStamp constant on the Front Panel, shown below, as "9 am tomorrow", when I wired it to a TimeStamp Indicator, LabVIEW added the suffix "2" to help me keep them straight].  So the two TimeStamp indicators, "9 AM tomorrow 2" and "current time" should show dates of "tomorrow" and "today" and times of "9:00 AM" and "some time in the evening".

Seconds until 9 am FP.png

 

OK.  Build this for yourself.  Now, remember that the wires going from Function (or TimeStamp) to Indicators (TimeStamps) carry data, which (according to NI) is "time in seconds".  You know the time "now" (lower wire) and the time "tomorrow" (the upper wire), know it is "time in seconds", and you want to know "how many seconds from "now" to "9 AM tomorrow".  Think of an operation you could do to two data "wires" expressing Time in Seconds that will give you "seconds from Now to Tomorrow at 9 AM".  Go code that function, and connect an Indicator to the output (just for fun, right-click the output "node" and choose "Create Indicator" and let LabVIEW decide what type it should be.  Run the code and see if it makes sense to you.

 

Does this "solve your problem"?

 

Bob Schor

0 Kudos
Message 12 of 13
(340 Views)

@lorc34 wrote:

... and i am not sure what the error line does, I am still learning i will look it up.


Many LabVIEW functions (and almost all of the VIs that I write) have Error In and Error Out on the lower corners ("In" on the left, of course).  They are very useful, particularly if you want to write "beautiful" LabVIEW code (meaning code that is visually appealing and easy to understand).

 

First, what does it do?  Well, remember that LabVIEW is a "Data Flow" language.  What if you bring some data into a Function or sub-VI and "do something illegal" inside (like "divide by 0" or try to open a File that doesn't exist?  You generate an Error (sometimes a useful one that gives you a clue what you did wrong) and a message that tells you where the Error occurs.  

 

Another "unsung hero" duty the Error Line does is keep your functions lined up nice and neat (if you move them around so the Error Line is nice, straight, and horizontal).  It also is a very easy way to make sure one VI runs before the other, particularly if they don't otherwise pass data between each other -- the Error Line acts as "data" between the two VIs or functions.

 

It took me about a year of using LabVIEW before I began to understand LabVIEW "Style" and the importance of neat-looking code.

 

Bob Schor

0 Kudos
Message 13 of 13
(336 Views)