01-26-2010 02:45 PM
I recently switched from PCI 6250 with 3 - 8 bits port to PCI6254 with 1 - 32 bit port (Port 0). Below is the codes I used to write data out to the 8 bit digital port and it worked well with PCI 6250. However, I do not know how to make it work with the 32 bit port (I need to utilize all 32 bits in Port 0 on PCI6254). When I used the exact code on PCI 6254 (32 bit port), it give me an error " The requested memory could not be allocated. Task Name = DigitalWriteTask". I will appreciate your help!
CNiString physicalChannel = "Dev1/Port0";
try
{
// Create the task
CNiDAQmxTask digitalWriteTask(_T("digitalWriteTask"));
// Create an Digital Output channel and name it.
digitalWriteTask.DOChannels.CreateChannel(
physicalChannel,
"",
DAQmxOneChannelForAllLines);
// Write digital port data. WriteDigitalSingChanSingSampPort writes a single sample
// of digital data on demand, so no timeout is necessary.
CNiDAQmxDigitalSingleChannelWriter writer(digitalWriteTask.Stream);
writer.WriteSingleSamplePort(true, (unsigned long) dataToWrite);
}
Thanks,
Yajai.
02-01-2010 09:49 AM
Hello Yajai,
When it gives you this error, does it have an error number with it? Also, is this code one of the examples the come with the driver? If it is not, try running one of those, and see if that also throws the same error. Also, in the error that it throws, did it say Task Name = DigitalWriteTask, or digitalWriteTask. I don't see anywhere in the code you posted that you use DigitalWriteTask, so if you try to reference that somewhere in your code, the capitalization could be the problem.
-Christina