Navigation:  Equipments (Devices) > PLC200 > Program > Conversion > REAL >

STRING_TO_REAL

Conversão de String para Real

Previous pageReturn to chapter overviewNext page

Block that performs the conversion of a STRING value into a REAL value.

 

Ladder Representation

 

STRING_TO_REAL_block

 

Block Structure

 

Tipo

Name

Data Type

Description

VAR_INPUT

EN

BOOL

Block enabling

STR

STRING

Value in STRING

VAR_OUTPUT

DONE

BOOL

End of operation

OUT

REAL

Value in REAL

 

Operation

 

When this block has a TRUE value in EN, it reads the value of STR as STRING character by character, performing the conversion to REAL and storing in DONE. If the first character is not mathematically valid, the OUT output receives zero. If there are valid characters, these characters will be converted to the end of STRING, or until it finds an invalid character.

 

wpshelp_common_fig_note

NOTE!

The block interprets the dot (.) as a decimal tab, and not the comma (,).

 

When EN has FALSE value, OUT remains unchanged and DONE remains FALSE.

 

The DONE value forwards to the next Ladder block the EN value after the operation is completed.

 

Compatibility

 

Device

Version

PLC300

2.10 or higher

 

Block Flowchart

 

STRING_TO_REAL_flowchart

 

Example in Ladder

 

The following examples show various conversions of STRING into values of REAL type. All conversions enable the DONE output to the end of the operation.

 

STRING_TO_REAL_example01

 

The conversion above was successfully completed. The decimal point is a valid mathematical character.

 

STRING_TO_REAL_example02

 

The conversion above was successfully completed. The dash and decimal point are valid mathematical characters.

 

STRING_TO_REAL_example03

 

The conversion above was successfully completed. The dash and the power indicator of 10 "and" are valid mathematical characters.

 

STRING_TO_REAL_example04

 

The conversion above was not successfully completed. The first character was not identified as mathematically valid, and the output was zeroed.

 

STRING_TO_REAL_example05

 

The conversion above was successfully completed. The "p" character is not mathematically valid and ends the conversion, truncating the result to what had already been converted.

 

Example in ST

 

 The example below displays the instructions for applying the example above in the ST language.

 

 

VAR

   STR : STRING := '105p0';

   OUT : REAL;

END_VAR

 

OUT := FB_STRING_TO_REAL(EN:=DI1, STR:=STR, DONE=>DO1);