LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Button freeze

Solved!
Go to solution

Hello!

I have this program that is generating random numbers to a Waveform Graph. I want to be able to generatre new values every time I press the button, but I'm only able to use the button once in every run. What can I do?

0 Kudos
Message 1 of 5
(3,011 Views)
Solution
Accepted by topic author joali1

Your "Status 1" case does not enqueue a state.  So the Dequeue Element on the next iteration will wait forever.  You should probably put a timeout of 0 on the Dequeue Element and make sure the default value throws an error and/or takes you back to the Wait For Event state.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 5
(3,000 Views)

Nice. Thanks!

One more thing. 

I want to read files and get the values in the same waveform graph, do I have to use shift register or something else? 

0 Kudos
Message 3 of 5
(2,998 Views)

Just read the file and write it directly to the graph.  If you have multiple states that could update the graph, I would probably just use a Local Variable in the additional cases.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 5
(2,982 Views)

Some more comments:

 

  • All your buttons should be latch action and placed inside their respective event case.
  • Not sure why you even use a queue and all that heavy machinery. Wouldn't it be sufficient to just put the next state into a shift register (the queue is useful if you want to enqueue multiple successive actions with one event, but in that case you probably should use two loops and more advanced architecture anyway). (See image)
  • You should wire your waveform data across all cases that don't modify it and place the graph indicator before the event/case structure. No need for local variables. (linked tunnels make it easy!) This will also clear the graph from any stale data from the previous run if you properly initialize the shift register.
  • Typically is is not a great idea to place an event structure inside a case structure. (OK for simple cases, but does not scale well).
  • Your state should be a typedef. If you later add another state, you currently would need to replace all diagram constants!

 

*Where did you find that "template"? Here's how the same code could look like. (No, I don't recommend to do it this way either. Look at the templates that ship with LabVIEW)

 

altenbach_0-1614895482706.png

 

0 Kudos
Message 5 of 5
(2,932 Views)