laitimes

The use of Velun Tong touch screen macro condition assignment

author:A sprouted potato

1. Macro concept

A macro is a predefined piece of code that can be called multiple times in a program, and they are often used to simplify repetitive tasks or improve the readability and maintainability of code, and macros can be expanded at compile time to insert their code into the program.

Macros can handle complex operations, string processing, and communication between users and projects.

2. Instructions for the use of the macro editor function

1. Click [Project File] ----- [Macro] in the menu bar

The use of Velun Tong touch screen macro condition assignment

2. Click [Add] to enter the macro editor

The use of Velun Tong touch screen macro condition assignment

3. After entering the macro editor, you can see the editing area interface

The use of Velun Tong touch screen macro condition assignment

4. Toolbar function in the editing area

The toolbar provides: [Restore], [Repeat], [Cut], [Copy], [Paste], [Create/Unbookmark],

Buttons such as [Next Bookmark], [Previous Bookmark], and [Clear All Bookmarks] are convenient for quick selection and use.

The use of Velun Tong touch screen macro condition assignment

5. Edit area trigger function

1) Refers to the macro creation function number

2) Start the macro condition, which can be triggered by the address to execute or not to execute the macro when it is ON or OFF

3) When the user checks [Execute once when HMI starts], the macro will be automatically executed once when HMI starts.

4) When the user checks [Periodic Execution], this macro will be triggered periodically, and the time interval of periodic macro execution will be set, the unit is seconds, and the range can be set 0~86400 seconds.

The use of Velun Tong touch screen macro condition assignment

3. The structure of macros

Macros are made up of statements containing constants, variables, and various operator notations, which are placed in a specific sequential position in order to achieve a desired execution result after execution. The structure of a macro is generally in the following format:

The use of Velun Tong touch screen macro condition assignment

A macro must contain a main function and a ending function to start and end the macro execution.

The format looks like this:

macro_command main()

end macro_command

Variable declarations must be placed in front of macro statements, otherwise if the statement is placed in front of variable declarations, the macro will not be compiled.

4. Instructions for using the getdata setdata function

1. Instructions for using the getdata function

Function: Read the data of the device, and transmit the address value of the HMI or other PLC device to the variable defined in the macro.

2. Instructions for using the function setdata

Purpose: Write data to the device, and write the variable values defined in the macro to the HMI or PLC address.

5. Compilation of conditional assignment macros

Requirements: Assign LW10 to 100 when LB0 is equal to 1 and LW10 to 200 when LB0 is equal to 0.

Task implementation: You need to use variable declarations, IF conditional judgment statements, getdata setdata, and annotation functions

The meaning of each paragraph of the following figure function has been marked with a note at the end, and you can refer to the note if you don't understand.

The use of Velun Tong touch screen macro condition assignment

Click Functions in the macro editor to open the function dialog box, as shown in the following figure:

The use of Velun Tong touch screen macro condition assignment

The category selects PLC, which here refers to HMI or PLC or device address collectively referred to as PLC

Function Name: Select the getdata setdata function, for details, please refer to [Instructions for GetData SetData] in this document.

The read address is sent to the address of variable 1, and vice versa variable 1 is sent to the write address

The use of Velun Tong touch screen macro condition assignment

The following matters should be noted during the preparation process:

(1) Before writing, you need to manually add or the software automatically generates the main function macro_command main() and the ending function end macro_command, otherwise the compilation will fail.

(2) In the macro command, it is judged whether the condition is true, and the sign is ==, and the double equal sign refers to whether it is equal to the following value.

(3) The address variable defined in the macro is internal to the macro instruction, and cannot be transmitted by other devices such as HMI and PLC if the getdata setdata function is not called.

(4) Pay attention to the relationship, range, and data type between the read and write addresses through the function, otherwise the data transmission will fail.

6. Component association

1. Associate macro execution permissions through function keys

Type Select Execute Macro

The macro selects the number of the macro entry you want to execute

The use of Velun Tong touch screen macro condition assignment

2. Trigger the judgment condition through the bit status switch switch

Associate the address of the macro trigger condition

condition-triggered selection toggle

The use of Velun Tong touch screen macro condition assignment

3. The numerical value of the execution and non-execution of macro assignment is displayed through the numerical display component

The use of Velun Tong touch screen macro condition assignment

Fourth, the operation demonstration effect

When the trigger condition LB0 is equal to 0, click the trigger macro function key to start running the macro program statement, and the current value is displayed and equal to 200.

When the trigger condition LB0 is equal to 1, click the trigger macro function key to start running the macro program statement, and the current value is displayed and equal to 100.

The use of Velun Tong touch screen macro condition assignment

Read on