09-10-2014 01:17 AM
In a state machine I'm setting the current time for a process as the start time and adding 6 hours for end time in the initial state. Later in the 7th state, i can change the start time and the second/ms value rounds off (e.g. 12:30:00.000 PM) but the end time when changed rounds off to say 4:20:39.333 PM. But I want it to look like 4:20:00.000 PM. What do I do? [Increment value for both are 60, coerce down]
Solved! Go to Solution.
09-10-2014 01:21 AM
Attach your vi or a code snippet so we can see what you're doing, then maybe someone can comment on how to fix it.
09-10-2014 01:27 AM
tabs-FS is the main VI and 6hours is the subVI used. Look into Initialize and Scheme states of tabs-FS. Other subVIs are too large to attach. Thanks.
09-10-2014 01:41 AM - edited 09-10-2014 02:08 AM
For the indicator, truncate the wire value to a multiple of 60 using code, e.g. as follows:
Alternatively, you can change the display format to omit the seconds. (see image)
No need to show the seconds....
09-10-2014 01:45 AM - edited 09-10-2014 01:46 AM
Also note that the subVI code could be simplified dramatically.
You don't need to unbundle-rebundle all elements, just the one that changes (hours, top image)
Even simpler, add the number of seconds to the timestamp (bottom image).
09-10-2014 02:07 AM
@altenbach thanks for the simplification for addition of 6 hours. but the rounding off problem still exists. even though the display format is as required, the exact values in the probe watch window show the 39.333s in the end time. As this is to be implemented for a practical application later, it has to be exactly 6hours, cannot have the 39.333 seconds
09-10-2014 02:53 AM - edited 09-10-2014 02:54 AM
@shreya005 wrote:
As this is to be implemented for a practical application later, it has to be exactly 6hours, cannot have the 39.333 seconds
Did you try the two methods I showed above (truncate the timestamp in the wire going to the indicator or change the display format). If you don't show seconds, they cannot be wrong 😉
09-10-2014 03:23 AM
i implemented the truncate function it works. thanks 🙂
09-10-2014 05:35 AM - edited 09-10-2014 05:39 AM
@altenbach wrote:
Also note that the subVI code could be simplified dramatically.
You don't need to unbundle-rebundle all elements, just the one that changes (hours, top image)
Even simpler, add the number of seconds to the timestamp (bottom image).
Jim Kring posted a few years ago on his blog a cool feature of timestamps; they support units!
You can set the units for the constant to hours and add that directly to the timestamp; no units scaling required...
(Oops; looks like altenbach commented on that blog, you already know about this)
http://thinkinging.com/2007/06/08/labview-tip-easy-relative-timestamp-calculations/
09-10-2014 09:27 AM
@PhillipBrooks wrote:
@altenbach wrote:
Also note that the subVI code could be simplified dramatically.
You don't need to unbundle-rebundle all elements, just the one that changes (hours, top image)
Even simpler, add the number of seconds to the timestamp (bottom image).
Jim Kring posted a few years ago on his blog a cool feature of timestamps; they support units!
You can set the units for the constant to hours and add that directly to the timestamp; no units scaling required...
(Oops; looks like altenbach commented on that blog, you already know about this)
http://thinkinging.com/2007/06/08/labview-tip-easy-relative-timestamp-calculations/
Doesn't mean that old... umm... hands... don't need reminding every so often. 😉