Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

counter digital output with E-Series (DAQmx)

I  have read many messages indicating that DIO are software-time in the E-series (I own a 6034) however
I have got an idea that I don't see (yet) why it should not work. 
 
As suggested by many, I am using a counter task to generate a single pulse which I want to use as a trigger in
my application.To trigger other devices, I would however prefer using a DI0 line instead of terminal CTR0_OUT (pin 2) 
because it seems safer given the lower limits in sinking and sourcing current of the  CTR0_OUT terminal.
 
To obtain an hardware-timed pulse on DIO0 with my 6034E, I had the idea of using two digital ouptut tasks. The
first task would start when a RISING edge is detected on CTR0_OUT (configured with DAQmxCfgDigEdgeStartTrig),
then it would put DIO0 in the HIGH state (using DAQmxWriteDigitalLines to write a single sample), and then it would
- I assume - automatically stops. The second task would put DIO0 in the LOW state when a FALLING edge
is detected on CTR0_OUT in a similar manner.  My attempts to implement this approach have been unsucessful
but I do not understand exactly why it does not work (see code below).
 
Another question is what I need to add to my code so that I would get a new impulse each time
I start the counter task.
 
Thank you,
 
Gabriel
 
// Configure counter task
DAQmxErrChk( DAQmxCreateTask("",&mCtrTask));
DAQmxErrChk (DAQmxCreateCOPulseChanTime(
  mCtrTask,
  "Dev1/ctr0",
  "",
  DAQmx_Val_Seconds,
  DAQmx_Val_Low, //int32 idleState: DAQmx_Val_High  or DAQmx_Val_Low
  0.000,         // float64: initialdelay
  0.001,         // float64: lowtime (must be different from 0)
  hightime));    // float64: hightime
 
// Configure digital output tasks
long sampsPerChanWritten;
unsigned char High[1]={1};
DAQmxErrChk(DAQmxCreateTask("",&mDigOut1Task));
DAQmxErrChk(DAQmxCreateDOChan(mDigOut1Task,"Dev1/Port0/line0","",DAQmx_Val_ChanForAllLines ));
DAQmxErrChk(DAQmxWriteDigitalLines(mDigOut1Task,1,true,1,DAQmx_Val_GroupByScanNumber,
    High,&sampsPerChanWritten,NULL));
DAQmxErrChk(DAQmxCfgDigEdgeStartTrig(mDigOut1Task,"Dev1/ctr0",DAQmx_Val_Rising));
unsigned char Low[1]={0};
DAQmxErrChk( DAQmxCreateTask("",&mDigOut2Task));
DAQmxErrChk( DAQmxCreateDOChan(mDigOut2Task,"Dev1/Port0/line0","",DAQmx_Val_ChanForAllLines ));
DAQmxErrChk( DAQmxWriteDigitalLines(mDigOut1Task,1,true,1,DAQmx_Val_GroupByScanNumber,
    Low,&sampsPerChanWritten,NULL));
DAQmxErrChk( DAQmxCfgDigEdgeStartTrig(mDigOut2Task,"Dev1/ctr0", DAQmx_Val_Falling));
 
// trigger single pulse
DAQmxErrChk( DAQmxStartTask(mCtrTask));
 
 
0 Kudos
Message 1 of 10
(5,441 Views)

The basic problem is that your backdoor workaround is also not supported by your board.  There just isn't a way to get hardware-driven timing for digital output bits on that board.  Not with a sample clock, and also not with a trigger.

Maybe you can wire your counter output to a simple external chip that'll reproduce the pulse while sourcing more current?

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 2 of 10
(5,429 Views)
Thank you Kevin
 
Right now I am trying to use CTR0_OUT as a switch. The other system has a line (named sync-in)  that is usally at 3.3 V
and that I want to ground when the value on CTR0_OUT is high. To that end, I have connected VTR0_OUT to the
base of a NPN 2N2222 transitor via a 1kOhm resistance. Collector is connected to the sync-in line and emitter is connected
to the ground.
 
                                                                C  _ _ _ _  sync-in (3.3V)
                           | /
CTR0_OUT --- /\/\/\/\ -----|/
             1KOhm       B |\
                           | \
                            E|
                             |
                           -----
                            ---
                             -
 
