Quantcast
Channel: Counter/Timer topics
Viewing all 1243 articles
Browse latest View live

measuring counter periodicaly

$
0
0

Dear all,

 

So I have a counting edges task :

DAQmxCreateCICountEdgesChan(aoTask, "Dev1/ctr1", "", DAQmx_Val_Rising, 0, DAQmx_Val_CountUp);

wich I can interogate by the click of a button :

DAQmxReadCounterScalarU32(aoTask,1 ,&count,0);

now I would like to interogate this counter periodicaly  using an external clock and store the results in a buffer.

DAQmxCfgSampClkTiming(aoTask,"/Dev1/PFI15", samplesPerSeconds, DAQmx_Val_Rising, DAQmx_Val_ContSamps, bufferSize);

up until that point, I followed blindly the "Cnt-Buf-Cont-ExtClk" example. but it doesn't work : every time I try to read the buffer

DAQmxReadCounterU32(aoTask, bufferSize, 1.0, counterData, bufferSize, &read, NULL)

I get the following error message :

Some or all of the samples requested have not yet been acquired.

To wait for the samples to become available use a longer read timeout or read later in your program. To make the samples available sooner, increase the sample rate. If your task uses a start trigger, make sure that your start trigger is configured correctly. It is also possible that you configured the task for external timing, and no clock was supplied. If this is the case, supply an external clock.

Property: DAQmx_Read_RelativeTo

Requested Value: DAQmx_Val_CurrReadPos

Property: DAQmx_Read_Offset

Requested Value: 0

Task Name: _unnamedTask<1>

Status Code: -200284

 

even if I wait enough to be sure that the buffer is full...

 

so I tried to trigger the reading with a "every N Sample event"

 

DAQmxRegisterEveryNSamplesEvent(aoTask, DAQmx_Val_Acquired_Into_Buffer, bufferSize, 0, EveryNCallback, this);

but the function is never called.

I don't know what I doing wrong here, is my external clock badly configure (wrong source) or something else???

 

I'm using a PCIe-6351 and I code in CPP using DAQ-mx

 

Thanks in advance for your answer

 


Multiple edge separation measurement

$
0
0

I wondered if someone could tell me if this was possible or how I might set it up if it were. I want to do a variation of Two-Edge Separation measurement with an NI PCI 6602 and DAQ-mx, but with multi-stop capability. What I'm basically trying to do is create a simple multi-stop time to digital converter (TDC). I'm looking at events happening on a millisecond time scale.

 

What I would like to have happen is to arm a counter in response to a digital start trigger on one line, counting ticks from the onboard clock (80MHz for the 6602 I think). I want the counter to log to a buffer tick count each time a "stop" trigger appears on a different line. However, there are potentially multiple stops that can occur on each cycle. So, for example, I might arm the counter and 3 digital triggers occur on the stop line after (say) 2, 6 and 7 ms. The task itself should stop after a timeout (say 10 ms from the start trigger). On issuing a Read command after the timeout I would like to return an array with those 3 values (or the proportional number of ticks) which is then histogrammed over multiple cycles.

 

Is that possible/straightforward?

Simple Period Measurement

$
0
0

Hopefully this will be an easy one for somebody, but working on site under pressure and I can't see what is wrong Smiley Frustrated

 

I have a PCI-6351 card and I am testing it with NI-MAX, I setup a simple task to measure the period of the TTL level square wave running at 500Hz.  I don't put much faith in the function generator for the frequency value but the signal is clean.  Using NI-MAX I run the task and would expect to get constant values around 0.002 seconds, but I get all sorts of values.  The image below shows the results and settings.  

 

image.png

 

There shouldn't be anything more to it should there?

Thanks much,

Mande.

Counter clock from PXI

$
0
0

Hello, I thought it is a simple problem but still I was not able to solve it. I have a very generic counter VI as shown in the snippet.

The counting signal is a non-periodic TTL. The VI fails if this signal is used for a clock (as well). For now my solution is to run periodic TTL from the frequency generator as the clock. However, I think it is waste of the resource and that must be possible to get the clock running from PXI 1042Q express which I am using. This VI does not support use the on board clock or 10 MHz from the chassis (which does not make sense to me). My question is how can I still use the current VI and get the lock from the chassis.

Cheers !

Fast simultaneous edge counting without stopping the task

$
0
0

Hi all,

I am trying to do edge counting with two counters simultaneously. The idea is to use them for photon counting application with two detectors. For this I use the third counter for synchronization. I configure it to generate single square pulse, and update the duration with my acquisition time for every measurement with DAQmxSetPulseHighTime function. The measurement counters are configured to use the rising edge of this pulse as arm start trigger (to start counting) and the low level of the pulse as pause trigger (to stop counting). And this works nicely.

 

