05-29-2006 04:14 AM
m_taskWrite = std::auto_ptr<CNiDAQmxTask>(new CNiDAQmxTask(_T((LPCTSTR) tempString)));m_taskWrite->DOChannels.CreateChannel("Dev1\Port0","", DAQmxOneChannelForAllLines);m_writer = std::auto_ptr<CNiDAQmxDigitalSingleChannelWriter>(new CNiDAQmxDigitalSingleChannelWriter(m_taskWrite->Stream));m_writer->WriteSingleSamplePort(true,value /*12*/);
m_taskRead = std::auto_ptr<CNiDAQmxTask>(new CNiDAQmxTask(_T((LPCTSTR) m_DeviceUniqueString)));
m_taskRead->DIChannels.CreateChannel("Dev1\Port0","", DAQmxOneChannelForAllLines);
m_reader = std::auto_ptr<CNiDAQmxDigitalSingleChannelReader>(new CNiDAQmxDigitalSingleChannelReader(m_taskRead->Stream));
m_reader->ReadSingleSampleMultiLine(readData);
05-30-2006 08:13 PM
Bird,
There should be no need to create a new task, as it looks like that is what you are doing to just do the digital read after a write. In the same task as your digital write, right after you write your value, put a DAQmx Digital Read command and that should do it for you. Let us know how that goes. -GDE05-31-2006 08:44 PM
Hi GDE,
I really don't understand how you implement a digital read when you create the DOChannels (Writer).
If I need to create DIChannels after write as the following, it would have the following exception:
m_taskWrite = std::auto_ptr<CNiDAQmxTask>(new CNiDAQmxTask(_T((LPCTSTR) tempString)));m_taskWrite->DOChannels.CreateChannel("Dev1\Port0","", DAQmxOneChannelForAllLines);m_writer = std::auto_ptr<CNiDAQmxDigitalSingleChannelWriter>(new CNiDAQmxDigitalSingleChannelWriter(m_taskWrite->Stream));m_writer->WriteSingleSamplePort(true,value /*12*/);
m_taskWrite ->DIChannels.CreateChannel("Dev1\Port0","", DAQmxOneChannelForAllLines); ---> exception error here
//m_reader = std::auto_ptr<CNiDAQmxDigitalSingleChannelReader>(new CNiDAQmxDigitalSingleChannelReader(m_taskWrite ->Stream));
//m_reader->ReadSingleSampleMultiLine(readData);
06-01-2006 07:11 PM
Bird,
You don’t need to run the DIChannels.CreateChannel… This is what is causing the error. You already have the resources reserved for your output task, so now trying to reallocate them is throwing this error. All you should need to do is run your next two lines, that were commented out:
m_reader->ReadSingleSampleMultiLine(readData);
”
The idea is, you don’t need to create any new tasks, or reallocate any resources, the digital write tasks, have the ability to read their same channels as well. So the strategy is to just do all of your writes as usual, and if you need to read the same lines to ensure things worked you can just do so without reconfiguring anything.
I hope that clears up the confusion.
-GDE06-05-2006 10:45 PM
Hi GDE,
Thank you. It works now.
Bird