Damica

Real Numbers or Floating Point

9 posts in this topic

Have looked on this forum and found NO hint of a solution. I hope someone can provide me with a starting point. I have a Allen Bradley Micro830 & Connected Component Workbench that I use to SMS text message out the value of an Analog sensor. The value is a real number data type so it holds a number like this 123.32659+e. All I want to do is to "Truncate" so that the value ends up being like this 123.32 this would then be what sms receiver would see as the value. Thanks

Share this post


Link to post
Share on other sites
Multiply by 100 and convert to a DINT. That will give you 12332. Then I guess you'll convert that to an ASCII string and insert the decimal point. I haven't done SMS, so I'm not sure how that is set up.

Share this post


Link to post
Share on other sites
That's probably workable, can you guide me as to how to insert a decimal into a string into the 3rd location from the right? Thanks for your help.

Share this post


Link to post
Share on other sites
That depends on how the micro830 handles strings and what instructions are available. I haven't done string manipulation on one of them yet. In RSLogix 5000, for example, strings are stored as a series of integers. There is a length subelement, then a array that stores the ascii code for each character. I would use the MID instruction to pull out the two halves of the data, create a third strong with the decimal in it, then use the CONCAT instruction to put them together again.
1 person likes this

Share this post


Link to post
Share on other sites
I want to thank you for your suggestions, I have not had the time to actually program up a unit, but I have created a simple ladder with what I feel will work per your suggestions. Probably won't get a chance to program unit until this weekend but will keep you posted, once again you have been of great help. David

Share this post


Link to post
Share on other sites
Well I did get this working, lot of trial and error. But it is working just as I need it to. Real numbers Example: 123.456 get sent out through SMS text as String (123.45) Makes NO difference where decimal is or how many digits in number, end result will also have 2 place decimal. Thanks JRoss it was your suggestion that got me thinking in the right direction.

Share this post


Link to post
Share on other sites
This ended up being a BIG DEAL. So if anybody needs this, this is what works for me.

Share this post


Link to post
Share on other sites
Thanks for the update! Glad you go it working.

Share this post


Link to post
Share on other sites
I too thank you for the update! Using IsaGraph on some well pads and a gprs modem, so this has opened some possibilities !!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now