LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert prescaled to postscaled values with custom scale?

Hi,

 

Is there any way to convert between prescaled and postscaled values using an arbitrary custom scale (i.e. linear, map, polynomial, or table)? 

 

I'm trying to write a driver which allows users to choose an arbitrary (previously defined) custom scale, but I need to know within the program the values which are actually output/input, which means I need a way of determining the max/min values for an arbitrary custom scale based on the known unscaled max/min.  Surely there is a NI-DAQ internal function which accomplishes this task, but there doesn't seem to be a VI for it.

 

Any ideas?

 

-Lee

Labview version 9.0f3

0 Kudos
Message 1 of 7
(3,672 Views)

It occurs to me now that one could write a VI to do this, by first checking the ScaleType property of the custom scale provided and then dealing with each case (linear, polynomial, map, table) separately using the properties appropriate to that type, but I was just wondering if there was an easier way, since this functionality obviously exists already within the NI-DAQ VIs.  Perhaps it could be added in a future version of the driver VIs.

 

-Lee

0 Kudos
Message 2 of 7
(3,658 Views)

Hi lee.bassett,


Have you considered using this polymorphic VI in a case structure?

SS-2010-04-05_14.24.51.png

 

You can find this in the Measurement I/O»DAQmx»DAQmx Advanced»DAQmx Scale Setup.

 

Good Luck!
Dustin D

0 Kudos
Message 3 of 7
(3,637 Views)

Hi Dustin,

 

Thanks very much for the suggestion, but I'm afriad I don't see how this helps.  It seems to me that this VI only creates a scale but doesn't allow one to use it in order to convert between unscaled (voltages) and scaled quantities.  

 

Take for example an AO channel.  In my application I want to keep track of the actual voltage sourced at any given time, for instance in order to avoid requesting a value which is out of range and hence generating an error.  I therefore need a way to convert the scaled values requested by a user to unscaled voltages for storage and range checking, obviously without actually sourcing the value with 'DAQmx Write.vi' or something similar.  The appropriate VI would therefore accept an arbitrary custom scale as well as a set of input values (scaled or unscaled) and output the corresponding values which result from scaling in either the forward or reverse direction.

 

If I'm wrong, however, and this VI does actually help one accomplish this, then please explain!

 

Thanks,

Lee

 

 

0 Kudos
Message 4 of 7
(3,627 Views)

Hi Lee,

 

Sorry I wasn't very clear before.  I've written an example and posted it to our Users Community.  It will show you how to use the VIs I was talking about earlier.  Just know that the scales I used were arbitrary so they don't mean anything.  Post back if you have questions!

 

Hope this helps!

Dustin D

0 Kudos
Message 5 of 7
(3,605 Views)

Dustin,

 

Thanks again for your suggestion.  I'm sure your example will be useful to others, but I'm afraid it doesn't actually address my question.  I guess I'm not being very clear.

 

The point is that I want to keep track of the values currently being sourced on my analog output channels.  In my application, users can specify max and min values for the sources, which may reflect the hardware limits of the device (e.g. +/-10V in my case) or a more constrained set of software limits determined by whatever the channel is driving.  If the user tries to write a value outside this range, it will be coerced and the limiting value will be sourced instead (without generating an error in this case).  It is then this limiting value which should be saved in output memory, rather than the out-of-range value requested, to avoid users believing they have sourced a value they have not.

 

If I then allow users to choose a custom scale, then the requested values are given in scaled units, while the device max and min are still unscaled (volts).  This means I need a way to convert the unscaled limits to scaled limits based on an arbitrary custom scale in order to accomplish the procedure described above.  I have attached an example VI that handles linear scales only.  Obviously this could be extended by adding a case structure to handle the other types of scales, but it just seemed a bit silly to me that there is no VI to accomplish this scaling already, given that it most certainly happens inside the various NI-DAQmx routines that accept custom scales.

 

Much of this would also be easier if it were possible to 'read back' the currently sourced value from DAQ output channels, so I wouldn't have to fake it by keeping a local memory of them, but that is a separate issue.

 

-Lee 

0 Kudos
Message 6 of 7
(3,582 Views)

Hi Lee,

 

It seems like if I'm understanding you correctly that you want a set of data and the ability to apply or remove arbitrary scales at will for viewing or saving, it may be better to try a different approach.  Maybe you could save your raw data and then in post processing be able to apply or remove a scale as well as save or display after the scale has been applied.  Unfourtunately there is not a set of VI's specifically designed for post processing scales, but there are VI's that can be used for some of the complicated scales.  Post back if you have more questions

 

Have a good one!
Dustin D

0 Kudos
Message 7 of 7
(3,569 Views)