Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Counting Rising Edges with NI-USB 6009 and Logging data

Hello, 

 

I have a program that measures pulses and displays the number. I figured out how to create a reset button, but it needs to be automatic, not manual. In other words, the counter must start counting from the beginning after every loop iteration.

 

I also need to store the data of each iteration in a table. I have attached the picure of my program.

 

Thanks a lot.

0 Kudos
Message 1 of 5
(6,394 Views)

Hi Evangelos,

 

Without simulating your code myself, I have two quick recommendations for you based on looking at your code.

 

1.  You could wire a True constant into the input of your case structure instead of a Reset control.

 

2.  Remove the case structure and Reset Control, move the DAQmx Start Task VI into left side of your while loop and place a DAQmx Stop Task VI at the right side of your while loop.

 

These methods should work if you want to reset the counter for each loop.  Give both of these methods a try and let us know how it works.

Andrew T.
National Instruments
0 Kudos
Message 2 of 5
(6,381 Views)

Thank you Andrew. I tried both recommendations and both of them worked pretty well. I chose to use the first one though because it's more concise.

 

However, I still can't figure out how to write the number of pulses of each iteration to a table. The "Write" task seems a little bit confusing/

 

 

0 Kudos
Message 3 of 5
(6,376 Views)

hello Andrew,

 

I actually found a way to store the pulses in a table. I have attached the modified code which includes

a digital input channell that stops the loop when it goes high. However, what I need to do is to configure

the program so that when the signal goes high, the counter needs to reset and start adding the pulses

to the data which are already stored in the table (but not clearing them).

 

Also, the digital input seems to be always high, even when it's not wired.

 

0 Kudos
Message 4 of 5
(6,374 Views)

Hi Evangelos,

 

I think you are going to want to include a second while loop inside the main one around your digital bool read, which only exits once the signal goes high.  You also will want to have the counter VI and the write to table functionality in this loop.

 

As far as adding pulses to the table instead of overwrighting them, I would recommend looking into creating an "Edit Position" Property Node for your table output.  Before you start writing to the table for each loop, set the position to where you were right before the digital signal went high.  For help on property nodes, check the link below:

 

http://zone.ni.com/reference/en-XX/help/371361J-01/glang/property_node/

 

Have a great weekend!

Andrew T.
National Instruments
0 Kudos
Message 5 of 5
(6,358 Views)