Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

How to set port/channel number to read values from a digital input port?

Hello
 
I am trying to read voltage from a digital input with the 6025E device using the C++ code, WriteDigPort.c from NI examples. I think I have to select the pin number to be read the data from. Could you advise how to select that?
 
Could you also advise if i need to enter the device number in C code or will the device automatically be recognised?
 
Thanks in advance
Yusuf

Message Edited by yusuf on 10-08-2006 06:31 AM

0 Kudos
Message 1 of 4
(3,643 Views)
Hi Yusuf,
 
The board should be recognised automatically in Measurement and Automation Explorer (MAX) if the NI-DAQmx driver is correctly installed on the PC. If you check in MAX under devices and interfaces, you will see that the device will have been given a Device Number, you will need this to reference the board from your C++ code.
 
In the actual code, the following line is where you will need to specify the board and the port or lines you want to read from.
 DAQmxErrChk (DAQmxCreateDOChan(taskHandle,"Dev1/port0","",DAQmx_Val_ChanForAllLines));
Where the "Dev1/port0" gives the port to read from.
 
If you take a look at the help for the C API, it will explain these functions and how to use them in more detail, and what to specify as the device and line numbering. This will also be installed, and will be available from the Start bar under National Instruments>>NI DAQ.
 
I hope this helps, let me know if you have any questions.
 
Regards
Hannah
NIUK & Ireland
Message 2 of 4
(3,627 Views)

Thanks Hannah for clarifying. Its now working well.

Now i have moved to NI USB-6009 device. Using the examples in VB, it is pretty successful to generate digital, but reading analog inputs(with VB AcqIntClk)  it displays around 3.5 V whereas it should be 5V. What do you suggest to increase the accuracy?

Also, examples provided use the library, nidaqmx.tlb . Can you advise a simple piece of code without any .tlb or .dll (in VB and/or C++) to generate/read inputs outputs through 6009 device?

Many thanks and regards

Yusuf 

0 Kudos
Message 3 of 4
(3,622 Views)

Hi Yusuf,

Have you tried checking your analogue input in NI Measurement and Automation Explorer (MAX)? This will show you whether the difference in voltage is down to the hardware setup or the software. The 6008 and 6009 devices have fairly low input impedance (around 144kOhm). Check whether you're using RSE or differential mode, and that the software setup is matched to this properly.

The library is included to make DAQmx programming easier in VB:

http://digital.ni.com/public.nsf/websearch/B22FE2B0F9C8935286256E920073DA07?OpenDocument

The only other way to call the DAQmx drivers from Visual Basic would be to wrap the dlls individually for each function you need, which isn't easier than using the examples you've already looked at.

Hope this helps.

Mark

National Instruments

Message 4 of 4
(3,597 Views)