Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop acquisition and generation with a case structure

Hy,

I am in trouble with labview...

I have to stop the acquisition and the generation when an acquired data is below a reference value. That value is calculating by using the first 200 hundreds points. So, if for a voltage of 5V, the recorded data is below the reference value, the software must stop and generate a DC voltage of 5V. To achieve such a goal, I decided to compare the input data to the reference value. I will have 2 results true or right. Then I wired it to the stop buttons of the while loop. My idea is : "keep running until the case True occurs then Stop". It seems that I can't compare each point in real time. I mean point by point. But only all the datas acquired during an iteration. That's why I have an array of boolean result which can wired to a stop button or a case structure. I don't know if I should use the "Waveform tools" or working with DBL datas.

Thank you for having a look on my computation 

Download All
0 Kudos
Message 1 of 13
(4,061 Views)
Not sure exactly what you mean 'I can't compare each point'. The result of the comparison is a true/false for each point. If you want to stop if any point fails the comparison, you just have to AND the array elements (Boolean palett).
0 Kudos
Message 2 of 13
(4,044 Views)

Thanks for the answer. I tried to "And" the array with a true constant but nothing changed. Is it what you told me to do?

There are 3 steps in my computation:

step1: synchronisation of the AO and AI.

step2: calculation of the threshold by analysing the first 100points.

step3: stop the computation when a value is below this threshold.

I am introuble with the step3. It seems that the software must finish the acquisition of all the samples. And then, the step 3 occurs. Unfortunately, I will have other points below the threshold and I can't stop the experiment because I haven't one "True value" but an array of boulean value.

My aim is to "stop" when the first true case appears.

0 Kudos
Message 3 of 13
(4,034 Views)

No, I wasn't exact enough in my description. On the Boolean palette is the function 'AND Array Elements'.

 

Yes, of course your computation must wait until you've acquired the samples you've requested. You have set the sample rate for 10000 Samples/sec and the number of samples requested is 10000. That means you get 10000 samples each second.  It's simple arithmetic. All of those samples are transferred from the DAQmx Read as a single array - not one point at a time. If you don't want to wait for one second, request fewer samples at a time. Request 1000 samples and you will get that number every .1 sec. Request 100 samples and you will get that number every .01 sec.

0 Kudos
Message 4 of 13
(4,032 Views)

Ok. But I need my 10Kpoints per experiments. How can I collect it if I fixed the number of samples to 10?

I tried a "for loop" with a 1000 iterations but it doesn't work with the daqmx "read" inside the while loop.

Thanks in advance.

0 Kudos
Message 5 of 13
(4,021 Views)
A DAQmx Read inside a for loop with 1000 iterations will work exactly like a DAQmx Read without a for loop if you create the output data correctly. Are you using the Append Waveform function with a shift register?
0 Kudos
Message 6 of 13
(4,018 Views)

Yes, I am using the "append wfm" vi tool.

Thanks for your advice. So now I can acquire the data as fast as I want.

But now, I don't know how to define my threshold. My first idea is to use a "events" structure.

  1. The step 1 will calculate that threshold by using the first 100points. Then I will define a local constant
  2. In the step 2, every data point is compared to this value.The computation stop to run when the first "true" case occurs.

I am oscillating between a "flat sequence" structure or a "events" structure?

0 Kudos
Message 7 of 13
(3,999 Views)
A sequence structure is seldmon required and I don't know how an event structure would help. From your description (and topic), isn't a case structure appropriate?
0 Kudos
Message 8 of 13
(3,992 Views)

Thank you for your quick reply to my post. It's very helpful.

A case structure is appropriate to stop the computation. But how can I calculate the threshold (based on the first 100 points) without stopping the "for" loop?

0 Kudos
Message 9 of 13
(3,977 Views)

So finally, I used a flat sequence structure. But I still have 2 problems. I am very much near to my purpose now.

The first frame calculates the threshold. The second one compares every data point to the threshold and stop the computation when a true case occurs.

1--It seems working but I am losing the data because I stopped the "for loop" before the N iteration required. So how can I get back the data acquired before the stop? 

2--If my true case occurs for a generated voltage of -6V, I expected that this voltage would stop at -6V. But there is a delay and my software keep running few points below up to 7V. How can I be more accurate and minimize this delay?

You can see my computation in enclosed files.

Cheers

0 Kudos
Message 10 of 13
(3,969 Views)