Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Keep track of counter value after restarting buffered acquisition?

I have to continuously read a counter in my application (M-Series card). Is it possible to keep track of the counter value even after stopping the continuous acquisition? Stopping and restarting the acquisition normally causes a counter reset which means I am losing my absolute counter value. I have to stop the acquisition because I must be able to set another sample rate during execution of the application. Is there a solution?
0 Kudos
Message 1 of 6
(4,578 Views)

Hi Steffan,

 

It's quite hard to give you real solutions if we cannot see the code. Maybe you could post your LV Code over here?

 

The easiest way to "remember" the counter value is to write it continuously to a register or control/indicator and when you  restart the application read from this register/control/indicator and write this as the start value of yor counter (DAQmx Channel Property Node).

 

DAQmx Channel Property Node.PNG

 

Hope this will help you further with your application.

 

If not, please post your project here, and we'll look for a more detailed answer.

 

Regards,

Peter S

0 Kudos
Message 2 of 6
(4,549 Views)

Thank you very much for your reply Peter. I quickly wrote a vi that represents the problem. I know I can start the counter acquisition with an initial value but after the second DAQmx Start Task I do not know the counter value (do I?) while I do want to keep track of the encoder during the execution of my application. Without an initial value the counter starts at 0.

 

Hope this explains it a bit.

0 Kudos
Message 3 of 6
(4,544 Views)

Hi Steffan,

 

I've been looking at your code, but right now I'm in doubt what you want to achieve.

 

Do you want to adjust the samplerate for the counter (which is just detecting edges)? I see that you are using the AI/SampleClock as the reference, are you measuring analog signals next to the counter? Should these be mixed up together?

 

Please tell me more on what you want to achieve (whole application), than we can have a closer look to what's teh best approach for your situation!

 

Regards,

Peter S

0 Kudos
Message 4 of 6
(4,531 Views)

I’m indeed measuring analog samples as well (I did not implemented it in the example code).

Here is an explanation of the application:
I have to monitor the absolute displacement of a digital linear sensor as long as the application runs. The sensor has an encoder with two wires. The DAQmx counter is configured as a Linear Position Counter so I am able to detect the displacement of the sensor in both directions. The LabVIEW application controls a process. In the first phase of this process I have to sample and log the counter value (along with some analog inputs) continuously at for example 200 S/s. This is the point where I start the first acquisition. After a few minutes the process is in a sort of idle state and I do not need to log the data anymore so I stop the acquisition. Lets say that the last sample of the counter reads 4865 which is the last measured position. Meanwhile the process continuous, the sensor position is still changing but I do not measure it anymore.


A next phase of the process can take quite a while (24 hours).  During this phase I again have to sample and log the counter and analog inputs but at a far less sample rate, for example 1S every 10s (defined by user). So I change the sample rate. When I then start the (buffered) acquisition for the second time the value of the counters starts at 0. And this is where my problem begins. I lost the absolute position of the sensor. It is of no use to initialize the counter with 4865 because I know that the sensor position has been changed between both acquisitions. What I want is that the DAQmx counter keeps counting even though I’m not measuring it with LabVIEW.

Any suggestions are welcome!
0 Kudos
Message 5 of 6
(4,527 Views)

Dear Steffan,

 

we talked on the phone about this issue, I just want to post the results of our conversation for the people out there finding a solution for a similar problem. We found out that pause triggering is a possible solution. Unfortunately this requires an extra counter to generate a sample clock which can be paused. Please notice that not all hardware support this feature.

 

Best regards,

Martijn S
Applications Engineer
NI Netherlands
0 Kudos
Message 6 of 6
(4,513 Views)