DASYLab

cancel
Showing results for 
Search instead for 
Did you mean: 

count only the values in a specific range

I have a program that can monitor and log the readings of 8 pressure sensors. The data acquired from the sensors is logged every second. I need to implement a system that counts the time that the pressure values are within specific range. For instance, if the set pressure is 150 psi. I need to know how many seconds or minutes the pressure was within 147.0 psi and 153.0 psi in the course of the duration of the test. By the way, I am using DasyLab version 11

0 Kudos
Message 1 of 12
(7,593 Views)

For one sensor:

 

Sensor's data >>> Pre/Post Trigger >>> Counter (Statistics section) >>> Display module

 

Pre/Post Trigger

- Within the limits -- lower=147 & upper=153

- Post-trigger: 1 value (this option defaults to 512 values, I do not know the reason for that)

 

Counter:

- Events to count: Time for high level

- check: Reset after edge (automatically reset the counter to zero, if the sensor's data enters the range again in the future)

 

 

The Combi Trigger examines the sensor's data.

If the value is in range 147.0 and 153.0, the module outputs 5.0V.

If the sensor's data is outside of the defined range, the module outputs 0.0V.

 

The counter examines the data from the trigger: it's either 0.0V or 5.0V.

If the Trigger module's output goes from 0.0 to 5.0:

- first, the Counter module recognizes the "rising edge" and resets the counter value to 0.0.

- Then, it starts to count the "high time" of the incoming signal.

If the Trigger module's output goes from 5.0 to 0.0:

- the Counter module simply stops counting, but it keeps putting out the last time.

 

 

You can set variables for the lower/upper treshold in the Pre/Post trigger, e.g.:

Variable 1 -- the center of your range, set value to 150

Variable 2 -- Double-click Variable 2, "Calculate expression automatically", and set as formula: ${Var_1} - 3

Variable 3 -- Double-click Variable 3, "Calculate expression automatically", and set as formula: ${Var_1} + 3

M.Sc. Holger Wons | measX GmbH&Co. KG, Mönchengladbach, Germany | DASYLab, DIAdem, LabView --- Support, Projects, Training | Platinum NI Alliance Partner | www.measx.com
Message 2 of 12
(7,584 Views)

Thank you for your answer. I have implemented your suggestions in the program and it works well. However, each time that I sotp and restart the program the counter go back to zero and start counting from zero. I was wondering what I need to do to keep the last values and keep counting from the last value untill I reset it mannually somehow and then start counting again from zero. I have attached the software just in case you need it.

0 Kudos
Message 3 of 12
(7,497 Views)

Add a second Counter module, do not use the "reset after edge" option.

 

Starting the measurement will set the counter to zero automatically.

To reset the counter manually, use a Switch module and an Action module. Configure the Action module so, that the Action module examines the Switch's data for a rising edge (button pressed) -- if that occurs, reset the the Counter module.

 

 

Alternatively: add a second channel to the existing Counter module. Activate channel 0, press function key F8 to copy the settings of channel 0 to all other channels. Activate channel 1, unselect the "rest after edge" option.Now you have two counters in a single Counter module. The counter in channel 0 resets itself on a rising edge, the counter in channel 1 will keep the value between events, and resume counting from that value if the next event occurs.

Use the Switch and Action module series and configuration from the first alternative, but you need to modify the Action module's configuration a bit.

In the text field "Channels (empty = module)" you need to enter the number of the channel of the second counter in the Counter module, here it's 1.

Otherwise, the Action will reset the entire Counter module, not only the counter in channel 1.

M.Sc. Holger Wons | measX GmbH&Co. KG, Mönchengladbach, Germany | DASYLab, DIAdem, LabView --- Support, Projects, Training | Platinum NI Alliance Partner | www.measx.com
0 Kudos
Message 4 of 12
(7,477 Views)

I have implemented your suggestions and the system is running. But I have another issue. In the second line of your answer, you state: "Starting the measurement will set the counter to zero automatically". What can I do not to reset the counter automatically to zero when I restart the system? Each time that I stop the system, the counter stop. But, when I restart the system, the counter will start from zero automatically. By doint this all the counted time of all the channels will dissapear. I need to keep this time in all the channels. Thank you four your help. I really appreciate it.

0 Kudos
Message 5 of 12
(7,452 Views)

(attached image)

The Counter module counts the high-time of the switch, the value is displayed as "current value" in the digimeter. The value is written to global variable 1.

Stopping the measurement will fire the copy action: copy the value from variable 1 to variable 2.

When you hit Start again, the "high-time value" from the previous measurement is now in variable 2.

When the Counter module counts the high-time of a "new" event, the Formula** module adds the current value from the Counter module to the value of variable 2, the result is displayed as "total time", and written to variable 1.

 

Stopping the worksheet will copy the current time (that was increased by the value from the previous measurement) to variable 2 again.

 

 

** The formula is IN(0)+{VAR_2}

 

 

To reset the "previous time" in variable 2: enable the option "enter value in startup dialog box" for that variable (hit the "green ball with black '1'" button).

When you start a measurement, a dialog box will appear. You can now enter a 0.0 for the "previous value".

 

 

EDIT: Example worksheet added.

M.Sc. Holger Wons | measX GmbH&Co. KG, Mönchengladbach, Germany | DASYLab, DIAdem, LabView --- Support, Projects, Training | Platinum NI Alliance Partner | www.measx.com
Download All
0 Kudos
Message 6 of 12
(7,445 Views)

Variable 1 and variable 2 mentioned in your example are completely different at the ones you mentioned previously right?

 

You can set variables for the lower/upper treshold in the Pre/Post trigger, e.g.:

Variable 1 -- the center of your range, set value to 150

Variable 2 -- Double-click Variable 2, "Calculate expression automatically", and set as formula: ${Var_1} - 3

Variable 3 -- Double-click Variable 3, "Calculate expression automatically", and set as formula: ${Var_1} + 3

0 Kudos
Message 7 of 12
(7,342 Views)

Of course, my last reply is a possible solution for your last question only.

You need to transfer that isolated application in your "main worksheet". 😉

M.Sc. Holger Wons | measX GmbH&Co. KG, Mönchengladbach, Germany | DASYLab, DIAdem, LabView --- Support, Projects, Training | Platinum NI Alliance Partner | www.measx.com
0 Kudos
Message 8 of 12
(7,324 Views)

Ok, thank you for clarifying it. Now, I have another question: You said that "Stopping the measurement will fire the copy action: copy the value from variable 1 to variable 2." Do I need to set up something or once I stop the program the copy action from variabel 1 to variable 2 happened automatically?

0 Kudos
Message 9 of 12
(7,307 Views)

This is done automatically for you -- it's the job of the Action module to make another module (or DASYLab itself) do "something" when you want that to be done.

An "action" has three parts, that need to be configured in the Action module's configuration dialog: who should do something, what should be done, when should that be done

You should not have any problems to identify the locations, where to set the who/what/when parameters. 🙂

M.Sc. Holger Wons | measX GmbH&Co. KG, Mönchengladbach, Germany | DASYLab, DIAdem, LabView --- Support, Projects, Training | Platinum NI Alliance Partner | www.measx.com
0 Kudos
Message 10 of 12
(7,240 Views)