However I noticed that Starting/Stopping tasks every time takes about 120 ms, so for acquisition time of, say, 100 ms this adds a considerable delay which I would like to avoid. I tried to keep the counting tasks running, but then the counter does not reset to zero, which obviously makes the results incorrect. I tried to reset the counters at the rising edge of the same pulse with DAQmxSetCICountEdgesCountReset but then it does not allow me to use the pause trigger, so that the counters do not stop counting when the pulse ends.

 

The only working solution that I was able to derive is to read the counter value before starting the trigger pulse, and then subtract this value from the counter value but this of course is nasty and I don't know what happens when the counter buffer overflows.

 

Is there a better way to achieve this goal?

 

The other thing is that in the future I would like to do the gated counting, meaning that there would be a hardware gate present when the laser pulse is present, so that the counting task would only run for a number of hardware gates (without resetting the count to 0) within a larger hardware gate that defines the acquisition time.

 

My board is NI USB-6366. The code is written in python but directly accesses DAQmx C functions so the question relates to ANSI C library.

 

Thanks,

Anton

 

External sample clock with encoder

$
0
0

Hi everybody,

 

I have an external encoder wired to a 9423 module on a 9185 chassis, where i count the impulses of the encoder using channel A and B.

I also have some sensors connected to a 9205 analog Input module. Now I want to use the counter as a sample clock on the PFI on the 9205 module. So basically I have to route the counter signal to the PFI. At least I think that is the best approach. No idea how though. Probably easy with LabView, however I am not using it. Instead I am using Matlab or VS\C++.

 

If I connect one channel (A or B) ´from the encoder to PFI on the 9205,  I can set up the clock without a problem as an external clock connection. Then I wait until x-samples are gathered and execute some functions.

 

So basically my question is, if it is possible to use the counter from the digital input module (I have an output module too, it that helps) as a means of controlling the sampling rate of the analog module? Or am I looking at this wrong?

   

Here the basic set up in Matlab, if it will do any good.

s = daq.createSession('ni'); % Create session

ch1 = s.addAnalogInputChannel('cDAQ9185-1C7CD64Mod1','ai0', 'Voltage'); % analog Input channel

cc = addClockConnection (s,'External','cDAQ9185-1C7CD64Mod1/PFI0','ScanClock'); % set an external clock (e.g. channel A from the encoder)

 

Cheers

contador de tiempo y suma de paro

$
0
0

Buenas noche e logrado hacer un contador de tiempo transcurrido, como por parte de proyecto de  la universidad esto lo e hecho 

con el shif register pero a donde quiero llegar es que también  el contador  me pueda sumar el tiempo cada ves que se  presione el stop me baya sumando el tiempo total de paro 

les a agradezco por si tiempo

 

How to use counters NI 6363

$
0
0

Hi

I got to use the counters on the NI 6363. My problem is, I got a nearly full card.

So my question is. If I use a counter out i.e. CTR 1 OUT, can I use the other pins (CTR 1 Aux/SRC/Gate) for some digital signals? And on the other way the same question if I use CTR 2 Gate?

 

Did I need to use a Counter out to greate a variable square frequency or does the digital out is enough (fmax<500Hz)?

 

Thanks


DAQmx large range 2 counter frequency measurement 1 count off error

$
0
0

I'm using a NI PXI-6229 to measure a 32.768kHz RTC ref clock.

 

I'm setup in MAX with a task using the largerange2 counter frequency  measurement, as I need a very precise measurement.

 

Every say, 1 in 30 measurements comes back wildly out of value compared to the baseline.

ie. 32950.1287968 Hz with a divisor of 181.  

 

When it fails it always is 32950.XXXX when the divisor is 181.  Otherwise  seems very accurate.

 

This value is 181/180 * the value.

 

I figure that one extra trigger in the sample pre divisor might be the problem, but scoping the signal I don't see any glitches.

 

Is there a way to filter higher frequencies.

 

Any ideas?

Taking time measurements when measuring frequency

$
0
0

I am needing to read the frequency of a TTL signal as part of a data acquisition program that also records analog voltage (at 6 kHz). I've looked at the shipping examples for Counter - Read Frequency... etc. but none of them provide a waveform output that would give me time measurements. I'm wondering if it is possible to do this? The only way I can see to do this is to run in "On-demand" mode and take a time measurement when writing to a TDMS file, but this is too slow for my application. I would like to be able to run in "Continuous" mode and obtain time values for all the elements that are read in that "block" of samples. I'm using a 9402 module and generating input TTL signals with a USB-6341.

Using NI 9205 module, external trigger into the PFI0 input.

$
0
0

