VisualHMI text control: string display input, GBK/UTF-8/UNICODE encoding, and marquee

freeFree Technical Resource

This content is free to read, suitable for basic learning and search traffic.

Text control is used for displaying and keyboard inputting thestring type variable: device status prompts, parameter configuration, and user comments. It supports GBK/UTF-8/UNICODE encoding, with a maximum storage capacity of 2KB.

1. Core Features

  • Input: HMI built-in keyboard input, supporting GBK and UTF-8 encoding
  • PLC communication encoding: GBK (Chinese internal code, compatible with GB2312), UTF-8, UNICODE - must be consistent with the PLC protocol definition
  • Length Limit: Maximum 2KB (2048 bytes); approximately 1024 Chinese characters (2 bytes/character) in GBK, approximately 682 characters (3 bytes/character) in UTF-8 for Chinese, and 2048 characters for English

VisualHMI text control: string display input, GBK/UTF-8/UNICODE encoding, and marquee插图

2. Attribute Introduction

2.1 Function Settings

AttributeDescription
Startup InputAllow Keyboard Input
Keyboard Type/Screen/Position/Initial ValuePop-up Keyboard/External Keyboard; Keyboard Screen; Pop-up Position; Display Initial Value
Prompt InformationAssociated Text Label, Keyboard Screen Control Associated $SysKBTipInfo Display
Read/Write AddressCan be the same or different
Maximum LengthMaximum Number of Bytes for Text Input
EncodingKeyboard input: GBK/UTF-8; Display: GBK/UTF-8/UNICODE
Password displayContent displayed with *
Swap high and low bytesSwap high and low bytes of strings (in accordance with specific PLC storage order)

VisualHMI text control: string display input, GBK/UTF-8/UNICODE encoding, and marquee插图1

2.2 Appearance settings

  • Font/size/alignment: Left/centered/right
  • Do not split words: Do not break words at the end of lines when displaying multiple lines (English/German, etc.)
  • Line spacing/character spacingLine spacing is a multiple of font size; word spacing is in pixels
  • flashing/ticker: Flashing frequency; marquee direction (left/right/up/down movement) + speed (pixels/second)
  • Control Address: Same numerical control - +0 font (high 8 font/low 8 font size), +1 foreground color RGB565, +2 background color RGB565

VisualHMI text control: string display input, GBK/UTF-8/UNICODE encoding, and marquee插图2

3. Application cases

3.1 UTF-8 encoded input

readLW1001, encoding UTF-8, keyboard screen 101_full800*480, prompt information associated tag. Input "Hello", the frame sent by DCBUS isAA 55 00 0E F2 10 01 04 E4 BD A0 E5 A5 BD 00 00 CC CC- note that each character in UTF-8 Chinese is 3 bytes (E4 BD A0=you).

VisualHMI text control: string display input, GBK/UTF-8/UNICODE encoding, and marquee插图3

VisualHMI text control: string display input, GBK/UTF-8/UNICODE encoding, and marquee插图4

3.2 GBK encoding

readingLW1020, Encode GBK. Enter "Hello" and sendAA 55 00 0C F2 10 20 03 C4 E3 BA C3 00 00 CC CC- GBK Chinese 2 bytes per character (C4 E3=you). Compared with UTF-8 frames, the encoding differences can be visually observed.

VisualHMI text control: string display input, GBK/UTF-8/UNICODE encoding, and marquee插图5

VisualHMI text control: string display input, GBK/UTF-8/UNICODE encoding, and marquee插图6

3.3 High Low Byte Swap+Control Address

ReadLW1040, encode GBK, check High Low Byte Swap, Control AddressLW8000. Input "AB" to issue... 42 41 ...(after high and low swapping, B A transmission); The PLC displays 2143 as 31 32 33 34. Control address LW8000=0x0132 to display font 1/50, LW8001 foreground, LW8002 background.

VisualHMI text control: string display input, GBK/UTF-8/UNICODE encoding, and marquee插图7

3.4 Unicode+ticker

ReadLW1060, encode Unicode, ticker left movement speed 10. Enter "Hello, VisualHMI" and the text will scroll from right to left.

VisualHMI text control: string display input, GBK/UTF-8/UNICODE encoding, and marquee插图8

Encoding Triple Concatenation Pit:① The keyboard encoding and PLC side must be consistent, and GBK input in UTF-8 will read out as garbled code; ② Chinese characters occupy 2 bytes but UTF-8 occupies 3 bytes in Unicode encoding, and the number of registers should be calculated correctly; ③ Have you checked the high and low byte swap? Many domestic PLCs store strings with high bytes first, and if not checked, the display will be reversed.

Compiled from the VisualHMI development documentation of Guangzhou Dacai Technology (hmi-doc.gz-dc.com), the configuration control tutorial "Text Control", copyright reserved by Dacai Technology.

Put this resource to use in a real project?

Go to the Tool Center for message parsing, CRC verification and device debugging, or submit your requirements for selection and integration advice.

Engineer Membership

Turn this article into actionable debugging resources

After activation, you can use advanced message parsing, resource pack downloads, code examples, engineering cases and priority technical support, suitable for real project delivery.

Unlimited Advanced Tools
Resource & Code Packs
Complete Engineering Case Library
Priority Technical Support

Leave a Reply

Your email address will not be published. Required fields are marked *.