09-11-2015 09:43 AM - edited 09-11-2015 09:46 AM
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.
09-11-2015 09:50 AM - edited 09-11-2015 09:50 AM
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
09-11-2015 10:29 AM
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
09-11-2015 12:35 PM
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!
09-11-2015 01:36 PM
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.