Generate counter output based on a digital trigger

I am trying to output a train of pulse based on a digital trigger (GO bit). When the GO bit goes high, I want to output a pulse train after an initial delay (ie: 2 seconds). When the GO bit goes low, I want to stop this pulse train. When the GO bit goes high again, I want to start the same pulse train with the same initial delay.
The output pulse train has 2 frequencies so I am using 2 counters that generate the same pulse but one of them is delayed by a certain amount. Then I combine the output from both counters into one output using simple BNC T connector. Since I am using 2 counters (max # of counters available to me), I can't create a finite pulse train.
If I use a pause trigger, the only problem is that  the second time the GO bit goes high, the initial delay is not used (each channel or counter has a different delay).
So far the only way I can think of is by software timing the counter (by counting the time since the task has started) and stopping the task once certain amount of time has passed. Then I wait for a second trigger which should start the pulse train again with the initial delay.
Is there a better way to do this? 

One more thing:
Is there any way to use a digital trigger that is based on two different digital signals ANDed together? I basically want to output the pulses when 2 digital inputs are binary 1 at the same time.

Similar Messages

  • STO - Generating an Output based on the Plant

    Hello
    I do have a requirement to generate an Output(EDI) based on the Plant to which the material is being delivered to. The condition record that I have in place(Configured via M/59) is Doc. Type/P.Org/P.group/Supplying Plant/Plant. In the list of available fields, i see both Supplying plant as well as Plant. Access sequence and MN04 condition records have been maintained. Likewise an output device has also been maintained. The Q's i have are -
    1. Have any of you had such a  requirment( to use the Plant)?
    2. Plant is at item level and what should happen if the plant in the STO is different at the item level.
    3. SAP have also provided Material, which again is at the item level. What is the logic behind such?
    Appreciate if you can advice.
    Thanks
    Ajay

    Hi Ajay,
    This is related to PP/MM query pls put in the pp/mm form.
    Regards,
    Anil

  • 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

  • Generate an Event based on Counter Trigger

    Hello,
    I have the following part that is already working: a counter (used for period measurement) which is triggered by a digital input. After that I'm reading the data and I'm puting them in a Queue. Here I get an error. The Enqueue Element Vi is providing an error. (Error 1, something with a @  character that is illegal). I've notice that if I disable the trigger for the counter I don't get the error. I'm thinking that this is cause by the delay between the moment in which the Enqueue Block tries to enqueue and the moment in which the counter provides something to its ouptut.
    What I want to do is to Generate an Event based on the Counter Trigger Signal and to put all the reading and Enqueue part in an Event Structure. I've tried to do that using an Export Signal - Property Node, but I didn't manage to make it work.
    If you have any solution for this (with or without events -  I just want to get rid of that error) please let me know.
    PS: I have Labview 8.5.1 and the USB-6210.
    Thanks,
    LostInHelp

    Hello Mike,
    Thanks for your replay.
    I've attached two vi files. In one you can find how I've tried to generate an event based on the counter trigger (test.vi).
    The second one (test1.vi) is the vi where I get the queue error. I've deleted from the second vi the part where the data are dequeue and handled.
    Thanks
    LostInHelp
    Attachments:
    test41.vi ‏50 KB
    test110.vi ‏35 KB

  • Trigger digital output at every 10 digital pulses

    How can i generate an output pulse at every 10 input pulses comming from an encoder?
    I need to trigger a sensor at every 10 encoder pulses to get data from the sensor.

    Hello jyp777,
    What you will need is a counter with an if statement that activates a digital output every 10 ticks. To do this, I would look at a LabVIEW example titled: Counter - Count Edges (Continuous Clock) that can be found under Help >> Find Examples... >> Hardware Input and Output >> DAQmx >> Counter Input in LabVIEW. Using this example VI, it should be a simple step to add a condition that triggers a digital output when the count reaches 10. 
    You can also use a Digital Output example if you need help in this area. These examples can be found by going to :
    Help >> Find Examples... >> Hardware Input and Output >> DAQmx >>Digital Output. I would recommend "Digital - Continuous Output.vi". 
    Happy LabVIEW coding!
    Thanks,
    Collin D.
    Applications Engineer
    National Instruments

  • Can I generate pulse trains on more than one counter output at the same time?

    I have a PCI 6601 card with a BNC 2121 to connect the signals to two devices. The card is used as a trigger for both devices and I want to be able to generate pulse trains on two output channels at the same time, with a time delay between the two. How do I do that in Labview 7.1 Development with DAQmx?

    I feel foolish for not being able to figure this out, but it still doesn't work. Attached is the VI I use now. Counter 0 generates a finite pulse train and I programmed Counter 1 to generate a retriggerable single pulse triggered by CtrOinternaloutput. I still get the same error message: -50103 The specified resource is reserved. The operation could not be completed as specified.
    The same happens if I set the trigger for counter 1 at PFI36 (default output of counter 0) or any other PFI line. If I try a pulse train generation on only one of the counters, both work fine.
    If I try the example in traditional DAQ for multiple counter outputs with phase delay, it works fine.
    Can you tell me what I'm doing wrong?
    Attachments:
    Shutter_AND_lamp_trigger.vi ‏103 KB

  • How to generate a Spool based on output type in SAP Script

    Hi all,
    Is it possible to generate a spool based on output type for a SAP Script (without explicitly trigger in Tcode VF02 and selecting output type from there )
    Actually a background job will be scheduled to process output types selected in VF01 / VF02
    When output type is ZABC in the background a work flow is called pdf is generated

    Any suggestions please

  • Counter Output as Sample Clock of Digital Signals

    I have a situation where I need to use a hardware counter as sample clock of digital output signals.
    How do you specify the "Counter Internal Output" signal as a sample clock of digital output?
    I want to do something like this:
      // Create counter task
      CNiDAQmxTask m_Task(_T("ATask"));
      m_Task.COChannels.CreatePulseChannelTicks(_T("Dev1/ctr0"), "", _T("20MHzTimebase"), DAQmxCOPulseIdleStateLow, 0, 10, 10);
      m_Task.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger("PFI0", DAQmxDigitalEdgeStartTriggerEdgeRising);
      // Create digital output task                     
      CNiDAQmxTask m_Task2(_T("ATask2"));
      m_Task2.DOChannels.CreateChannel("Dev1/port0/line0", "", DAQmxOneChannelForAllLines);
      m_Task2.Timing.ConfigureSampleClock("XXXXXX", 0, DAQmxSampleClockActiveEdgeRising, DAQmxSampleQuantityModeFiniteSamples, 400);
    How do I specificy "counter 0 Internal Output signal" instead of "XXXXXX" above, i.e. the sample clock of the digital output signal. Can't find the name of the signal anywhere in the documentation and help files. I have a 6259 DAQ board. 
    /pek

    Thank you for your answers, but I can't get it to work.
    When I use "ai/SampleClock" as sample clock everything works correct. When I try to use a counter as sample clock the task completes imediately, before any digital signals has been sent/measured. The task even completes before I have started the trigger, which is very confusing. No error appears.
    I think that something is wrong about how I setup the counter. I use the code below:
    // Create counter task
    CNiDAQmxTask m_Task(_T("ATask"));
    m_Task.COChannels.CreatePulseChannelTicks(_T("Dev1/ctr0"), "", _T("20MHzTimebase"), DAQmxCOPulseIdleStateLow, 0, 100, 100);
    m_Task.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger("PFI0", DAQmxDigitalEdgeStartTriggerEdgeRising);
    // Create digital output task
    // The code below works with "ai/SampleClock" as sample clock
    CNiDAQmxTask m_Task3(_T("ATask3"));
    m_Task3.DOChannels.CreateChannel("Dev1/port0/line0", "", DAQmxOneChannelForAllLines);
    m_Task3.Timing.ConfigureSampleClock("Dev1/Ctr0InternalOutput" /*"ai/SampleClock"*/, 0, DAQmxSampleClockActiveEdgeRising, DAQmxSampleQuantityModeFiniteSamples, 400);
    // Create samples
    CNiUInt32Vector ui_data;
    for(int i = 0; i < 200; i++)
      for(unsigned int j = 0; j < 2; j++)
        ui_data.Append(j);
    // Create digital writer
    CNiDAQmxDigitalSingleChannelWriter m_writer3(m_Task3.Stream);
    m_writer3.WriteMultiSamplePortAsync(true, ui_data);
    // Wait until task completes
    m_Task3.WaitUntilDone(-1);

  • Start Counter Output on a Analog Trigger in the PCI 6259 Mseries board

    Hi,
    My question is regarding how to use Analog Triggering to start a counter in the PCI 6259 M-series board.
    I have attatched a program here
    'Mult_Device_Digital_Analog_Out_on_Analog_Trigger.​vi'
    and I'll explain my problem regarding this program.
    I've tried to include all the details about the program in the documentation for the VI, but what the program
    does is essentially output a set of digital and analog patterns as specified by an end user, and at times
    specified in the front panel.
    Problem 1.
    I wish to start the whole operation on a analog trigger signal, in the program its the boolean "Line Trigger",
    but I get an error saying that trigger type is not supported, when the M Series board manual clearly says it can be done.
    Is there something wrong with my program ?
    Thanks.
    Shomu
    Attachments:
    Programs.zip ‏101 KB

    Shomu
    Admittedly, it might take a little time to find the documentation, but it is there. Also, the error you are getting indicates the proper trigger signals to use. In the help look at the analog Triggering Considerations for E Series, M Series, and S Series.
    With that being said the easiest thing to do is to setup an Analog Input task configured to start on an Analog Trigger. Then, setup a digital edge trigger for the Counter task. The signal you are going to want to look for is the Analog Comparison Event. This signal won't show up by default in the list. What you need to do is right click on the trigger source constant or control and select I/O Name Filtering. Then check Include Advanced Terminals. Once you have done this you can select the Analog Comparison Event
    StuartG

  • 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

  • Counter as a digital Trigger

    Hi,
    I wrote a programm for a PCI 6289. It realises a triggered analog voltage in- and output with the internal counter. With this PCIcard I can use the trigger directly with the PFI12 pin and everything is fine.
    Now, I transfered it to a PC with a PCI-MIO16E1 (6070E) card.With this card the Counter isn`t linked to PFI. My question is: What can I do to bring the card to use the counter correctly. I tried already with "connect terminals" but I`m not able to select the counter in that configuration. Has someone a good idea?
    Greeting Daniela 

    Hi Daniela,
    I think the easiest way ist to wire it directly from counter out to one PFI, isn't it?
    Furthermore you can do it this way maybe:
    Internally Routing Counter Signals in LabVIEW
    http://digital.ni.com/public.nsf/allkb/8A85E97855E​DADC98625730C00065F58?OpenDocument
    regards
    Tobias

  • Generate output based on the analysis of a input array

    Hello!
    I would appreciate some help with this:
    - I have an input array X. It is a phase array, in other words, it has values from -pi to pi. 
    - I want to create digital pulses that match with certain values of phases in X. Example: If a value of X, in position "5", is -3*pi/2, i would like to generate , in the output array Y, a value of 1 in its position "5".
    My problem here is that i am not being able to detect the position of the array where my condition is met. I tried to use a case structure and a for to do this, without success.
    I hope i was clear enough, thank you very much.

    Ok, now that i Got the phases, i have to generate the output. Knowing the period of the phases wave and the timing of a certain phase, i want to generate a digital output in a future time that falls in the specified phase. It's a closed-loop of stimulation. What i'm trying to do is this:
    - First of all, I get the phases like Altenbach said.
    - Then, i do the time calculus to predict time intervals that i would wait to generate my pulse, and that pulse should fall in the specified phase of the input waveform, since its a closed-loop system.
    I'm attaching the current vi that i designed, and I appreciate any help. 
    The real trouble now is generate the output pulse/ boolean in the right time, with a duration of, i dont know, 10ms, just to make it work. something like this: _______|              |________
                                                                                                                                                                                                                                                <--10ms-->
    Best Regards,
    Attachments:
    PLOT_SIGNAL_ALTERNATIVA.vi ‏67 KB

  • Setting time critical digital output based on axis position (PCI-7358)

    HI,
    I need to set a time critical digital output based on encoder position (this will switch fast acting valves). I was planning to try the general purpose DIO but I can't find any examples, I have been through the manuals, searched the site etc. Where can I find help with this, all the examples only seem to deal with digital input triggering or RTSI? I'm thinking of an onboard program that just monitors encoder positions and sets digital outputs.
    Some time back I seem to remember reading that general purpose DIO should not be used for time critical operations, is that correct? And if so what are the other options - RTSI going to another DIO board? The DIO really needs to be deterministic, is RTSI the only option?
    Any advice appreciated / Martin
    Certified LabVIEW Architect

    Even with an onboard program you will always get a delay of several milliseconds between your axis has crossed the position and until the digital outputs are set. If this is ok for you then you could choose this approach.
    For the case that you only want to toggle one digital line the Breakpoint feature should be the best solution as it toggles the breakpoint output almost immediately when the breakpoint positions are reached.
    If you need to change a whole pattern instead of only a single line then the approach you mentioned would be the best solution (RTSI and high-speed DIO like the 653x boards). Combine this approach with the breakpoint feature by routing the breakpoint output to RTSI and using this as a update clock signal for the DIO board.
    Best regards,
    Jochen Klier
    National Instruments Germany

  • 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 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

Maybe you are looking for

  • How can i run a executable right after a rman job has run?

    How can i run a executable right after a rman job has run? I have a rman job that execute every night. The backup is local. I want to have a duplicate of the backup on another machine. I want the executable to sync the directory to execute right afte

  • Error message when extending skype number

    Hi guys Really hope someone can help me with this. Been dealing with skype chat and email support for hours and hours over last three days with absolutely no progress. I have 8 skype numbers within my skype manager account and for some reason, one of

  • Does the union improves the performance?

    Hi all, I would like to know does the union in sql or pl/sql optimizes the performance of the query? here we are retreiveing the data from a remote databse to see about 3700 hundred records it took on oracle 9i 40 seconds to get, where as when we add

  • JSP tags

    When I am trying to figure out how to use Class XXX from the core API I simply look up the Java docs and everything is explained. I have downloaded the TagLibs implementation of suns JSTL but cannot find anything similar for figuring out how to use t

  • Videos taken on a sony hx9v camera to iphoto

    how do i import videos taken on my sony hx9v camera to iphoto