Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

period measurement .NET

Hi
 
  I have even tried using Ctr7Internaloutput. Following is the code
 

firstTask =

new Task();

DaqSystem.Local.ConnectTerminals("/Dev1/Ctr7InternalOutput","/Dev1/Ctr5Gate");

firstTask.COChannels.CreatePulseChannelFrequency(

"/Dev1/Ctr7", "PulseTrainSequencer", COPulseFrequencyUnits.Hertz, COPulseIdleState.Low, 0, 5000, .5);

firstTask.COChannels.CreatePulseChannelFrequency("/Dev1/Ctr6", "PulseTrainAPDSimulator1", COPulseFrequencyUnits.Hertz, COPulseIdleState.Low, 0, 30000, .5);

firstTask.Timing.ConfigureImplicit(

SampleQuantityMode.ContinuousSamples, 1000);

secondTask =

new Task();

secondTask.CIChannels.CreatePeriodChannel(

"/Dev1/Ctr5", "BufferedEventCounting", .000000025, 53.6, CIPeriodStartingEdge.Rising, CIPeriodMeasurementMethod.HighFrequencyTwoCounter, .0002, 4, CIPeriodUnits.Ticks);

// secondTask.CIChannels[0].PeriodTerminal = "/Dev1/PFI18"; /tried this too but not working

dataReader =

new CounterReader(secondTask.Stream);

myCallBack =

new AsyncCallback(CounterReadCallback);

dataReader.SynchronizeCallbacks =

true;

dataReader.BeginReadMultiSampleDouble(-1,myCallBack,

null);

taskRunning =

true;

firstTask.Start();

  I get an error in the callback while reading the data .Status code -89137 . Specified route cannot be satisfied,because it requires resources that are currently in use by another route

 COChannel PulseTerminal

Dest Device :Dev1

Dest Terminal : ctr5gate

 Resources are used by Source Terminal : Ctr7InternalOutput  Destination Terminal :Ctr5Gate 

 

Can anyone let me know what is wrong ?

I 'm also supposed to connect internally the Ctr7 output to multiple counters gate . How should I go about it ?

  Thank you

Murugan

 

0 Kudos
Message 11 of 53
(2,493 Views)
Murugan,

Try routing the output signal to RTSI_0 and then to the gate of counter 5, that is how you can connect multiple gates together.  You connect a signal to an RTSI line and then to your multiple points from there.

http://digital.ni.com/public.nsf/websearch/CE99A0B2A9048A2A86256C630062F550?OpenDocument

This KB describes this type of operation.

Regards,
Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 12 of 53
(2,484 Views)

Hi Kenn

 Thanks for the reply. But in the code given I'm only internally connecting one signal. But I get the error specified in my previous email.

Question 1: What is the cause of the error ?

Question 2: In the articles they specify about C and Labview. Nothing is specified about C# .

 Should I have to use ConnectTerminals twice to connect to RTSI0 and then to another counter's gate ?

DaqSystem.Local.ConnectTerminals("/Dev1/Ctr7InternalOutput","/Dev1/RTSI0");

DaqSystem.Local.ConnectTerminals("/Dev1/RTSI0","/Dev1/Ctr5Gate");

 It doesnt work it gives the same error.

How to go about this using DAQMX API's?

 I couldnt find anything other than connectTerminal for select signal and Change_parameter

  Thanks for your Advance help.

Thanks

Murugan

 

0 Kudos
Message 13 of 53
(2,481 Views)
Murugan,

You cannot route the signal to the RTSI bus or any other PFI line since you are are using the counter in a task.  The resource is reserved.  This is partly described in this KB article.  http://digital.ni.com/public.nsf/websearch/A7A4024278353BF7862570230072C6E1?OpenDocument 

The process of routing a counter output to more than one gate can be done but not while you are using that counter for an additional task like period measurement.

Regards,
Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 14 of 53
(2,473 Views)

Hi Kenn

  Thanks for the information.

  How will I go about in the following scenario.

 Each of the 5  counters will be connected  to a unknown source. I have to take the known gate signal from a 6th counter as a reference to count the edges of the unknown source for each of the counter.

  As per the information given by you If I cannot route the gate signals to the counter as I'm using the period measurement for five of the counters. How will I go about this ? 

 I will be using the period measurement to count the edges in the five counters .

 Instead of using the gate signal is there any other way to go about it?

 Another angle : if I dont connect the gate but if I give the measurement time parameter to be the 1/frequence of the gate signal in the CreatePeriodMeasurement function with 2 counter high frequency parameter it works fine giving the number of edges of the unknown source. I think in this case for the measirement time given it counts the number of edges. But the 2 counter high frequency doesnt make any sense.

