Jakeus
2007-01-09 20:10:10 UTC
Alright, I'm attempting to write data to the onboard memory of a 653X series PXI DIO board. I want to do this because buffering data using the computer's RAM will be too slow for the higher speed applications I am trying to program for. I'm using Lab Windows CVI and the latest DAQmx drivers. Here is the code I have come up with:
#include <ansi_c.h>#include <NIDAQmx.h>void main(){ int32 sampsWritten = 0;
int i; TaskHandle Output = 0; char chrBuffer[80]; uInt8 WriteArray[8]={1,0,0,0,0,0,0,0}, WriteArray2[8]={0,0,0,0,0,0,0,0};
for(i=0; i < 10000; i++){ DAQmxCreateTask("",&Output); DAQmxCreateDOChan(Output, "Output/port0/line0:7", "test", DAQmx_Val_ChanForAllLines); DAQmxCfgSampClkTiming (Output, "OnboardClock", 100, DAQmx_Val_Rising,DAQmx_Val_FiniteSamps, 10); DAQmxCfgOutputBuffer (Output, 10); DAQmxWriteDigitalLines (Output, 1, 0, 10.0, DAQmx_Val_GroupByChannel, WriteArray,&sampsWritten, NULL); DAQmxStartTask(Output); DAQmxClearTask(Output);
DAQmxCreateTask("",&Output); DAQmxCreateDOChan(Output, "Output/port0/line0:7", "test", DAQmx_Val_ChanForAllLines); DAQmxCfgSampClkTiming (Output, "OnboardClock", 100, DAQmx_Val_Rising,DAQmx_Val_FiniteSamps, 10); DAQmxCfgOutputBuffer (Output, 10); DAQmxWriteDigitalLines (Output, 1, 0, 10.0, DAQmx_Val_GroupByChannel, WriteArray2,&sampsWritten, NULL); DAQmxStartTask(Output); DAQmxClearTask(Output);
}
printf("\nPress ENTER to exit"); gets (chrBuffer); }
Basically I'm just trying to toggle Port0 pin 0 high and low.
I have had problems trying to find decent examples of this application in CVI, so please don't criticize too much.
Any advice on what else I need to configure or any ways I can optimize this code?
#include <ansi_c.h>#include <NIDAQmx.h>void main(){ int32 sampsWritten = 0;
int i; TaskHandle Output = 0; char chrBuffer[80]; uInt8 WriteArray[8]={1,0,0,0,0,0,0,0}, WriteArray2[8]={0,0,0,0,0,0,0,0};
for(i=0; i < 10000; i++){ DAQmxCreateTask("",&Output); DAQmxCreateDOChan(Output, "Output/port0/line0:7", "test", DAQmx_Val_ChanForAllLines); DAQmxCfgSampClkTiming (Output, "OnboardClock", 100, DAQmx_Val_Rising,DAQmx_Val_FiniteSamps, 10); DAQmxCfgOutputBuffer (Output, 10); DAQmxWriteDigitalLines (Output, 1, 0, 10.0, DAQmx_Val_GroupByChannel, WriteArray,&sampsWritten, NULL); DAQmxStartTask(Output); DAQmxClearTask(Output);
DAQmxCreateTask("",&Output); DAQmxCreateDOChan(Output, "Output/port0/line0:7", "test", DAQmx_Val_ChanForAllLines); DAQmxCfgSampClkTiming (Output, "OnboardClock", 100, DAQmx_Val_Rising,DAQmx_Val_FiniteSamps, 10); DAQmxCfgOutputBuffer (Output, 10); DAQmxWriteDigitalLines (Output, 1, 0, 10.0, DAQmx_Val_GroupByChannel, WriteArray2,&sampsWritten, NULL); DAQmxStartTask(Output); DAQmxClearTask(Output);
}
printf("\nPress ENTER to exit"); gets (chrBuffer); }
Basically I'm just trying to toggle Port0 pin 0 high and low.
I have had problems trying to find decent examples of this application in CVI, so please don't criticize too much.
Any advice on what else I need to configure or any ways I can optimize this code?