<< 点击显示目录 >> 主页 mappView帮助助手 > mapp View帮助信息 > Widgets > Motion > MotionPad > Concept > Debugging a CNC program |
This section explains how to use widget "MotionPad" to debug a CNC program.
The widget provides an interface to connect to mapp Motion in order to monitor execution of CNC programs.
Functions of widget "MotionPad" can be controlled via actions and events using button widgets.
It can look like this, for example:
In order to use the debugging function, the axes and the axis group must be added and configured.
For information about how to add and configure the axis group, see the mapp Motion "Getting started" tutorial here: CNC. |
So that CNC programs can be loaded and also stored later, the MpFileManager configuration must be added.
For information about how to add and configure the MpFileManager configuration, see "Getting started" tutorial Text editor for CNC programs. |
On widget "MotionPad", the correct axis group name must be selected for property "mpLink" in order to establish a connection to the correct group.
The widgets can be added to the piece of content as shown in the image below.
Widgets to be used:
•1 "MotionPad" widget: This widget is used to edit and monitor the programs.
•8 "Button" widgets: These widgets are used to trigger the various "MotionPad" widget actions.
•3 "TextOutput" widgets: These widgets are used to display information.
The following explains all debug actions and events used for setup in more detail.
Action "Run" can be used to start a loaded CNC program.
The action can be enabled by clicking on a button. In this example, button "Run" was added.
To start the program, the axis group must be switched on and ready. This information can be read with getter GetPlcOpenState . This getter can be called within an action operand and only triggers action "Run" if the state of the axis group is "standby mode".
The following binding can be used for button "Run":
<EventBinding>
<Source xsi:type="widgets.brease.Button.Event" contentRefId="content_1" widgetRefId="Run" event="Click" />
<Operand name="plcOpenState" datatype="ANY_INT">
<ReadTarget xsi:type="widgets.brease.MotionPad.ReadAction" contentRefId="content_1" widgetRefId="MotionPad1" >
<Method xsi:type="widgets.brease.MotionPad.Action.GetPlcOpenState" />
</ReadTarget>
</Operand>
<EventHandler condition="(NOT fileModified) AND (plcOpenState = 220)">
<Action>
<Target xsi:type="widgets.brease.MotionPad.Action" contentRefId="content_1" widgetRefId="MotionPad1" >
<Method xsi:type="widgets.brease.MotionPad.Action.Run" />
</Target>
</Action>
</EventHandler>
</EventBinding>
In addition, getter "GetModifiedState" can be used to prevent unsaved programs from starting. This operand and event handler can also be added in the above example.
<EventBinding>
<Source xsi:type="widgets.brease.Button.Event" contentRefId="content_1" widgetRefId="Run" event="Click" />
<Operand name="plcOpenState" datatype="ANY_INT">
<ReadTarget xsi:type="widgets.brease.MotionPad.ReadAction" contentRefId="content_1" widgetRefId="MotionPad1" >
<Method xsi:type="widgets.brease.MotionPad.Action.GetPlcOpenState" />
</ReadTarget>
</Operand>
<Operand name="fileModified" datatype="BOOL">
<ReadTarget xsi:type="widgets.brease.MotionPad.ReadAction" contentRefId="content_1" widgetRefId="MotionPad1" >
<Method xsi:type="widgets.brease.MotionPad.Action.GetModifiedState" />
</ReadTarget>
</Operand>
<EventHandler condition="(NOT fileModified) AND (plcOpenState = 220)">
<Action>
<Target xsi:type="widgets.brease.MotionPad.Action" contentRefId="content_1" widgetRefId="MotionPad1" >
<Method xsi:type="widgets.brease.MotionPad.Action.Run" />
</Target>
</Action>
</EventHandler>
<EventHandler condition="fileModified">
<Action>
<Target xsi:type="clientSystem.Action">
<Method xsi:type="clientSystem.Action.ShowMessageBox" type="OK" message="The file is modified, save if before run it." header="File not saved!" icon="Information" />
</Target>
</Action>
</EventHandler>
<EventHandler condition="plcOpenState <> 220">
<Action>
<Target xsi:type="clientSystem.Action">
<Method xsi:type="clientSystem.Action.ShowMessageBox" type="OK" message="The axes is not in standby: check that the axes group is powered, not in error or running any other program already" header="Axes Group not ready!" icon="Information" />
</Target>
</Action>
</EventHandler>
</EventBinding>
If button "Run" is pressed in the browser, the corresponding event handlers are executed.
When the program starts, widget "MotionPad" automatically switches to monitoring mode. In this mode, the widget is disabled so the program cannot be edited and the line currently being executed is highlighted.
Action "Stop" can be used to stop execution of the program.
The following binding can be used for the added "Stop" button:
<EventBinding id="StopProgram" >
<Source xsi:type="widgets.brease.Button.Event" contentRefId="content_1" widgetRefId="Stop" event="Click" />
<EventHandler>
<Action>
<Target xsi:type="widgets.brease.MotionPad.Action" contentRefId="content_1" widgetRefId="MotionPad1" >
<Method xsi:type="widgets.brease.MotionPad.Action.Stop" />
</Target>
</Action>
</EventHandler>
</EventBinding>
If the user wants to change something while the program is running, the program must first be stopped by clicking button "Stop" in the browser.
If the program is stopped, monitoring mode is disabled and the widget switches to edit mode. In this mode, MotionPad is no longer disabled and the file can be edited.
If the program has been stopped, it can be restarted. Action "Restart" can be used for this.
Button "Restart" has been added for this purpose. It is important here that the axis group is switched on and ready. For this reason, the getters are used as operands like in the "Run" example.
The following binding can be used for the added button "Restart":
<EventBinding id="RestartProgram" >
<Source xsi:type="widgets.brease.Button.Event" contentRefId="content_1" widgetRefId="Restart" event="Click" />
<Operand name="fileModified" datatype="BOOL">
<ReadTarget xsi:type="widgets.brease.MotionPad.ReadAction" contentRefId="content_1" widgetRefId="MotionPad1" >
<Method xsi:type="widgets.brease.MotionPad.Action.GetModifiedState" />
</ReadTarget>
</Operand>
<Operand name="plcOpenState" datatype="ANY_INT">
<ReadTarget xsi:type="widgets.brease.MotionPad.ReadAction" contentRefId="content_1" widgetRefId="MotionPad1" >
<Method xsi:type="widgets.brease.MotionPad.Action.GetPlcOpenState" />
</ReadTarget>
</Operand>
<EventHandler condition="(NOT fileModified) AND (plcOpenState = 220)">
<Action>
<Target xsi:type="widgets.brease.MotionPad.Action" contentRefId="content_1" widgetRefId="MotionPad1" >
<Method xsi:type="widgets.brease.MotionPad.Action.Restart" />
</Target>
</Action>
</EventHandler>
<EventHandler condition="fileModified">
<Action>
<Target xsi:type="clientSystem.Action">
<Method xsi:type="clientSystem.Action.ShowMessageBox" type="OK" message="The file is modified, save if before run it." header="File not saved!" icon="Information" />
</Target>
</Action>
</EventHandler>
<EventHandler condition="plcOpenState <> 220">
<Action>
<Target xsi:type="clientSystem.Action">
<Method xsi:type="clientSystem.Action.ShowMessageBox" type="OK" message="The axes is not in standby: check that the axes group is powered, not in error or running any other program already" header="Axes Group not ready!" icon="Information" />
</Target>
</Action>
</EventHandler>
</EventBinding>
Execution of the program is continued in the line where it was last stopped. All previous lines are simulated. This simulation phase can require different lengths of time depending on the file size. With event ProgramPhasedChanged and getter GetProgramPhase, the user can find out whether the program is currently in the simulation phase.
If you click on button "Restart" in the browser, the program first runs as a simulation up to the line where it was stopped. When the simulation phase is completed, the program is in phase "mcPRGPH_WAIT_FOR_AXES_REPOS". This means that the axes must now be positioned correctly. To position the axes correctly, action "Resume" must be executed. The program is then in phase "mcPRGPH_WAIT_FOR_REAL_RUN", i.e. it is waiting until a command is issued before continuing the program. Action "Resume" must also be triggered for this. Then the program will continue running.
Adding/Deleting lines has no effect on the line where the program is started.
Action "Pause" can be used to stop the running program after executing the current line.
The following binding can be used for the added button "Pause":
<EventBinding id="PauseProgram" >
<Source xsi:type="widgets.brease.Button.Event" contentRefId="content_1" widgetRefId="Pause" event="Click" />
<EventHandler>
<Action>
<Target xsi:type="widgets.brease.MotionPad.Action" contentRefId="content_1" widgetRefId="MotionPad1" >
<Method xsi:type="widgets.brease.MotionPad.Action.Pause" />
</Target>
</Action>
</EventHandler>
</EventBinding>
Action "Resume" can be used to continue execution of the paused or stopped program.
It is important to note that after a restart of the program, action "Resume" must be executed 2 times to resume the program correctly. For more information, see Restart (restart program).
The following binding can be used for the added button "Resume":
<EventBinding id="ResumeProgram" >
<Source xsi:type="widgets.brease.Button.Event" contentRefId="content_1" widgetRefId="Resume" event="Click" />
<EventHandler>
<Action>
<Target xsi:type="widgets.brease.MotionPad.Action" contentRefId="content_1" widgetRefId="MotionPad1" >
<Method xsi:type="widgets.brease.MotionPad.Action.Resume" />
</Target>
</Action>
</EventHandler>
</EventBinding>
Action "StepOver" can be used to execute the paused program line by line.
When the program stopped using action Pause, this command can be started to execute the next line and pause again immediately afterwards.
The following binding can be used for the newly added button "StepOver":
<EventBinding id="StepOverProgram" >
<Source xsi:type="widgets.brease.Button.Event" contentRefId="content_1" widgetRefId="StepOver" event="Click" />
<EventHandler>
<Action>
<Target xsi:type="widgets.brease.MotionPad.Action" contentRefId="content_1" widgetRefId="MotionPad1" >
<Method xsi:type="widgets.brease.MotionPad.Action.StepOver" />
</Target>
</Action>
</EventHandler>
</EventBinding>
If a problem occurs while loading the file, event OnError is triggered. The event contains the error code in the argument.
Using events PlcOpenStateChanged and ProgramPhaseChanged, you can check the states and find out more about the axis group and the program.
<!-- Error code info -->
<EventBindingid="ErrorCode">
<Source xsi:type="widgets.brease.MotionPad.Event" contentRefId="DevTestContent" widgetRefId="MotionPad_DebugMode" event="OnError"/>
<EventHandler>
<Action>
<Target xsi:type="widgets.brease.NumericOutput.Action" contentRefId="DevTestContent" widgetRefId="ErrorCode">
<Method xsi:type="widgets.brease.NumericOutput.Action.SetValue"value="=result"/>
</Target>
</Action>
</EventHandler>
</EventBinding>
<!-- Program phase info -->
<EventBindingid="ProgramPhase">
<Source xsi:type="widgets.brease.MotionPad.Event" contentRefId="content_1" widgetRefId="MotionPad1" event="ProgramPhaseChanged"/>
<EventHandler>
<Action>
<Target xsi:type="widgets.brease.NumericOutput.Action" contentRefId="content_1" widgetRefId="ProgramPhase">
<Method xsi:type="widgets.brease.NumericOutput.Action.SetValue"value="=value"/>
</Target>
</Action>
</EventHandler>
</EventBinding>
<!-- PlcOpenState info -->
<EventBindingid="PlcOpenState">
<Source xsi:type="widgets.brease.MotionPad.Event" contentRefId="content_1" widgetRefId="MotionPad1" event="PlcOpenStateChanged"/>
<EventHandler>
<Action>
<Target xsi:type="widgets.brease.NumericOutput.Action" contentRefId="content_1" widgetRefId="PlcOpenState">
<Method xsi:type="widgets.brease.NumericOutput.Action.SetValue"value="=value"/>
</Target>
</Action>
</EventHandler>
</EventBinding>
Additional information is also available in the Logger. This information is entered by mapp Motion.
Another way to get information about the axes is to use mapp Cockpit.