03-15-2015 03:51 AM
Hi, I am trying to control the blinking rate of LED by three push buttons. When I press P1, LED blinking rate is 1s, for P2 - 0.5s and for P3 - 0.25s.
Problems occurs only when P2 is pressed, I cannot change to P1 while P2 is pressed.
Please anybody can solve me that problem!
Thank you!
03-15-2015 09:48 AM
Is this homework?
03-15-2015 06:12 PM
Yes, it is.
03-15-2015 06:13 PM - edited 03-15-2015 06:13 PM
Could you save it in LV 2013 so i can see what you're doing and maybe give you some hints?
03-15-2015 07:55 PM
Throw away what you have and start over. That is a nightmare of case structures and while loops all embedded inside of each other.
A user would need to figure out the magic combination stop button presses and pushbutton presses to get the code to work the way they would expect.
Your master stop button should have a mechanical action of Latch when Released as opposed to the switch action you have now.
You can do this with a single while loop, a single case structure, and also a set of radio buttons.
03-15-2015 09:17 PM - edited 03-15-2015 09:25 PM
@absias wrote:
Hi, I am trying to control the blinking rate of LED by three push buttons. When I press P1, LED blinking rate is 1s, for P2 - 0.5s and for P3 - 0.25s.
Problems occurs only when P2 is pressed, I cannot change to P1 while P2 is pressed.
Your problem is actually more than changing from P2 to P1. The third requirement of P3 blinking at .25s wasn't met and once you do add that wait time you will find that the problem is actually going from a higher P to a lower P.
I agree with RavensFan that you should probably start over but you are technically not far off from the solution. With your current set up you can actually get the behavior you want by placing a sequence structure in every true case that will have the while loop in the first frame and the two case structures in the next frame.
Edit: I should clear up that technically my solution is incorrect. If you are at a higher P and select the lower P in between when the VI checks the case structures in the second frame but before it starts the next loop you will not see expected behavior.
03-17-2015 05:19 AM - edited 03-17-2015 05:19 AM
Hello guys, thank you for all of you, the tips you gave me were very useful.
Here is the new vi. Everything is working,
Just want to ask one more question, if I want to put timer interrupt, for ex. if switch one is pressed and LED blinking each second, then after 10 seconds interrupt takes action and stops the blinking. If during this 10 seconds switch 2 is pressed, then reset the interrupt timer back to 10 second.
Thank you for all the replies, really appreciate it.
03-17-2015 05:31 AM
03-17-2015 05:43 AM
Dear GerdW,
Thank you, really good method. I just start learning labview, and I am already fell in low with it.
Thanks
03-17-2015 06:49 AM - edited 03-17-2015 06:50 AM
Hi again,
Can anybody please check this vi.
I put a timer, so that after 10 seconds LED turned off in any case. But when SW0 is on, and after 4 seconds I press SW1 and then I press SW0 back, timer counts only 6 seconds and resets, but I want 10 seconds after I press any switch. What should I include?
Thank you!