LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Create a digital clock

Hello,

 

I am trying to build a digital clock in LabView. The problem is I have to show my teacher all the boolean expressions for it. Therefore I cannot simply use the built in Get time/date string function. I have to build it with some kind of ticking clock that starts a loop, which is adding 1 every 60 seconds to an indicator showing minutes.

 

So the problem: How to add 1 to an indicator every time after 60 seconds? 

 

I should mention that, in the attached picture, I use 5 seconds instead of 60 to remove the need to wait 60 seconds for the case loop to add 1 to the indicator.

 

 

Message 1 of 5
(5,056 Views)

The right way is with a shift register.  It is basically like a variable in other languages (but not really).  It allows you to put data in a place, and the next iteration of the loop you can read that data without passing it into controls which are really just meant for the user to see things.

 

You can put your minutes in a shift register, then if a condition is right, add one two it.  If the condition is not right then just put the same value you have.  Each iteration you can display whatever is in the shift register by wiring it to an indicator.

 

Also the output of your Elapsed Time has a boolean of Time Has Elasped.  Just use that as your condition of 60 seconds has gone by.  You can wire a constant to the Elapsed Time and set it to 5 like you have to speed up a test.

 

Oh and in the future post code not pictures of code.  You wouldn't take a screenshot of notepad and post it on text language forums.  Attach the VI, or a snippet which contains the code.

0 Kudos
Message 2 of 5
(5,044 Views)

a few more notes:

1) Add delay (100 ms) to your loop (timing-> wait function). Now it loads one cpu core completely.

2) When using comparison functions, be carefull with equal. Greater or equal is safer. For your rates (especially running at top speed - see above) it will not skip second, but when running fast, it can miss strict condition. Also, if you put greater or equal than five, you do not need rounding.

3) Snippets are better than VIs because code can be seen right in the browser, also Vis can not be open in earlier labview version

0 Kudos
Message 3 of 5
(5,021 Views)

I gave you a kudo because:

 

You made it clear you were a student.

You made it clear that this was a homework assignment.

You came here with a couple of examples.

 

This is the hallmark of someone who wants to learn.  Someone who came here to have us help you with your homework, not to help you do your homework.

 

Awesome!

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 5
(4,991 Views)

I would recommend using this code to start your clock rather than the Elapsed Time express VI.  This way seems more clear to me because the Unbundle by Name provides your wire labeling. As Hooovahh mentioned, you'll want to add some shift registers to your loop and initialize them with these values to get the process started. 

Example_VI_BD.png

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 5 of 5
(4,965 Views)