I'm trying to put my external trigger into the PFI0 digital input.   When I connect up my hardware clock, it loads down my signal.  After putting a DC meter on the PFI0 line, open ckt, I see 1.85vDC just sitting there.   I have tried 2 different modules, and they show the same thing.   I am only looking at 1 chan input on AI1, and it is just a 5 volt level.

PWM input with CompactDAQ & LabWindows

$
0
0

I need to measure the pulse width of a 244Hz PWM signal using CompactDAQ.  Is there a white paper or tech note out there to help me set this up?

Can't read data for the same lap from two counters

$
0
0

Hi

I am using NI 6624 counter board and building an app in C#.

 

I have one counter (0) which counts edges of Index pulse (Z) from a Angle encoder and triggering on PFI4 on rising edge of Z pulse. Where I set a new lap while motor is spinning. Between each Z pulse there is 360 Degrees (time).

 

Another counter (3) is triggering on PFI0. Around 15 degrees after Z pulse.

 

The problem is that before next Z pulse the counter 3 is not reading its value on time which means it missed the lap. 

 

Can someone please suggest how I can make the two counters synchronize?  

 

I want counter 3 to always read before the next trigger of Counter 0.  

 

Below are my counter 0 & 3 code in C#

 

_myTask = new Task();
// Counter 0 use the Z pulse to count laps
_myTask.CIChannels.CreateCountEdgesChannel("CNT/ctr0", "LapCnt", CICountEdgesActiveEdge.Rising,
(long)0, CICountEdgesCountDirection.Up);
_myTask.Stream.ReadWaitMode = ReadWaitMode.Yield;

_myTask.Timing.ConfigureSampleClock("/CNT/PFI4", 350.0, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, 5);
_myCounterReader = new CounterReader(_myTask.Stream) { SynchronizeCallbacks = true };
_myTask.Start();

_myCounterReader.BeginReadSingleSampleInt32(_asyncDaqmCb, _myTask);

 

Counter 3:

_myTaskBeta = new Task();

_myTaskBeta.CIChannels.CreateAngularEncoderChannel("CNT/ctr3", "AngleCnt3", CIEncoderDecodingType.X4, true, 0.0, CIEncoderZIndexPhase.AHighBHigh, 600, 0.0, CIAngularEncoderUnits.Degrees);
_myTaskBeta.Stream.ReadWaitMode = ReadWaitMode.Poll;

_myTaskBeta.Timing.ConfigureSampleClock("/CNT/PFI0", 350.0, SampleClockActiveEdge.Falling, SampleQuantityMode.ContinuousSamples, 5);
_counterInReaderBeta = new CounterReader(_myTaskBeta.Stream) { SynchronizeCallbacks = true };
_myTaskBeta.Start();
_counterInReaderBeta.BeginReadSingleSampleDouble(_asyncDaqmCbBeta, _myTaskBeta);

 

 

NI 9411 Continuous Edge Counting - external sample clock

$
0
0

Hi

 

 I have a DAQ setup that uses the following:

  • Chassis NI cDAQ9188
  • NI 9411
  • Quadrature Encoder

 

I want to make continuous buffered measurement of position reading from the quadrature encoder. I first set up a task in NI MAX:

  • It works if I configure my signal as 1 Sample (On Demand).
  • It doesn’t work if I change to Continuous Samples (Use digital input sample clock as the external sample clock). I received Error 200284, which indicates not getting enough samples within the Timeout period.
  • The only Sample Clock it accepts seems to be the 100kHz Timebase, and the sample rate needs to be 100kHz as well. This is too fast for what I need.

image.pngimage.png

 

To simply the problem, I changed the task from position measurement to edge counting. The problem still there.

  • I tried running the Counter – Count Edges (Continuous Clock).vi shipping example, the result is still the same.
  • I have read up about the buffered continuous edge counting; it only says that an external sample clock is required, doesn’t go deeper beyond that.
  • I have checked the KBs:
    • DAQ Assistant Edge Counting Error for N Samples or Continuous Samples
    • DAQmx Read VI Error -200284 Samples Have Not Been Acquired
    • Neither of them really answers my question.

Since I can acquire edge counts if the task is set to “On Demand”; I would say the hardware is configured correctly. 

 

It seems that when the task is set up as continuous buffered acquisition, then it needs an external clock to drive the data acquisition, which is fine. My question is: Why does it only accept the 100kHz Timebase and nothing else? It seems that it will not accept the external sample clock unless it’s the 100kHz timebase (and sample rate = 100kHz). With no sample clock => no samples acquired => Error -200284.

 

Continuous sampling works in simulation mode. I can use any sample clock, but with thee actual hardware that I have, it only works with 100kHz Timebase.

 

