08-09-2010 02:32 PM
I'm starting to learn Labview and I've created a demonstation VI just to get familiar with funcitonality.
I would like to simply turn an output on and off (blink) based on a cycle I set via the UI.
I know I don't understand loops very well because when I try a loop it just stays in there and the rest of my program doesn't proceed.
I will attach where i landed, maybe I need a sequence or other control funciton, I'm not sure.
Solved! Go to Solution.
08-09-2010 02:59 PM
You were close. You need to use shift registers to carry any data changes from one loop iteration to the next. I've made the necessary changes in your code, and I put a small wait function inside the loop to prevent chewing up 100% CPU time. You should make a habit of doing this. Also, I changed the number that goes to the For Loop N from 5 to 4 so that the boolean ends on a green instead of a red when the measurement comes back within tolerance.
One more thing. That green front panel has caused me permanent eye damage. I'm sending you my eye doctor bill.
08-09-2010 05:29 PM
Thanks tbob...I ran it and it works as expected. I'm glad I was at least in the ball park.
I will compare your changes to my original file to make sure I understand it.
If you don't like the Green, you will have to tell me how to change it!
UD57
08-09-2010 06:14 PM
@uberdog57 wrote:
If you don't like the Green, you will have to tell me how to change it!
That was just a silly remark. You can color your front panel any way you like. You may find that others think it is obnoxious, or maybe not. How did you get that color in the first place? The default is grey.
If you want to change the background color, use the color tool from the tools palette (last one at the bottom, looks like a small paint brush). Click on the lower color box for the background color, and select a color from the color selection pop-up. Then click on the background of the front panel. It should change to the color you chose.
08-09-2010 06:16 PM - edited 08-09-2010 06:18 PM
You should really use the outer while loop for the shift register, else the inner loop delays the outer loop. (You can also use a globally initialized feedback node)
You also have way too much duplicate code. You can operate on arrays instead, simplifying the code. Do you want all LEDs to blink or just #2? Here is a solution that blinks all and uses arrays. Modify as needed. See if it makes sense. 🙂
08-09-2010 06:25 PM
I forgot to tell you that there is a much simple way to have a boolean LED blink. If you right click on the indicator in the block diagram, then select Create -> Property Node -> Blinking. Right click on the resulting property node and select Change to Write. Then wire a True constant into the property node to make it blink. Wire a false to make it stop blinking. It will blink at a rate that is set in Labview.
To change the blinking rate, click on the Tools menu from the top menu bar. Click on the Front Panel catagory. In the General section, you will see an entry box for Blink delay for front panel controls (milliseconds). Change that number to anything you wish.
This is much simpler than having code to blink. See the attached VI, with a much subdued front panel color.
08-09-2010 06:28 PM - edited 08-09-2010 06:33 PM
The blinking property has the disadvantage that it blinks with a different color and the blink rate is globally fixed.
You would also need some code that the property node is only called when the value changes and not with every iteration of the loop.
08-09-2010 06:42 PM
@altenbach wrote:
The blinking property has the disadvantage that it blinks with a different color and the blink rate is globally fixed.
You would also need some code that the property node is only called when the value changes and not with every iteration of the loop.
Minor things to a beginner, don't you think. After learning the basics, he can go on to bigger and better stuff. Like event structures and state machines.
08-09-2010 06:47 PM
tbob wrote: Minor things to a beginner, don't you think.
I try to keep them as far away as possible from property nodes.
Soon, they discover value properties and everything goes down the drain... 😄
08-09-2010 06:51 PM
@altenbach wrote:
I try to keep them as far away as possible from property nodes.
Soon, they discover value properties and everything goes down the drain... 😄
Awww, now you went and let the cat out of the bag...