The PR200 mini PLC from akYtec can display the values of BOOL, INT or REAL variables, as well as constant text on its LCD screen, which is not the case for the STRING variables. The STRING data type is not supported by akYtec ALP programming environment. But what can be done if you want to display a variable text?

Suppose a PR200 mini PLC and a TRM202 process controller are connected via the RS485 interface and via the Modbus protocol. The goal is to display the firmware version of the TRM202 process controller on the display of the PR200 mini PLC.

According to the TRM202’s user guide, the ASCII code of the firmware version of the process controller is stored in binary format in 4 consecutive registers beginning with the address 0x1004 (hex).

Therefore, three steps are required:

  • - read data from the corresponding registers
  • - decode the data
  • - display the data as ASCII symbols on the PR200’s display.

The 4 registers can be read into 2 INT variables, for example.

Modbus variables

These network variables can now be processed by the display manager of akYtec ALP. However, that would not make sense, since they are only 32-bit integers that have nothing to do with ASCII symbols. Therefore these two variables should be divided into single bytes. For this purpose, the ASCII_CHAR macro should be used. This macro and its description are available in the Component Manager (akYtec ALP: Main menu > Device > Component Manager).

The ASCII_CHAR has two INT inputs and one INT output. If an INT variable is applied to the first input and the sequence number of the required byte of this variable to the second input, the macro will output an INT value generated from the 8 bits of the corresponding byte.

Since each network variable, Version_TRM202_r1 and Version_TRM202_r2, contains 4 bytes, the ASCII_CHAR macro must be applied to each byte to get 8 INT values.

ASCII_CHAR macro Modbus

Each of these INT values is a code that corresponds to a symbol from the ASCII character set. It still remains to decode these ASCII codes and display the correct characters on the PR200’s LCD screen. This is where the Dynamic Box display element comes into play:

Display element Dynymic Box, akYtec ALP

Dynamic box is used to display one of the text lines from a list, depending on the value of the referenced Integer program variable. The display element Dynamic box has three parameters: variable, row list and length.

The Variable parameter can be used to reference a program variable. The Row list is a table with lines of text. In this case, the row list is the ASCII character table. Length defines the number of characters that can be displayed.

To display the entire line of the firmware version of the TRM202, 8 Dynamic Box display elements must be used:

Dynamic box, 8 in a row, akYtec ALP

‘The firmware version of the TRM202 on the LCD of the PR200’ ‘The firmware version of the TRM202 on the LCD of the PR200’.