LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Retriggerable pulse using GPCTR0 on 6062E STC

Solved!
Go to solution

I desire to have an external sync signal (too short a duration) detected by a 6062E board and output a pulse of longer duration as a sync signal that I would be reading on an analog channel along with other sensors on other analog channels. I used example program 2055.zip, STCgeneratesinglepulse, for LW/CVI as my starting point. I modified the sample program so that it is retriggerable instead of just single pulse. This example code uses GPCTR0. The program does work but not as I expected. GPCTR0_OUT has the generated output pulse and programmable duration that I was wanting. GPCTR0_GATE is for the input trigger/sync signal. What I found was that the GATE has a constant +5VDC signal. The problem is that the only trigger that works is an intermittent grounding to the GPCTR0_GATE. I was wanting to work with an external sync signal (short low-high-low signal). I was using the DAQ board's +5VDC power pin to mimic an external trigger. How can I use such a trigger signal to generate the pulse? I have included a stripped down, short version of the revised sample program below and also as an attachment.

 

 

#include "nidaqex.h"
/*********************************************************************
* Example program:  Based on 2055.zip
* STCgenerateSingleTriggeredPulse.c   //changed to retriggerable
*
* Description:
* Generates a retriggerable digital pulse 1 ms LOW and 100 ms HIGH using
* general purpose counter 0 upon a trigger (for devices with the
* DAQ-STC counter/timer)
*
* Pin Connection Information:
* Your digital output pulse will be on the GPCTR0_OUT pin (2 for 6062).
* Connect this output to an analog channel for time syncing w/normal DAQ.
* Connect your digital input trigger pulse to the PFI9/GPCTR0_GATE pin (3 on 6062).
* Connect the ground reference to the 'digital ground' pin (4 or 18 on 6062).
*
* To trigger, connected pin 3 to ground. But, this is not what I want.
* Want trigger to be a LOW-HIGH-LOW. How?
*
* Presence or absence of following line had no effect.
* iStatus = GPCTR_Change_Parameter(iDevice, ulGpctrNum, ND_GATE_POLARITY, ND_NEGATIVE);
*
*********************************************************************
* Used a second computer/DAQ system to monitor.
* Monitoring System connected to                DAQ Computer
* ----------------------------------------------          -----------------------
* ACH0 (68)                                                   GPCTR0_OUT (2)
* ACH8 (34) jumpered to AIGND (67)           DGND (4)
*
* OR
*
* Use Counter on second computer/DAQ system to monitor.
* Monitoring System connected to  DAQ Computer
* --------------------------------              -----------------------
* PFI9/GPCTR0_GATE (3)             GPCTR0_OUT (2)
* GND                                              GND
*
*********************************************************************/

void main(void)
{
 char c; //for testing
    i16 iStatus = 0;
    i16 iRetVal = 0;
    i16 iDevice = 1;
    u32 ulGpctrNum = ND_COUNTER_0;
    //u32 ulLOWcount = 100;  //1ms
    //u32 ulHIGHcount = 10000; //100ms
    u32 ulLOWcount = 2;   //0.02ms
    u32 ulHIGHcount = 10;  //0.1ms  varied for testing
    
    iStatus = GPCTR_Control(iDevice, ulGpctrNum, ND_RESET);
    iStatus = GPCTR_Set_Application (iDevice, ulGpctrNum, ND_RETRIG_PULSE_GNR);
    iStatus = GPCTR_Change_Parameter(iDevice, ulGpctrNum, ND_SOURCE, ND_INTERNAL_100_KHZ);
 //iStatus = GPCTR_Change_Parameter(iDevice, ulGpctrNum, ND_GATE_POLARITY, ND_NEGATIVE);
    iStatus = GPCTR_Change_Parameter(iDevice, ulGpctrNum, ND_GATE, ND_PFI_9);  //Gate, apply trigger here
    iStatus = GPCTR_Change_Parameter(iDevice, ulGpctrNum, ND_COUNT_1,ulLOWcount);
    iStatus = GPCTR_Change_Parameter(iDevice, ulGpctrNum, ND_COUNT_2,ulHIGHcount);
    /* To output a counter pulse, you must call Select_Signal. */
    iStatus = Select_Signal (iDevice, ND_GPCTR0_OUTPUT, ND_GPCTR0_OUTPUT,ND_LOW_TO_HIGH);
    iStatus = GPCTR_Control(iDevice, ulGpctrNum, ND_PROGRAM);
    //printf("Apply your trigger pulse to PFI9 now.\nThe rising edge will arm and the second falling edge will gate in the value.\n");
    c=getchar(); // this simulates normal DAQ.
    iStatus = GPCTR_Control(iDevice, ulGpctrNum, ND_RESET);
    /* Note that the following Select_Signal call will cause the
     output to be high impedance which will most likely bring the logic
     level HIGH if there is a pull-up resistor on this pin. (Check your
     hardware user manual.)  If you do not want this behavior, comment out
     the next line. */
    //iStatus = Select_Signal(iDevice, ND_GPCTR0_OUTPUT, ND_NONE, ND_DONT_CARE);
 return;
}

0 Kudos
Message 1 of 5
(3,256 Views)

Hi jimmek,

 

I'm not quite sure if I understand your issue. Are you saying that if you manually ground the gate on CTR0 to simulate an external sync signal (high-low-high), your application is working, but if you provide an actual 5V (low-high-low) that your counter no longer generates the pulse? Also is there any particular reason why you are using the older Traditional NI-DAQ as opposed to NI-DAQmx? Otherwise, I highly suggest moving over to our newer DAQmx driver as it provides several advantages such as performance improvements as well as ease of use. When you install the NI-DAQmx drivers, you can refer to the DigPulseTrain-Cont-Dig Start.prj in your NI Example Finder as this will be a good place to start. I have gone ahead and made the necessary modifications. Please let me know if this works for your application.

 

Also, I believe you meant 6052E instead of 6062E. 

 

Regards,

S_Hong
National Instruments
Applications Engineer
0 Kudos
Message 2 of 5
(3,234 Views)

S_Hong,

 

Thank you for the reply.

 

I have a DAQCard 6062E (Traditional NIDAQ).  The government lab I work in has not updated anything in 3 years. LW/CVI 7.0 is the latest I have access to.

 

The setup and code I have generates the desired pulse to GPCTR0_OUT (pin 2) only when I tap the ground DGND (pin 18) to GPCTR0_Gate (pin 3). Momentarily tapping the +5VDC to pin to GPCTR0_Gate (pin 3) does nothing.

0 Kudos
Message 3 of 5
(3,215 Views)

Hi jimmek,

 

I saved the .uir file in the CVI project for 7.1. Please let me know if this is works for you.

 

Regards,

S_Hong
National Instruments
Applications Engineer
0 Kudos
Message 4 of 5
(3,200 Views)
Solution
Accepted by topic author jimmek

S_Hong,

 

I have solved my problem.

 

I had in my code

 

iStatus=GPCTR_Change_Parameter(iDevice,ulGpctrNum,ND_GATE,ND_PFI_9);

 

and was using it for my input trigger. This is wrong because PFI_9 is an echo OUT of whatever my trigger is connected to.

 

I changed the statement to

 

iStatus=GPCTR_Change_Parameter(iDevice,ulGpctrNum,ND_GATE,ND_PFI_0);    for the source of the signal.

 

and now a trigger on the PFI_0 pin generates the pulse.

0 Kudos
Message 5 of 5
(3,190 Views)