12-22-2015 12:58 PM - edited 12-22-2015 01:00 PM
@winterfresh11 wrote:
So is this what the final solution should look like, it seems to work?
No, it does not work! A timeout event with a -1 hardwired to the timeout, will never timeout and will stall the loop in the first iteration forever or until stop is pressed.
Why don't you wire an indicator to the iteration terminal to see for yourself?
Before attaching a VI, you should also place reasonable default values into all controls (Do you know how to do that?). Currently we get a division by zero unless we change the values.
12-22-2015 12:59 PM
It appears that you cannot run any other code in the while loop though because the loop is just waiting for the event structure to do something. For example, I wired in a simple counter and it counted when the event structure was disabled but no when the structure was enabled
12-22-2015 01:09 PM
@winterfresh11 wrote:
It appears that you cannot run any other code in the while loop though because the loop is just waiting for the event structure to do something. For example, I wired in a simple counter and it counted when the event structure was disabled but no when the structure was enabled
Yes, you are learning about the simple principles of dataflow: All code in the while loop (and the current cases) will run, but the loop cannot go to the next iteration until every part of the loop code has completed, of course. If you want to truly run things in parallel, use two independent while loops. All the tools are right there!
Can you explan your timeout calculation? It seems to always retun the same value. What should happen if the inputs are changed while it is still waiting? (e.g. complete the current wait, break the wait and update to the new value, etc.)
12-22-2015 01:22 PM
I don't have a calculation for the event structure timeout, I just weired in 1 and it appears to wrork now. The other calculation in the code is just to determine how long each iteration should take based upone the final power one would want to get to and how fast they want to get there.
12-22-2015 01:27 PM
@winterfresh11 wrote:
I don't have a calculation for the event structure timeout, I just weired in 1 and it appears to wrork now. The other calculation in the code is just to determine how long each iteration should take based upone the final power one would want to get to and how fast they want to get there.
No that will defeat the entire purpose because the loop is still stalling at the wait and you even have now a race condition because the event structure times out in 1ms and the stop button will most likely not be read until the next iteration.
12-22-2015 01:30 PM
So what kind of timeout calculation would be ideal for this? I guess I'm still a bit confused
12-22-2015 01:33 PM
@winterfresh11 wrote:
I don't have a calculation for the event structure timeout, I just weired in 1 and it appears to wrork now. The other calculation in the code is just to determine how long each iteration should take based upone the final power one would want to get to and how fast they want to get there.
If you don't want the values to change while the loop is executing, the timeout calculation needs to be before the while loop. No need to constantly recalculate it.
What are the units of "final"? How is it defined? Why are the controls DBL? Shouldn't they be integers? (Multiply by 1000 before the division and use Q&R for the division to keep it all blue.)
You still haven't told us the typical values for the controls.
12-22-2015 01:35 PM - edited 12-22-2015 01:36 PM
@winterfresh11 wrote:
So what kind of timeout calculation would be ideal for this? I guess I'm still a bit confused
Try something like this, for example.
12-22-2015 01:41 PM
The units of "final" would be in Watts, the typical value for final could be anything from 1 to 100. The controls don't need to be DBL so i changed them. The value of "ramp time" could be anything really, but typically in the 300 seconds to 1800 seconds range.
12-22-2015 03:00 PM
Indeed what you want is break comment in text base programing but labview do not have break to break the loop or while suddenly but there are some trick that you can use them for do it i attach you a vi with two method for do this test them and tell me if it is what you want