Discussion:
How to set port/channel number to read values from a digital input port?
(too old to reply)
yusuf
2006-10-08 11:40:08 UTC
Permalink
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
YusufMessage Edited by yusuf on 10-08-2006 06:31 AM
hannahW
2006-10-09 08:40:11 UTC
Permalink
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
MarkLe
2006-10-11 08:40:11 UTC
Permalink
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:
<a href="http://digital.ni.com/public.nsf/websearch/B22FE2B0F9C8935286256E920073DA07?OpenDocument" target="_blank">http://digital.ni.com/public.nsf/websearch/B22FE2B0F9C8935286256E920073DA07?OpenDocument</a>
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

Continue reading on narkive:
Loading...