Add Real to string to send message

thorgalrose

Member
Join Date
Jun 2009
Location
West-Vlaanderen
Posts
5
Dear all,

I have following problem.
I'm sending an SMS when i got an alarm.

For now I'm sending "Temp to high" but now i want to change this to "Temp to high 6.2 °"

I know that i can move the "temp to high" text with block move. But i can't seem to get the real value (6.2) into the string format.

I have tried to do this with the function REAL_TO_STRF from oscat but it scales automatically to 6.

Can anybody help me with this problem.

Best regards

PS: I'm worktin with Siemens CU313 (normally in LADDER and SCL)
 
Last edited:
I think you should be able to do it by converting your real to DINT. (Ceilling). Then use FC5 (standard library converts DINT to String)
Never tried it myself, but i think once converted to DINT you lose the numbers behind the point.
 
There is another standard function, but i can't get it to wrok FC30
Real To string.
Maybe someone else knows more about it
 
I don't use the Siemens 300 range but have done similar with a lot of other software. You usually have to give the conversion 'Real to String' function a format for the conversion giving the number of decimal places to use. Check your function for a FMT or Format parameter.

Bryan
 
he function FC30 converts a variable in REAL data type format to a string. The string is shown with 14 digits:
±v.nnnnnnnE±xx
± Sign
v 1 digit before the decimal point
n 7 digits after the decimal point
x 2 exponential digits
 
Can you format you string data so that you have, "text in here" "first number here" "." "second number here" if you can, you can use some mathematics to extract the data out of it. Atleast in STL there is instruction to truncate the real always down. So you could do:

6.2*10=62
then 6*10=60 //this is truncated real times ten
62-60=2 //now you can do minus and you have that decimal part.

then put it on proper place on your string.
 
Can you format you string data so that you have, "text in here" "first number here" "." "second number here" if you can, you can use some mathematics to extract the data out of it. Atleast in STL there is instruction to truncate the real always down. So you could do:

6.2*10=62
then 6*10=60 //this is truncated real times ten
62-60=2 //now you can do minus and you have that decimal part.

then put it on proper place on your string.

This is probably your best bet. Multiply the number you want to convert by 10 for one decimal place, 100 for two, etc. Then concatenate the Integer and Decimal separately.
 
Hello everybody,

Ok, now I split my real into the part before the decimal point and the part after the decimal point.
No i want to get this in a string like following: "temp to high 5.4°

With function FC5 i can put both of them in different strings. But how do i get them in one string together.

Code:
  waarde_voor := FC5(I := waarde_VoorDeKomma);
   waarde_na := fc5(I := waarde_NaDeKomma);
Best regards

With waarde_Voor and waarde_na declared as string[2]
 
Last edited:

Similar Topics

I can't say I recall ever encountering this, but when adding a decimal number to a REAL, I'm getting a strange precision. For example, starting...
Replies
4
Views
1,469
I would like some comments on adding an Express Card/serial adapter used with a PCMCIA to Express Card adapter. I have an older Dell Latitude...
Replies
6
Views
2,498
Hi, I have questions. I have Analog Input that need to put into Ignition Designer. But I don't know how to put?
Replies
1
Views
119
I have just installed Studio 5000 V30.11 on my Windows 11 Pro machine. First I had an "Invalid Pointer" error that required me to update Factory...
Replies
2
Views
118
Im trying to create a level indicator for water Tank i have used the ADD function while the pump is on and level increasing everything works...
Replies
33
Views
1,023
Back
Top Bottom