LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

search for string and move decimal

Solved!
Go to solution

Hello,

 

I am trying to write code that will search for a fractional string within an array and convert it from mV to V so it can be properly compared to the other fractional string numbers in the array.

 

I have an array that outputs x iterations  each with a minimum and maximum column including several different types of decimal strings (negative/positive with several decimal places) each ending with either mV and V (example string: -725.543mV).

I then split the array into columns containing the minumum and maximum values of each iteration. I want to compare the minimum values of each iteration and find the most minimum, and do the same thing with the maximum values.

Unfortunatley the way I'm doing it, when I convert from fractional string to number it removes the V or mV unit label but does not convert the number from mV to V. so it compares -725.543mV with -52.334V as -725.543 & -52.334 thus declaring the mV value the most minimum. I need the program to recognize that mV is less than V or search each array for values labeled with mV and move the decimal place so it is in standard V format.

The unit label is actually part of the string and not the display (as you can see in the code I've attached) and I understand this is a little tricky with the way I have to do it. But this is a dumbed down chunk of code I will eventually incorporate into my larger program which reads the values and their units from several different types of oscilloscopes. The Scopes output the values as strings as they appear on the screen and don't differentiate between mV and V unless they are told to output the units which just tags them on the end of the string.

 

I'm sorry for the large post. SO to sum up I need to search an array to make sure all values have the same units, if they don't I need to convert each value to the proper unit and output the max and min from the resulting array. my code is attached. Thank you for your help.

0 Kudos
Message 1 of 12
(3,601 Views)

Why don't you search for all string elements with mV and convert them into V?  If you need them as mV later, just convert them back.

 

That is take -725.543mV.  Find mV using the search string function.  Take the before match output.  Turn into a number.  Divide by 1000. Turn back into a string.  Concatnate a V at the end of it.

Message 2 of 12
(3,585 Views)
Solution
Accepted by Vtem

Example_VI.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 3 of 12
(3,573 Views)

thanks for the help guys. I appreciate it. 

0 Kudos
Message 4 of 12
(3,552 Views)

Sorry, Jim, that's not quite right. You forgot to consider significant figures (your third min is not quite right). It does add a bit to the problem, though, because of machine math. You have to work your magic in strings when there are a large number of sig figs (looks like above 8 or so). See attached.

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
Message 5 of 12
(3,542 Views)

@camerond wrote:

Sorry, Jim, that's not quite right. You forgot to consider significant figures (your third min is not quite right). [...]


 

Good catch, but, really?  mV_Conversion_w_sig_figs[1]_FP.png  😉

Here's how I modified mine to handle precision:

 

Example_VI.png

 

No loops! 😄

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 6 of 12
(3,513 Views)

@jcarmody wrote:

@camerond wrote:

Sorry, Jim, that's not quite right. You forgot to consider significant figures (your third min is not quite right). [...]


 

Good catch, but, really?  mV_Conversion_w_sig_figs[1]_FP.png  😉


That "Finally!" comes out to -5569492V to me.  Holy crap.  -5.569492MV!  I think there's a problem there.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 12
(3,504 Views)

What about this one:

check.png

Just to get the idea: scan for SI units...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 12
(3,499 Views)

@crossrulz wrote:

@jcarmody wrote:

@camerond wrote:

Sorry, Jim, that's not quite right. You forgot to consider significant figures (your third min is not quite right). [...]


 

Good catch, but, really?  mV_Conversion_w_sig_figs[1]_FP.png  😉


That "Finally!" comes out to -5569492V to me.  Holy crap.  -5.569492MV!  I think there's a problem there.


Carp! Stupid negative numbers, shouldn't be allowed. Put a piece of duck tape over the place for that negative sign, that'll fix it.

 

I'll get back, it's now a matter of principle.

 

Jim, how does your algorithm do when there are 8 or 9 sig figs, say -56.9492345mV? (Yep, too lazy to draw it in myself.)

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 9 of 12
(3,491 Views)

Jim, how does your algorithm do when there are 8 or 9 sig figs, say -56.9492345mV?


Untitled 9 Front Panel on M3K CAN ESS.jpg

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 10 of 12
(3,487 Views)