LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting float numbers from Arduino Serial Monitor

Hello All

I am a new learner in Labview and I have a question. Thank you all in advance for helping.

I am receiving numbers from Serial Monitor in Arduino to Labview as String. And labview shows these value in Vaweform Charts.

In labview output numbers are in integer format. Thus, vaweform charts draw graphics as integer. However, I need float numbers and desiring show them in output.

How can I obtain float numbers to Labview?

You can find attached vi file.

Thank you again.

0 Kudos
Message 1 of 6
(3,697 Views)

Hi suzui,

 


@suzui wrote:

In labview output numbers are in integer format. Thus, vaweform charts draw graphics as integer.

However, I need float numbers and desiring show them in output.
How can I obtain float numbers to Labview?


Thanks for attaching a VI. And many thanks for attaching a VI with data embedded!

 

Well, as can be seen in that "Response" string indicator you receive just integer numbers from your Arduino.

So to obtain float numbers in LabVIEW you need to send float numbers in your Arduino!

 

You forgot to also attach the Arduino sketch used to send those numbers. Are you sure you are sending float values? (Can you prove that to us?)

 

Btw. it doesn't make sense to keep an ever growing "Response" string and convert that string again and again to numbers!

Convert to numeric data once and collect those in a shift register.

(Or don't even collect data in arrays when you just need to display them in charts with their own history buffer…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(3,673 Views)

Just to clarify, are you after number with decimal points?

 

It looks like you are only sending integers from your Arduino (Assuming the data in the response indicator is the same as what you have been receiving from the Arduino). You need to change your Arduino code to send data with decimal points.

0 Kudos
Message 3 of 6
(3,672 Views)

Dear GerdW and Niatross

First of all, thank you for helping

Please let me put some data to explain more.

I am receiving those number from ADXL335 sensor as you see picture below. When I export the results to excel, my values are integer.

suzui_0-1610036726384.pngsuzui_1-1610036801170.png

 

As fo Arduino, Yes I am getting float data.
Please find atttached Serial Monitor Arduino.

suzui_2-1610036937321.png

 

The codes in Arduino which I convert integer to float.

suzui_4-1610037021465.png


If you need some file or something, please let me know.

Thank you for your great advices and helping me!

0 Kudos
Message 4 of 6
(3,639 Views)

Hi suzui,

 

then the problem is in converting the received string into numeric data!

Is your computer set to "German" number formats using the comma as decimal separator? If yes: use a better format string like "%,;%f"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 6
(3,621 Views)

I wouldn't be surprised if this is a decimal "comma" problem.  But so far what has been presented doesn't indicate that.

 

The problem as it was originally presented in the original VI, which contains the raw data coming in from the Arduino, doesn't show any commas or decimal points.  It is completely integer.  So of course there will be integer data.

 

Meanwhile in the picture in message #3, something must have changed because now you do see decimal points in the raw string data.

So something was fixed.

 

Now if the problem still exists, whether it is in LabVIEW or Excel.  I would hope that anyone living or working in a country that uses a decimal "comma" as the decimal point would already beware of the problems that commas cause.  I just don't know from the latest message whether the conversion error is in LabVIEW converting what are obviously decimal points, or in Excel trying to import a data file that has decimal points.

 

 

0 Kudos
Message 6 of 6
(3,613 Views)