LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

set a trigger and perform an action based on the result

I need to develop an application that works like an oscilloscope. The instrument i am trying to build should
1. Recieve an input signal
2. Use the RMS value of the signal to build a histogram
3. Find out what the mode is (from the RMS values)
4. Set a trigger value to be 5 times the mode value.
5. Go back to the waveform and see if the trigger value was reached.
6. If trigger, then save the segment of the wave that caused the trigger to a binary file i.e segment of the wave whose value exceeded the trigger value.
 
Basically I have done tasks 1-4. I need help on how to do 5 and 6
many thanks
0 Kudos
Message 1 of 2
(2,739 Views)

I have some ideas on how to perform these tasks, but it is to be said that I never faced such a problem so consider them as suggestions to work on...

Task 5: the simpler. MaxMin1D on your waveform permits you to decide wether the trigger value was reached or not. If so, proceed to step 6.

Task 6: on this I only have teorical ideas to submit to you (apart from scanning the waveform and comparing every two elements with the limit). If you subtract from your array the trigger value, you'll have negative values for figures below the limit and positive on values over the limit. Your problem then reduces to setting up some kind of zero-crossing detector.

I found in this post an useful idea on how to perform this task: Enrique has said: "A common way to do so is by multiplying the previous number and the current number. If the product is positive, both has the same sign and thus there was no zero crossing. If the product is negative, there was a zero crossing." To do so, you can multiply original array by the same array shifted by 1, put the result in a second array and pass this result array with a loop exiting on the first negative value. Something like this:

Suppose your waveform is stored in an array named data and that it is long samples elements. Create a new array result with the same lenght.

// Subtract the limit value
Set1D (result, samples, limit);
Sub1D (data, result, samples, data);
// Obtain the sign and scan the array
Mul1D (data, data + 1, samples - 1, result);
for (i = 0; i < samples - 1; i++) {
 if (result[i] < 0) break;
}

I hope these suggestions can help you in developing your application
Roberto



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 2
(2,712 Views)