Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

ActiveX Analog Output in C#

I'm using c# to develop an app. to collect data using a DAQ 6062E. To test my app, I would like to use the two AOs on the card to simulate a squarewave. I've generated my squarewave and put it in an array. However, when I write it using the cwao.write method I get an error. The stacktrace is as follows:

You have passed an invalid type into a parameter of a VARIANT type.
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at CWDAQControlsLib._DCWAO.Write(Object Data, Object WriteSpec)
at AxCWDAQControlsLib.AxCWAO.Write(Object data, Object writeSpec)
at MotorTest.BearingForm.generateAnalogOutput(Boolean status) in c:\projects\p3
9\base_gantry\motortest\bearingform.cs:line 562

I'm not sure what the second parameter is suppose to be in the method call. Any help would be appreciated.

Thank You,
Philip
0 Kudos
Message 1 of 4
(3,856 Views)
The second parameter is optional - if you don't want to use it, just use Type.Missing. What kind of array were you using for the first parameter? Have you tried using an object array to contain the values that you pass in? Please try these suggestions and post a reply to let us know how it worked out. If you're still having problems, please post some sample code to give a better idea of how you're calling the Write method. Thanks.

- Elton
0 Kudos
Message 2 of 4
(3,856 Views)
Elton, thank you for responding and telling me about the Type.Missing static field. I was unfamiliar with it. I finally got my code working when I discovered the CWAOWriteSpecClass. My code is as follows:

cwao.Configure();
CWAOWriteSpecClass spec = new CWAOWriteSpecClass();
cwao.Write(pattern, spec);
cwao.Start();

pattern is an array of doubles.

I also tried using the Type.Missing field and the code works fine, too.

Thank You,
Philip
0 Kudos
Message 3 of 4
(3,856 Views)
Philip,

It is now possible to use the DAQCard 6062E with the new NI-DAQmx driver. I'm sure you will find the DAQmx API to be much easier to use in C# and also to allow more complete control of your card's capabilities. Refer to the Knowledge Base article NI-DAQmx 7.0 Support for PCMCIA DAQCards for information on how to use your DAQCard with NI-DAQmx. For more information on using the NI-DAQmx API in your application, refer to the example installed with the NI-DAQmx .NET API in Program Files\National Instruments\MeasurementStudio70\DotNET\Examples\DAQmx\Analog Out\Generate Voltage\ContGenVoltageWfm_IntClk\CS. If you do not have NI-DAQ
7.0, you can download it here.

If you don't already have it, you may also find the DAQmx productivity tools, as well as UI and analysis components, included with Measurement Studio 7.0 to be helpful. You can get more information on those here.

TonyH
Measurement Studio
0 Kudos
Message 4 of 4
(3,856 Views)