Thanks for  your advance help Kenn.

Thanks

Murugan

 

 

 

 

 

0 Kudos
Message 15 of 53
(2,460 Views)
Murugan,

So it sounds as though you have it working with just one counter each.  What is the frequency of each of the unknown signals? 

If the frequency is lower than say 20MHz you should be fine using 1-counter period measurement.  Otherwise if you need to use 2 counter period measurement you will only be able to measure the period of 4 signals since you have 8 counters.

Regards,

Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 16 of 53
(2,443 Views)

Hi Kenn

 Thanks for the reply.

  Quest ion 1: But I didnt get the reply for my first part of my question in my previous email . Regarding the connections if I'm going to connect each of the counter gate to a single output of a  counter.

Question 2:  Yes it works with one counter. The frequency of the unknown signal will be less than 20 MHZ. But if i change the parameter for the create period measurement API form 2 - high frquency counter to one . It doesnt work .Please clarify.

Question 3: If I'm going to go with one counter period measurement and I want all the counters to start counting at the same time How do I go about it? I read about ArmStart Trigger. If I use ArmStartTrigger what will be the source while using the single counter period measurement. Should I have to use a Start Trigger after using the ArmStrart Trigger ? What will be the source of the start trigger? Can you please explain. I did a search on this but couldnt find much information on DAQMX. Few I found didnt answer my questions.

 Please clarify/answer/explain  the above specified questions.

Thanks

Murugan

 

 

 

0 Kudos
Message 17 of 53
(2,437 Views)
Murugan,

To address each of your questions I have replied to each one seperately.

  Question 1: But I didnt get the reply for my first part of my question in my previous email . Regarding the connections if I'm going to connect each of the counter gate to a single output of a  counter.

Route your the output of the counter you want to use to a RTSI line.  Then route from that down to each of the gates.  This should work in a one counter period measurement. Or simply connect them externally with wires.

Question 2:  Yes it works with one counter. The frequency of the unknown signal will be less than 20 MHZ. But if i change the parameter for the create period measurement API form 2 - high frquency counter to one . It doesnt work .Please clarify.

I am not sure what you are asking here, what doesn't work?

Question 3: If I'm going to go with one counter period measurement and I want all the counters to start counting at the same time How do I go about it? I read about ArmStart Trigger. If I use ArmStartTrigger what will be the source while using the single counter period measurement. Should I have to use a Start Trigger after using the ArmStrart Trigger ? What will be the source of the start trigger? Can you please explain. I did a search on this but couldnt find much information on DAQMX. Few I found didnt answer my questions.

You can use the Arm strart trigger to arm your counters and then the start trigger to begin the counter operation.  You can use one of the available PFI lines as your trigger source, such as PFI0


Lastly, what is your overall application from a high level perspective?

Regards,

Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 18 of 53
(2,423 Views)

Good morning Kenn

Question 2:  C# API to create period measurement is

measurementTasks[i].CIChannels.CreatePeriodChannel(inCtr,

"BufferedEventCounting", .000000025, 53.6, CIPeriodStartingEdge.Rising, CIPeriodMeasurementMethod.HighFrequencyTwoCounter, .0002, 4, CIPeriodUnits.Ticks);

Even for the case of one counter the program works only if I give the CIPeriodMeasurementMethod to be HighFrequency 2 counter. If the parameter is given as lowFrequency one counter the data is always null. Can you please clarify .

 Thanks I got the ArmStartTrigger to work. Instead of Start trigger I have created a Digital Channel with Dev1/port0/line0 and toggled the bit to true to false to start the counters at the same time.

  Higher level view of this project is to identify the specific pathogens in the atmosphere.

  Sequence-specific probes are hybridized to genomic DNA. Proprietary microfluidics stretch the DNA to full contour length and deliver the individual molecules to be read by the laser excitation . x number of  APD's will be collecting burst of photons from the laser excitations and data analysis will be done to identify the barcode of the pathogens based on the data collected.

Thank you

Murugan

 

0 Kudos
Message 19 of 53
(2,411 Views)
Murugan,

We discussed earlier the different signal connections for a 2 counter Period measurement and a 1 counter period measurement.  So if you change the type of period measurement without adjusting your signals accordingly it will not work correctly.  This may be your problem.  Refer to that part of our discussion on this thread to see the different signal connections.

I'm glad you got the Arm start trigger to work, and creating the pulse on line0 sounds like a good solution.

Regards,

Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 20 of 53
(2,394 Views)