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

STRING_TO_DWORD

Conversão de String para Double Word

Previous pageReturn to chapter overviewNext page

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

 

Ladder Representation

 

STRING_TO_DWORD_block

 

Block Structure

 

Variable Type

Name

Data Type

Description

VAR_INPUT

EN

BOOL

Block enabling

STR

STRING

Value in STRING

VAR_OUTPUT

DONE

BOOL

End of operation

OUT

DWORD UDINT DINT

Value in DWORD

 

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 OUT. 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!

If the number represented in the string is higher than the maximum supported by a DWORD, the Result value saturates in this maximum value.

 

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_DWORD_flowchart

 

Example in Ladder

 

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

 

STRING_TO_DWORD_example01

 

The conversion above was successfully completed.

 

STRING_TO_DWORD_example02

 

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

STRING_TO_DWORD_example03

 

The conversion above was successfully completed. The decimal point is not mathematically valid for decimals and ends the conversion, truncating the result to what had already been converted.

 

STRING_TO_DWORD_example04

 

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

 

Example in ST

 

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

 

 

VAR

  STR : STRING := 'A290';

   OUT : DINT;

END_VAR

 

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