LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview custom scale No effect

Solved!
Go to solution

I want to convert a voltage signal of -10 to 10 volts using custom scale by labview coding.

I referred to this website :NI-custom scale and tried, but I sadly find that the final data I got did not change.

Is there any problem with this code?

John_Ming_1-1687310936437.png

 

John_Ming_0-1687310883791.png

 

0 Kudos
Message 1 of 9
(1,319 Views)

Hi John,

 


@John_Ming wrote:

I referred to this website :NI-custom scale and tried, but I sadly find that the final data I got did not change.

Is there any problem with this code?


Usually applying a scale will work as expected - as long as you apply a correctly defined scale…

 

Unfortunately we cannot edit/debug/run images (of parts) of code within LabVIEW.

Can you create a simplified version of your VI to test the scale behaviour? Could you even attach that simplified VI?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(1,286 Views)

Sure!

I attach the simplified VI.

0 Kudos
Message 3 of 9
(1,277 Views)

Hi GerdW,

 

As you said, I simplified the VI and tested it.

Unfortunately, My problem has not been resolved.(I used a virtual compactDAQ for testing. After converting 10 V to 2500 bar, I still got data from -5 to 5, I am not sure where the problem is).

I attached my simplified VI so that you can edit/debug/run it.

 

Yours sincerely,

John

0 Kudos
Message 4 of 9
(1,217 Views)

John,

 

     Thus far, you haven't posted code I can read -- you have only posted some code as LabVIEW 2023, and I'm using mainly 2019 (but also have 2021 installed).  "Pictures" of pieces of VIs don't work for me.

 

     But something I thought of is how have you scaled your Waveform Charts (or Graphs -- I can't tell which you are using)?  Does the Y Axis go from -5 to +5?  Then it is probably plotting Volts.  If you correctly set the Scale to be 0 .. 2500, then this should be reflected in the Scale values for the Charts.

 

     To be honest with you, I found the description of Custom Scales somewhat confusing.  I did use it once, when working with students who wanted to measure small accelerations due to muscle twitching, and used an inexpensive tri-axial accelerometer (ADXL335) which is designed to be powered by a 3V supply.  Its specs are a gain of 300 ± 30 mV/g and a bias of 1.5 ± 0.15 V for X and Y (Z bias is ±0.3 V).

 

Note that the DAQ device always records Volts.  If you acquire unscaled data, and you had the Accelerometer not moving, flat on the table, so Z = +1, you'd expect to get out X = 1.5 V, Y = 1.5 V, and Z = 1.5 + 0.3 = 1.8 V.

If you wanted to plot Z, you'd want 1.8 V to be "scaled" to 1 (g), and 0 V scaled to 0 g.  How do you get there?  Subtract the bias and divide by the gain -- (1.8 V - 1.5 V)/(0.3 V/g) = 1 g.

 

So how do I scale my plot?  I wanted to plot accelerations that were in the range of ±2 g.  My units were already in "g", so I set my plot Scale (for Y) to Offset 0, Multiplier 1, and the Scale to Max +2, Min -2.

 

You'll need do so something analogous (and similar) for converting Volts to Bars.  Notice that the "factors" that you need are the inverses of what we often consider Bias and Gain.  Similarly, you'll need to adjust the Scales on your Plots to use the scaled values.

 

Bob Schor

 

 

0 Kudos
Message 5 of 9
(1,200 Views)

Hi Bob,

John_Ming_0-1687656750248.png

 

    Thanks!I noticed that I did't set the max and min value of creat task VI,causing it used default value -5 to 5 and I got data from -5 to 5.

I try to change it to -2500 to 2500 and I got the desired data.😂😂😂

    In addition, I want to set an offset value for each curve in the waveform chart by setting attribution. But I found the the corresponding attribution just affect one curve, How should I set my attribution?🤔🤔🤔

John_Ming_2-1687657327076.png

 

 

 

 

0 Kudos
Message 6 of 9
(1,189 Views)
Solution
Accepted by John_Ming

Sorry, a picture of a function identified by Chinese characters with which I am not familiar doesn't help me.  We keep asking Forum Posters to attach your VI, preferably saved for LabVIEW 2019 or 2021 so we can see and understand the code/functions you are using.

 

The easiest way to adjust a plot of multiple traces where the actual Y value is not as important as having a fixed offset for the traces is to add an offset to each trace before plotting.  So plot 0 plots "Y", plot 1 plots "Y + 100", plot 2 plots "Y + 200", etc.  [Another method is to have multiple graphs/charts, one for each Channel ...].

 

Bob Schor

0 Kudos
Message 7 of 9
(1,175 Views)
Solution
Accepted by John_Ming

@John_Ming wrote:

Hi Bob,

John_Ming_0-1687656750248.png

 

    Thanks!I noticed that I did't set the max and min value of creat task VI,causing it used default value -5 to 5 and I got data from -5 to 5.

I try to change it to -2500 to 2500 and I got the desired data.😂😂😂

    In addition, I want to set an offset value for each curve in the waveform chart by setting attribution. But I found the the corresponding attribution just affect one curve, How should I set my attribution?🤔🤔🤔

John_Ming_2-1687657327076.png

 

 

 

 


Yes, when you apply a Scale to a DAQmx Channel,  the Range setting is in Scaled Units.  For example you have a AI Voltage Channel reading across a 0.1Ohm Shunt Resistor and apply the Scale M = 10, B = 0 Scaled Units = Amps your MAX Range setting would be +/-100 (Amps) for a +/-10 (Volts) input.


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 9
(1,172 Views)

@ Bob_Schor:

John_Ming_0-1687757248327.png

 

Thanks for your patient answer! Sorry for my confusing questions.🤣

I applied multiple graphs/charts and added an offset to each Channel.

All the problems have been solved. Next time I will provide appropriate labels and attachments.

 

John

 

 

Message 9 of 9
(1,155 Views)