I have checked the routing of the sample clocks, the counter sample clock seems to support all external clocks.

image.png

 

Any ideas?

 
Thanks
Yu-An

DAQmx Channel Property node for mixed counter task, error 200452

$
0
0

Hi Folks,

 

I've a task where I'm measuring 4 frequencies and 1 encoder (A/B).Screen Shot 2018-04-24 at 15.44.17.pngI want to enable and set the filter on the frequency channels. This works, if I remove the encoder channel from the task, but when I include the encoder channel again, it results in the error below.Screen Shot 2018-04-24 at 15.43.38.pngError:

Screen Shot 2018-04-24 at 15.43.10.png

 How could I prevent this error for counter tasks? Selecting a channel only works for the analog inputs.

 

Thanks,

 

Jasper

 

 


2 finite pulse generation by a counter triggered by one counter

$
0
0

Hi guys,

I am using NI USB-X 6353 and 6343 for a test system. I need two sequential pulses from a counter after triggering it with another counter on the same board. I would like to start the trigger counter once and then generate 2 sequential signals from other counter on the same board. I tried to explain it on a graph below. I am able to generate one counter signal after the first one, however, I need one more without starting the first counter again. Is it possible to do it with these devices? I also added a code that I was using to generate just one counter after triggering other one without any problem. Is it possible to modify this code to work in this manner as I explained? Thanks in advance guys.

explanation.png

 

 

 

can't run example of DigPulseTrain-Cont-Buff-ExtClk

$
0
0

Hi all,

 

I was trying to run NI DAQmx example of "DigPulseTrain-Cont-Buff-ExtClk", but there is an error generated once the external clock is supplied at frequency of 1 Hz as specified in the example. Error message as the following and I am using x-series PCI-e:

 

Sample Clock pulse occurred before a pulse could be generated using the previous pulse specification. Use a Sample Clock that is slower than the pulse train you want to generate.
Task Name: _unnamedTask<0>

Status Code: -201318

 

Any help would be highly appreciated.

[NI 9361] Dynamic Averaging on Period Measurements not working as expected

$
0
0

I am trying to demodulate a frequency modulated square wave by using a NI 9361 counter on a NI 9174 chassis. I am measuring the period length in ticks, but it is always quantized at 2k ticks. At lower frequencies, 2k ticks quantization gives a comparatively low quantization error, and its hard to notice, but at higher frequencies of my application, the quantization is 10x my signal amplitude.

 

With the 100MHz time base, this translates to what I would expect if I was discretely sampling a square wave at 50kHz. However, this absolute quantization is independent of signal carrier/mod freq/amplitude and also independent from the Dynamic Averaging Measurement Method parameters, namely, the user inputs for expected signal range ('minimum value', 'maximum value'), 'measurement time' and 'divisor'. It was my understanding that these parameters could be tweaked to affect how the dynamic averaging affects quantization error?

 

Is this an effect of the chassis perhaps? Or am I fundamentally misunderstanding how this counter works. Is it not theoretically possible to have quantization of one tick? This is how I've interpreted the datasheet.

PXI-6602 Counters

$
0
0

I am using a PXI-6602 card connected to a SCB-68 break out.  I am able to generate an output from CNTR 0 and CNTR 1.  None of the other counters 2 thru 7 appear to work.  I monitor their outputs with a Oscope and I see nothing.  Do I need to enable them some how.  

Counter logic confirmation

$
0
0

G'day,

 

I'm coming here from this post, with the aim of confirming my understanding of counters in Labview.

 

I've tried to build stable, accurate square wave output waveforms using software timing, which isn't going to work for my application. As such, I'll be selling my PCI-6509, and replacing it with either a PCI-6601 or 6602. What I'd like to confirm is the following; can each counter task in Labview (I'm using 2014) be used for multiple digital outputs (DAQmx Write)? My understanding is the counter can be used to increment a shift register, so I can change (during runtime) the frequency of two separate DO channels by changing their respective rate of going HIGH/LOW as the shift register increments.

 

I.e. the rate of change of the shift register is static, and determined by the hardware clock on the PCI card (e.g. 100kHz). SquareWave1 might toggle HIGH/LOW every 100th increment, whereas SquareWave2 might toggle HIGH/LOW every 200th increment. These numbers (100, 200) could be controlled (during runtime) with a slider, gauge, etc.

 

Is my understanding correct? I'm trying to gauge whether I'll need the 4-counter (6601) or 8-counter (6602) card, as I'll certainly need more than 4 accurate square wave outputs. If my understanding is NOT correct, I'll opt for the 6602. If my understanding is correct and I can share a single counter with multiple DAQmx Write events, then the 4-counter card will be sufficient.

 

Thanks!

Viewing all 1243 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>