PT_SIZE (STRUCT) ¶ TYPE PT_SIZE : STRUCT InOut: Name Type Comment pString POINTER TO BYTE Pointer to the text uiSize UINT Size of the text
Encoding ¶ BASE64 (Function)
BASE64 (FUN) ¶ FUNCTION BASE64 : PT_SIZE encodes 8 bit binary data into ASCII data A text block (string, binary, array of bytes) will be base64 encoded. The maximum of the block is set in the TextBlockSize parameter. This size can be changed but must be divisible by 3. If the text block is only a part of a text and followed by more text, the size must be TextBlockSize.iBlockSize and the isLastBlock variable must be set to FALSE . If a text is not followed by another block, the specific length of it must be used and isLastBlock has to be set to TRUE , as shown in the following example. The reason is three 8-bit letters will become four 6-bit letters. If only two 8-Bit letters are remaining at the end, the encoded text is filled with “=”. This must only be at the end of a text. Example: StringToConvert : PT_SIZE ; EncodedString : PT_SIZE ; byError : BYTE ; sText : STRING := 'This is a test string.' ; StringToConvert.uiSize := LEN ( sText ); (* When another block follows, use the size TextBlockSize.iBlockSize and set isLastBlock to FALSE. *) StringToConvert.pString := ADR ( sText ); EncodedString := Base64 ( TextToEncode := StringToConvert , isLastBlock := TRUE , pbyError := ADR ( byError )); InOut: Scope Name Type Comment Return BASE64 PT_SIZE A structure with a pointer to the text and its size (comprising the terminating character) Input TextToEncode PT_SIZE The text block which should be encoded isLastBlock BOOL TRUE : The current text block is the end of a text FALSE : The current text block is just a small text pbyError POINTER TO BYTE 0: No error 1: Text block is too long 2: Not divisible through 3 4: Empty string
Function Manipulators ¶ CHARCURVE (FunctionBlock) RAMP_INT (FunctionBlock) RAMP_REAL (FunctionBlock)
CHARCURVE (FB) ¶ FUNCTION_BLOCK CHARCURVE Maps an input signal onto a characteristic curve The characteristic curve is given by an array of POINTs, which include a set of X-values with their corresponding Y-values. Example in ST: VAR CHARACTERISTIC_LINE : CHARCURVE ; KL : ARRAY [0..10] OF POINT := [(X:=0,Y:=0),(X:=250,Y:=50), (X:=500,Y:=150),(X:=750,Y:=400), 7((X:=1000,Y:=1000))] ; COUNTER : INT ; END_VAR COUNTER := COUNTER +10 ; supply CHARCURVE with for example a constantly increasing value CHARACTERISTIC_LINE ( IN := COUNTER , N := 5 , P := KL ); Illustration of the resulting curve InOut: Scope Name Type Comment Input IN INT Input signal N BYTE Number of points defining the characteristic curve : 2 <= N <= 11 Inout P ARRAY [0..10] OF POINT Array of points to describe the characteristic curve Output OUT INT Output variable, contains the manipulated value ERR BYTE 0 : No error 1 : Error in P : wrong sequence (completely tested, only if IN is equal to largest X-value of P ) 2 : IN outside of limits of P 4 : N invalid, number of points not within the allowed range 2..11
RAMP_INT (FB) ¶ FUNCTION_BLOCK RAMP_INT Limits the slope of a value to a certain value The limitation of the slope is given by the maximum ascend ASCEND and the maximum descend DESCEND and a time base TIMEBASE defining the time for which ASCEND or DESCEND hold. Note It is not necessary to readjust the controller parameters (KP, TN, TV) if the cycle time changes. Example InOut: Scope Name Type Comment Input IN INT Input value ASCEND INT Limitation of acceleration: Maximum ascent per time base Example: ASCEND := 25 and TIMEBASE := T#1s => Maximum ascent of 25 increments per second DESCEND INT Limitation of deceleration: Maximum descent per time base ( DESCEND > 0) Example: DESCEND := 20 and TIMEBASE := T#500ms => Maximum ascent of 20 increments in 500 milliseconds TIMEBASE TIME Reference for ASCEND/DESCEND : t#0s : ASCEND/DESCEND defined per call else : ASCEND/DESCEND defined per specified time If TIMEBASE = t#0s , then the time base is equal to the task cycle time. In this case the limitation refers to a task cycle. Usually this corresponds exactly to one call of the function block RAMP_INT . Note If the time base TIMEBASE is smaller than the task cycle time, then this will lead to a violation of the sampling theorem and might result in a loss of information in the output signal. RESET BOOL Reset of the function block TRUE : Stops the internal calculation and reinitializes the function block. The last calculated output value in OUT is maintained in order to start the internal calculation with it at the next restart of the function block. FALSE : Outputs the smoothed input signal at output OUT . Output OUT INT Function value with limited ramp The value gets stored internally and will be used for the calculation of the ascent and the descent of the input signal.
RAMP_REAL (FB) ¶ FUNCTION_BLOCK RAMP_REAL Limits the slope of a value to a certain value The function block is similar to RAMP_INT with the difference that the inputs IN , ASCEND , DESCEND and the output OUT are of the type REAL . RAMP_REAL takes more computing time but calculates more precisely than RAMP_INT . Note A reset of the function block ( RESET = TRUE ) stops the calculation and the last output value OUT is maintained. So if afterwards the ramp gets restarted by RESET = FALSE , it will start with this last output value! InOut: Scope Name Type Comment Input IN REAL Input value ASCEND REAL Maximum positive slope DESCEND REAL Maximum negative slope (non-negative!) TIMEBASE TIME Reference for ASCEND/DESCEND : t#0s : ASCEND/DESCEND defined per call Else : ASCEND/DESCEND defined per specified time RESET BOOL Resets the function block Output OUT REAL Fnction value with limited slope
Mathematical Functions ¶ DERIVATIVE (FunctionBlock) INTEGRAL (FunctionBlock) LIN_TRAFO (FunctionBlock) ROTATION_DIFFERENCE (FunctionBlock) STATISTICS_INT (FunctionBlock) STATISTICS_REAL (FunctionBlock) VARIANCE (FunctionBlock)
DERIVATIVE (FB) ¶ FUNCTION_BLOCK DERIVATIVE Approximates the derivative of a given value in its time course Four consecutive values are recorded and used in the calculation so that the resulting derivative is as accurate as possible. Example: Function block in FBD InOut: Scope Name Type Comment Input IN REAL Input value TM DWORD Time since last call in msec RESET BOOL TRUE : OUT is set to zero and saved values are set to the current input IN Output OUT REAL Derivative
INTEGRAL (FB) ¶ FUNCTION_BLOCK INTEGRAL determines approximately the integral over time. Example: Function block in FBD InOut: Scope Name Type Initial Comment Input IN REAL Input value TM DWORD Time since last call in msec RESET BOOL TRUE : OUT is set to zero and OVERFLOW to FALSE Output OUT REAL Value of the integral. This is done by summing all part integrals IN * TM OVERFLOW BOOL FALSE TRUE : The value of OUT is out of range of REAL variables. he function is blocked till it is new initialised by input RESET .