Example Code

Clock using Boolean Arrays[1]

Code and Documents

Attachment

Download All

This simple example uses the system current time, converts this to a bitmask of booleans and outputs a 2D array display of the current time, complete with half second count.

Clock.PNG

Uses a high level VI for the timing, and a SubVI to convert the current time to boolean values

Clock_Code.PNG

Applications Engineer

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Arnoud
Member
Member
on

Using the "Format Date/Time String" function instead of the "Get Date/ Time" will solve localization issues with different time formats. Use %H:%M as format.

Arnoud de Kuijper,

Albert.Geven
Trusted Enthusiast Trusted Enthusiast
Trusted Enthusiast
on

And why use wait multiple ms, instead of the simple wait?

Wait multiple ms is mostly used in multiples of 50 ms so all LabVIEW programs that use this start computing at the same moment! Only use this when absolute timing is required and then realize that software timing never achieves that and so you should use hardware timing instead of software timing for that purpose.

Conclusion: almost never use wait multiple ms and especially not in examples

greetings from the Netherlands
tbob
Trusted Enthusiast
Trusted Enthusiast
on

When the hour is not a double digit number (before 10:00), the display is totally wrong.  For example, when the time string is "9:32 AM", the four substrings will be "9", ":", "2", " "(space).  The colon tranlates to a numerical 0, so does the space.  The display shows 90:20, which is wrong.  Code needs to be added to prepend a 0 when the hour is not in the double digits.  Obviously the author tested this code after 10:00 and before 1:00.

- tbob

Inventor of the WORM Global
Contributors