15.4.22 Interrupt commands
15.4.22.1 IRegister — Register interrupt
Explanation |
Register an interrupt, determining whether it can be triggered once, whether it can be debugged (triggered during single-step or single-step pause), as well as the interrupt number, trigger signal, and trigger type. . One trigger source can only be bound to one interrupt function. |
Definition |
IRegister([\SINGLE,][\DEBUG,][\LOGIC,]int_num, signal, trigger_type, trap_function); [] indicates optional parameters int_num, data type: interrupt number variable, used as an interrupt identifier signal, register signal/DI signal trigger_type, trigger method DI signal trigger methods:
Note: High/low level triggering will continuously trigger interrupts Register (int+bool+bit+byte) trigger methods: 0 represents low level, non-0 represents high level trap_function: interrupt function name \SINGLE, single trigger (optional) \DEBUG, debuggable (optional), adding this parameter allows interrupts to be triggered during single-step or single-step pause states \LOGIC, logic interrupt (optional), adding this parameter prevents the interrupt from interrupting robot motion after it is triggered |
Example |
Register an interrupt where when DI signal DI1_0 has a posedge change, execute trapfun1 function and stop responding to this interrupt after one trigger; this interrupt can be triggered during single-step and single-step pause states; intnum0 serves as an identifier for this interrupt, used for IEnable, IDisable, and GetTrapData commands |
15.4.22.2 IVRegister — Register variable interrupt
Explanation |
Register a monitored variable and bind an interrupt. When the variable changes or changes to a specified value, the interrupt is triggered. |
Definition |
IVRegister([\SINGLE,][\DEBUG,][\LOGIC,]int_num, varname, TrigMode, [specific_value], trap_function);** int_num, data type: interrupt number variable, used as an interrupt identifier varname, variable name TrigMode, trigger mode
specific_value, comparison value, must be the same type as varname; optional, used with \SPECIFICVALUE trap_function: interrupt function name \SINGLE, single trigger (optional) \DEBUG, debuggable (optional), adding this parameter allows the interrupt to be triggered in single-step mode when the program is not running \LOGIC, logic interrupt (optional), adding this parameter prevents the interrupt from interrupting robot motion after it is triggered Variables can only be global variables (from the variable list) and must be of type bool, byte, double, or int. If the variable is modified very quickly, some trigger occurrences may be missed. If the interrupt program reads the variable value while the interrupt is being executed, the read value cannot be guaranteed to be the value that originally triggered the interrupt. |
Example |
Register a variable interrupt. When global_var changes, execute trapfun2. This interrupt triggers only once and can be triggered in single-step mode when the program is not running. |
15.4.22.3 ITRegister — Register timed interrupt
Explanation |
Given a cycle time $t$, allow the program to trigger an interrupt periodically. |
Definition |
ITRegister([\SINGLE,][\DEBUG,][\LOGIC,]int_num, time_gap, trap_function);** int_num, data type: interrupt number variable, used as an interrupt identifier time_gap, time interval, int type trap_function: interrupt function name \SINGLE, single trigger (optional) \DEBUG, debuggable (optional), adding this parameter allows the interrupt to be triggered in single-step mode when the program is not running \LOGIC, logic interrupt (optional), adding this parameter prevents the interrupt from interrupting robot motion after it is triggered The interrupt cannot be triggered strictly according to the set timing and may be delayed due to timer error and call overhead. |
Example |
Register an interrupt that executes trapfun1 every three seconds. |
15.4.22.4 IGRegister — Register GI signal interrupt
Explanation |
Register a GI signal-triggered interrupt. When the GI signal changes, the interrupt is triggered. |
Definition |
IGRegister([\SINGLE,][\DEBUG,][\LOGIC,]int_num, signal, trap_function);** int_num, data type: interrupt number variable, used as an interrupt identifier signal, GI signal trap_function: interrupt function name \SINGLE, single trigger (optional) \DEBUG, debuggable (optional), adding this parameter allows the interrupt to be triggered in single-step or single-step pause states \LOGIC, logic interrupt (optional), adding this parameter prevents the interrupt from interrupting robot motion after it is triggered |
Example |
Register an interrupt that executes trapfun1 when GI signal GI1 changes. |
15.4.22.5 IEnable — Activate interrupt
Explanation |
Activate an interrupt disabled by IDisable, lookahead triggered (activated by default after IRegister) |
Definition |
IEnable (int_num); int_num, data type: interrupt number variable, used as an interrupt identifier |
Example |
Activate interrupt corresponding to intnum0, can be triggered by bound signal source after activation |
15.4.22.6 IDisable — Disable interrupt
Explanation |
Disable an interrupt, lookahead triggered. Note that, for an interrupt configured with single-trigger mode, if it receives an interrupt signal after being disabled by IDisable, it will still be treated as completion of the single trigger |
Definition |
IDisable(int_num); int_num, data type: interrupt number variable, used as an interrupt identifier |
Example |
Disable the interrupt corresponding to intnum0; after being disabled, it cannot be triggered by the bound signal source |
15.4.22.7 GetTrapData — Get interrupt information
Explanation |
Get information about an interrupt, lookahead triggered. |
Definition |
GetTrapData (int_num, str); int_num, data type: interrupt number variable, used as an interrupt identifier Str, data type: string receiving interrupt information |
Example |
Get interrupt information corresponding to intnum0, store information in string0 |