Optimizing HMI Register Usage for Strings
Categories

Optimizing HMI Register Usage for Strings

Conserve HMI register space in your PLC configuration by copying strings to INT registers.

The SMLC’s HMI/Modbus Interface allows you to create STRING registers containing 80 characters using the equivalent of 40 registers. However, ORMEC’s MMI-series touch screens strings are limited to 32 characters (16 registers). This results in wasting the equivalent of 24 registers per HMI string. Since the PLC Configuration HMI/Modbus is limited to a maximum of 2000 registers, in some string intensive applications, this waste of register space can be a problem.

This function allows you to put STRING data to INT registers. You can specify the length of the string from 1 to 80 characters. By using this technique you can use four 40 INT Variable register blocks to hold ten 32 character strings without waste. Using standard STRING registers would waste 240 registers.

To use the function:

1) Download the SET_GET_STRING_REG.EXP file and import it into your CoDeSys project.

2) Use the CoDeSys Library Manager to add the SysLibMem library to your project

3) Create enough 40 INT Variable blocks in the HMI/Modbus Interface section of the PLCConfiguration for all the string variables your program will need. Each INT variable register can hold 2 characters. It is easier if you make all of your strings registers have an even number of characters. For this example we will say your program needs two 20 character string registers and one 32-character register.

4) Place an INT variable at the first register of the block and additional INT variables separated by the number of characters in each string. In our example, you will define the first integer variable at address %QW1. Since 20 characters requires 10 registers, the next variable will be at %QW1 + 10 = %QW11, and the next will be at %QW21. If there were to be a fourth register it would be at %QW21 + 16 = %QW37.

The variables defined will be INTs and will be used to find the address of the start of each string register. Give each a name that is appropriate for the string for which it will be used.

You can create an additional 40 INT Variable Blocks and allow the string registers to span the blocks. For example, four 40 INT Variable blocks allows you to create the equivalent ten 32 character string registers without the waste of 240 registers that would occur using standard string registers.

5) Assign the address of the first INT variable defined in step 4 to the RegAddr input, the number of characters to the Size input and a STRING variable containing the data to be sent to the HMI to the Text input. You can use the ADR() function to get the Address.

6) Repeat step 3 using the other INT and STRING variables

7) In the HMI, the device addresses are the register numbers associated with each INT variable. In our example g_iHMI_MyFirstString is at %QW1 which is HMI Device address 1. g_iHMI_MySecondString is at %QW11 which is HMI Device address 11 and g_iHMI_MyThirdString is at %QW21 which is HMI Device address 21.

The number of words used by each HMI alphanumeric object is one-half the value of the Size input used in the SetStringReg and GetStringReg functions. This is why it is best to use strings with an even number of characters.

Example PLC Configuration:

To copy the data from your program's string variable to the registers, use:
dwJunk := SetStringReg(ADR(g_iHMI_MyFirstString), 10, sText_1);
dwJunk := SetStringReg(ADR(g_iHMI_MySecondString), 10, sText_2);
dwJunk := SetStringReg(ADR(g_iHMI_MyThirdString), 32, sText_3);

To copy the data from the registers to your program's string variables, use
sText_1 := GetStringReg(ADR(g_iHMI_MyFirstString), 10);
sText_2 := GetStringReg(ADR(g_iHMI_MySecondString), 10);
sText_3 := GetStringReg(ADR(g_iHMI_MyThirdString), 32);

The g_iHMI_MyFirstString, etc. variables identify the register to the text should be copied to or from. The sText_1, etc. variables identify the string variables in your program to copy from or to.

RSS
Archive

Archive by Years
Sitemap
eNews Signup
Trademarks
Privacy StatementTerms Of UseCopyright © 2008-2015 ORMEC Systems Corp.