AN00182-004 Mint NC Example Application
AN00182-004 Mint NC Example Application
Application note
Mint NC example application
AN00182-004
Introduction
MintNC is a comprehensive Windows based machine control front end specifically designed to interface easily to a Mint controller
and can be used for fast profiling applications such as:
Acting as the command interpreter, MintNC can import HPGL, DXF and G-Code, converting these files directly into motion. A Mint
program is used in conjunction with MintNC to provide general machine control functions.
MintNC is not a fully featured CAD drawing package. Drawings would normally be prepared using third party software packages,
saved in an appropriate file format (e.g. Version 12 DXF) and then imported into MintNC. However, MintNC can be used to edit the
drawing line paths into a continuous motion path if necessary and simple nesting facilities are included.
A Windows application programming interface (API) using ActiveX technology is also installed with MintNC, allowing custom
operator front ends to be quickly realised. This API gives access to much of the functionality supported in the main MintNC
application, but allows the programmer to extend the control options and also create a user interface that is specific to the target
application. Four Visual Basic version 6 example projects are installed as part of the MintNC installation as well as one VB.Net
example.
This application note provides a further insight into some of the techniques which can be used to easily implement a MintNC based
host application.
Typical machines that could use MintNC, such as a waterjet cutter and flatbed tangential knife cutter/plotter are illustrated by the
animations at www.abbmotion.com/solutions
For this application note we have implemented a very simple laser cutting machine (this is very similar in principle to the waterjet
machine shown on the website). A full Visual Studio (VS) 2015 example program written in Visual Basic (VB) including source code
and installable executable accompanies this application note. The Mint code that accompanies this application note is designed to
run on the ABB virtual controller (part of Mint Workbench) allowing the user to run the host and Mint code on a PC and simulate the
machine. This code will run without a MintNC dongle allowing program development/demonstration to be performed using the free
tools available for download from www.abbmotion.com
For further information about the use of MintNC please refer to MN1923 – Getting started with MintNC (this manual is installed as
part of the MintNC installation).
Pre-requisites
You should ensure that the following components are installed on your PC. Your PC needs to be running Windows XP or later (if
using Vista or later applications may need to be installed and run as an Administrator) -
Mint Workbench Build 5852 (or later)
MintNC build 10.2014 (or later) These are both available for download from www.abb.com/motion
You will also need these files included in the zip file with this application note -
Mint sample code (Sample.mnt)
Visual Studio 2015 project and setup files (included in the zip archive with this application note)
Highlight the virtual controller and click on the Select button…you will be taken online to the virtual controller. This provides control
of 16 virtual axes and a number of virtual I/O banks. Mint programs can be downloaded and run on the virtual controller allowing
applications to be developed without the need for external hardware. It is even possible to connect a host application to the virtual
controller (via the Mint ActiveX setVirtualControllerLink method).
From the File menu select Open File… and navigate to the sample Mint program included with this application note (Sample.mnt).
Open this and the program will appear in the Editor window. To download and run this on the virtual controller select
Program>Compile, Download and Run (or keyboard shortcut CTRL+F5).
The Workbench Spy Window ‘Monitor’ tab can be used to monitor position of the controlled axes (0 and 1). As the application
executes you will see these axes moving to the programmed locations.
If you have the VS 2015 development environment you can open the VS project included with this application note and start the
program. If you don’t have this programming environment simply run the setup file (MintNC Sample Install.exe) included with this
application note and then start MintNC Sample (Laser Cutter) from the Windows Start menu.
The main application window will appear and look like this…
2
3
5 6 7 8 9
1 - Menu bar – providing means to Open/Import/Save drawing files, adjust axis jog speeds from fast to slow and vice versa and
adjust laser power (from 0 – 100%)
2 - Program List – displays a list of G-code instructions when a file is opened/imported
3 - Graphic view – displays a pictorial representation of the file when it has been opened/imported
4 - X and Y Axis controls – allowing the user to manually jog the axes forward and backwards
5 - File Control Buttons – providing means to setup the machine parameters, go online/offline to the machine and open/import
files
6 - Zoom Control Buttons – allowing the user to zoom in/out of the opened file
7 - User Control Buttons – allowing manipulation of the drawing and assigning of a tool to the drawing
8 - I/O Indicator Panel – displaying the run time state of the key inputs and outputs for the application
9 - Run Control Buttons – allowing the user to start and stop the machine process
Click on the Setup button and the application should show the machine setup dialog as below:
The title bar of this dialog shows that the machine setup file for this application is called SAMPLE.pl4 (if the application has failed to
open this file click on the Open button in the dialog and navigate to C:\Program Data\MintNC Sample\ where you should find the
file).
Double-click the Controller icon to view the setup for the Mint controller:
This dialog shows that we have selected a ‘Virtual’ controller for the application. MintNC will operate (send motion commands etc...)
a virtual controller without fitting the MintNC dongle to the PC. Click OK to accept this setup and then close the machine setup
dialog.
Now click on the File Import button. Select DXF for the file type to import as
shown.
Open TREE.dxf and the application will show the equivalent G-code
instructions for this shape in the program list and will display a picture of the
drawing of a Christmas tree in the graphic window.
The main tree outline is drawn on layer 0 of the AutoCAD DXF file using a Continuous line type. To check whether this is associated
with a MintNC tool click the Setup button again and then double-click the ‘Data Keys’ icon to open the Data Key editor.
In the screenshot above it can be seen that MintNC has automatically created Data Keys for each of the layers/linetypes that were
detected in the imported file. The first time a Data Key is created it is necessary to manually configure which tool this is associated
with (MintNC will then retain this information in future).
Double-click the 0:CONTINUOUS legend and a new dialog appears allowing you to configure the tool to associate with this key…
Select the Example Tool from the lower dropdown and click on OK.
In the main Data Key editor window now select a colour for the tool from the right
side of the dialog (we selected RED).
Lines in the drawing that have been assigned to a tool will automatically change
colour according to the colour selected in this dialog. This gives an instant
indication of whether the tool will be used when the file is run.
Close the data key editor window and close the machine setup dialog.
Now click on the button that currently reads ‘Offline’ – this will attempt to take MintNC ‘Online’ to the virtual controller. If it works
you should see the following dialog:
Now you’re online to the virtual controller the application automatically enables the Run button and the axis jog buttons. As a
drawing is open some of the zoom control buttons also enable. Try clicking the jog +/- buttons for the X and Y axes. You should
see the position of the axes changing (switch to Workbench and you will see the axis positions changing there too).
From the Parameters>Jog Speed menu change the speed from slow to fast and try jogging again. You should notice the jog speed
is now increased.
Click on the Run button and the Run dialog will appear:
Select ‘From Beginning’ and ‘Defined Order’ to run the whole file in the
order it is listed in the program list. Click OK to start the process.
As the file executes you will see the axis positions changing and a cursor
in the graphic window will show their position with respect to the file. As
MintNC processes the file it will lower the laser head and switch the laser
on at the start of the connected lines and switch the laser off and raise
the head at the end of a series of lines. The output monitor panel will
show this happening.
Now open the supplied VS project. Generally the project is very similar to the VB6 projects installed as examples with MintNC but
this example highlights some of the slight differences when using a .Net platform and contains some additional features that are
very commonly included in MintNC applications (e.g. custom Axis control panels).
For those that do have the VS development environment we will detail some of the salient features of the host application…
- Program List
- Graphic View
- Button Array (x6)
- Parameter (x2)
Other controls are available in the VS toolbox (e.g. Feedrate override control) but for this simple application those listed above are
adequate.
The controls are placed on the main application form at design time (if required the form resize event can be used to manually place
and size the controls to suit the system resolution for example – for this example we’ve just left the controls in their design time
state).
The two parameter controls (one configured as a parameter value and one as a parameter slider) are included on a secondary form
to illustrate how user-created MintNC parameters can be modified at run-time.
'MintNC parameters
Public XAxisPosition As DNCCOMINTERFACELib.DMParameter
Public YAxisPosition As DNCCOMINTERFACELib.DMParameter
Public LaserPowerParameter As DNCCOMINTERFACELib.DMParameter
Mint is the name of our ‘MintController’ and MintNC is the name of our ‘Machine’.
XAxisPosition and YAxisPosition are MintNC parameters (which we will use to display the position of the X and Y axes on the
controller. By using a MintNC parameter we can automatically use the precision and units configured within the MintNC setup file –
we’ll describe this in more detail later)
LaserPowerParameter is a MintNC parameter (which we will use to adjust the laser power output in the range 0-100% - we’ll
describe this in more detail later)
hXAxisPosition and hYAxisPosition are two variables used to store handles to the position parameters.
In our main form’s load event procedure the MintController is then initialised using the following code…
This code tells VB to jump to a label in the event procedure named ‘OnError’ if something goes wrong. It then sets a form level
(public) variable called bControllerOK to True. This variable can be used to ‘wrap’ MintMT ActiveX calls such that the call is only
made if the controller is connected. The code now sets the link to the controller (in this case the virtual controller) and then attempts
to read the controller’s firmware version. A second test is then done to see if the Sample.mnt Mint program is running on this virtual
controller. We will look at this OnError event procedure shortly…
Next the MintNC Machine is then initialised using the following code…
This defines a two axis (X and Y) machine controlled by a NextMove family controller and tells the MintNC libraries to use
“Sample.ini” to retrieve various application settings (see ‘Getting started with MintNC’ for further information about this ini file). Finally
the code loads the machine settings from the relevant MintNC pl4 file (this file is referenced by SAMPLE.ini and in this example is
named SAMPLE.pl4). The pl4 file defines machine parameters such as axis lengths, axis scales, tool settings, MintNC script setups
etc…
OnError:
If nBuild = 0 Then
MsgBox("Could not connect to Virtual controller", vbExclamation, "Controller Error")
Else
MsgBox("Mint program not running", vbExclamation, "Mint Program Error")
End If
bControllerOK = False
Resume Next
This code checks nBuild, if it is still 0 then we know that connection to the virtual controller failed. It then displays a message box
indicating this and sets the bControllerOK flag to False (thereby preventing further Mint ActiveX calls from being made) and resumes
the program on the next line. If nBuild is not 0 then we know that the connection to the virtual controller was made but can assume
that the bRunning variable in the Mint program couldn’t be read indicating that the Mint program isn’t running. It once again will
display an appropriate message box and set bControllerOK to false to indicate this.
This approach is a good way to allow the application to run ‘offline’ without any form of Mint controller connected.
These parameters can be used for anything you like in the application. You could use the
Mint ActiveX control to read/write variables or NVRAM values in the controller and design
your own parameter adjustment interface but using the inbuilt MintNC parameter objects
allows you to use the existing pl4 setup dialog
In our example application we have created a ‘Laser Power’ parameter (range 0 – 100%). This parameter is ‘tied’ to NVLONG(1) on
the Mint controller. The Mint program uses this value to set the value of analog output 0 whenever a job is being processed.
The parameter is initialised in our main form’s load event procedure with the following code…
As we’re using a virtual controller the first time the application starts the value of NVLONG(1) will be zero (as the virtual controller
doesn’t really have non-volatile memory). With a real controller the MintNC parameter would be initialised to have the value read
from NVRAM on the NextMove.
Having issued these commands the MintNC integrated setup dialog will now display “Laser Power” in its list of Parameters. If we
double-click this icon we can access the Parameter setup…
However, we may not want to allow the operator access to the pl4 setup
dialog (as it provides access to some critical settings such as scale factors)
so instead we have created our own parameter setup dialog in this example
(Form2).
The Parameters>Laser Power menu on our main form displays our parameter setup dialog.
The form load event for Form2 then initialises the two MintNC parameter objects placed on
the form (ties these two parameters to the ‘Laser Power’ parameter we created on the main
form and sets the colours of the various parts of the label and scroll bar)….
To gain access to the MintNC button click we have to create the button with no use handler…
'Create buttons with no use handler. This allows us to intercept the click on these buttons later...
AppButtons.ButtonCreate(DV_BUTTON_OPCODE, DO_DATASET_IMPORT Or DV_BUTTON_NOUSEHANDLER,
BUTTON_IMPORT, 0, "Import")
In the above example a button is created that has a style of DO_DATASET_IMPORT or DV_BUTTON_NOUSEHANDLER. This tells
MintNC that the button is a file import button but when it is clicked it shouldn’t automatically call this functionality.
The third parameter in the ButtonCreate call is the button’s IDC (unique identifier). In our application we have created a global
constant called BUTTON_IMPORT (with a value of 101) for this. The IDC is then used by the button array’s click event to detect
which particular button in an array was clicked.
Our Import button is part of an array of buttons called ‘AppButtons’ and in the OnButtonClick event associated with these buttons
we placed the following code…
e.idc contains the IDC of the button was clicked and we pass this to a subroutine that takes the necessary action. Using a
subroutine allows us to perform actions associated with buttons from other parts of the application (e.g. from the File menu)
End Select
End Sub
Note how we use InvokeHandler to call the inherent functionality associated with the button (in this case ‘Import’) and how the
button number is related to the order in which the buttons are initially created.
Having invoked the inherent handler for this button to import a file we then call a subroutine called Optimise() which calls an
optimisation method of the MintNC machine object.
We have used a similar technique to intercept clicking of any of the Jog buttons in the axis control panels. Again, each of these
buttons are declared with ‘no use handler’ and a unique IDC is assigned to each button in the relevant button array (e.g.
BUTTON_XJOGPLUS is the IDC assigned to the first button in the cmdJogX button array).
For the Jog buttons we have used the OnLButtonDown event procedure to intercept operation of the button and in this procedure
we check whether a Jog is allowed (i.e. is the Emergency Stop clear) and then determine whether the axis is already enabled (in
which case we can just invoke the handler associated with the button – i.e. Jog the axis) or whether we need to enable the axis first
(by calling the DriveEnable method of the Mint ActiveX control) before calling the invokehandler method of the MintNC machine.
DV_BUTTON_ANNUNCIATOR:
DV_BUTTON_LED:
The main form’s load event is used to initialise the watch window…
The buttons are created in a similar fashion to all the other buttons in the application (i.e. a button array is created and then each
button is added in turn, complete with unique IDC). In the case of these buttons we include a handle to the input or output on the
controller the button relates to as the fourth parameter (e.g. the Head Down button is related to digital output 1 on the controller).
The final parameter in the button create method allows us to specify a caption for the button.
It is possible to force the digital outputs on/off by clicking the relevant button (the panel lights when the output is on). If required this
manual operation can be disabled via the machine setup dialog…
Run the VB program and click on the Setup button to display the machine/pl4 editor dialog.
Scroll down the dialog until you reach the ‘Digital Output’ section…
Note that in this dialog the outputs are numbered from O1 onwards (this corresponds to outputs 0
onwards on the Mint controller).
Double-click one of the outputs and a further dialog appears that includes an ‘Output Actions’ section.
Contact us
For more information please contact your © Copyright 2016 ABB. All rights reserved.
local ABB representative or one of the following: Specifications subject to change without notice.
www.abb.com/motion
www.abb.com/drives
www.abb.com/drivespartners
www.abb.com/PLC