01-12-2019 08:42 PM
Hello everyone.
I am making a program in which a counter starts from 5 and goes to 0 and then a LED light gives an indication by turning on. After that a random event occurs whose value is added to or subtracted from original counter value of 5 and the counter runs again to 0 and then LED turns on. This process repeats itself unless its stopped. Now, the value of the counter due to random event can be in decimals like 4.36, 5.12, 4.89 etc. I want this counter to decrement in real time with counter values to be considered seconds/milliseconds. Currently I am using time delay but it will be applicable only for the initial counter value of 5 and not the later updated values in decimals. I have tried using Elapse time express VI but have not been able to get it run properly. Please help me with this issue. I have attached the VI and image of block diagram. Your help and guidance will be highly appreciated.
Best regards,
Fahad Bin Zahid
01-12-2019 02:08 AM
Hello everyone.
I am making a program in which a counter starts from 5 and goes to 0 and then a LED light gives an indication by turning on. After that a random event occurs whose value is added to or subtracted from original counter value of 5 and the counter runs again to 0 and then LED turns on. This process repeats itself unless its stopped. Now, the value of the counter due to random event can be in decimals like 4.36, 5.12, 4.89 etc. I want this counter to decrement in real time with counter values to be considered seconds. Currently I am using time delay but it will be applicable only for the initial counter value of 5 and not the later updated values in decimals. I have tried using Elapse time express VI but have not been able to get it run properly. Please help me with this issue. I have attached the VI and image of block diagram. Your help and guidance will be highly appreciated.
Best regards,
Fahad Bin Zahid
01-13-2019 07:45 AM - edited 01-13-2019 07:47 AM
There are several goals here that appear (to me) to be mixed up. Let me see if I can reformulate your task slightly, and see if this helps at all --
Bob Schor
P.S. -- there are, of course, many ways to "solve" this problem. I'm suggesting some steps that, if you try to do them, should teach you some fundamental principles of LabVIEW that you'll need to understand in order to master it. "Doing it yourself" is the best way to learn.
01-13-2019 07:56 AM
Hi, thank you for your kind response.
1. There is no condition for the timer to change value after 1 second. It can run in milliseconds for whole or decimal numbers.
2. Yes, I know about the working of shift register and while loop infact I am already using them together for the counter.
3. Yes, I have the idea of creating sub VI but the problem is I am not getting how to implement timer on this counter or do this whole task in some other way. I have been struck on this problem. I have tried different things but nothing worked.
Please see the attached VI. Any help would be highly appreciated
01-13-2019 09:05 AM
01-13-2019 10:38 AM
I'm assuming you are trying to learn LabVIEW -- the best way to do that is to learn the basic concept and then apply them to problems (such as the assignment you have been given). I'll suggest some approaches that you can consider.
The nice thing about developing a sub-VI (or "breaking your Big Task into a number of smaller, simpler tasks") is that you can test the smaller parts by trying to run them with various inputs to convince yourself that they work.
The above should be all that you need to start solving your problem by yourself. Try it, you will learn a lot, and it will "stick" with you since you figured it out by yourself.
Bob Schor
01-13-2019 10:46 AM
Oops, I see I've answered the same question twice (because you asked it twice, and the second one was moved to the LabVIEW Forum from Hardware).
Go read my other response, and then come back with your version of Timer.vi, the routine that does a wait of up to 1 sec so that "Time Out" is a "whole number of seconds to continue waiting". Once you so that, the problem essentially is solved ...
Bob Schor
01-13-2019 07:55 PM
Thank you very much for your kind response.
I am not doing some assignment, I am working on an industrial project for which I have to use LabVIEW and this countdown timer is a small part of it. So while doing it, yes, I am learning LabVIEW as I am not an expert and have never used timers along with many other things.
Thank you for your advice on using sub VI. I know about sub VI and shift registers and I am already using them. The problem at this stage is not the organization of the program, but the implementation of timer on this variable countdown, be it in a sub VI or in the same program. Also, I don't require it to elapse time in milliseconds for decimal part and in seconds for whole number part, the whole figure can elapse in milliseconds. There has to be a random value for the countdown every time and every time when the count down goes to zero LED must give indication. I have tried using elapsed time express VI and some other things but not been able to get what I want.
Again, thank you for your time.
Best regards,
Fahad Bin Zahid
01-14-2019 09:38 AM
Here's the question I was trying (unsuccessfully, I'm sorry to say) to get you to consider:
Suppose I want a "random wait" of from 0 to 10 seconds.
Suppose I get 4.5678. The Wait (ms) requires a millisecond count, so I "round to the nearest millisecond" (can you figure out how to do this?) and get 4.568 seconds, or 4568 milliseconds. What do I want the first "wait" to be?
Go ahead and try your hand at creating such a VI that gets Timer In, waits (up to) 1 second, and returns "Timer Out". Once you have it working, see if you can embed it in a While Loop and solve your entire problem. If you have trouble, post your VI and I'll provide more help. You cannot learn LabVIEW (or any other Programming Languages) without writing some code and getting feedback on whether your code works. Note that some of the best feedback is to simply run your code yourself and see if it "does the right thing" (it should always do what you tell it to do -- the trick, and skill, is getting it to do what you want it to do -- I hope you see the subtle distinction).
Bob Schor