Any other circuit suggestion about how to use CTR0_OUT either as
a switch (with a Photocoupler for example) or as a TTL trigger signal 
would be appreciated. I would appreciate resistance values and component
names if possible since I am not an electronic expert.
 
Also, what is the powere-on state of CTR0_OUT and what to it
once the task has been stopped?  
 
Best.
 

Message Edited by gavril on 11-01-2006 10:07 AM

0 Kudos
Message 3 of 10
(5,423 Views)

gavril:

I use the HPCL-2300 high speed optocoupler quite often to isolate counter signals. Google it to find the app notes. If power on state does not match your requirements, you can use an inverter (SN7404) Attached is a screenshot of a schematic from a system that uses such. No need for U1 in your app, U2 is the aforementioned inverter, C1, R1A/B, U3 and C4 are needed. The output of U3 can be used to pull your 3.3V input low.

Good Luck

-AK2DM

Message Edited by AnalogKid2DigitalMan on 11-01-2006 09:20 AM

~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
Message 4 of 10
(5,418 Views)

AnalogKid-

That's the strangest LabVIEW code I've ever seen. And what's with the green wires?

0 Kudos
Message 5 of 10
(5,391 Views)

Thank you Analog Kid.

Another strange LabView code Smiley Happy  that I have received. In this case, Sync-in is grounded when DAQ output goes into low state. I was told that the resistor can be as low as 1K or as high as 10K. What would be the best value if the DAQ output corresponded to the CTR0_OUT terminal (pin 2)? How does one determine this value? As usual, I appreciate any comment/suggestion. Gabriel

Message Edited by gavril on 11-02-2006 05:18 AM

0 Kudos
Message 6 of 10
(5,368 Views)

gavril:

Are you speaking of the resistor to use on the phototransistor side that connects to your 3.3V sync_in signal?

~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 7 of 10
(5,345 Views)
AnalogKid, I was talking about the 4.7 K resistor on the DAQ side. On the sync-in side, the signal can be grounded safely (there must be
some internal resistor).
0 Kudos
Message 8 of 10
(5,334 Views)

I'm thinking more along the lines of 370 ohms. R= (5V-1.3V)/(0.010A) = 370 ohms. The 1.3V represents the forward voltage drop of the 4N35, forward current of it is 0.010A. (Figures taken from spec sheet)

Here's a good link to Vishay's version of the 4N35 with specs and app note links.

http://www.vishay.com/optocouplers/list/product-83717/

You may want to search for the like for the ones specific to the manufacturer of your 4N35.

Message Edited by AnalogKid2DigitalMan on 11-02-2006 01:28 PM

I see the 6034 counter output is rated for 5mA sink max so you may need to buffer between the DAQ card and the 4N35- could use 74series TTL 2 inverters in-series or an AND gate with both inputs wired together.

Message Edited by AnalogKid2DigitalMan on 11-02-2006 01:31 PM

~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 9 of 10
(5,331 Views)

It looks like the 4N35 can operate the photodiode from 0.5 mA to 50 mA. Therefore,it might be possible to operate it with a 1K  resistor, which will result in 3.7 ma current (below 5mA). I haven't tried it yet though because I found out that the issue I am dealing was in fact different and that the simple transistor switch circuit (see a previous post) woks well.

The problem is in fact that the terminal (ctr0_out) on the DAQ card (NI 6034E) is tri-stated when I export it to the RTSI bus (where it is used as a trigger by other DAQ cards):

DAQmxExportSignal(myTask_,DAQmx_Val_CounterOutputEvent,"/Dev1/RTSI0")

After exporting the signal, the pulse produced by the counter is not present on Ctr0_Out anymore.  The solution seems to run the task once before the exporting the signal

http://forums.ni.com/ni/board/message?board.id=250&message.id=7069&query.id=257729#M7069

As stated by reddog in the above thread in a slightly different context, "Although the destination for the signal has changed, the original route will remain in place and you should be able to see the signal at both locations"

There seems to be no other way to have the signal at both locations in this case since it is impossible to connect physically RTSI0 and ctr0_out but I would be glade to be corrected.

Also, I could not find any documentation on this point (except for the hints from users in the forums).

 

 

0 Kudos
Message 10 of 10
(5,299 Views)