09-30-2009 02:16 PM
I have a display where I am sending data via USB to a 4 digit display. I write the time pause and then write the barometric pressure. A request was made to write a single line of the string and data to a LVM file every 4 hours. I am not sure just how to enable and disable the ENABLE line. I don't want to write more than one line on the write cycle.
Any Ideas.
Thanks
Philip
09-30-2009 03:01 PM
09-30-2009 03:21 PM
Thank you for the fast response. I starting taking the hour and divide by 0,4,8,12,16,20,24. If equle to 0 then write.
Thank You,
Philip
09-30-2009 03:46 PM
Why not just use the modulus function? The Quotient of the division isn't as useful as the Remainder for something like that. For example
4 hrs = 14,400 secs
0 % 14,400 = 0
1 % 14,400 = 1
2 % 14,400 = 2
...
14,399 % 14,400 = 14,399
14,400 % 14,400 = 0
...
28,799 % 14,400 = 14,399
28,800 % 14,400 = 0
Everytime the result = 0, it has been 4 hours.
09-30-2009 04:03 PM
That is exactly what I did. I tested the VI at 1 minute and 5 minutes. Now I have it set for 4 hours. I will leave it overnight and verify the results.
Thanks for your help. It did not work at first! I was off by one 0.
Thank You
Philip Nielsen
09-30-2009 04:03 PM
If you use Nickerbocker's suggestion, make sure that you test the time at least once per second. For example suppose that you test at 28799 (remainder = 14399) and then do not test again until 28802 (remainder = 2). In this case you would never have remainder = 0 and would miss the write to file. Of course you could test for current remainder < previous remainder to indicate a rollover.
Lynn
09-30-2009 04:11 PM
Now that I did not think of at all. Excelent point to consider. I have my VI running with 14400 seconds right now. I will check on it in the morning. This data is for the FAA records.
Thank You,
Philip
09-30-2009 04:24 PM - edited 09-30-2009 04:28 PM
Good catch Lynn!
There is an express vi called "Elapsed Time" which might make the problem simpler.
09-30-2009 04:34 PM
Nickerbocker wrote:Good catch Lynn!
There is an express vi called "Elapsed Time" which might make the problem simpler.
Message Edited by Nickerbocker on 09-30-2009 03:28 PM
Isn't that what I said? I don't think you want the shift register. It will automatically reset after the target and not go high until another 4 hours have elapsed.
09-30-2009 05:16 PM
So you did. I read the authors last post and saw something with divisors = 0 and thought that the simple answer was overlooked.
BUT, did you provide a snippet?