Jump to content

(Numeric) String to Array - Displaying numbers received from serial port to a virtual meter


Recommended Posts

Hello experts,

Firstly, thank you for reading this

Now,I have tried in other forums but couldn't get a final / working solution

What I am trying to do:

I receive temperature and pressure information form a sensor through a micro-controller and through the serial port

The values are simply displayed in numbers, e.g 234 for temperature and 23456 for pressure

These two values will be in later stage divided by 10 and 100 regardless.

I thought of sending the number in a 10 byte string by simply adding a double space between the temp and press values,

e.g data send out the serial port are raw numbers : ' 234 23456'

I thought of doing that as it could be easier to then split the string in half (5 bytes each) and have to separate strings for the two readings

That all works good so far

Where I get troubled is in the conversion bit. I have tried doing the following

String to Array->Index Array->Join Numbers->Type Cast->Cluster but something is wrong which I can't figure out

Are there any other possible ways of doing this a bit easier, especially for a beginner, such as me?

Thank you in advance


Link to comment

I assume the numbers are coming across as ASCII "234"... This would make typecast the wrong primitive to use. You would want Decimal String to Number under the String -> String/Number Conversion pallet.

I would also recommend using Match Pattern->Decimal String to Number->cluster instead.

  • Like 1
Link to comment

Thank you for your reply Tim,

It seems to be working fine by splitting the string into 3 parts but still there is something wrong with the VI which I can't notice

Here I have attached a screen shot to make things clearer

It looks like the output c of Match Pattern function, ie the pressure as it is after the AB(Header), includes the string before AB, ie the temperature

Also, I have noticed that Decimal String To Number function outputs 3 for temperature and 5 for pressure instead of the correct numeric values

Any ideas how to proceed?

Just curious, why 'posted on the dark side'?

Thank you again

Any help would be much appreciated


It looks like it reads the number of bytes instead of the decimal values

Oops, sorry that was me being silly.

I have connected the meters to the wrong output of the Decimal String to Number function

It all works fine, thank you



Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.