Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

CWAOPoint CWAIPoint and C#

I'm trying to use the current outputs of a 6704 and read the voltage inputs of a 6052E board from Visual C# .Net. Both cards are in a PXI rack, and my PC connects to them over RDA.

Both cards work perfectly from within Labview and MAX test panels.

I added the CWAOPoint and CWAIPOint controls to the form and called them AI1 and AO1. In properties I configured them to device 1 and 3 (the device numbers in MAX).

Then I use the following code:


// Write
float[] target = new float[16];
for (int i=0; i< 16; i++)
target[i] = i; // from 1 to 16 mA
AO1.ChannelString = "16..31";
AO1.SingleWrite(target, true);
// Read
object result = null;
float[] results = new float[5];
float lowerlimit = 0.0F;
float upperlimit = 5.0F;
fl
oat timelimit = 1.0F;
AI1.Channels.RemoveAll();
ChannelString = "0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13";
AI1.Channels.Add(ChannelString, upperlimit, lowerlimit, CWAIInputModes.cwaiDefaultInputMode, CWAICouplings.cwaiDC);
ChannelString = "6, 7"; AI1.Channels.Add(ChannelString, upperlimit, lowerlimit, CWAIInputModes.cwaiDIFF, CWAICouplings.cwaiDC);
AI1.SingleRead(ref result, timelimit);
results = (float[])result;

Both the SingleRead and SingleWrite lines produce an exception:
System.Runtime.IneropServicdes.COMException(0x800A28A1): Configuring channels. The specified device is not a National Instruments product, the driver does not support the device (for example, the driver was released before the device was supported), or the device has not been configured using the Measurement & Automation Explorer. at ...

"Configuring channels." is only shown for the AI1.SingleRead call.

Somebody knows what I could be doing wrong here?
0 Kudos
Message 1 of 5
(4,171 Views)
Hi,

Remote data acquisition (RDA) is a useful tool that ships with the NI-DAQ driver software. RDA is only supported in LabVIEW and LabWindows/CVI. To utilize RDA in the CVI environment, developers must even restrict the scope of their functions to the Easy I/O library for DAQ.

It could be possible with the following link:

http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RNAME=ViewQuestion&HOID=506500000008000000C26A0000&ECategory=Measurement+Studio.For+Visual+C%2B%2B

Regards.

Joris Vanderschrick
Applications Engineer
NI Belgium
0 Kudos
Message 2 of 5
(4,171 Views)
Thanks,

Now I run the program on the PXI system itself. This produces another error:

System.Runtime.InteropServices.COMException(0x800A2711):
An error was detected in the input string; the arrangement or ordering of the characters in the string is not constistent with the expected ordering
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at CWDAQControlsLib._DCWAOPoint.SingleWrite(Object Values, Object Scaled)
at ...

Still using the same code as in my original question.
0 Kudos
Message 3 of 5
(4,171 Views)
There must be something wrong with your channel string syntax. Probably the following:

AO1.ChannelString = "16..31";

Don't you need to set this with the following string:

"16:31".

Regards.
0 Kudos
Message 4 of 5
(4,171 Views)
Thanks. I have the analog input part working now. The analog output part still produces an error:

The analog input or analog output voltage or current range is invalid for the specified channel, or you are writing an invalid voltage or current to tho analog output.

I tried adding this:
AO1.ChannelType = CWAOChannelTypes.cwaoCurrent;
AO1.LowerLimit = 0.01F; // Limits according to pxi6704 user manual
AO1.UpperLimit = 20.2F;
AO1.ReferenceSource = CWAOReferenceSources.cwaoInternal;

But this still gave me the same error. I tried all sort of values for the limits and the values but always the same error.
0 Kudos
Message 5 of 5
(4,171 Views)