LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to compare system time with set time to on/off any LED

Dear Friends,

how can i compare system time with set time by user to turn on/off any LED.

Let say i want one LED to  turn on every evening at 5pm and turn off every morning at 6am???

 

Thanks,

Asif Iqbal

0 Kudos
Message 1 of 10
(3,898 Views)

You can do this.

0 Kudos
Message 2 of 10
(3,888 Views)

not working...Smiley Sad

0 Kudos
Message 3 of 10
(3,878 Views)

Hi Asif,

 

sure the example is working!

 

Maybe your implementation is buggy?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 10
(3,872 Views)

@Asif138 wrote:

Dear Friends,

how can i compare system time with set time by user to turn on/off any LED.

Let say i want one LED to  turn on every evening at 5pm and turn off every morning at 6am??? 

 


Hi, Asif.  Can I assume that you are just learning LabVIEW, and maybe are also fairly new to Programming, in general?

 

The first thing to think about is how do you really want your code to function.  Suppose I read the time and it is 5:01 PM.  What do you want your code to do?  Suppose it is 5:00:00.0001 PM.  Note that it may be "highly unlikely" that the time will ever be exactly 5:00 PM.

 

The next thing to think about is that you are concerned only with a 24-hour clock, not with the date.

 

Closely related to the first point is how often you want to check the time.  I assume you don't want the program to spend 99.9999% of the time checking-and-doing-nothing because it is not "turn-on" or "turn-off" time.  If it "wakes up" and checks every 5 minutes, then 99.9999% of the time the computer can be doing other, more useful, things, and you'll turn on and off "close" to the right time.

 

Take a look at the Seconds to Date/Time function, and read its Help to see how it works.  You can use it to give you the Minute (0 to 59) and Hour (0 to 23) when it is called.  That, and a little logic (and possibly some arithmetic) should provide a solution for you.

 

Bob Schor

0 Kudos
Message 5 of 10
(3,860 Views)

It works buddy.

here i am posting the vi.

Try by modifying your system time and modify the desired time in string constant.

0 Kudos
Message 6 of 10
(3,844 Views)

@sridhar..reddy wrote:

It works buddy.

here i am posting the vi.

Try by modifying your system time and modify the desired time in string constant.


And exactly how does that answer the question?

 

That VI return a True for only 1 second of the day.

0 Kudos
Message 7 of 10
(3,841 Views)
0 Kudos
Message 8 of 10
(3,801 Views)

Hi sridhar,

 

comparing strings isn't the best idea you can have! Your example will also result in TRUE for a string input of "05abcdef"…

 

When you want to compare numbers you should stick with numbers:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 10
(3,793 Views)

yes you are right.

Thanks.

0 Kudos
Message 10 of 10
(3,788 Views)