Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with semi period measurement and more than 3 counters measurements

For our application we want to continuously measure different PWM signals on more counter inputs. For this purpose we used the semi period measurement, because here it is possible to calculate the frequency and duty cycle of the signal.

 

Now following problem were discovered on making the measurement with a NI PCI-6602 card. If we used more than 3 counter channels in parallel and the frequency of the input signals was greater than 1000Hz than some counter measurement tasks have been stopped with the error code -200141. (Error Message: "Measurements: Data was overwritten before it could be read by the system. If Data Transfer Mechanism is Interrupts, try using DMA. Otherwise, divide the input signal before taking the measurement.")

 

After some research in the NI-Forum we maybe found the reason for this problem. It seems the problem comes from the interrupt driven counter measurements. Maybe the interrupt latency is to long and the data can’t be picked up from the HW fast enough. This corresponds with our observation. Only the interrupt driven counter measurements were stopped. The DMA driven tasks run without problem.

 

We have tried several things to solve this problem. E.g. we used the nSamples mode and cyclic restarted the task after measurement has stopped or tried to use some different properties. But nothing really solved the problem. The error message didn’t disappear and the tasks still stopped.

 

We also tried to poll the value with the function DAQmxReadCounterF64 or DAQmxReadCounterScalarF64. But with the function DAQmxReadCounterScalarF64 it isn’t possible to calculate the frequency and duty cycle, because we only get one pulse high or low of the signal. With the function DAQmxReadCounterF64 and reading 2 samples we had the problem that the measured samples weren’t useful for our calculation. Because sometimes the first value in the buffer was the high pulse and sometime the low pulse or sometimes all two values had the high or low pulse.

 

Now our question to this topic is: Exists there any possibilities to fix that problem to measure the PWM signal with a higher frequency on all available channels? For our application it isn’t so important to capture the whole signal. It’s also enough for use if we can measure the signal with fix polling rate. The polling rate is normally greater than 1ms.

 

I have attached a small test program to reproduce the error. We used a NI PCI-6602 card and connected the output of ctr0 to the inputs of ctr1-ctr7.
0 Kudos
Message 1 of 13
(4,436 Views)

Hey,

 

I had a look at your example code and I'm wondering about the values of the "dev" variable.

Can you change the "for(int i = 0; i < NUM_OF_TASKS; ++i)" to "for(int i = 0; i < NUM_OF_TASKS; i++)".

 

 

Christian

0 Kudos
Message 2 of 13
(4,409 Views)

The suggested change in the for loop has no effect on the example because it makes no difference if you use a preincrement or a postincrement for the index variable in the loop. It’s an old habit of mine to use the preincrement in loops because this is faster in some situations.

 

The "dev" variable contains the needed string for the different counter lines. Started with string "Dev1/ctr1" for the first task and ended with "Dev1/ctr7" for the last task.
0 Kudos
Message 3 of 13
(4,400 Views)

You said: "If we used more than 3 counter channels in parallel and ...."

Does it mean that you can use CTR0 for generation and CTR1, CTR2 for measurement without problems, but when you add another counter Task, e.g. CTR3 for measurement, then you get the error?

 

 

Christian

0 Kudos
Message 4 of 13
(4,395 Views)
Yes we use CTR0 for geneartion and CTR1, CTR2, ... ,CTR7 for the measurement. CTR1, CTR2 and CTR3 working without problems but the other counters are making the errors.
0 Kudos
Message 5 of 13
(4,393 Views)

So it seems that your system cannot run more then one counter with IRQ. The pci-6602 hast three DMA channels, which in your case will be used for CTR0, CTR1 and CTR2. CTR3 then runs with IRQ. Adding an additional coutner also needs another IRQ channel, whereas your system seems to be unable to handle that.

 

 

Christian

0 Kudos
Message 6 of 13
(4,390 Views)
The problem seems not to be that no more IRQ channels are avaialbe on the system because the measurement works on all channels if a lower frequency will be used. Only on higher input frequencies the descriped problem occurs.
0 Kudos
Message 7 of 13
(4,388 Views)

It's not the number of IRQ channels, it's the number of IRQs itself.

Imagine with every additional counter channel besides the first three you have IRQ transfer which means in your case that you can get 1000 IRQs per second per channel for your CPU to handle.

 

 

Christian

0 Kudos
Message 8 of 13
(4,384 Views)

Yes that's true. It isn't impossible for the CPU to handle so much IRQs. This was also one of our thoughts where the error comes from. Therefore we are searching for another possibility to use all 8 counters. Are there maybe any properties available to avoid this problem? Or isn’t possible to use all 8 counter simultaneously?

 

How I posted in the first message it isn’t so important for us to get the data of the whole signal. It’s also enough for our application to poll the signal with a fix cycle time to calculate the frequency and duty cycle of a PWM signal.

0 Kudos
Message 9 of 13
(4,358 Views)

You can run 8 Counters for Semi Period Measurement in parallel, but it's system dependend how much IRQs you can handle.

So you could externally devide your signal to measure with lower frequencies then 1kHz per counter.

 

 

Christian

0 Kudos
Message 10 of 13
(4,350 Views)