Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Set maximum and minimum range beyond +/- 10 when using a custom linear scale?

Hello,
 
This seems like it should be simple, but it has me baffled.  I am using vb.net, MeasStudio 7.0,  DAQmx 7.4 with a USB-6015 and trying to create virtual scaled channels.  My custom scale seems to work OK, but the scaled output values are limited to +/- 10 and DAQmx will not let me set the max and min values beyond those limits when I create the channel.
 
Here is the code that creates the custom scale and the channel:
 

myTask0 =

New Task("aiTask0")

Dim accelerometerChannel0(numDevChans - 1) As AIChannel

Dim ChanScale(maxsigs) As LinearScale

Dim
myChanScale As New LinearScale(SigChanName(ichan), SigChanScale(ichan), SigChanOffset(ichan))

ChanScale(ichan) = myChanScale

accelerometerChannel0(ichan - 1) = myTask0.AIChannels.CreateVoltageChannel(DevString0, "", _

AITerminalConfiguration.Differential, Convert.ToDouble(minimumValueNumeric.Value), _

Convert.ToDouble(maximumValueNumeric.Value), ChanScale(ichan).Name)

If I try to use any value outside the range of +/- 10 for minimumValueNumeric or maximumValueNumeric I get the following error message:

Any suggestions?

Thanks,

Jerry

 

 

0 Kudos
Message 1 of 6
(4,367 Views)
 
Greetings Jerry:
 
      Could you please repost with the image of the error. Unfortunately I am not able to view the image. Could you type in the wording of the error just in case the image does not come through the next time. Listed below is an example program we have created in VB.Net for custom scales. Please verify and you should be able to set custom scales with no problems.
 
 
 
In the link below is a known issue customers have seen before.
 
 
Looking forward to hearing back from you. Thanks much and have a wonderful day Jerry,
 
Avi Harjani
 
0 Kudos
Message 2 of 6
(4,345 Views)
Dear Avi,
 
Thanks for the reply, but even after looking at your "save" examples, I am still having the same problem.
 
Here is the text of the error message (I hard-coded a value of 100 for AIChannel.Minimum and .Maximum in this case):
 
Requested value is not a supported value for this property.
Property: NationalInstruments.DAQmx.AIChannel.Minimum
You Have Requested: -100.000000
Valid Values Begin with: -10.000000
Valid Values End with: 10.000000
Channel Name: Dev3/ai0
Task Name: aiTask0
Status Code: -200077
 
The strange thing is that the scaled output data is clipped at a value of 50, not 10 - independent of the voltage input level.  In other words, if I set the scale factor(slope) to 100 in my custom scale, and input a signal of 1 volt, I get a scaled output value of 50.  If I use a scale factor greater than 50 for the same 1 volt input signal, I always get 50, but if I use a scale factor less than 50, then I get the correct scaled value.  The other strange thing is that if I set a large Offset value, say 500, for example, then the scaled data is again correct, and not saturated.  What I really need is example code of how to programmatically define and apply a custom scale using vb.net.  I have searched MS Help and the website extensively and cannot find any examples.
 
Scaling voltages into Eng Units would seem to be something quite commonly needed?
 
Thanks in advance for any additional help,
 
Jerry
 
 
Message 3 of 6
(4,342 Views)
 
Greetings Jerry:
 
    Thanks for the email. Listed below are the solutions to your problem. Please refer to the attachment as well.
 
1) You have to select 100 to be the maximum range and -100 to be the minimum range for the task
 
2) In the scale for the m value (slope) you have to specify 100 , do not specify any intercept value
These two steps would definitely fix your problem and the fact that you are able to read it until a particular value implies that the device is working just fine. And you might want to reset the device when you bump up the scale and save the configuration in max.
 
3) You can try the same in Max and see how that goes
 
4) To answer your request for the code, please modify the save scale program to do the following ( In simple terms you have to merge the analog input example code with the save scale code and you should be good to go)
 
1. Create a Linear Scale
2. Save the scale in Max
3.  Create an analog input voltage channel.  Make sure to assign a name to the channel you are creating.  Add the custom linear scale which you added and saved in steps one and two. 
4. Save your local virtual channel as a Global Channel. This new global channel can be viewed in Measurement and Automation Explorer.
5. Start the task
 
We do not write code for customers, and I am working on a program which will do what you are looking for and will try to get it to you in the next day or two. But I am sure this should take care of your problem,
Please let me know if you have any more questions
Thanks
Avi Harjani
 
 
 
0 Kudos
Message 4 of 6
(4,316 Views)
Greetings Jerry:
        Hope you were able to resolve the problem from the solution steps posted in my earlier mail. Attached please find an example program built which will create a task, scale and load the same task and scale and run an acquisition. You can look at the saveScale.prj file and the MainformN.vb code. Please keep in mind that it is not National Instrument policy to write code for customers although I have gone above and beyond to help you just in this case. Hope you have a great time developing your application.
Thanks much and have a wonderful day
Avi Harjani
 
 
 
0 Kudos
Message 5 of 6
(4,304 Views)

Dear Avi,

Thanks for your help and the attachments.  The problem is now fixed!

Jerry

 

 

 

0 Kudos
Message 6 of 6
(4,298 Views)