LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

delay within loop, only want to apply it once

Hello all
 
I am trying to delay a signal that is a switch reading, with respect to the signal that it is triggered from. Right now I have a while loop running around the entire vi, and the (EMG) signal is input through DAQ board, filtered, rectified and put through the trigger/relay mechanism. After output from the relay I would like to have control to delay to my liking. ie, having synchronous (ie real time) switch to iEMG (*integrated), or disynchronous (where the delay is applied).
 
corollary, The output from the relay is a signal that has zero values when relay is open, and passes the signal 'y' = 1 when closed, is there a way to output from the relay a digital signal instead of my 'home made' digital signal?
 
attached is the vi i am working on, the wire just to the left of the relay is where I would like to apply the delay.  The VI does not run by itself, I open a data file in another VI and output through DAQ and then in this VI input through the DAQ again, so later in development we can just input EMG straight from animal and run this.
 
pmn


Message Edited by BMEstudent on 07-10-2008 09:30 AM
0 Kudos
Message 1 of 16
(2,672 Views)

Put the delay function in the true case of a case statement where the condition is that the i terminal of the while loop is equal to 0.  Then it will only delay on the first iteration of the while loop.

You will need the boolean wire, or the constant in the case structure  or passing through in both the true and false cases so the relay express VI will be dependent on the completion of the case structure which will take either the delay time when i=0, or no time at all if i <>0.



Message Edited by Ravens Fan on 07-10-2008 10:45 AM
0 Kudos
Message 2 of 16
(2,665 Views)

thanks. I'll try these and see what happens.Smiley Happy



Message Edited by BMEstudent on 07-10-2008 09:47 AM
0 Kudos
Message 3 of 16
(2,660 Views)

so I put in the case structure and that solves the problem of having the delay happen more than one time while running the VI, but not the problem of having it happen only to the relay passed signal. I do not really understand your second statement.   is this question what it is trying to address? Do i just put the relay into the case structure with it, and then in the false case have no delay but only the relay??  what do yo think.   I'll keep mussin' with it see what happens.

 

pmn

0 Kudos
Message 4 of 16
(2,647 Views)
The case statement should be driven by the value of the relay.  You can either put the value of the relay or the relay itself into the loop if it is possible (Best way) or read its value from a property node, variable or action engine all of which have thier advantages / disadvantages.
Craig
LabVIEW 2012
0 Kudos
Message 5 of 16
(2,644 Views)
I think the question is malposed.   To try to clear it up i took a screen shot ofthe FP mid run and will describe what I want it  to look like.  It show the switch signal on top of the iEMG and they are running in 'real-time' synchrony. If it would not have been stopped the while loop would keep running and the relay would keep switching on after surpassing a threshold and off after dropping below a similar threshold (both calculated in above VI).  What I want is the switch signal to not change in duration of on and off, but to be the only thing delayed in teh entire VI.  The attached screen shot would have the identical iEMG signal (if using the same data file, of course) but the upper chart would be shifted to the right.  Hop this helps
0 Kudos
Message 6 of 16
(2,637 Views)
My second statement was just expanding on the first.  Just telling how/why to put the delay in a case structure.  Attached is a modified version of your VI with the delay added.
 
I don't understand from your first post what digital signal you are talking about.
 
Also, instead of posting a word document with an embedded picture.  Just post the image itself.  Preferably in .png format.  Jpegs are OK.  Never post a .bmp image (Actually the forum blocks those, but that doesn't prevent people from renaming them as a .jpg and posting them even though it is still actually a bitmap which is a file format with large file sizes.)
0 Kudos
Message 7 of 16
(2,629 Views)
thank you a lot for the mod version. But the switch signal is still not the only part of the VI that is being delayed, but the entire VI. I had the case structure set up pretty much correctly, but did not have the wire from the triggers to the relay through the structure. 
 
As for my second question, the relay express VI passes a signal of the creators choosing through when closed and zero values when open.  Right now I just have a constant of value 1 connected to the signal.  so the resultant chart is what you see in the screenshot, but this is not a truely digital signal.  when I tried to connect a digital generated signal of all true values the wire into the signal node of the relay is erroneous.  I guess two possible sol'ns, digital signal for the relay to pass, or convert to digital after relay (which I also have ever done before, but i'm sure should be self explainatory.)


Message Edited by BMEstudent on 07-10-2008 10:57 AM
0 Kudos
Message 8 of 16
(2,623 Views)

I guess there are a lot of things I don't understand about what you are trying to do.  There are a lot of filtering and integration functions going on.  You DAQ assistant only collects 4 samples, which is not a lot of data for a 1kHz sampling rate.  It doesn't seem like enough to send through the filter commands.

You have a while loop inside that does continuous integration rapidly on the same data while the "Stop" button is true.

What do you do with this signal besides displaying it?  What is the purpose of the delay?  Perhaps you just want to add a second's worth of a waveform at the beginning of the waveform to represent the delay?  In which case a waveform of zero data could be appended before the switching data.  I really don't understand the purpose of the Relay express VI.  That is one of those express VI's where I think it would be easier to wire up some comparisons with primitive LabVIEW functions and serve the same purpose.

The switch information coming out of the relay express, although it is a blue signal wire then converted to a double array, is really only a single value (one element 1-D array) that gets continually added to the chart.  If that array of doubles or  blue signal wire you want to convert to digital data (as in an array of boolean true and false), use the some basic comparisons to generate boolean arrays.



Message Edited by Ravens Fan on 07-10-2008 01:17 PM
0 Kudos
Message 9 of 16
(2,598 Views)
Hello again.  Sorry, I was away from the project last weekend. But just to answer your questions:  The purpose of the program is to use the output (which will hopefully eventually be delayed) to inform a ventilator to start and stop a breath for a patient. The purpose of the delay is to try synchronous and asynchronous breathing with the information the diaphragm is not receiving (for one of multiple reasons), and see the correlation with muscle atrophy. This means that the input signal cannot be delayed but the switch data must be. 
 
I have implemented the boolean to (0,1) and it does work the same as the relay.  It shows that I have not been a programmer for very many moon cycles.  I have been doing a lot of searching through the functions palette and the tutorials given with lv 8.5 all push the express VIs, although after a month of using it they do not seem to be the most useful in a lot of cases.
 
Now, I will try to put together a waveform to add to the beginning of the switch signal in order to mimic an actual delay. Although I would like to be able to control the delay size eventually.
 
I hope this is what you need to now, if you need more info let me know. 
 
Thank you for your continued help.
 
pmn
0 Kudos
Message 10 of 16
(2,556 Views)