Conversion From Real to ASCII and Int to ASCII

SIMATIC S7-200/300/400, Step7, PCS7, CFC, SFC, PDM, PLCSIM,
SCL, Graph, SPS-VISU S5/S7, IBHsoftec, LOGO ...
Post Reply
yogi_g2982
Posts: 15
Joined: Fri May 18, 2012 8:54 am

Conversion From Real to ASCII and Int to ASCII

Post by yogi_g2982 » Fri Sep 07, 2018 3:42 am

Hi All,

I need block which we convert Real Value to ASCII and Int to ASCII format. I need to send command to printer.

Please let me know if any block is availbale for this.

Regards,

Yogendra K

Info
Faq & Info
Faq & Info
Posts: 425
Joined: Wed Oct 05, 2005 9:00 am

Re: Conversion From Real to ASCII and Int to ASCII

Post by Info » Fri Sep 07, 2018 6:42 am

(sfaq) https://support.industry.siemens.com/cs ... d-and-real
4 Converting a decimal number into ASCII characters:
You can use the FC5 function, which can be found in the IEC library, to convert decimal digits into ASCII characters. The FC5 function performs the conversion. The block is configured with two transfer parameters:

Parameter "i":
number to be converted in double-word format
Parameter "RetVal":
Data type STRING into which the ASCII characters are written.

The FC5 function is called in the OB1, and the parameters are supplied accordingly. The result of the conversion appears in the DB1 from data block byte 2. You can monitor the result with the aid of a variables table.

S7iec.zip ( 135 KB )

Copy the "S7iec.exe" file into a separate directory and then start the file with a double-click. The STEP 7 project is now unpacked with all the associated subdirectories. You can then use the SIMATIC Manager to open and process the extracted project.
5 IEC standard function for the STRING variable:
Using the IEC standard functions FC5, FC16, FC30, FC37, FC38 and FC39 you can convert variables in the DINT format into a string and vice versa.
  • FC5 DI_STRNG: Conversion of a variable of the DINT type into a variable of the STRING type.
    FC16 I_STRNG: Conversion of a variable of the INT type into a variable of the STRING type.
    FC30 R_STRNG: Conversion of a variable of the REAL type into a variable of the STRING type.
    FC37 STRNG_DI: Conversion of a STRING variable into a variable of the DINT type.
    FC38 STRNG_I: Conversion of a STRING variable into a variable of the INT type.
    FC39 STRNG_R: Conversion of a STRING variable into a variable of the REAL type.
More information is also available in our entry entitled "What standard STEP 7 functions are there for the conversion and comparison of string variables and ASCII characters?" in Entry ID: 10913338.
https://support.industry.siemens.com/cs ... -variables

Post Reply