LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cancel a while loop on a rising flank

Hello everyone,

 

I'd need to trigger a sequence depending on a ramp (sawtooth). Right now, I use the attached sequence in the first frame of a while loop. In each iteration, it reads the input voltage (which is just a double value) and compares it to a preset value with TRUE beind redirected to the stop terminal when the given number is lower than a premade number (-0.9 here). This is a rather dirty solution, I'd like the while loop to cancel on the rising flank, meaning when the current value is bigger than the value in the previous iteration.

Could someone give me some hints on how to achieve that?

 

Thanks in advance.

0 Kudos
Message 1 of 10
(4,003 Views)

ReBoot,

 

Try using a shift register to hold the last iteration data and make it available for comparison.  Might look something like this. 

Message Edited by centerbolt on 11-11-2008 08:26 AM
Message 2 of 10
(3,986 Views)
Thanks, this looks helpful, I'll try that.
0 Kudos
Message 3 of 10
(3,982 Views)
I've tried the solution and it doesn't work. I've tried to cancel on the falling flank, but the VI ends up just canceling anywhere. Strangely, the problem is not the shift register or the compare VI, the problem seems to be the DAQmx analog input VI. I've tried to use "Analog DBL 1Chan 1Samp" mode and canceling the loop when the measurement value is lower than a certain value ("cancel if value<0.05") but the VI also ended up canceling the loop just anywhere!
0 Kudos
Message 4 of 10
(3,925 Views)

ReBoot,

 

A couple of things to check.  Is the ramp signal you are sampling noisy?  Did you start the DAQmx task outside the while loop?

0 Kudos
Message 5 of 10
(3,905 Views)
The signal does not look noisy when looked at and yes, the task is started outside the loop.
0 Kudos
Message 6 of 10
(3,881 Views)
Can you post your code?
0 Kudos
Message 7 of 10
(3,861 Views)
0 Kudos
Message 8 of 10
(3,830 Views)
Can you make VI containing typical readings (from your daq). Make data as an array constant or a control with default values


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 9 of 10
(3,826 Views)

ReBoot,

 

You are acquiring a series of data points an then looking to see if any of the points was the start of the rising edge.  That won't work.  You need to be analyzing each point.

 

Attached vi demonstrates how you could use a shift registers to accomplish this.  The boolean shift register acts as a trigger enable and will not allow a rising edge to be detected until a falling edge has been first detected.  Note that the DAQmx Read is 1Chan, 1Samp.  This vi will only work for fairly slow signals.  If you need to handle higher frequencies or need better response time, then I suggest you look into using an Analog Trigger for your task.  Please note that this feature is not available on all DAQmx devices.

Message 10 of 10
(3,813 Views)