Changing application state by user program
Changing application state by user program
In this tutorial are described the guidelines and procedures for change state of your PLC using the user program.
Components
Software: MasterTool IEC XE 3.34
PLC: XP325
Tutorial Sections
1. ARCHITECTURE
2. DEVELOPMENT
1. ARCHITECTURE
In this tutorial architecture we use the Nexto Xpress Series PLC powered by a 24VDC source, where the XP325 Ethernet port was connected to the computer`s Ethernet port, using the NX92xx cable.
2. DEVELOPMENT
Finally, the logic to control the application state can be implemented. As shown on the screenshot below, the code is composed by three parts:
- A GVL ApplicationCommands
- A code on StartPrg
- The Function ApplicationControl
// ApplicationCommands GVL VAR_GLOBAL bStop: BOOL := FALSE; bRun: BOOL := FALSE; pApp: POINTER TO APPLICATION := NULL; Result: RTS_IEC_RESULT; END_VAR |
(*The code inserted by the user into this POU is executed once after startup. Before this fist cycle it is not executed again. In case of redundant system, this one is executed in both CPUs during the startup.*) PROGRAM StartPrg VAR Result: RTS_IEC_RESULT; END_VAR --------------------------------------------------------------------------------------------------------------- ApplicationCommands.pApp := CmpApp.AppGetCurrent(ADR(Result)); |
FUNCTION ApplicationControl : DWORD VAR_IN_OUT EventPrm: CmpIecTask.EVTPARAM_CmpIecTask; END_VAR VAR END_VAR --------------------------------------------------------------------------------------------------------------- IF ApplicationCommands.pApp <> NULL THEN IF ApplicationCommands.bStop THEN ApplicationCommands.bStop := FALSE; ApplicationCommands.Result := CmpApp.AppStopApplication(ApplicationCommands.pApp); ELSIF ApplicationCommands.bRun THEN ApplicationCommands.bRun := FALSE; ApplicationCommands.Result := CmpApp.AppStartApplication(ApplicationCommands.pApp); END_IF END_IF |