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

Remove counter output route

$
0
0

I have a PXI-6251 card. To trigger simultaneous analog and digital output, I use one of the counters. Since I use all digital lines, I would like to not have the counter output on any of the lines.

Is there a way to remove the counter output from PXI12?

 

Thanks,

Jonas


Missing Tooth Detection MyDAQ Counter

$
0
0

I'm trying to use the MyDAQ to detect a trigger wheel missing tooth using the Counter period function but have thus far had spotty results. My input signal looks like this:

trigger_output.PNG

Which is the output from a 36-1 trigger wheel (which means teeth are spaced evenly for 36 teeth but 1 is missing). My goal is to detect the missing tooth (so I can synchronize other measurements to it) and use the period from all of the other non-missing teeth to get RPM.

 

I have attached the code I'm working on - it's not very pretty at the moment and has a few inputs that have not been hooked up yet because the core logic is not working properly. I know that my signal is extremely consistent but the periods in the output array indicate otherwise (I have thuroughly tested the signal generator I'm using to create this signal - I know that it is not the problem). Here's a sample:

output_array_sample.PNG

There seem to be a lot of missing or incorrect periods - it should have the (relatively) same period for 35 samples and then 1 period should be roughly 2 times that of the previous period.

 

Any idea what I'm doing wrong or how I can do it better?

 

Thanks!

PCI-6133 always returns huge constant number of counts

$
0
0

Hi,

I am trying to use a PCI-6133 with a BNC-2110 adapter to counting leading edges of pulses.  Please excuse my high degree of ignorance of how to do this.  Anyway, I connected up my TTL input signal according to the BNC-2110 instructions (to PFI-8 via User-2). Whenever I run the DAQmx sample program Count Digital Events.vi, it recognizes the PCI-6133 OK, but always returns an absurdly high and constant number of counts, like 3.2e9.  The number doesn't change as I send test pulses into the input.  It also remains the same even if I disconnect the input line entirely and rerun the sample program.

Rebooting yields the same behavior.

 

Using DAQ assistant to generate my own code, instead of the sample program, produced exactly the same result.

 

Thanks for any help you can give me.  I don't even know where to start to debug this problem.

 

Thanks,

Andy

 

Counter that triggers off the rising and falling clock edges?

$
0
0

I've got an interesting problem of a device that flips its state between high/low everytime an event happens (so two events make one complete cycle).  I'd like to clock an E series synchronously with it, but looking at the documentation I can't see anyway to tell a PFI input or counter to generate a new clock cycle on both the rising and falling edge.  Instead, it just generates a new cycle at half the actual event rate.  

 

I realize I could generate a new clock at approximately the same frequency using the internal timebase, but unfortunately any jitter between the two clocks must be very, very small (<5 ns) for my application to work and the internal time base doesn't have great resolution.  

 

Is there some obvious solution I'm missing ?

How do I modify my simple state machine into a counter?

$
0
0

Part 2 (50 points): Modify the appropriate files in PE2SimpleState.lvproj to create a counter.  The counter should:

  1. (5 points) Be automatically initialized to zero.
  2. (5 points) Be able to count the number of times a button is pressed.
  3. (5 points) Be able to be reset to zero, and allow the user to continue to count button presses.

The front panel of PE2Main.vi should have 3 buttons labeled:

  1. (5 points) Count
  2. (5 points) Reset
  3. (5 points) Stop (You will receive 5 points if pressing Stop, stops the program.)

On the block diagram you must:

  1. (5 points) Use the event structure in the Wait for Event state to handle the button presses.
  2. (5 points) Create additional states to initialize, increment, and reset the counter.  (You will not receive full credit if you take these actions within the event structure itself- instead events in the event structure should cause the correct state in the case structure to execute.)

Type definitions must be modified correctly:

  1. (5 points) PE2Data.ctl must store the current count in a control (field) called count.
  2. (5 points)PE2State.ctl must have the appropriate states to make the counter work.  Don’t forget that you need to create a case for each item in PE2State.ctl.

When you have completed parts 1 and 2, create a new Zip File Build Specification and upload the generated zip file to the Practical Exam 2 Wednesday Blackboard assignment.

DO wave in step-ncreased frequency, possible?

$
0
0

Using cDAQ 9174 + NI 9402 DIO,

To generate DO wave in gap-step-up mode,   Is it possible and how to set that step-increasment?

for example : one pulse-width + step-changing gap time between pulses

  20131206180207.jpg

How to synchronize trigger the start and stop of 4 timer/counter(with different duty cycle) ?

$
0
0

Hi, every Sir :

 

I am using cDAQ 9174 + NI 9402 to generate some relate triggers for instruments controls.

To generate the 4 DO wave with 4 counters, like this:

 

mcounter.gif

 

For the delay between channels, should be adjustable in us level.  like this:

 

mcounterSpulse.gif

 

 

But for default setting with interlock, 4 channels are not synchronized, the time uncertain in ms level.

 

So how to synchronize trigger the start and stop of  4 timer/counter(with different duty cycle)?

 

I noted the related topics, for examples thise use arm start trigger somethings.

 

but  cDAQ 9174 + NI 9402 maybe not have those ai/ao start trigger.

 

Is any triggers internal to control the start and stop of  4 timer/counter?

 

for example, an another counter inner-directedto trigger this start and stop?

 

 

Any suggestions are welcome, VI, DAQmx.....

 

 

 

 

using asynchronous timer for data flow control

$
0
0

Hi all,

  I am using system sleep to control the data flow (some digital lines and analog output). The pseudo code is something like this

 

Sleep(150);
// the following sections are exectuted in parallel
  #pragma omp parallel sections
  {
    #pragma omp section
    {
      DAQmxWriteDigitalLines(...); // output TTL to one digitla line
    }
    #pragma omp section
    {
      DAQmxWriteDigitalLines(...); // output TTL to another digitla line     
    }
    #pragma omp section
    {
      Sleep(2); // sleep 2ms
    }
  }

// the following sections are exectuted in parallel
  #pragma omp parallel sections
  {
    #pragma omp section
    {
      DAQmxWriteDigitalLines(...); // output TTL to one digitla line
    }
    #pragma omp section
    {
      DAQmxWriteAnalogScalarF64(...); // analog output to one channel
    }
    #pragma omp section
    {
      Sleep(1); // delay 1ms
    }
  }

// the following sections are exectuted in parallel
  #pragma omp parallel sections
  {
    #pragma omp section
    {
      DAQmxWriteDigitalLines(...); // output TTL to one digitla line
    }
    #pragma omp section
    {
      DAQmxWriteAnalogScalarF64(...); // analog output to one channel
    }   
#pragma omp section
    {
      DAQmxWriteAnalogScalarF64(...); // analog output to another channel
    }
    #pragma omp section
    {
      Sleep(11); // delay 11ms
    }
  }

// ... other stuffs

 

 

I am running windows XP and I know it is not possible to get realtime control but  I want a as precise timing as possible. Above code is not perfect but it works 95% of times. I just read an article about using the asynchronous timer to control the time delay. I try that idea with the following code frame

 


int CVICALLBACK ATCallback(int reserved, int timerId, int event, void *callbackData, int eventData1, int eventData2) { if (event==EVENT_TIMER_TICK) { int *nextdelay = (int *)callbackData; SuspendAsyncTimerCallbacks(); if (timerId>=0) { double time; if (*nextdelay==0) time=2.0; else if (*nextdelay==1) time=1.0; else time=12.0; SetAsyncTimerAttribute(timerId, ASYNC_ATTR_INTERVAL, time); if (*nextdelay==0) { #pragma omp parallel sections { #pragma omp section { DAQmxWriteDigitalLines(...); // output TTL to one digitla line } #pragma omp section { DAQmxWriteDigitalLines(...); // output TTL to another digitla line } } *nextdelay++; } else if (*nextdelay==2) { #pragma omp parallel sections { #pragma omp section { DAQmxWriteDigitalLines(...); // output TTL to one digitla line } #pragma omp section { DAQmxWriteAnalogScalarF64(...); // analog output to one channel } } *nextdelay++; } else if (*nextdelay==3) { #pragma omp parallel sections { #pragma omp section { DAQmxWriteDigitalLines(...); // output TTL to one digitla line } #pragma omp section { DAQmxWriteAnalogScalarF64(...); // analog output to one channel } #pragma omp section { DAQmxWriteAnalogScalarF64(...); // analog output to another channel } } *nextdelay++; } } ResumeAsyncTimerCallbacks(); } return 0; } void main(void) { int n = 0; int timeid; timeid = NewAsyncTimer(120.0/1000.0, 3, 1, ATCallback, &n); }

But it doesn't work. There is no compilation and runtime error but the timing just not right. I wonder do I have to suspend the timer in the callback function when I reset the delay for next call? If I do so, I am worry if it will apply too much delay (since I suspend and resume the timer in the delay) so it will cause even worse timing. But if I don't suspend the timer before I reset the time, what happen if the code running in the callback function not finished before the next callback arrive. It is quite confusing how to use asynchronous timer in this case. Thanks.

 

 


Please help with C code to synchronize counter output to analog input

$
0
0

Hi All,

 

I am using NI DAQ USB-6353 with text-based C code to control it. I would like to send a continuous pulse train from the DAQ to pulse a power supply, which then activates an electron beam producing current to be read by the analog input port of the same DAQ. I would like to keep only the analog samples during the pulse peak and samples of a couple pulse widths right after. I am successfully to generate a pulse train using the sampled clock from a counter output channel, but fail to use the same clock to synchronize the pulse train with the analog input. DAQmxReadAnalogF64 is not called by the static function EveryNCallback set for the analog input task. Am I doing something wrong with the following codes? It would be great if it turns out only I am using the wrong sampled clock name of the counter ("dev1/PFI8") for the analog input. Or is something more fundamental that a counter cannot be sync. with an analog input?

 

Would someone be able to send me a link to an example in C or C++ or visual basic showing how to synchronize a buffered sample clocked digital pulse train from a counter output channel to an analog input? To simplify the post, the below codes do not include the static functions EveryNCallback and DoneCallBack, but I can send them if needed.

 

Many thanks in advance for your help,

Thuc Bui

 

//setting operation parameters

double initDelay = 0.0, freq = 10;

double dutyCycle = 0.0001;           //thus pulse width is 10 microsec

unsigned highTicks = 4;   //per period

unsigned numSamplesPerPeriod = highTicks / dutyCycle;   //40000 samples/period

unsigned lowTicks = numSamplesPerPeriod - highTicks;      //per period

unsigned sampleRate = 2*numSamplesPerPeriod*freq;       //800000 samples/s

//create counter

TaskHandle counterTask;

int errCode = DAQmxCreateTask("", & counterTask);

errCode = DAQmxCreateCOPulseChanFreq(counterTask, "dev1/ctr0", "",

                                 DAQmx_Val_Hz, DAQmx_Val_Low,

                                 initDelay, freq, dutyCycle);

errCode = DAQmxCfgSampClkTiming(counterTask, "dev1/PFI8", sampleRate, DAQmx_Val_Rising,

                           DAQmx_Val_ContSamp, numSamplesPerPeriod);

//create analog input

TaskHandle aiTask;

double minVolt = 0.0, maxVolt = 1.0;

errCode = DAQmxCreateAIVoltageChan(aiTask, "dev1/ai0", "", DAQmx_Val_Diff,

                                 minVolt, maxVolt, DAQmx_Val_Volts, "");

unsigned bufferSize = 10* numSamplesPerPeriod;

errCode = DAQmxSetBufInputBufSize(aiTask, bufferSize);

errCode = DAQmxCfgSampClkTiming(aiTask, "dev1/PFI8", sampleRate, DAQmx_Val_Rising, DAQmx_Val_ContSamp, numSamplesPerPeriod);

 

errCode = DAQmxRegisterEveryNSamplesEvent(aiTask, DAQmx_Val_Acquired_Into_Buffer,

                                        numSamplesPerPeriod, 0, EveryNCallback, 0);

errCode = DAQmxRegisterDoneEvent(aiTask, 0, DoneCallBack, 0)

 

//start aiTask first

errCode = DAQmxStartTask(aiTask);

//then counterTask

errCode = DAQmxStartTask(counterTask);

 

how can I specify a delay generate a counter pulse?

$
0
0

Hi all,

  I have a question about using the counter to generate the pulse train. I don't have how to program it but I try the test panel in the MAX and I see it generates the pulse train at some rate and with some pulse duration. I am thinking if it is possible to generate only one pulse with given pulse duration at sometimes after I start the task? I have a code to output an analog waveform, the waveform lasting for 35ms. I wonder if it is possible to syncronize the output of the analog waveform as well as the counter such that at 12.5ms after the waveform output started, I send that single pulse from the counter port out. I have no idea how to do that, I am thinking to use a delay but it is hard to precisely control the time to exact 12.5ms.

external timer using ni usb 6251 code with labview

$
0
0

i need help pleas 

how to write external timer using ni usb 6251 code with labview to measurment pulse width about 5 msec

 

 

Difference between CI Freq and CI Pulse Freq

$
0
0

I'm using a NI 9401 to collect counter data for a optical tachometer and a flow meter but I noticed there was a specific subsection of DAQmx counter channels for Pulse measurement.  I think I understand the Pulse time and pulse tick inputs but I'm not getting the Pulse freq.  Namely I don't understand how that is different than the normal CI Freq measurment.

 

Glancing at the LabVIEW detailed help doesn't seem to offer a clear difference that I can see. I don't suppose anyone can explain the difference or has a link to a resource explaining this in greater detail than the help document?

 

Freq vs pulse freq.PNG

 

Thanks,

Richard

Please help.

$
0
0

Hello, I am fairly new to multisims and electrical engineering in general so bear with me.

I am trying to create a four-bit asynchronous counter that counts from 1 to 14.

I know how to create the normal counter that counts from 0 to 15 but what would I need to do to make it count from 1 to 14.

I am using J-K flip-flops to create this. (74LS76N)

Could anyone of you nice people explain this to me?

Thanks in advance!

 

where is RTSI trigger lines in 6711 card

$
0
0

Hi there,

  I have a PCI-6711 card. The manual said it supports the RTSI trigger line to connect the external clock as the timing source. I try to find the pin associate with the RTSI in the layout for PCI 6711 but I didn't see any. I only see PFI8/GPCTR0_SOURCE. Is it the same thing? I am pretty confusing how to use external clock to replace the internal software-based clock. Thanks.

should external clock be pulse or sinusodial wave?

$
0
0

Hi there,

  I am going to connect an external clock source to 6711 card. But I wonder if the source should be pulse trains (squre wave) or could be sinusodial wave. When we say the frequency of the clock, does it mean the occurence of the rising edge or fall edge but not the pulse, right? And what's the voltage range for the clock signal?


optical encoder

$
0
0

I connect an optical encoder (angular) to a counter pinout of digital io part of the card. I get correct positioning from 10 degrees and above. I get wrong values if i tried to move from 1 to 10 degrees.

 

Can you help me about this problem please?

 

Thank you very much.

counter trigger

$
0
0

Hi All,

 

i use ni-6111 (Nidaqmx; C++, Delphi,VB), start the measurment for one channel ai0 over a trigger signal from counter0, it works; but want to start counter1 with same trigger signal, which fails.

if i try to generate event when counter0 changes gets error too, suppose not supported event for 6111? found no document for this.

Is there a way to use one counter as trigger source for the other counter and one ai channel?

 

Thanks,

hassan

 

about set clock rate and actual clock rate

$
0
0

Hi there,

  I am connecting the PFI pin to clock genrator which output clock signal at rate 1MHz (constant). But in the DAQmx Timing (Sample Clock).vi, I can set the sampling rate to anything other then 1MHz? So what happen if I set it to 1kHz instead? Will it use 1kHz or 1MHz actually?

 

What happens if I choose the rate to a numeber such that 1MHz is not dividible by that number?

 

The last quesiton. If I use the PFI as the source for timed sequence, will it really works at that high frequency? I doubt that becaue in windows, the time resolution interval is about 1ms, so what will happen if I use 1MHz clock to drive it?

synchronize continuously Analog Read with trigger C Code

$
0
0

Hello, I have a problem

 

I have NI USB-6251.

I have to synchronize continuously Analog Read with trigger.

My code working correctly only with finite mode, but in continuously mode signal not synchronizing!

I have no error.

 

Here working finite code:

 

/********* finite code ********************/

DAQmxErrChk(DAQmxCreateTask("",&task));

 

DAQmxErrChk(DAQmxCreateAIVoltageChan(task,"Dev1/ai1","",DAQmx_Val_Diff,-6.0,6.0,DAQmx_Val_Volts,NULL));

DAQmxErrChk(DAQmxCfgSampClkTiming(task,"",1000000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,800));

DAQmxErrChk(DAQmxCfgDigEdgeStartTrig( task, "/Dev1/PFI0", DAQmx_Val_Falling));

DAQmxErrChk(DAQmxSetPauseTrigType(task,DAQmx_Val_DigLvl));

DAQmxErrChk(DAQmxSetDigLvlPauseTrigWhen(task, DAQmx_Val_High));

DAQmxErrChk(DAQmxStartTask(task));

DAQmxErrChk(DAQmxReadAnalogF64(task,-1,-1,DAQmx_Val_GroupByScanNumber,data,800,&samples,NULL));

DAQmxErrChk(DAQmxStopTask(task));

DAQmxErrChk(DAQmxClearTask(task));

/********* END finite code ********************/

 

Here continuously code:

/********************** continuously code ***************/

 

DAQmxErrChk(DAQmxCreateTask("",&task));

DAQmxErrChk(DAQmxCreateAIVoltageChan(task,"Dev1/ai1","",DAQmx_Val_Diff,-6.0,6.0,DAQmx_Val_Volts,NULL));

DAQmxErrChk(DAQmxCfgSampClkTiming(task,"",1000000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,12500));

DAQmxErrChk(DAQmxCfgDigEdgeStartTrig(task,"/Dev1/PFI0",DAQmx_Val_Rising));

DAQmxErrChk(DAQmxSetDigLvlPauseTrigSrc(task, "/Dev1/PFI0"));

DAQmxErrChk(DAQmxSetPauseTrigType(task,DAQmx_Val_DigLvl ));

DAQmxErrChk(DAQmxSetDigLvlPauseTrigWhen(task, DAQmx_Val_High ));

DAQmxErrChk(DAQmxRegisterEveryNSamplesEvent(task,DAQmx_Val_Acquired_Into_Buffer,SIZE_OF_MAIN_READ,0,EveryNCallback,NULL));

DAQmxErrChk(DAQmxRegisterDoneEvent(task,0,DoneCallback,NULL));

DAQmxErrChk(DAQmxStartTask(task));

/********************** END continuously code ***************/

 

Moreover, I tried to synchronize using internal clocking, but it didn't work correctly too:

 

/********************** clocking code ***************/

DAQmxErrChk(DAQmxCreateTask("",&task));

DAQmxErrChk(DAQmxCreateAIVoltageChan(task,"Dev1/ai1","",DAQmx_Val_Diff,-6.0,6.0,DAQmx_Val_Volts,NULL));

DAQmxErrChk(DAQmxSetDelayFromSampClkDelayUnits(task,DAQmx_Val_Seconds ));

DAQmxErrChk(DAQmxSetDelayFromSampClkDelay(task, 0.000125));

DAQmxErrChk(DAQmxCfgSampClkTiming(task,"/Dev1/PFI0",1,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1));

DAQmxErrChk(DAQmxSetAIConvRate(task,1000000));

DAQmxErrChk(DAQmxCfgInputBuffer(task,10000));

DAQmxErrChk(DAQmxRegisterEveryNSamplesEvent(task,DAQmx_Val_Acquired_Into_Buffer,1000,0,EveryNCallback,NULL));

DAQmxErrChk(DAQmxRegisterDoneEvent(task,0,DoneCallback,NULL));

DAQmxErrChk(DAQmxStartTask(task));

 

/********************** END clocking code ***************/

Periodically timed pulse counting

$
0
0

Hi all,

 

For my research project I'm working on a tabletop fusion device. The main goal is to investigate the neutron production. At the moment I'm automising as much as possible. 

I have 3 analog input signals for voltage, pressure and current and 1 analog output signal to control the voltage and I have a USB camera continously filming the inside of the reactor. Furthermore the neutron counter puts out TTL pulses usually at 25-100Hz.

 

The aim of my program is to continuously measure the analog signals so I can see the pressure, current and voltage and video in real time. Furthermore I'd like to periodically (when I press a button) measure the neutrons for a set period of time and during this time I'd like to record a movie. After such a measurement I'd like to plot the pressure, voltage and current vs. time (for the duration of the measurement) in one plot and total counts, and counts per second vs. time in a second plot.

 

I've done this with a different ADC/DAC device and it worked allthough the aquisition rate was low. I used to measure pressure through serial communication with the pressure meter (which made the loop time very long) but now I've figured out a way to measure the pressure directly with an analog signal. Since the other adc/dac device had only 2 adc channels I switched to the PCIe-6361 and now I'm  trying to replicate my program.

I've made two timed loops, one running on its own doing all the analog and video aquisition, and another timed loop inside a case structure inside a while loop. When I press a button the case with the timed loop is selected and this loop starts the aquiring the counter data and outputting that together with the data from the other (continuous) loop. In my old program I used a local variable of the cluster with my data, in my new program I'm trying notifiers. After the set time is up the timed loop should end and all data should be put in an array to be made into a waveform and plotted. I also would like to see the remaining time of a counting period and perhaps the total counts in real time during counting.

 

At the moment I'm stuck configuring the DAQ counter to do the same thing I did with my old program. I read some stuff about pause triggers, and using a second counter to generate a clocksignal for the first but that only confused me more, escpecially what clock times to pick . Furthermore I'm worried about the timed loops running in parallel, I assume they're not synchronized, is that a problem?

Is it an option to put the counter in the continous loop, and use the second (occassional) loop purely for data logging, resetting the counter when I start a measurement? 

Are there any other bottlenecks I'm not aware of? 

 

I added both VI files, FusorDiag and FusorDiag2. The first, allthough some VI's in it are not visible, works and is instructive of what I'd like to achieve. The second is very similar, but not yet finished, (I haven't put the data in an array, or attempted to make the waveforms and plots). Any advice is more than welcome.  

 

Kind regards, 

 

Mick Wijnen

Viewing all 1243 articles
Browse latest View live


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