F252_ACHK

ASCII data check

Checks whether the ASCII codes stored in the area specified by s2_AsciiData can be converted correctly using the conversion method specified in by n_ConversionMethod and the 4 control characters specified by s1_Control.

Parameters

Input

s1_Control (STRING)

Control string

  1.  (1) D: converts to decimal ASCII data

    H: converts to hexadecimal ASCII data

  2.  (2) + Normal direction

    - Reverse direction

  3.  (3) 16: converts in 16-bit (1-word) units

    32: converts in 32-bit (2-word) units

s2_AsciiData (BOOL, INT, UINT, WORD, DINT, UDINT, DWORD, REAL, DATE, TOD, DT, STRING)

Starting area for storing ASCII data

n_ConversionMethod (WORD, INT, UINT)

16-bit equivalent constant or 16-bit area for storing conversion method

Output

d_BinaryData (BOOL, INT, UINT, WORD, DINT, UDINT, DWORD, REAL, DATE, TOD, DT, STRING)

Starting area for storing binary data

Remarks

  • If the results are correct, the system variable sys_bIsEqual turns on.

  • If the results are incorrect, the system variable sys_bIsEqual turns off.

  • For an detailed description of s1_Control and F251_ATOB, please refer to F251_ATOB.

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if there is an error in the control string specified by s1_Control.

  • if normal direction (+) is specified in s1_Control when the format is decimal.

  • if the number of ASCII characters per converted unit specified by n_ConversionMethod exceeds 4 for 16-bit data or 8 for 32-bit data when hexadecimal format is specifed by s1_Control.

  • if 0 is specified for the no. of 16- or 32-bit (1- or 2-word) units to be converted in n_ConversionMethod.

  • if the number of 16- or 32-bit decimal numbers to be converted specified by n_ConversionMethod exceeds the area for storing ASCII data.

  • if the converted result exceeds the area.

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if there is an error in the control string specified by s1_Control.

  • if normal direction (+) is specified in s1_Control when the format is decimal.

  • if the number of ASCII characters per converted unit specified by n_ConversionMethod exceeds 4 for 16-bit data or 8 for 32-bit data when hexadecimal format is specifed by s1_Control.

  • if 0 is specified for the no. of 16- or 32-bit (1- or 2-word) units to be converted in n_ConversionMethod.

  • if the number of 16- or 32-bit decimal numbers to be converted specified by n_ConversionMethod exceeds the area for storing ASCII data.

  • if the converted result exceeds the area.

Example

POU header

All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.

	VAR
		bExecute: BOOL:=FALSE;
		sString1: STRING[10]:='1234567890';
			(*Important: Initialize the string with the desired current length*)
		bAsciiDataAreCorrect: BOOL:=FALSE;
	END_VAR

POU body

When bExecute is set to TRUE, the instruction checks whether the data connected at s2_AsciiData can be converted when the control string is 'D-16' and the conversion method 16#214.

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 9 ;
        NETWORK_BODY
B(B_VARIN,,'D-16',21,5,23,7,);
B(B_VARIN,,16#214,21,7,23,9,);
B(B_F,F252_ACHK!,Instance,23,3,35,9,,?DEN?Ds1_Control?Ds2_AsciiData?Dn_ConversionMethod?AENO);
B(B_CONTACT,,sys_bIsEQ,36,4,38,6,);
B(B_F,Adr_Of_VarOffs_I!,Instance,10,5,19,9,,?D@'Var'?DOffs?CAdr);
B(B_VARIN,,2,8,7,10,9,);
B(B_VARIN,,sString1,8,6,10,8,);
B(B_COIL,,bAsciiDataAreCorrect,43,4,45,6,S);
B(B_COMMENT,,Result  ø^bAsciiDataAreCorrect: TRUE,35,6,48,8,);
B(B_CONTACT,,bExecute,3,4,5,6,R);
B(B_COMMENT,,When bExcecute ist set to TRUE~ the instruction checks whether the data connectd atø^s2_AsciiData can be converted when the control string is 'D-16' and the conversion method 16#214.,2,1,40,3,);
L(19,7,23,7);
L(35,5,36,5);
L(38,5,43,5);
L(1,0,1,9);
L(1,5,3,5);
L(5,5,23,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

IF DF(bExecute) then
    F252_ACHK(s1_Control := 'D-16', s2_AsciiData := Adr_Of_VarOffs(Var := sString1, Offs := 2), n_ConversionMethod := 16#214);
    IF (sys_bIsEQ) then
        bAsciiDataAreCorrect := TRUE;
    end_if;
END_IF;

Modified on: 2019-01-24Feedback on this pagePanasonic hotline