Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

period measurement .NET

Hi Kenn
 
  I have a quick question. Under the same settings mentioned in my previous emails I acquire data using period measurement from 5 counters and save the data in the respective text files.
 
  For testing purposes the source input is a signal generator of varyiing signal frequency from 40 to 60 KHZ. This input is the source for all the counters. Gate Signal is 10 KHZ for all the counters.
 
 I  use seperate callbacks for each counter to continue acquisition till the stop button is pressed. Under this condition I'm supposed to get the same output for all the counters as the source frequency and the gate is same for all the 5 counters.  But I could find some slignt change in the output. The data is the same for couple of lines and varies by a count in one line and then its the same then again it varies by a count .
 
Am I missing some thing ? Any idea this scenario may happen?
 
Thank you
Mullai JK
 
0 Kudos
Message 31 of 53
(1,927 Views)
Mullai,

Synchronization seems to be the culprit.  If your gate and soruce are phase locked then you may get different counts on occasion, depending on how far off synch the signals are.

Regards,
Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 32 of 53
(1,916 Views)
Hi Kenn
 
Can you please explain more on this. I dont get a clear picture of the problem.
 
What should I do to solve this problem?
 
 
Thank you
Murugan
0 Kudos
Message 33 of 53
(1,912 Views)
Murugan,

Somehow you need to syrnchronize your two signals.  This is usually done with an external PLL (Phase-Lock Loop) circuit.  Your devices may have some outputs on the backplane to accomplish this, but if they don't you will have to build this circuit yourself or buy it from some other company.  We don't have this type of circuitry in an external circuit.  We use PLL's in many of our devices, but that is all internal to the card or chassis.  This may take some research on your part to figure out.

Regards,

Message Edited by Kenn N on 10-27-2006 12:20 PM

Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 34 of 53
(1,911 Views)
Hi Kenn
 
 I dont think the problem is related to the phase lock.
 
  I have this problem when I use seperate callbacks for each counter . I could see a difference in 1 or 2 counts in the output at some random offset.
 But If i use the same call back for all the counters and do the read and write in a for loop then I dont see any difference in the output. But In this case I have some other problems such as I'm not able to stop the measurement tasks .While doing the Measurement task dispose the program hangs/or takes a long time to dispose.
 
  We also have the same application implemented in C++ using Traditional DAQ . It works fine.
 
 Please clarify. If you want I could email the code.
 
 I'm stuck with this problem.Any help as early as possible will be appreciated.
 
Thank you
Murugan
0 Kudos
Message 35 of 53
(1,888 Views)
Murugan,

If you are calling code between counting measurements there will be latency due to the software timing.  Even if the calls took no time I don't think you have guaranteed that your signals are locked in phase.  There will be some error over time if they are not locked.

Regards,

Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 36 of 53
(1,876 Views)
Hi Kenn
 
 Thanks for your time and effort. 
 
But as I said before I couldnt find the difference in the output if the same callback is used for all the counters. So I move forward in this direction.
 
 But In this case if I dispose the task it hangs/takes a long time to get disposed . I have gone through the forums related to this but it doesnt correlate to the above specified scenario.
 
 
 I made it sure that the callback will not be called again once the Stop button is pressed by passing

BeginReadMultiSampleInt32 with a null parameter for the call back in the read thread (I'm using a thread to read) .I also set the task running to false so that the flow doesnt enter the code block (EnReadMultipleSampleInt32 and writing to a file ) in the callback.

for( int k = 0; k < measurementTasks.GetLength(0);k++)

{

measurementTasks[k].CIChannels[0].Dispose();

measurementTasks[k].Dispose();

}

Even tried Stop before Dispose . 

 Still it takes long time/hangs

I even tried using abort . But when I press start again it says the resources are reserved.

Any suggestions/ideas/cause for this problem ?
 
Thank you
Murugan
 
0 Kudos
Message 37 of 53
(1,871 Views)
Murugan,

So is your problem that it takes too long to stop or that the resources are reserved.  There is a way to decrease the time it takes to start and stop.  If you "commit" the hardware first and then start the task and then stop, it goes back to the state it was in before the task was started, which is the commit state.  This should decrease your time.  There is information on this function in the .NET help for DAQmx, it is under the Task.Control Method.

Regards,

Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 38 of 53
(1,857 Views)
Hi Kenn
 
 I tried using commit before the start task. But it still takes a long time (couple of minutes depending on how many minutes I acquire the data) to dispose .
 
 I logged out some messages and found out that the asynchronous callback is getting called when the stop task is being executed. Anyway no code fragment is executed in the asynchronous callback as the task running is false.
 
 What is causing the problem ?What is supposed to be done to solve the problem ?
 
 Advance Thanks Kenn
 
Murugan
 
 
0 Kudos
Message 39 of 53
(1,849 Views)
To give a clear picture of the previous post
 
- Stop task takes a long time to stop.
- When the stop task is called the asynchronous callback is being continuously called. Anyways no code fragment is executed in the callback as soon as the stop button is pressed. But still I could see the call back being called for a long time .
 
 Hope this gives a clear picture of whats going on.
 
 
 
Thanks
Murugan
0 Kudos
Message 40 of 53
(1,850 Views)