Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

using two counters

I'm trying to use two counters in MS. One to create a pulse train and the other to count digital edges from an external source. Both of them work fine separately, but when I try to have them run at the same time I get an error say the resources aren't avaiable.

Also, If I wanted the counter input to be something other than ctr0 or ctr1. How would I program that? I've tried using pfiN, N=1..9, but that doesn't work. I'm using c#.

Thanks
JMD
0 Kudos
Message 1 of 4
(4,064 Views)
JMD

In order to specifically address your question, I will need a little more information.

1. What version of Measurement Studio are you using?

2. What hardware (model number) are you using?

3. What exactly is the error you are getting? Is there an error code?

This is a link to an example program that may help you with using PFI pins for counters.

Russell G.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(4,064 Views)
I'm using MS7, and PCi 6036. I get an error "The specified resource is reserved" and Status code: -50103. I'm using the following code:
coTask = new Task("");
coTask.COChannels.CreatePulseChannelFrequency("/6036/ctr0", "",
COPulseFrequencyUnits.Hertz, COPulseIdleState.Low, 0, rate, 0.5);
coTask.Timing.ConfigureImplicit(SampleQuantityMode.FiniteSamples, count);
coTask.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger("/6036/pfi0",
DigitalEdgeStartTriggerEdge.Rising);
coTask.Triggers.StartTrigger.Retriggerable = true;
coTask.Control(TaskAction.Verify);

ciTask = new Task("ci1");
ciTask.CIChannels.CreateCountEdgesChannel(
"/6036/ctr1",
"",
CICountEdgesActiveEdge.Rising,
0,
CICo
untEdgesCountDirection.Up);
ciReader = new CounterReader(ciTask.Stream);
ciTask.Control(TaskAction.Verify);
0 Kudos
Message 3 of 4
(4,064 Views)
From your code, it looks like you are trying to do finite pulse generation with one counter. You need both counters to do finite pulse train generation. One counter generates the pulse train, and the other counter generates a pulse that acts as a gate for the first counter. If you change the pulse train to generate continuously or only generate one pulse, both run at the same time without error.

When you say you want to program the counter input to be something other than ctr0 or ctr1, what do you mean? The source of ctr1 is PFI3, and the source of ctr0 is PFI8.

Russell G.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(4,064 Views)