Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

digital I/O on 6534 in C++

I can do a single DIG_Block_In, but how do I call this function in a loop to continuously take and display data as it comes in?
 
rt
0 Kudos
Message 1 of 17
(6,584 Views)
rt,
Generally using the Traditional NI-DAQ C API you use the DIG_Block_In to start the digitial input acquisition, whether you are doing finite or continuous acquisition, and you do not have this function in any kind of loop.  Within the loop you read samples off the buffer.  There are quite a few examples that ship with the driver that demonstrate various digital input tasks -- a good one to look at would be C:\Program Files\National Instruments\NI-DAQ\Examples\VisualC\Di\DIdoubleBufPatternGen653x.C.

However, I would highly recommend moving to our newer, much easier to use API and driver, NI-DAQmx.  NI-DAQmx supports the PCI-6534 and is available for free download on our website.  It too ships with many examples on doing basic I/O functionality.

I hope this helps!

Doug M
Applications Engineer
National Instruments
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 2 of 17
(6,577 Views)
Doug,
 
thanks for your great answer, I have been playing with the double_buffer_pattern example and I need to read the chapter 4 in the DAQ manual to really understand exactly what the function in the loop is doing.
 
As far as the new NI-DAQmx, I have that installed as this card is brand new, but can't find the code samples, where are the code samples for NI-DAQmx?
 
thanks, ryan
0 Kudos
Message 3 of 17
(6,575 Views)
Ryan,
Assuming you did install the examples with your installation of NI-DAQmx, the examples should be at: C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\

I believe that you can select to install this support when you initially install the driver.  If these files aren't present, put in your NI-DAQ CD and modify the install, adding the examples and support.

Doug M
Applications Engineer
NI
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
Message 4 of 17
(6,568 Views)
Wow this is amazingly easier.  I'm right at the beginning of this application so I'm glad you told me to take a look at NI-DAQmx first.
 
I need to receive 32-bit packets at an external sample clock rate of 20kHz.  There are a number of places on the card where I can receive clock apparently.  But the documentation for DAQmxSampClkTiming( ) is rather vague on the source.  If I use the default from the example (PFI0), where does that correspond to on my 6534 card?
 
I have REQ1, REQ2, PCLK1, and PCLK2.  How do I specify that one of these should be my clock source?
 
Thanks for all your help,
 
Ryan
0 Kudos
Message 5 of 17
(6,562 Views)
Ryan,
The NI-DAQmx Help is a great reference here.  To get to it, go to Start >> Programs >> National instruments >> NI-DAQ >> NI-DAQmx Help.  Once the help file is open, you can see the device pinouts for the PCI-6534 by going to NI-DAQmx Help >> NI-DAQmx Device Terminals >> Digital I/O >> NI 653x.  You can also see the pinouts for a device from Measurement and Automation Explorer (MAX) by going to My System >> Devices and Interfaces >> NI-DAQmx Devices >> (your board) then right-click on your board and choose Device Pinouts.   This will shows that PFI0 is pin 4.  There is also a table that shows the equivalent names between Traditional NI-DAQ terminology and NI-DAQmx terminology.  This can be found in the NI-DAQmx Help at NI-DAQmx Help >> NI-DAQmx Device Terminals >> Terminal Name Equivalents.  This mentions that REQx in Traditional NI-DAQ is equivalent to PFIx in NI-DAQmx.  Hope this helps.

Doug M
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 6 of 17
(6,553 Views)
Doug,
 
Thanks this has been a great help.  I am using the Digital Pattern Recognition Start Trigger, and there doesn't seem to be any sample code showing how to do this (or am I missing it?).  Here is my bit of code that works, except for the start trigger part.
 
I'm sending the trigger pattern over the ports (it's a 32 bit pattern across "Dev1/port0:3") but the task times out, so I am not sure what is wrong.
 
 /*********************************************/
 /*/ DAQmx Configure Code
 /*********************************************/
 DAQmxErrChk (DAQmxCreateTask("",&taskHandle));

 DAQmxErrChk (DAQmxCreateDIChan(taskHandle,"Dev1/port0:3","",DAQmx_Val_ChanForAllLines));

 DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"/Dev1/PFI2",20000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,arraySize));
 
 DAQmxErrChk (DAQmxCfgDigPatternStartTrig (taskHandle, "Dev1/port0:3", "11000100000000100000010000110001", DAQmx_Val_PatternMatches));
 
 
 /*********************************************/
 /*/ DAQmx Start Code
 /*********************************************/
 DAQmxErrChk (DAQmxStartTask(taskHandle));
 
 /*********************************************/
 /*/ DAQmx Read Code
 /*********************************************/

  DAQmxErrChk (DAQmxReadDigitalU32(taskHandle,-1,10.0,DAQmx_Val_GroupByChannel,data,arraySize,&sampsRead,NULL));
 
 
I feel like after this it should start taking data once it sees the pattern indicated above.  Is there something wrong here?

Message Edited by rt_quantum on 09-20-2005 06:17 PM

0 Kudos
Message 7 of 17
(6,516 Views)
Hi Ryan,
 
Since you are getting a timeout, it seems that the function call is setup correctly, but maybe that pattern is not actually being detected before your timeout of 10 seconds is up.  Could you start with only 1 port and using either all 1's or 0's for the trigger?  This way you can be more certain that the pattern is actually there. 
 
Thanks,
Laura
0 Kudos
Message 8 of 17
(6,496 Views)
Hi Laura,

So it is no problem to use port0:3 for my virtual channel and the same ports for my  pattern match trigger?

I get an error message that tells me that the specified lines may be reserved or that the device is not present.  I'm sure that the device is present, so that only leaves the lines being reserved.  I'm assuming that's because I've designated them for use in my virtual channel in DICreateChan()

If this is the case, can I use any other open line (like PFI3,4,5,6 etc..) for pattern matching?

Thanks,

Ryan
0 Kudos
Message 9 of 17
(6,490 Views)
FYI I tried to use the line PFI6 and matching the pattern "1" on this line and it errors out saying that the "specified channel is not in the task"
 
 
 
0 Kudos
Message 10 of 17
(6,482 Views)