12-12-2018 11:44 PM
The following code is being used to control a USB-6008OEM1 board, the code works, but, if the board is powered down then back on, this code does not work until the Measurement and Automation Explorer, Test Panel "Start" button is clicked.
For example, the code below is standard code to set digital outputs. The output is not set until the Measurement and Automation Explorer, Test Panel "Start" button is clicked.
I am curious what functionality does the "Start" button perform.
Specifically, using the NIDAQmx.lib and NIDAQmx.h in this C++ code example, does anyone know what API equivalent calls is being used when the "Start" button is clicked?
Here is the sample code (very basic):
Solved! Go to Solution.
12-14-2018 09:44 AM
It looks like the DAQmxStartTask may not be configured with the proper TaskHandle for your code.
This document will explain the configurations for these functions.
http://www.ni.com/tutorial/5409/en/#toc3
12-14-2018 10:03 PM
Niki,
Could you explain your response please. Notice the code is using "h" as the handle in all cases in the code above. BTW, I have since found a solution so we can close this, but the code above does work as-is. Furthermore, I am still curious if anyone knows what code runs under the "Start" button as described in my original post. The "workaround" uses a wrapper initialization routine that flips the digital state on all lines. The full explanation is more complicated and depends on the full system which has devices connected to the digital output lines, which also has LEDs to show the state. The problem has something to do with the way the board keeps the previous state when de-powered. Upon power up the connected LEDS (in my system) show all lines are false, so when I set the pattern to debug and it did not appear to work in fact it was due to the fact that I was setting the lines to the same state so nothing changed on the output LEDs. I added initialization code to first read the line, set it to the opposite state, then proceed as needed, this works with the code above as-is, so the handle is fine. Thank you for the help.
12-17-2018 01:22 PM
Hello,
I am glad that you were able to get your code running.
My response was to the way the Task Handle is configured (TaskHandle h(0)). This notation is not something I have seen when using this API. The article in my previous post details how I would go about configuring the task in this API.
12-21-2018 03:17 PM
Niki,
Thanks, that notation is C++, nothing to do with the NI API. For example, the TaskHandle is defined using a typedef as:
typedef void* TaskHandle;
The notation:
TaskHandle h(0)
uses the C++ initializer, which in this case is identical to the two-stage construction of trivial memory allocation followed by assignment, but the notation is cleaner and generally preferred.
I am still curious as to what is going on under the hood with the "Start" button in the Measurement and Automation Explorer.