LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Formating a string to a number

Solved!
Go to solution

Hi Jay,

 


@JÞB wrote:

Gerd, what is the search and replace doing in there?  Just use "%,%.6f" format string


I know about those formatting codes, but the OP apparently does not.

For simplicity and easier understanding of the OP I didn't change the OP's code for this specific code improvement…

 

Instead I want to improve the way the data is transferred from Arduino to LabVIEW.

Best regards,
GerdW


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

Hey GerdW,

 

here is my code and the display on the front panel, here you can clearly see that i get the full data from the Arduino (or am i getting something completely wrong here?). The thing is that after the conversion to numbers i loose all of the digits except for the 3 after the comma. So i guess i have something wrong with either the conversion or so, so i will try to just save the string immediately and just convert to display the numbers even though the plot wont be 100% correct then. As you can see here i get all the data in LabVIEW just after the conversion and saving it it only Shows the 3 digits (also on the probes in LabVIEW itself as you can see in my first post). 

code_LV.pngMeasurement_LV.pngMsmatch_0-1644938738561.png

 

Best regards and thanks again,

 

Mismatch

0 Kudos
Message 12 of 19
(1,166 Views)

Hey crossrulz,

 

to 1: i know but i wasnt able to just put some time values into the file for a quick test so my solution was this i will try now to make it work with your point 2.

to 2: thank you the Write Text File VI worked just fine to get all the digits into the saved file 🙂

to 3: i will do that thank you.
to 4: Also everything is good in the csv then since i get a new column for every value.

to 5: i will try to clean my code up with all the unnecessary thing when i know what i need and what not, until now it is just the basic Programm so i can get started with some testing and when that works i would clean up my whole code to make it more user friendly.

 

Best regards,

 

Mismatch

0 Kudos
Message 13 of 19
(1,146 Views)

Two things to check.

 

First: how is the display formatting set in Excel for column B. The default is %.3f because.....well, it's a spreadsheet.  BTW, Excel handles math a bit differently than the IEEE 754 standard for some cases.

 

Next: let's see the configuration inside the Express VI.  One of the reasons they are so hated is that they hide what you told them to do and don't have a default that fits every use case..

 

Essentially, you are getting yourself confused.   What you see in LabVIEW Front Panel Controls / Indicators and in Excel cells are text strings.  Known as a object's Display.Text.Text property.  A Value property is much different and is formatted into a display string by the owning application. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 14 of 19
(1,157 Views)

hey ,

 

First: i tried to increase the commas and excel just adds 0 after the 3 digits, also LabVIEW already only Shows 3 digits with the probes.

next: here a screenshot of my configuration of the Express VI.

Msmatch_0-1644941706433.png

But since i already plan to do it with the string value and using the "write to text file" VI i don´t think this is necessary anymore.

I am just having struggles now with adding a time value for every string value i get into the file, but i guess this question was here somewhere already so i will look for a solution to this.

 

Best regards,

 

Mismatch

 

0 Kudos
Message 15 of 19
(1,150 Views)

Hi mismatch,

 


@Mísmatch wrote:

here is my code and the display on the front panel, here you can clearly see that i get the full data from the Arduino (or am i getting something completely wrong here?).


Then why did you present completely different data in your attached VI?

How should I know the data you show now?

 


@Mísmatch wrote:

The thing is that after the conversion to numbers i loose all of the digits except for the 3 after the comma. So i guess i have something wrong with either the conversion or so, so i will try to just save the string immediately

It could be so simple, once you get rid of ExpressVIs:

Why do you create a filepath with a ".csv" file suffix, but use the ExpressVI to create a XLSX file???

(Using the WriteTextFile function you can use a .csv file suffix.)

 

Edit: use the file reference coming from your FileOpen function instead of the file path to avoid overwriting the text file again and again!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 16 of 19
(1,149 Views)

Hey,

 

i did not change anything i just saved the VI as an older version, I didn´t know that could change anything so i am sorry for that. (never had this kind of data you have in your screenshot or that is in the VI i posted)

Yes thank you i will work with the string and the VI i got suggested now.

 

EDIT: These values were set as default that´s why they are in there like that, i didn´t realize this since normally i just start the Programm with the Arduinos connected so i get my normal values nearly immediately. Sorry for the confusion.

 

Best regards,

 

Mismatch

0 Kudos
Message 17 of 19
(1,136 Views)

@Mísmatch wrote:

hey ,

 

First: i tried to increase the commas and excel just adds 0 after the 3 digits, also LabVIEW already only Shows 3 digits with the probes.

next: here a screenshot of my configuration of the Express VI.

Msmatch_0-1644941706433.png

 

Mismatch

 


See that Advanced button?

That pulls up a page that configures formats.

 

Probes in LabVIEW (Actually "Smart Probes") have a default format too!  Create new Probe with a %.20f specifier.  Just right-click the orange wire to launch the wizard. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 18 of 19
(1,135 Views)

Here it will just let me configure the Timestamp so i dint look into this at all.

Msmatch_2-1644942925581.png

 

 

0 Kudos
Message 19 of 19
(1,130 Views)