Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

DIG_Out_Line not working

I've just installed my board DIO-96 and can't seem to toggle the state of a line to 0 and measure the result. The DIG_Out_Line function and DIG_In_Line functions are both executed, but the line state winds up as 1 no matter what the argument to DIG_Out_Line is. The board is definitely installed because my program has it returning a hexadecimal base address-- The IO is just messed up. Perhaps I'm configuring the port wrong? Here's my code (I've cut some
irrelevant parts out):
-----------------------------------------------
#include "c:\Program Files\National Instruments\NI-DAQ\Include\nidaq.h"
#include "c:\Program Files\National Instruments\NI-DAQ\Include\nidaqcns.h"
#include "c:\Program Files\National Instruments\NI-DAQ
\Include\nidaqex.h"
#include "iostream.h"
#include "malloc.h"
#include "stdio.h"
#include "stdlib.h"
#include "time.h"
#include
#include


void main(void)
{
int deviceNumber= 1;
int portNumber= 6;
int mode= 0;
int dir= 3;
int lineNumber= 0;
short lineState= 0;
short* addr= &lineState;
FILE* OUTFILE= fopen("output.txt", "wb");

int status = DIG_Prt_Config (deviceNumber, portNumber, mode, dir);
status = DIG_Out_Line (deviceNumber, portNumber, lineNumber, lineState);
status = DIG_In_Line (deviceNumber, portNumber, lineNumber, addr);
status = Get_DAQ_Device_Info (deviceNumber, ND_BASE_ADDRESS, infoValue);

cout<<"The base address is "<<<"and the final output state of the line is "<<<"\n";
}


-----------------------------------------------
So what is going on here?
0 Kudos
Message 1 of 2
(3,778 Views)
I would recommend a couple of steps to help troubleshoot your situation:

1) If you are using a PC-DIO-96 (ISA) try reversing your 100 pin cable as discussed in the KnowledgeBase article at:

http://ae.natinst.com/operations/ae/public.nsf/fca7838c4500dc10862567a100753500/c9f9207c318b0037862565fa007aa84a?OpenDocument

2) Try using the test panels in the Measurement & Automation explorer to toggle the different lines. Using this utility would eliminate the possibility for code error.

3) Look at the examples that ship with NI-DAQ to verify you are calling the right functions with the right parameters. These examples are typically installed in the "C:\Program Files\National Instruments\NI-DAQ\Examples\" directory. The VisualC folder has a number of different .c files
that will point you in the right direction.
0 Kudos
Message 2 of 2
(3,778 Views)