iQ-F - Conversion between single STRING and array of WORD values

iQ-F - Conversion between single STRING and array of WORD values

This article contains GX Works3 function blocks for iQ-F CPU that that allow division of a single string into an array of WORD values and joining an array of WORD values into a single string.

Function blocks

These function blocks can be used to convert an array of numbers to one string with specified separator or to convert string with specified separator to an array of numbers. An example of application where this could be useful is exchanging multiple numerical values with another device over serial communication.

 

a) Array to string conversion

 This block takes all the WORD values specified by wArray (up to wArrayLength) and converts them to one string (sResult) containing the numbers separated by sSeparator.


Input:

bEnable- signal to start the conversion  [bit]

wArray- array of numbers   [Word [Signed](0..4)]

sSeparator- separator of numbers in final string [String(32)]

wArrayLength- length of wArray    [Word[Signed]] (maximum value is 5 by default)

 

Output:

sResult- result string  [String(68)]

 

b) String to array conversion

This block takes the string specified by sString, searches it for separators based on sSeparator and divides the string into an array of WORD values (wArrayOutput).

 

Input:

bEnable- signal to start the conversion   [bit]

sString- string which will be converted   [String(68)]

sSeparator-  separator of words in sString        [String(32)]

 

Output:

wArrayOutput-  array of numbers   [Word [Signed](0..4)]

 

In both cases the size of WORD arrays is 5, it is possible to change the sizes of the arrays by changing local variables of function blocks.

The same situation with the output string which is by default a String(68) variable. If you need to have a longer string than (68) you can change it.


Conversion example




    • Related Articles

    • GX Works3 - iQ-F - Function for converting LREAL to REAL numbers

      This article contains GX Works3 function for iQ-F CPU that converts LREAL numbers to REAL numbers. This function converts a value from LREAL data type to REAL data type on iQ-F CPU. Input/Output Data Type Description LREAL_IN Word [Signed](0..3) ...
    • FR-E800 CC-Link IE Field Basic Function Blocks (iQ-F/iQ-R)

      This project contains the configuration and commissioning of function blocks for controlling FR-E800 inverters using the CC-Link IE Field Basic network. Inverter parameters. 1.1 Set Pr. 544 to value 18. 1.2 Set Pr. 1429, 1436, 1449-1454 as on the ...
    • iQ-F PID controller function block

      This article describes implementation of a PID instruction inside a function block for iQ-F PLC. Ten artykuł opisuje blok funkcyjny dla sterownika iQ-F implementujący instrukcję PID. "Copyright © Mitsubishi Electric Europe B.V. IMPORTANT ! These ...
    • Mitsubishi library for SISTEMA

      This document inform how to instal SISTEMA library and what products are included in current version of library. PL: Dokument ten opisuje sposób instalacji biblioteki SISTEMA oraz pokazuje listę produktów występujących w aktualnej bibliotece. 1     ...
    • INV - FR-E800 - CC-Link IE TSN communication with iQ-R plc

      This article how to set up CC-Link IE TSN connection between iQ-R PLC and FR-E800 inverter. It also presents ready to use function blocks to realize basic control, read inverter monitors as well as read and write E800 parameters through the network. ...