Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending a Reset command using CWVisa causes Data Acquisition to stop

Hi,
 
Here is the basic setup, I have written a multi-threaded application that does Data Acquisition on PXI-6031E cards and controls a GPIB-based power supply at the same time. The application uses ComponentWorks controls like CWAI, CWAIChannel, and CWVisa to interface with the instruments. Whenever the power supply has an Over-Voltage trip, the application needs to send a Reset command to it in order to restore it to a good state.
 
The problem is whenever the application sends out the Reset command after an Over-Voltage trip, the Data Acquisition fails, returns errors, and then stops. In addition, the application loses its Visa connection to the power supply too.
 
A few things I noticed were, if my application sends out a Reset command when the power supply is NOT in an Over-Voltage trip state, then Data Acquisition is not affected. Although the power supply takes less time to perform the Reset when it's not in an Over-Voltage trip state. This lead me to believe that it might be a problem with the power supply. However, if I send out a Reset command during an Over-Voltage trip using other clients (like the NI 488.2 Communicator client), the power supply is reset without affecting Data Acquisition in my application. Thus it seems more like a software problem than a hardware one. So I was wondering if this problem might be caused by using multiple ComponentWorks controls in a multi-threaded application.
 
Thanks in advance to anyone who can help.
 
 
VRMan
 
0 Kudos
Message 1 of 4
(3,566 Views)
Hi VRMan,

We need to figure out how talking to the power supply is connected to your data acquisition.  I would assume you are running the code for each of these tasks in separate threads since you are running a multi-threaded application.  Is this correct?

How else could these tasks be connected?  When you send the reset to the power supply, is the code waiting on the power supply to reset?  Are you acquiring any data during this time?  When exactly does the data acquisition fail, and what errors do you get?

Try taking a spy capture using NI-SPY to see what driver-level calls are being made to your hardware.  Please post the capture so we can see exactly what's happening on your system.

Thanks,

Robert Mortensen
Applications Engineer
National Instruments
Robert Mortensen
Software Engineer
National Instruments
0 Kudos
Message 2 of 4
(3,560 Views)
Hi Robert,
 
The power supply and data acquisition aren't connected in any way. The code that control each run in separate threads and do not interact with each other.
 
The code uses the Write method on CWVisa to send a *RST command to the device, but it does not wait after sending the command. According to the CWVisa documentation, the Write method is synchronous and waits for the transfer to terminate before returning, so the thread communicating with the power supply might be waiting inside the call to Write. However, that's all happening on its own separate thread apart from data acquisition.
 
Data acquistion is always going and does not wait on the power supply in any way, because it's on a different thread. However, several seconds after sending the *RST command, the application receives an OnDAQError_ContainedCWDaq error with status code -10846 and context ID 4096. I'll see if I can get some more information from NI-SPY.
 
The main thing I'm wondering is whether or not ComponentWorks controls are safe to use concurrently in different threads in the MTA of a multi-threaded application.
 
Thanks,
 
 
 
VRMan
 
0 Kudos
Message 3 of 4
(3,553 Views)
You must call the ComponentWorks controls from the thread that creates them. If you want to call different controls from different threads, you need to create each control in the thread that will call it.
 
If you own Measurement Studio and are using MFC, you could consider using the Measurement Studio C++ VISA class library instead of the ComponentWorks control.
0 Kudos
Message 4 of 4
(3,550 Views)