08-07-2015 10:39 PM
Hi All,
I am using several radio buttons for defining various stages of breathing. For each stage, I have a countdown timer that counts the number of seconds that particular stage has to last (different stages last for different durations).
I am using the elaped time VI. I have done the necessary coding and all works well except that I cannot reset the elapsed time VI as soon as a new radio button is clicked. As soon as a new radio button is clicked (a new breathing stage), I need the time in seconds of that stage to reset to its max (original) value and then the countdown should start (to indicate the end of that stage).
The above happens very easily if I also depress the elapsed time VI's reset button just after depressing a new radio button. But I want the action of the reset button to be automatic. So, each time I depress a new radio button, I want the timer to reset to time in seconds specified in that stage and begin a new countdown.
I am attaching my code and image. Any help would be greatly appreciated.
Thanks!
08-07-2015 11:07 PM - edited 08-07-2015 11:14 PM
Use a feedback node to store the value of the radio button from the last iteration. Whenever the current value is NOT EQUAL to the previous value, that True can reset the Elapsed time function. You can OR that boolean wire with your Manual Reset button.
Now, let's talk about the elephant in the room. MY GOD! What are you doing with those waveform wires and the long history of waveforms and all the build arrays. That is just painful.
Keep your 1-D array of waveforms in the shift register. Use replace array subset to replace the oldest waveform, and use rotate 1-D array to keep things in order.
Welcome to the Rube Goldberg thread.
08-07-2015 11:27 PM
Thank you so much for your prompt resposne RavensFan!
I think I understand what you have suggested about resetting the elapsed time VI. I will first try that.
And yes, I could not get the mixed signal graph to display 30 s of data from all 4 channels easily. Hence those massive build arrays! I will try what you suggest and see if it helps. How to convert to 1 D array?
I will keep you posted in any case.
Thanks!
08-08-2015 12:01 AM
The same way you are doing now. But you keep the 1-D array in the shift register, and you use Build Array with Conacatenate Inputs set to put the new wavefrom into the 1-D array of waveforms you get out of the shift register. You could then check if your array size is greater than 30, and if it is (which will happen after the first 30 iterations) you can delete the oldest waveform out of the array.
Or you can intialize your waveform with an array of 30 empty waveforms. Then when you get a new waveform, rotate the array 1 spot, and then replace the first item of the array (which was the oldest) with the new waveform.
08-09-2015 12:13 AM
Thank you so much for all your help RavensFan!!!
Using your suggestion, I finally got the latching action from the radio buttons that was needed to reset the timer each time (VI ending in SWATI attached). DONE!
But I still cannot get rid of the elephant ;). I tried concatenate array and insert into array using shift register. But does this does not seem to do anything (VI ending in TEMP attached). Could you send me a small example for one channel (maybe just an image) of how to do it. Then I am hopeful I can do it. I am quite confused as to what is inside these wires. Where is the time, values, etc. Does it come in rows, columns...
Thanks a lot!
08-09-2015 03:57 PM
First, I never said to use Insert Into Array.
Attached is your VI modified where I used Replace Array Subset along with Rotate Array.
08-09-2015 07:18 PM
Thank you so much RavensFan for the time you took to help me with this one! It now does exactly what I was doing the very hard way.
However, the mixed signal plot still sees the concatenated array and treats the elements therein separately. Therefore, if I choose size 20, the mixed signal graph creates 20 small plots -- if I ignore time, they are superimposed & if I choose time, they are concatenated with different colors. The mixed signal graph does not treat this concatenated array as ONE signal still.
This will be problematic because if I increase the size, the mixed signal graph will create new plots with different colors which will not match my original color (which I can set manually).
Please see attached screenshot.
I had the same issue with my version. I had to recolor each segment manually (right-clicking with the mouse). But since I don't change my window size, I am ok.
Is there a way around?
Also, since the window size parameter is outside the loop, I cannot change size while VI is running. To be able to change it during running would be nice too.
In any case, thanks so much for all your help!
08-09-2015 08:39 PM
Based on the fact that was the way you were programming your original VI, I thought that is what you wanted!
So you want a single waveform that consists of the last 30 captures discarding the older ones?
You could take that array, and use the Append Waveform function inside a For Loop iterating through each element in your array to build up a single waveform.
There is also a subVI called Buffer, or Circular Buffer, or something within LabVIEW. I can't find it right now. It may have been from an example, or buried in VI.lib. That demonstratres how to build a buffer of items.
08-09-2015 09:19 PM
Thanks RavensFan!
That is exactly wat I want 🙂
I will look this up & try it...
S
08-10-2015 01:06 PM
RavensFan wrote:
There is also a subVI called Buffer, or Circular Buffer, or something within LabVIEW. I can't find it right now. It may have been from an example, or buried in VI.lib. That demonstratres how to build a buffer of items.
I think you are looking for Data Queue PtByPt.vi