DAQmx: 2 Counter Outputs in 1 Task?

Is it possible to have two counter outputs with different timings in one task?
One counter will be used to generate a PWM pulse train and the other one will be used to re-arm the trigger for analog data acquisition.
Thanks for your help.

Hi,
Thank you for posting to the NI forums.  You should be able to output on two counters with separate timing sources.  I’ve done just this using an M Series DAQ device and the DAQ Assistant’s auto-generated LabVIEW code.  The screenshot to this VI is attached below.
I hope this helps.  Please post back if you have further questions.
Ed W.
Applications Engineer
National Instruments
Message Edited by Ed W on 01-26-2007 01:50 PM
Message Edited by Ed W on 01-26-2007 01:50 PM
Message Edited by Ed W on 01-26-2007 01:51 PM
Attachments:
Two Counters.JPG ‏56 KB

Similar Messages

  • DAQmx gate counter output

    Hello,
       I am trying to convert an existing legacy application developed in LabVIEW 6 (Traditional DAQ) into LabVIEW 2012 (DAQmx). The operation requires generating one counter output that is gated by another counter output. I have attached a fully functional example using Traditional DAQ. In the example you can see the Carrier Frequency output (4550 Hz or 5525 Hz) is generated by Counter 1. The counter Gate Frequency is generated by Counter 0. Counter 1 output is now gated by Counter 0 output in which you end up with bursts of the Carrier Frequency at a rate set by the Gate Frequency (from 3 to 21.5 Hz). This works fine but I cannot replicate this in DAQmx. The DAQ board I am using is an NI DAQCard-6062E (in a PCMCIA Slot).
       Any sugestions are appreciated.
    Thank You,
    Mike Westgate
    Attachments:
    Traditional DAQ Counter Gate Output.zip ‏32 KB

    Hi Mike,
    I wasn't able to properly look at your code since I have not install the Traditional DAQmx (Legacy) driver yet.
    But I do have the following links that can help you in transition from Traditional DAQ to DAQmx:
    Answers to Frequently Asked Questions about NI-DAQmx and Traditional NI-DAQ (Legacy)
    Transition from Traditional NI-DAQ to NI-DAQmx in LabVIEW
    Ee Lim
    See that button on the left side of this post...
    If you feel my post is helpful, all you need is just (at most) 2 seconds to click that button, to show your appreciation. Thank you~~

  • Pause the counter output in DAQmx

    Hi~
    I used two counters output on PCI-6602 card in LV7.1 to generate a PWM to control the velocity of two motors that control the position of mechanism.(Encoder was set on the motor.)
    When I set the same duty cycle in two counters, the position of two mechanisms were different(Two mechanisms were the same),that means one velocity of motor was fast, the other was slow.
    May I pause the counter output of the fast motor to wait the slow motor??
    ====================
    ●LV Version:LabVIEW7.1
    ●OS:WindowsXP(SP1)
    ●Hardware:PCI-7344, PCI-6602, PCMCIA 6024E

    Assuming you're using DAQmx, you can set up a Pause Trigger for each of the counters.  (A similar function can be done in traditional NI-DAQ too).  You could, for example, configure 2 different digital bits to be used to pause the 2 PWM counters independently.  The way 'Pause Triggering' works is that the counter's pulsetrain only goes to the output pin when the pause trigger signal is in the correct logic state.  This can be set to be low or high by programming. 
    You may also want to characterize the speed difference of your actuators, and give them correspondingly proportional PWM duty cycles.  That would do a better job of keeping them in sync throughout the motion.
    A feedback signal would give you even better options for control.
    -Kevin P.

  • Counter Output/Counter Input PXI Signals Behaving Erratically

    Question for all your LabVIEW guru's out there,
    I am running a frequency loopback test using the NI PXI 6229 MIO DAQ card.  I am generating a "Counter Output" pulse train signal which feeds through my device under test and then back out of my device under test and back into the PXI 6229 for a "Counter Input" frequency measurement.  Both the "Counter Output" and the "Counter Input" are assigned different PFI lines using DAQmx in LabVIEW.
    I have 4 lines to test on my DUT.  All four lines run this same frequency measurement but with different PFI lines on the PXI 6229.  Each line is test independently.
    This is my setup for the 4 lines:
    Path 1: P2.0 (Counter Output - Pulse Train) -> DUT (Device Under Test) -> P2.1 (Counter Input - Frequency Measurement)
    Path 2: P2.2 (Counter Output - Pulse Train) -> DUT (Device Under Test) -> P2.3 (Counter Input - Frequency Measurement)
    Path 3: P2.4 (Counter Output - Pulse Train) -> DUT (Device Under Test) -> P2.5 (Counter Input - Frequency Measurement)
    Path 4: P2.6 (Counter Output - Pulse Train) -> DUT (Device Under Test) -> P2.7 (Counter Input - Frequency Measurement)
    where:
    P2.0 = PFI8
    P2.1 = PFI9
    P2.2 = PFI10
    P2.3 = PFI11
    P2.4 = PFI12
    P2.5 = PFI13
    P2.6 = PFI14
    P2.7 = PFI15
    I have a LabVIEW VI which generates the "Counter Output" and reads the "Counter Input" frequency.  I am seeing weird behavior from the PXI 6229 card. I can test "Path 1" and "Path 2" and the frequency I read is what I generated. No issue there. However, when I test "Path 3" and "Path 4" the frequency measurement is erratic.  The readings are two different frequencies repeated over and over again and none of those frequencies are the expected frequency which was generated out of the "Counter Output."  If I reset the card, and start by testing "Path 3" and "Path 4" the frequency readings are correct and the erratic behavior is gone.  However, when I try to then test "Path 2" and "Path 1" now those lines have the erratic frequency issue. I can continue resetting the card and see same issue. The PFI lines that I test first will always pass.
    To summarize:
    Steps Taken:
    1. Test Path 1 = SUCCESS
    2. Test Path 2 = SUCCESS
    3. Test Path 3 = Erratic Frequency (Two Frequencies repeated over and over again in my frequency results array)
    4. Test Path 4 = Erratic Frequency (Two Frequencies repeated over and over again in my frequency results array)
    5. Reset the PXI 6229 Card
    6. Test Path 3 = SUCCESS
    7. Test Path 4 = SUCCESS
    8. Test Path 3 = Erratic Frequency (Two Frequencies repeated over and over again in my frequency results array)
    9. Test Path 4 = Erratic Frequency (Two Frequencies repeated over and over again in my frequency results array)
    I am wondering if Port 2 (P2.0-P2.7) on the 6229 card has certain dependecies and this is why I am seeing issues.  I am trying to get around this issue so that I don't have to always reset the card.
    Are P2.0-P2.3 (PFI8-PFI11) and P2.4-P2.7 (PFI12-PFI15) treated differently or require different setup?  How do I resolve this issue?
    Thanks so much!

    I have a theory...
    The DAQ card follows a policy called "lazy uncommit" wherein the terminal used for the output will continue to be connected to the counter even after the task has completed (until the terminal is needed for something else).  So as you run more tests, the counter output will end up driving more lines.  This behavior should be easy enough to confirm.
    As the DAQ card drives more lines, I'd imagine this affects the actual signal.  You could scope it to check, but it sounds like either the rise/fall times are becoming longer or some extra noise is being introduced on the line.  
    The readings are two different frequencies repeated over and over again and none of those frequencies are the expected frequency which was generated out of the "Counter Output."
    This implies you are picking up an extra edge during transitions--this isn't too uncommon if the signal is noisy since there is no built-in hysteresis on the DAQ card.  I would expect the measured frequencies to have periods that sum to either the full period or the semi-period of your actual signal (depending on how many duplicate edges are detected).
    Suggestions are as follows:
    To stop the DAQ card from driving multiple PFI lines, it would probably be easiest to just programmatically reset the device in between your tests (using DAQmx Reset Device).  If you can't reset the device (e.g. because you are running some other task that can't be interrupted) then you can instead configure a dummy task that uses the PFI line in question as an input.
    To stop the DAQ card from picking up multiple edges during transitions, you should configure a digital filter on the input terminals.  If you reset the device it sounds like this might not be necessary... it's up to you if you want to configure this or not.
    Best Regards,
    John Passiak

  • How to filter starttrigger on counter output precisely

    HW PCI6602
    Measurement studio 2008 (C#)NI-DAQmx 9.02I’m trying to trig a camera using the output from a counter.
    The camera should be trigged when the counter input pulse width is larger than approx (filterPulseWidth 10us).To do this a have set up the following tasktask.COChannels.CreatePulseChannelTime(counter,                "TriggerTaskChannel", COPulseTimeUnits.Seconds, COPulseIdleState.Low, 0, 80E-6, 0.007);             task.Triggers.StartTrigger.Type = StartTriggerType.DigitalEdge;            task.Triggers.StartTrigger.DigitalEdge.Edge = DigitalEdgeStartTriggerEdge.Rising;             task.Triggers.StartTrigger.Retriggerable = true;task.Triggers.StartTrigger.DigitalEdge.DigitalFilterMinimumPulseWidth = filterPulseWidth;            task.Triggers.StartTrigger.DigitalEdge.DigitalFilterEnable = true;Unfortunatly this filter has the following behaviour”If the period of the filter clock timebase is tfltrclk, this filter guarantees topass pulse widths that are 2*tfltrclk or longer and to block pulse widths thatare tfltrclk or shorter. A pulse with a width between these two ranges may ormay not pass, depending on the phase of the pulse with respect to the filterclock timebase”.It means that I have no sharp distinction on my filter as one would when applying a filter to an ordinary pulse width measuring task. Implementing this with via the software in a callback is to slow.The bottom line is that I would like to generate a pulse on my counter output when the trigger/counter input is greater than say 10us. The output pulse could be predetermind as in the sample code above or as long as the filtered input (I.e counter just pass filtered input to my output).How can this be done? BR
    Jongas
    Solved!
    Go to Solution.

    Hi Jongas,
    Is it OK if the trigger is sent once the pulse hits 10 us, rather than
    on the exact falling edge?  I'll assume the exact timing isn't as important, but you would like the trigger to occur very close to the falling edge (within a couple of us).  The important thing is that we trigger as close as possible to when the PWM has hit 50% duty cycle.
    Some brainstorming:
    Digital Filtering on the 660x Isn't the Best for This:
    Digital filtering might not be as practical here on your 6602 due to the region of uncertainty between 5 and 10 (or 10 and 20) us pulses.  The TIO boards count two consecutive edges of a filter clock to determine when to pass a signal through so the guaranteed rejected pulse width is always half of your guaranteed passed pulse width (providing an external filter clock timebase that is synchronized with your external signal could potentially reduce this uncertainty but I honestly haven't tried this before and I would imagine it is not going to be very straightforward).
    X Series Alternative:
    Our X Series devices use a different method of digital filtering that would work better for you.  If a hardware change is an option (and you can use PCIe) then you might consider this.  You could use the 20 MHz timebase as your filter clock timebase and could guarantee to pass 10 us (200/20M) and reject 9.95 us (201/20M).  The 6320 is currently our lowest cost X Series board.  A couple of points about this solution:
    1.  To configure the PFI filter, you need to use some sort of dummy task to
    access the property nodes.  Here is an
    example of this (although it is written in LabVIEW).
    2.  You can route the filtered PFI signal to be exported on another PFI line, but this will reserve Counter 3.  This is documented in the Device Routes tab of Measurement and Automation Explorer.
    3.  The filtered output will be 9.95-10 us delayed from the input signal, so you could trigger the camera off of the rising edge of the filtered output directly and be fairly close to the actual falling edge.
    External AND Gate Alternative:
    You could configure a Counter Output to generate a re-triggerable pulse with a 10 us initial delay (to be triggered off of the rising edge of your PWM signal).  Assuming the pulse is short enough to complete before the next period of your PWM signal, the counter output would only be high at the same time as the PWM signal if the signal was longer than 10 us.  Use the external AND gate to combine these two signals and the result would be the trigger for your camera (the rising edge would correspond to 10 us after the PWM signal first goes high).
    If you wanted to you could make the counter output pulse a little longer (say 8 us) and trigger the camera off of the falling edge out of the AND gate (a.k.a. rising edge out of a NAND gate) which would line up with the exact falling edge of the PWM signal.  Don't make the CO pulse too long or it will overlap with the next period of the PWM.
    Another Idea:
    One idea that I keep coming back to is to use the internal rollover event of a counter input task (a pulse is generated whenever a counter rolls over on its Internal Output which can be routed to a PFI line).  I don't think this will work, but the idea in theory would be to:
    1.  Set Default state to known value (e.g. 2^32-200).
    2.  Gate the Counter so it only counts during the time PWM is high.  Have it count the 20 MHz timebase.
    3.  Reset the Counter to default state on the falling edge of the PWM signal.
    4.  The counter would rollover if 200 pulses occurred of the 20 MHz timebase (10 us), and the Counter Output could be routed to a PFI line to trigger the camera.
    The problem is that there is no good way to reset the counter except for an encoder measurement (Kevin has already made a nice suggestion about this).  A Pulse Width Measurement would technically reset the counter, but you cannot currently set the default value of a Pulse Width Measurement task so there is no way to make the rollover happen prematurely).
    Configuring an encoder measurement and working with the multiple counters on the 6602 to produce appropriate A,B, and Z signals might be a method to look into further, but at this point I think you'd be better off with an external AND gate.
    I don't want to say it's impossible with just the 6602, but I can't think of a straightforward way to go about it without external hardware (although maybe I can sleep on it and think of something later... how many counters do you have to work with?). 
    With your current NI Hardware, I think your best bet is to go with an external AND gate.  If you're planning on purchasing an X Series card the digital filtering idea is actually not a bad way to go.
    I hope this is helpful!
    Best Regards,
    John Passiak

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

    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);

    Hi Xavier,
    Thank you very much for getting back to me. I really appreciate it. I followed your advice with the option 2 and simplified my code by using one of the NI C example templates to generate the below codes (also attached). I was able to see the pulses generated with an oscilloscope, and on the same oscilloscope I could see the ouput pulses of the electron beam probe. Unfortunately, the below code via DAQmxReadAnalogF64 reports of no data read from the probe and finally times out. Below is the error message given by this function. I did check the connection of the analog input wires to make sure they were connected to pin 1 (A0+) and 2 (A0-) because I was using the terminal configuration DAQmx_Val_Diff. Do you see any obvious errors I have made in my codes?
    Thanks a lot for your help,
    Thuc Bui
    Task started, waiting for trigger...
    Acquired 0 analog samples DAQmx Error: 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
    Corresponding Value: DAQmx_Val_CurrReadPos
    Property: DAQmx_Read_Offset
    Corresponding Value: 0
    Task Name: _unnamedTask<1>
    Status Code: -200284
    End of program, press Enter key to quit
    ********************** C Code **************************************************
    #include <stdio.h>
    #include "NIDAQmx.h"
    #include <math.h>
    #define DAQmxErrChk(functionCall) { if( DAQmxFailed(error=(functionCall)) ) { goto Error; } }
    int main(void) {  
    int32 error = 0;  
    char errBuff[2048]={'\0'};
    TaskHandle  taskHandleDig=0;  
    TaskHandle taskHandleAna=0;    
    double  timeout=10;  
    double minVol = -1.0, maxVol = 1.0;
    double initDelay = 0.0;  
    double freq = 10.0;  
    double pulseWidth = 1.0e-5; //10us  
    double dutyCycle = pulseWidth * freq;
    unsigned hiTicks = 4;  
    double sampleRate = hiTicks/pulseWidth; //samples/s  
    unsigned lowTicks = ceil(sampleRate/freq) - hiTicks;  
    unsigned nSpPeriod = hiTicks + lowTicks;
    unsigned numPulses = 1;  
    unsigned nSpCh = numPulses*nSpPeriod;    
    double sampleRate2 = ceil(2.0*sampleRate);  
    unsigned sampleMode = DAQmx_Val_FiniteSamps;
     /*********************************************/  /*/ DAQmx Configure Code  /*********************************************/  
    DAQmxErrChk(DAQmxCreateTask("", &taskHandleDig));  DAQmxErrChk(DAQmxCreateTask("", &taskHandleAna));    
    DAQmxErrChk(DAQmxCreateAIVoltageChan(taskHandleAna, "Dev2/ai0", "", DAQmx_Val_Diff, minVol, maxVol, DAQmx_Val_Volts, ""));  
    DAQmxErrChk(DAQmxCfgSampClkTiming(taskHandleAna, "/Dev2/Ctr0InternalOutput", sampleRate2, DAQmx_Val_Rising, sampleMode, nSpCh));
    DAQmxErrChk(DAQmxCreateCOPulseChanFreq(taskHandleDig, "Dev2/ctr0", "", DAQmx_Val_Hz, DAQmx_Val_Low, initDelay, freq, dutyCycle));  
    DAQmxErrChk(DAQmxCfgSampClkTiming(taskHandleDig, "/Dev2/PFI12", sampleRate2, DAQmx_Val_Rising, sampleMode, nSpCh));    
    unsigned bufferSize = nSpCh;  
    DAQmxErrChk(DAQmxSetBufInputBufSize(taskHandleAna, bufferSize));  
    DAQmxErrChk(DAQmxSetBufOutputBufSize(taskHandleDig, bufferSize));
    /*********************************************/  /*/ DAQmx Write Code  /*********************************************/  
    DAQmxErrChk(DAQmxWriteCtrTicksScalar(taskHandleDig, 0, timeout, hiTicks, lowTicks, NULL));
    /*********************************************/  /*/ DAQmx Start Code  /*********************************************/  
    DAQmxErrChk(DAQmxStartTask(taskHandleAna));  DAQmxErrChk(DAQmxStartTask(taskHandleDig));
    printf("Task started, waiting for trigger...\n");
    /*********************************************/  /*/ DAQmx Read Code  /*********************************************/  
    double* dataAna = new double[nSpCh];  
    int32 numReadAna = 0;  
    int errCode = DAQmxReadAnalogF64(taskHandleAna, -1, timeout, DAQmx_Val_GroupByChannel, dataAna, nSpCh, &numReadAna, NULL);  
    printf("Acquired %d analog samples\n",numReadAna);  
    if (numReadAna) {   
        unsigned nPts = (numReadAna < hiTicks)? numReadAna : hiTicks;  
        for (unsigned n = 0; n < nPts; ++n) {    
             printf("%6.3f ", dataAna[n]);   
        printf("\n");  
    delete [] dataAna;
    DAQmxErrChk(errCode);
    Error:  
    if( DAQmxFailed(error) )   DAQmxGetExtendedErrorInfo(errBuff,2048);  
    if( taskHandleDig!=0 && taskHandleAna!=0 ) {   
    /*********************************************/   /*/ DAQmx Stop Code   /*********************************************/   
        DAQmxStopTask(taskHandleDig);   
        DAQmxClearTask(taskHandleDig);   
        DAQmxStopTask(taskHandleAna);   
        DAQmxClearTask(taskHandleAna);  
    if( DAQmxFailed(error) )   printf("DAQmx Error: %s\n",errBuff);  
    printf("End of program, press Enter key to quit\n");  
    getchar();  
    return 0;
    Attachments:
    Correlated DIO AI_Sample_Clock Dig Start.c ‏6 KB

  • How to use counter output pulses to trigger analog input?

    Hello all,
    I hope the kind people using this forum can help me, a lowly beginner LV programmer! I have been attempting to create a VI that produces a user defined number of TTL pulses, separated by every n seconds. Each TTL would be outputted to a stimulator, which in turn generates its own TTL. Using the stimulator-generated TTL, I would like to trigger finite analog data acquisition (e.g. for every TTL, trigger the collection of a data sweep that contains 4000 samples (collected at 4000 Hz), with 1000 samples collected pre-trigger. I would like to also be able to see each data sweep as it is triggered on a chart. As I understand things (lots of online/book/forum reading), I should be using the counter output to generate my TTL pulses, and syncing each counter produced TTL with analog input, as well as using a reference trigger. Also, the AI part should be started first, so that I don' t miss any counter outputs. If it matters, I also need to use one of the AI channels to acquire the TTL, so I can see my stimulator-induced responses to the stimulator in time.
    I am able to generate the TTL pulses from the counter output, but I am having a problem with the AI part. I am unsure how to sync the counter output with AI. Also, since I need to acquire pre-trigger samples, I would be needing to acquire samples continuously, but when I set 'continuous samples' on daqmx timing, the VI doesn't work (hence why's its set to 'finite samples').
     I hope someone out there can help, as I have been at this for what seems ages, with limited success. I am using a USB-6259 and LabView v8.2. Thanks!
    Attachments:
    RC001 v_1.vi ‏49 KB

    Hello,
    Due to the fact that analog tasks themselves are not retriggerable, a
    pulse train produced by a counter is always used as the sample clock
    for the analog input task in order to recreate a retriggerable effect
    for analog input. This can be done by creating a finite pulse train set
    to retriggerable using the DAQmx Trigger Property Node, or the pulse
    train could be continuous and just be gated by another signal. Neither
    of these methods can be properly applied in hardware to create a
    retriggerable reference trigger. You can however implement something
    similar in software by just stopping and restarting your reference
    triggered analog input task within a loop. There will be some delay
    between when the task is stopped and restarted, as these events require
    software intervention, but if there is enough time between when each
    trigger signal is generated, there should not be any noticeable delay
    or missed samples.
    I have attached an example of this!
    Mark B
    ===If this fixes your problem, mark as solution!===
    Attachments:
    RC001 v_1mod.vi ‏25 KB

  • Setting the counter output mastertimebase divider?

    Hello
    I want to output single short pulses with varying pauses. My MuFu DAQ card has 20 MHz master clock rate and 24 bit counter (Good ol'6052E). When I try to output 1 µs with a pause duration of more than 839 ms, I get an error due to mismatch of clockrate and counter bit size with short and long duration. This is explained in great detail in the corresponding help:
    2/ counter clock rate <= X <= 2^24 / counter clock rate. with counter clock rate = master clock rate / divider
    0.1 µs               <= X     <=   16777215 / 20Mhz = 839 ms
    I could strech my limits by manually setting the CO.CounterTimebaseMasterTimebaseDivider to 10. But I've searched all property nodes I could find but I have not found this property.
    Does anyone know where it is hidden, and to which values it can be set?
    Thank you
    Michael

    Hi Michael,
    Unfortunately that property doesn't exist.  There are a few "Divisor" properties available for other subsystems (e.g. see Analog Input timing block diagram below).
    However, you'll notice in the above diagram that the valid divisors of the master timebase are only 1 or 200 (which then gives the AI Sample Clock Timebase).  You can get similar behavior on the counter by specifying to use the 20 MHz timebase or 100 kHz timebase for your source.  However, using the 100 kHz (1/10 us) timebase is going to prevent you from properly generating the narrow 1 us pulses that you require.
    So, you can use 20 MHz or 100 kHz without any additional resources, but 100 kHz wouldn't allow you to have a 1 us pulse, and 20 MHz won't let you have a high or low time of greater than ~839 ms.  You could generate frequencies in between these to use as the counter timebase (either use the frequency output or use the second counter to generate the desired frequency, or perhaps configure a dummy analog task) but of course there would always be a tradeoff between the resolution of the pulse and the maximum time between pulses.
    If you do have the 2nd counter available, here is my suggestion to get the best of both worlds:
    1.  Configure a counter output to generate a pulse every N seconds (I suggest configuring the output to generate at 1/N frequency at 50% duty cycle).  When you configure this counter, DAQmx will choose an appropriate timebase for you.  When N is less than ~1.67 seconds, DAQmx will use the 20 MHz timebase (since both the high and low time would be under the 839 ms).  When N is > 1.67 seconds but below ~335 seconds, DAQmx will use the 100 kHz timebase.  If you intend on modifying the rate of the output (to something above 1.67 seconds) after the task has started you would need to make sure to specify to use the 100 kHz timebase rather than relying on the DAQmx default.  You can't use a built-in timebase if you want to generate a delay greater than 335 seconds, but if you wanted to you could handle this case by checking for it and configuring the frequency output to generate an even lower timebase.
    2.  To generate the actual output signal, configure a retriggerable single pulse generation to be triggered off of the signal generated above.  This signal will be based off of the 20 MHz timebase (assuming you configure a pulse width less than ~839 ms) and so will give you a good resolution on the available pulse widths that you can generate.
    In summary, doing this would let you decouple the resolution of your generated pulse width from the resolution of the delay between the pulses.  The downside is that it uses two counters.
    The other option which I previously mentioned (and what you were asking about) would be to find a timebase that meets the two requirements: 1) fast enough to generate a narrow pulse and 2) slow enough to not roll-over between pulses.  You have 100 kHz and 20 MHz available to you, but you can generate intermediate frequencies using the frequency output.  If you plan on using a counter to generate the timebase instead, you should consider the other option which decouples the two counters.
    Of course, using a device with a higher counter resolution (most newer DAQ devices use 32-bit counters) would probably also resolve your issue depending on the full range of  delays that you need.  The downside here is the cost of new hardware.
    Best Regards,
    John Passiak

  • Changing the PXI-6624 Counter Output rate on the fly

    I'm programming an application in VB.net 2005 to set several counter output channels (each with its own task) on the PXI-6624 card. I'd like to know if there is a way to change the frequency of the output without stopping the task, changing the frequency and restarting the task. I'm using the PXI-6624 card to simulate encoders and speed sensors.
    Thank you very much,
    JonS101

    Hi,
    Yes, you can change the frequency on the fly. Here is a knowledgebase that will give you an insight of how you should approach this matter. How Can I Change the Duty Cycle on My Continuous Pulse Train? To find this property node and how to use it refer to the DAQmx .NET reference: Where Can I Find NI-DAQmx Property Node Listings and Help?
    I hope it helps
    Jaime Hoffiz
    National Instruments
    Product Expert
    Digital Multimeters and LCR Meters

  • Counter Output

    Hello
    I am using DAQ PCI 6221 card for analog inputs and outputs, I am using both the counter outputs for controlling temperature, by putting heaters On and Off through the digital pulse train I am getting from counter outputs.
    But I am having a problem with the counters that even if I change the Low time and High Time the pulse I get just dont changes accordingly,
    changes timing effects from next time when I run the VI, I am attaching the VIs(CTR1.vi and CTR0.vi are similar just change the channel name) involved in this, first I am acquiring the temperature and then comparing it with low and high limits and taking an action whether to On or Off heaters.
    High Time and Low time are required because as soon as I reach near to set temperature I increase the Low time and vice versa.
    Could anybody please tell me where I am wrong??
    Attachments:
    Show Alarm SV.vi ‏14 KB
    CTR1.vi ‏37 KB
    Dig Pulses2.vi ‏117 KB

    Are you trying to change these values once the task has started running?  Consult this KB for information on how to do to this:
    "Why Can't I Change the Duty Cycle on My Continuous Pulse Train?" 
    To summarize, you'll need to use DAQmx channel property nodes to set the pulse width and frequency.
    Elijah Kerry
    Senior Product Manager, LabVIEW
    Follow my Software Engineering for LabVIEW Blog

  • Counter Output Pin on PCI-6229

    I am using NI-DAQmx 7.3 C API with (among others) a PCI-6229.
    I have used DAQmxSetCOPulseTerm() to connect a counter output to a terminal other than the default. It seems to work- the output pulses do, in fact, appear at PFI 6 (the terminal I'm using for testing). But the pulses continue to appear at the default output pin as well.
    Is that expected?
    In order to reverse the situation, I used DAQmxResetCOPulseTerm() just before calling DAQmxClearTask(). The function returns zero, but if I subsequently make a new task to do pulse output from the same counter, pulses appear at both PFI 6 and at the default pin.
    Am I missing something?
    John Weeks
    WaveMetrics, Inc.
    Phone (503) 620-3001
    Fax (503) 620-6754
    www.wavemetrics.com

    Salvador Santolucito wrote:
    Hi John,
    I would suggest using the DAQmxTristateOutputTerminal. I have tried what you are doing in LabVIEW and I'm seeing the exact same results. When I set the default pin to tristate, the counter output does not show up on it.
    -Sal
    Thanks for trying it and confirming what I saw, and thanks for the pointer to DAQmxTristateOutputTerminal.
    John Weeks
    WaveMetrics, Inc.
    Phone (503) 620-3001
    Fax (503) 620-6754
    www.wavemetrics.com

  • Synchronize two counter outputs on 6071E card

    Well, it's the usual how do I synchronize two counters problem.
    I'm using the 6071E with DAQmx .NET 4.0. I define a Task and attach to it two counter output channels with implicit timing and zero initial delay . When running the program
    I catch the first edge with a scope single trigger. There is always a delay between the first edge of ctr0 and the first edge of ctr1 of 16.3 microsecs. Is there a way, besides setting the initial delay of ctr0 to 16.3 microsecs, to make the counters to always start together? what is the source of the delay(software/hardware) and should it always stay constant.
    any help is welcome
    Solved!
    Go to Solution.

    The source of the delay is that despite being in the same tasks the counters are still started sequentially by software.  I'm surprised the delay you are seeing is constant.
    If you want the counters to start together you should configure a start trigger.  Once you start the counter tasks in software, issue the start trigger to begin generating your output pulses.  The start trigger must be a hardware signal--as an example you might configure a software-timed digital output and wire it back in to one of the PFI lines.
    If you want to avoid any additional wiring, you could split the counters into two separate tasks.  Trigger one counter with the internal output of the other (start the task that is going to be triggered first).  Doing this instead of using an external trigger, I would expect an additional delay between the counters on the order of 100 ns as the initial delay is at minimum 2 timebase ticks.
    Best Regards,
    John Passiak

  • Error -200685 DAQmx Write Counter Frequency

    I have to generate 4 finite pulse trains with Counter Output and a X-series board (NI PCIe-6321). I know that with X-series boards only one counter is used to generate finite pulse train. I use LabVIEW 2010 sp1 and DAQmx 9.3.5.
    One task for each counter is created.
    When only one task runs, everything is ok, but, when more than one task runs, i receive "error -200685: Pulse frequency specified is not supported for this device given the Counter Timebase Rate." from DAQmx Write Counter Frequency. Error reports invalid data&colon; 0,000000
    I have checked data supplied and no zero frequency is passed to the VI. In fact, counter frequencies lower than 100 are forced to be 100 through a previous VI.
    Thanks for the help
    Attachments:
    Error.PNG ‏42 KB
    Zero frequencies avoided.PNG ‏7 KB

    OriginalP ha scritto:
     I payed attention to write non null frequencies and this is why this error sounds so strange to me.
    My last words... i found that two null frequencies (1018 and 1019 array indexes) were passed to Counter Output (see attached images "Counter Output Front Panel Data.PNG" and "Counter Output Block Diagram Data.PNG").
    It's quite strange, because VIs generating pulse train frequency data don't output these two null frequencies (see attached image "Array Output Data.png").
    This pair of null frequencies is random, but definetively the error is not in Counter Output DAQmx Write VI.
    Attachments:
    Counter Output Front Panel Data.png ‏33 KB
    Counter Output Block Diagram Data.PNG ‏21 KB
    Array Output Data.png ‏21 KB

  • Two counter inputs and counter output NI 9401

    I am trying to configure two counter inputs and one counter output on one NI 9401. I have looked and found how to configure digital lines in booth directions but it seems like I can only do two counters in all on one module. Can someone verify this for me or let me know how to get all three on to one module?
    Thank you

    Hi mschoenwald,
    The counters are actually located on the backplane of whatever chassis you are using--I'll assume you are using cDAQ and not cRIO.
    If you have the older <link no longer exists>, then there are only 2 counters available in general.  You can access both from a single parallel (8 lines or less) digital module in slot 5 or 6 of the chassis.
    The 2nd generation Compact DAQ chassis (including 9174, 9178, 9181, 9188, etc.) includes 4 counters.  You may access them from any slot with a parallel module.  There is no restriction preventing you from accessing all 4 simultaneously from a single module.
    The 9401 is bi-directional and configurable by nibble (line0:3 may be configured one direction, and line4:7 another).  However, it is quirky in that it requires the line direction to be configured before any of the tasks are started.  This is because the data lines themselves are used to set the line direction behind the scenes.  The best way to work around the behavior is to use DAQmx Control Task to explicitly reserve your tasks before any of them are started (see here).  Keep in mind that the counter output should use the opposite nibble from the two counter input tasks.
    Best Regards,
    John Passiak

  • DAQmx RTSI Counter

    Hello All,
    I am attempting to generate a 40kHz counter and export the signal to a RTSI channel in order to synchronize two PCI-NIDAQmx cards(6025 & 6259) for analog output signal generation.   I have made my best effort to create the VI, but am receiving the following error:
    "Labview: Internal Error.  Wrong memory zone accessed."
    Any assistance would be greatly appreciated, and I'm open to any suggestions or alternate methods!
    Sincerely,
    Zach
    Attachments:
    RTSI_Clock.vi ‏29 KB

    Hi Zach,
    I took a look at your code, and I believe I have the answer as to why you are
    receiving this error. It appears that you created a constant for your Simple
    Error Handler to specify the "type of dialog", but you accidentally
    wired it into the top-most input terminal, which is the "error code"
    input. Thus, since you selected "OK message + warnings" on that enum,
    it is passing the value of 3 into the error code, and thus returning the error
    you are seeing every time you run the VI.
    In addition, based on your explanation of what you are trying to accomplish
    overall, I am not sure that your code will do quite what you are expecting. You
    are using the Export Signal VI to route the Counter Output Event to the RTSI_0
    line, but this is not the same as routing the output of the counter. The
    Counter Output Event is a signal that will pulse when the counter reaches its
    terminal count during an input task. In your case, you would actually want to
    connect the counter output line, specified as "Dev1/Ctr0Out" to your
    RTSI line using the Connect Terminals VI. You will also then have to disconnect
    these terminals at the end of your program before clearing the task. I went
    ahead and made the above changes to your VI and have attached it below. Please
    also note that DAQmx allows you to route signals over the RTSI bus without
    having to manually connect the terminals to the RTSI line. Therefore, you could specify the source of your sample clock on one device to be the counter output of the other device, and as long as you have properly configured the boards in Measurement & Automation Explorer (MAX) to be used with the RTSI cable, it will automatically route the proper signal over the RTSI bus. Hope this helps with your application,
    Daniel S.
    National Instruments
    Attachments:
    RTSI_Clock3.vi ‏29 KB

Maybe you are looking for

  • Why can't I access the iTunes Store (iTunes 10.4.1)

    Every time I launch the latest version of iTunes and click on iTunes Store, I get the error message "We could not complete your iTunes Store request. You do not have permission to access the requested resource." In smaller print it says "There was an

  • Check material movement types that are activated for transfer to GTS in 4.7 ecc.

    Hi We are using 4.7 Version of R3 and GTS version 10. Please let me know how to check the list of movement types that are activated for transfer to GTS. Thanks & Regards Karthi

  • Sorting of picture print

    The sorting of the print preview and the print itself is different to the sorting of the folder! What can i do? The pictures in the album are sorted by the filename and shown in the right order on the screen but not on the print preview. Thx

  • Java.lang.ClassNotFoundException: oracle/webdb/provider/v2/adapter/soapV1/ProviderAda

    i am using tutorial "Building Java Portlets Using Oracle9i JDeveloper" from: "http://portalstudio.oracle.com/pls/ops/docs/FOLDER/COMMUNITY/PDK/ARTICLES/BUILD.JAVA.PORTLETS.USING.JDEVELOPER.V2.HTML " I recieve following error when i try to run this co

  • Installing firefox 4 in Linux Ubuntu

    Downloaded Firefox 4 beta3. I'm on Linux (Mint-ubuntu). I am assuming it detected my OS, because it offered no choices. (got a .tar.bz2 file) I was expecting a self-installing file (like Chrome and Virtualbox provide) where one can just click on the