Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Information on programming c++ for 6514 Digital I/O

I am using a NI-6514 to continuously record input from a 15 bit digital encoder. I have tested the setup with MAX to verify that I have made all of the correct connections, but I need information on how to communicate with the encoder via C++ .NET. I do not plan on purchasing Measurement Studio or Labview because the application is so simple. Please direct me towards documentation that will help me to get started in recieving digital inputs via Visual C++ .Net.
0 Kudos
Message 1 of 4
(3,788 Views)
Mike,

I would suggest that you begin by examining the examples available in the following folder:

C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Digital\Read Values

Specifically, the Read Dig Port example would be a good place to start.

Good luck with your application.

Spencer S.
Message 2 of 4
(3,788 Views)
Hi Spencer,

I set up Read Dig Port and compiled it, calling the Configure, Start, Read, and Stop functions. It compiles without error, but during run time (with the debugger) it gives me the following error:

"Unhandled exception at 0x00fa1d97 in VC_ReadDigPort.exe: 0xC0000096: Privileged instruction."

This error occurs right after I call the Configure function in the following line of code in Configure_ReadDigPort in ReadDigPort_Fn.c:

"DAQmxErrChk (DAQmxCreateDIChan(*taskHandle,chan,"",DAQmx_Val_ChanForAllLines));"

This kills the running of the program where it is.

I think the problem may be arising because I'm running the program in Visual C++ .Net rather than Visual C++ 6.0. Please advise on how to set or get the privilege so
that this error does not occur.

I'm attaching the code (I've modified the main function to include the Configure, Start, Read, and Stop functions, and to access my device, NI6514).
0 Kudos
Message 3 of 4
(3,788 Views)
Mike,

So, it appears that you forgot to add the & operator before the taskHandle parameter in the Configure_ReadDigPort function and the data parameter in the Read_ReadDigPort function. The modified section of code appears as follows:

Configure_ReadDigPort("Dev1/port0", &taskHandle);
Start_ReadDigPort(taskHandle);
Read_ReadDigPort(taskHandle, &data);
Stop_ReadDigPort(taskHandle);

Spencer S.
0 Kudos
Message 4 of 4
(3,788 Views)