LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Creating Custom Scale for executable

Highlighted

Hello,

 

I am currently working on an executable to perform data analysis on the battery of a device. I need to scale the units of some of the data that I am taking in. When I build an executable of my VI, I run into trouble with the custom scaling subvi attached to a virtual channel. I specifically error code 200378. Does anyone know how to create custom scaling units that do not require my computer's specific MAX properties? I have attached my VI.

 

Thanks ,

 

 

Mmoon

0 Kudos
Message 1 of 4
(1,101 Views)

Hello!

 

Have you tried to programmatically import settings to MAX?

 

You can export your settings manually, attach the file to your executable and import it according to the following solution:

http://digital.ni.com/public.nsf/allkb/BBB5B94C038267DF8625723E00030559

 

Marcin

              

Think Dataflow - blog.mtapp.tech
0 Kudos
Message 2 of 4
(1,086 Views)
Message 3 of 4
(1,076 Views)

Instead of creating a Custom Scale in either MAX or the Project, my recommendation would be to create a Task, and to create it in the Project.  Here are my reasons:

  • If it is in the Project instead of in MAX, it "stays with the Project", which means that if you, for example, have the code saved on Subversion, and someone (or even yourself, using another PC) checks out the code, the Task constants are still defined within the Project (even if the PC has a different, or no, DAQ hardware setup).
  • Creating a Task lets you set not only Custom Scales, but also Custom Channels and the other parameters (such as the Timing parameters) associated with a Task.  Once you have a Task thus defined, your DAQmx code can often be reduced to three functions:  Start Task, Read (or Write), and Stop (or Clear) Task.

Here's an example.  Let's say I have a Triaxial Accelerometer, with X, Y, and Z voltage inputs connected to Inputs AI0, AI1, and AI2 of a USB-6009.  The voltage range of each channel is 0 to 10v, corresponding to -5 to 5 g.  I want to use Differential inputs.  I want to sample continuously, taking 1000 samples at 1KHz.  Finally, I want a custom scale that "maps" 0-10v into -5 to 5 "g".

Here's what I do:

  1. Open my Project.
  2. Plug in my USB-6009 so that the Project can "see" (and identify) this device.
  3. Right-click "My Computer" (in Project), choose New DAQmx Task.
  4. Make the Obvious Choices (Analog Input, Voltage, choose USB-6009, choose channels 0..2).
  5. When the Task Configuration screen pops up, go (con)-figure.  Rename the channels to X, Y, and Z, set them to Differential, and set the Timing Parameters.
  6. Now choose Custom Scaling and configure a Custom Scale.  I chose slope 1, Y intercept -5 (so 0v = -5g, +10v = +5g).  I named the scale Accel_Scale and applied it to each channel, setting the Max and Min to +5 and -5 (g).
  7. Click OK.  LabVIEW will add both your Task (which I named Demo_AI_Task) and Custom Scale to the Project.

Here's a VI I made from this specification, using a "Simulated 6009".  Now you probably don't (yet) have LabVIEW 2016, so you might not be able to drag this Snippet to a Block Diagram and have it "expand", but it is so simple you should have no trouble duplicating it yourself.

Custom Scales.png

 

and here is the resulting Front Panel (the simulated 6009 generates a "full scale" slow sinusoid for each channel, offsetting them slightly from each other).  You can see that over 5 seconds (09 to 14), it does about half a cycle, with max at +5 and min heading toward -5.

Custom Scales FP.png

Note that using Defined Tasks makes DAQmx very simple to code for most simple "tasks" (no pun intended) -- you should never use "The Dreaded DAQ Assistant" (not that you did, but who knows who else is reading this post) for things like this!

 

Bob "Long-Winded" Schor

Message 4 of 4
(1,051 Views)