09-11-2007 09:25 AM
09-12-2007 11:38 AM
Hello Jjsomer,
Normally, you only want to create/configure and start each task only once. Then you can read/write to the task several times in a loop without reconfigure the task. After your application is completely done, you want to stop/clear the task. If you want to restart a task, then you just have to stop and start the task without resetting it up. Creating/configuring and stopping/clearing the task every time you want to read/write to a digital port can very time consuming.
29 seconds sounds like a very long time for your application to take even if you are creating/configuring and stopping/clear the task every time you read/write to a digital line. Are you running any other applications while you executing this program? Are there any delays that are created between reading/writing data out on the digital ports?
09-12-2007 01:46 PM
Thanks for the reply.
As I mentioned previously, I have one digital port that can either be input or output. If I create an output task for that port and start it running, then create an input task for the same port and start it running, I receive an error that says the digital lines are reserved. So, I have since modified my software to create an output task and an input task for this port and start the output task running. When I want to set the port status, I simply write digital lines. The speed lost from the traditional daq method is acceptable ~ 20 times slower. When I want to read the data from this port (set the port up to be an input port), I stop the currently running output task, start the previously created input task, and then read the input port. If I do one or the other, the software works fine. If I switch the port direction, I experience a significant slow-down.
The problem I am encountering is downloading 20,000 bytes of data to a microprocessor on an external device using this one digital port. The software sets a byte on this digital port, clocks the data to the micro with another output line on another digital port, then checks the one byte response from the micro on the same data port. So, the process of stopping one task (output or input) then starting the other task occurs 40,000 times (20,000 data bytes sent + 20,000 responses). This takes a significant amount of time to perform.
I had hoped there was a way to change the direction of the port without necessarily stopping the task and starting another task. But, from your response, this does not sound possible. Is the way that I have it set up currently the most efficient way to handle changing the digital port direction?
Thanks for your assistance.
Jeremy Smith
09-12-2007 01:55 PM
29 seconds sounds like a very long time for your application to take even if you are creating/configuring and stopping/clear the task every time you read/write to a digital line. Are you running any other applications while you executing this program? Are there any delays that are created between reading/writing data out on the digital ports?
The time details were for a particular task in my software. This task consists of several digital port writes with software coded time delays. It was only meant for reference to detail the amount of slow-down from traditional daq to daqmx. There are no other applications running on this pc. There are several tasks running at one time on the PXI-6508, 7 tasks total.
Task A execution with Traditional DAQ drivers ~ 0.2 seconds.
Task A execution with DAQmx drivers initial attempt (create a fresh task for each digital read/write) ~ 29 seconds.
Task A execution with DAQmx drivers most efficient method I've found (two tasks - one output and one input running at one time - only stopping/starting tasks when the type of access required changes for a particular port) ~ 4 seconds.
Hopefully, this isn't too confusing. What I really need is the most efficient method of changing direction of a digital port.
09-13-2007 06:25 PM - edited 09-13-2007 06:25 PM
Hello Jeremy,
Here is a simple example in LabVIEW that demonstrates how to read from a digital output channel. The only difference between VB6 and LabVIEW is that LabVIEW is going to use subVIs and VB6 is going to use functions that have all the same parameters. Make all of your tasks Digital Output tasks, then make them tristate when you would like to read from those channels. This will allow you to not stop and start the task.
Message Edited by Robert F on 09-13-2007 06:27 PM
09-14-2007 10:14 AM
Thanks for the reply.
I assume in your last response that I need to use the DAQmx funtion DAQmxTristateOutputTerm. The function takes as an argument a string representing the terminal name. I assume this is the same as the identification string I used to create the DO task - /Dev3/port0.
I am having a problem executing this function as it returns an error - "Device not available for routing. It is possible that the device needs to be reset or that the device is being reset. If you are resetting the device, wait for the reset to complete. For example, if you have used the device through Traditional NI-DAQ, you must reset the device before the requested route can be made. For SCXI devices, you must reset the communicator DAQ device. Call the Traditional NI-DAQ Device Reset VI or the Init_DA_Brds function. To reset all devices in Traditional NI-DAQ, right-click the Traditional NI-DAQ Devices folder in MAX and select Reset Driver for Traditional NI-DAQ."
I first create a DO task for /Dev3/port0 to set the port to value 255. Then I use the DAQmxTristateOutputTerm function for terminal /Dev3/port0 and I receive the above error. Not sure if my assumptions are correct.
The Labview diagram you provided does not help much as I am not familiar with that software.
Again, thanks for the help.
09-17-2007 06:56 PM - edited 09-17-2007 06:56 PM
Hello Jeremy,
You can read and write on one port if it is set to tristate mode. Setup the task as a digital output task then set the tristate mode on and off to read or write from that port. If you want to read from that line, then set the tristate mode to “TRUE” and read the data. If you want to write to that line, then set the tristate mode to “FALSE” and write the data.
You just need to set the tristate mode back and forth from “TRUE” to “FALSE” in order to read and write on the same line.
int32 __CFUNC DAQmxSetDOTristate(TaskHandle taskHandle, const char channel[], bool32 data);
Message Edited by Robert F on 09-17-2007 06:57 PM
09-18-2007 10:52 AM
09-21-2007 10:11 AM
Hello jjsomer,
Digital lines on the 6508 and 6509 can not be used in tristate mode. We are considering making the 6509 able to tristate its digital lines in the future. The 6509 is very similar to the 6508 in functionality but it only uses the DAQmx driver. The 6508 can use both the Traditional NI-DAQ and NI-DAQmx drivers.
The best way to accomplish your application is to stop and restart the different tasks, which is your current method.
We have already contacted you to discuss alternate options for your application.
09-21-2007 10:32 AM