Delta · DOP-100 · 25 стр.

Руководство по эксплуатации DOP Delta HMI — Lua-программирование

Оригинальное название: Краткая инструкция по написанию скриптов на языке Luascript для панелей оператора DOP-100

Читать онлайн

Похожие инструкции

Текст документа

Компания "СТОИК" Авторизованный дистрибьютор в России Тел.: (495) 661-2441, 661-2461 email: sales@deltronics.ru www.deltronics.ru 1. Lua program execution function Lua is a programming language similar to Python and JavaScript. Its syntax is easier and more user-friendly than the macros provided by the HMI. You can use simple instructions to complete complicated computing and develop variable functions, as well as programming the functions on your own, which makes the programming more flexible and easier to meet the application requirements.

The Lua program runs repeatedly during the HMI operation, which is similar to the HMI Clock macro and can run with other HMI macros at the same time without affecting the execution efficiency of each. The Lua program editing interface and the IDE (Integrated Development Environment) are similar. In addition to the program editing function, it has a debug function that allows you to run the program on the HMI or simulate online (with a simulator) to check if the Lua program is suitable for the circumstance. The debug function can set the breakpoint, run the code line by line, as well as monitor the variables for quick modification of the program.

1 HMI boots up or exits system screen and enters HMI screen Execute Clock macro Execute Lua Repeat Clock macro execution completed Lua execution completed Repeat Execute screen cycle macro based on the delay time of cycle macro No delay and execution continues (100 ms) HMI power off HMI power off Rep eat Clock macro exe cution completed Lua executio n completed Rep eat

Стр. 1

Please refer to Table 1.1 Lua programming example. Table 1.1 Lua programming example 2 1. Lua programming Edit [Main] program Step 1: double-click the [Main] tab in the DOPSoft project tree to enter the editing interface.

Стр. 2

3 1. Lua programming Edit [Main] program Step 2: add the following string to the [Main] program. This program reads the value from $100 and write this value plus 1 to $200. Next, write the string “Hello World!” to $300. -- read $100 v1 = mem.inter.Read(100) -- add 10 v1 = v1 + 1 -- write to $200 rev = mem.inter.Write(200,v1) s1 = "Hello World!" mem.inter.WriteAscii(300,s1,string.len(s1))

Стр. 3

4 1. Lua programming Edit HMI screen Go to Screen 1 to create two Numeric Entry elements with the read addresses as $100 and $200 _ respectively. Then, create one Character Entry element with the read address as $300 and the string length as 12. Execution results Step 1: download this project to the HMI. The display is as follows after HMI power-on. Step 2: change the value of $100 to 95, and the value of $200 changes to 96 immediately.

Стр. 4