Stav Posted November 27, 2012 Report Share Posted November 27, 2012 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 Stav Quote Link to comment
Tim_S Posted November 27, 2012 Report Share Posted November 27, 2012 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. 1 Quote Link to comment
crossrulz Posted November 27, 2012 Report Share Posted November 27, 2012 cross-post on the dark side:http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/Parse-one-String-containing-numbers-into-two-Arrays-and-display/m-p/2233252#U2233252 Quote Link to comment
Stav Posted November 28, 2012 Author Report Share Posted November 28, 2012 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 Stav 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 Stav Quote Link to comment
Ton Plomp Posted November 29, 2012 Report Share Posted November 29, 2012 You've connected the wrong output of the String to number function: Ton PS the dark side is a nick name we have for the NI forums. Quote Link to comment
Bobillier Posted November 29, 2012 Report Share Posted November 29, 2012 One another simplest thing you can test is something like that: Eric Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.