convert string to real

jimcav

Member
Join Date
Dec 2004
Location
new jersey
Posts
229
I have a string '+0022.345' that i am getting from the serial port the number will be positive or negative that i need to work with can someone let me know how to get this in a real format such as 22.345 or -6.876.

thank much
jim cav
 
There is the FC39 STRNG_R block. Unfortunately the string MUST be formatted as
±v.nnnnnnnE±xx
where
± Sign
v 1 digit before the decimal point
n 7 digits after the decimal point
x 2 exponential digits

So I think you may have to write your own parser.
This is not sooo difficult if you have SCL.
Does the formatting change to scientific notation if the values exceed certain limits ?

I think this has been discussed before. Maybe someone has already found a solution. (that is anothe way of saying "use the search function").
 
It just dawned on me that you never said which PLC it is.
First I apologise if it is not an S7 PLC. In that case ignore my first post.
And anyway ... ALWAYS STATE THE PLC TYPE AND ANY OTHER RELEVANT INFORMATION PERTAINING TO THE PROBLEM.
 

Similar Topics

Dear Sir, I try to write a function use SCL to read the string from a DB and convert it to real and transfer to another DB. But the simple...
Replies
34
Views
24,984
Hi I need to convert a DINT with HEX value e.g A0F15663 to a string with the same value 'A0F15663'. Any tips of good instructions to use ...
Replies
11
Views
3,382
First post here, hopefully not breaking any rules. I am working with a Redlion G3 HMI (yes, I know). I have a series of string tags that I am...
Replies
17
Views
4,025
hi, i try to capture barcode data using UDT with SINT ascii array. i have all the data i need but it in array format, how can i convert to 1...
Replies
5
Views
3,051
Found an awesome point of sale for $500. It sends an ascii string when a product is sold. Need to convert this into a number between 0 and 255 or...
Replies
1
Views
2,270
Back
Top Bottom