10-10-2007 04:00 PM
10-11-2007 07:42 AM
10-30-2007 03:48 PM
10-30-2007 04:45 PM
The "Basic Level Trigger Detection.vi is nice because it can be set to detect either positive or negative going pulses, and the level can be set by you. Basically it functions like a trigger on an o'scope.
Look in your functions under Waveform_Analog waveform_waveform measurements_Basic Level Trigger Detection, from there it is pretty simple to detect your upward and downward edges.
Chris
10-31-2007 03:18 PM
Thank you Chris.
I can now count pulses in my sample, but I'm having a hard time pulling the timestamp for the value from the dynamic data type. Here's an idea of what I'm doing:
Analog data (DAQAssistant): Dynamic data into a for loop converted to a dbl and using the iteration "i" of the loop indexing out one value per loop iteration, I take that value and put it through the trigger which then tells me if it's over or under the level.
When the value is under the level (produces a false), I want to record the time stamp of when that value was originally sampled. Then I want to compare it to the time of the next value above the level (produces a true) to determine if it's a 2 second pause or a 500ms pause.
How do I pull timestamp data from the dynamic data?
Thanks for the excellent help.
11-01-2007 05:17 PM - edited 11-01-2007 05:17 PM
Hi GradMarch,
From the dynamic data type (DDT) you can get the time stamp by converting the DDT to a waveform using the function “Convert from Dynamic Data” and selecting “single waveform” as the resulting data type. From there you can use the get Waveform components to extract the “t0” (first time stamp), the “dt” (step) and the Y values. As you can see elements in the “Y” array are going to be separated by “dt”. Remember that “dt” is the period of your rate (i.e. 1 / rate).
You can either build an array where one column is the data and the other column is the timestamp but this will slow down the while loop and also will take a little bit of programming. The best way of doing it is using the position of the data on the array as the stamp remembering that each position is an increment of “dt” and “t0” is when the first sample of that array was read.
I have also included the "Basic Level Trigger Detection.vi" that triggers a boolean every time the waveform crosses the "voltage level". This voltage level can be change in the block diagram to meet your needs. The timestamp of the occurrence of this event is also and output of this Level Detection VI.
For more timestamps examples go to NI Developer Zone and type timestamp in the search field.
I hope it helps
Message Edited by Jaime F on 11-01-2007 05:23 PM
12-06-2007 01:43 PM
Thank you everyone for your continued help. I thought I had this all figured out, but now I'm getting a very strange error.
Error -20308
occurred at "NI_MAPro.lvlib:ma_ptmFetch.vi:3"
when called from "NI_MAPro.lvlib:Pulse Measurements N chan.vi:2"
(waveform index 0 of 1)
Possible reason(s):
Analysis: The waveform did not cross the mid reference level enough
times to perform this measurement. Check the signal length, reference
levels, and ref level units.
Here is a picture of the waveform with the error box, and below you'll find a screen capture of my code.
The program logic is as follows:
If the data crosses 2V proceed to analysis, if not, pass a zero to the counter indicator.
2V seen ---> If the dt of the pulse is 2 sec pass which pulse# to count loop, else pass zero to count indicator
2sec seen ---> starting at pulse#+1, if dt is between 0.3 and 0.6 count, if over 2sec end and pass pulse count to indicator.
Thanks for any help you can give me. It's been working on all other pulse counts (2,3,4) I guess 5 is different.
12-07-2007 02:44 PM - edited 12-07-2007 02:47 PM
Hi GradMarch:
I have done a simplify version of your code; to simulate the issue, as you can see it works fine. You need to check you reference levels. Does it work a couple of times and it stops working on the last iteration? Because if that is the case, what I think is happening is that your last chunk of data is not crossing the reference levels needed to make the measurements, something that you might do is change the “ref units” to percent and check the output, this will help you debug your issue.
1. Block Diagram
2. Front Panel
I hope it helps
12-08-2007 05:51 PM - edited 12-08-2007 05:51 PM
Jaime,
This piece of code is embedded inside a while loop which checks for the 5 downward pulses on every iteration. For about 3 hours, this code runs perfect every 10-12 seconds in this loop. After 3 hours, when these 5 downward pulses are expected to apear, the error ocures and kills the test.
I have tried this with both the percent and the absolute (per your idea) and have seen the same issue. I have now changed the test so that it will start checking for the pulses after 3 hours (when they should not be present) in hopes of finding the pulses at about 4 hours into the test when they should be apearing.
Thanks you for you're help. Please don't hesitate if there is another idea.
12-14-2007 06:04 AM
This issue is still present.
Maybe the better question is: How do I get it to pass the error so I can handle it rather than fatally ending my program?