First steps with CODESYS and the MFN 100
This chapter will give an introduction on how to start working with the integrated soft PLC in the MFN 100. First, some configuration and installation of files and libraries are required.
Note
- Download the CODESYS Development System V3 from store.codesys.com for this chapter.
We recommend version 3.5 SP14 (32 bit) or newer. - Connect the workstation to the console port P1 of the MFN 100.
Installing the device descriptions
After downloading and installing the CODESYS Development System on the workstation, install the device descriptions of the MFN 100 and the SIMATIC ET200 SP I/O module in the CODESYS Development System. The device descriptions have the following filenames:
MFN 100 | Nerve_MFN_100_V3.5.XX.X.devdesc.xml |
SIMATIC ET200 SP | GSDML-V2.34-Siemens-ET200SP-20180926.xml |
XX.X stands for the current version of the CODESYS Development System. The device descriptions of the MFN 100 and the SIMATIC ET200 SP I/O module are available at the Nerve Software Center.
- Start the CODESYS Development System.
-
Go to Tools > Device Repository.
-
Click Install.
-
Go to the directory of the previously downloaded device description.
- Select the device description of the MFN 100.
- Click Open.
- Repeat steps 3 to 6 to install the device description SIMATIC ET200 SP I/O module.
When the installation was successful, the MFN 100 and the SIMATIC ET200 SP I/O module will appear in the list of device descriptions in the middle of the window. Close the window afterwards.
After installing the device description the CODESYS Development System can be worked with. However, libraries and device descriptions of generic devices might be missing so that the CODESYS Development System can work properly.
Downloading missing libraries
The error message for missing libraries might appear when opening or creating a CODESYS project. The CODESYS Development System identifies the missing libraries automatically but the following process might have to be repeated a few times.
- Open or create a CODESYS project.
- If the error message about missing libraries appears, click OK.
- Double-click Library Manager in the tree view on the left.
-
Click Download missing libraries.
-
Click Download in the new window.
-
Click Close when the download is finished.
- Repeat steps 3 to 5 until no more libraries appear in the download window.
Downloading missing device descriptions
Apart from the device description for the MFN 100, device descriptions of generic devices may be missing for the CODESYS Development System to function as intended. The CODESYS Development System will identify the missing device descriptions automatically but this time it will not generate an error message unless a CODESYS application is loaded into the MFN 100.
- Click Tools > Device Repository.
-
Click Download missing descriptions.
Note
If no device descriptions of generic devices are missing, the button for downloading missing descriptions will not appear.
-
Click Download in the new window.
- Click Close when the download is finished.
Creating a new CODESYS project
This example shows how to create a new project in the CODESYS Development System. The easiest way to get started is to create a Standard project.
- Start CODESYS
- Go to File > New Project.
- Click Standard project on the right side among the templates.
- Enter a name for the project.
- Choose a Location where the project will be saved.
-
Click OK to save the project.
-
Select Nerve_MFN_100 (TTTech) as the device.
-
Click OK.
The result is an empty project that is open in the main view of CODESYS.
Working with the default applications
To work with existing applications first, modify the default applications app1.project
and app2.project
. They can be downloaded from the Nerve Software Center under Example applications.
- Start CODESYS.
- Go to File > Open Project.
- Select the download location of the default applications.
-
Select the application to work with.
-
Click Open.
When opening the default applications for the first time, some libraries and device descriptions will be missing. Follow the instructions above to see how to download the missing files.
Connecting to the MFN 100
Before downloading CODESYS applications to the MFN 100, make sure that the device description of the MFN 100 is installed in the CODESYS Development System.
- Open or create a CODESYS project.
- Double-click Device (Nerve_MFN_100) in the tree view on the left.
-
Go to Communication Settings > Scan network....
-
Select the MFN 100 (here nerve-rtvm [XXXX.XXXX]) in this window.
Note
When more than one network is active on the workstation, it sometimes happens that the MFN 100 cannot be found. Continue reading if the MFN 100 does not appear in this window.
-
Click OK.
Typically the MFN 100 will be found automatically. If the MFN 100 cannot be found, enter the IP address and port of the CODESYS runtime manually.
- Double-click Device (Nerve_MFN_100) in the tree view on the left.
- Go to Communication Settings in the middle of the window.
-
Enter
172.20.2.2:11740
in the text box under the device on the right. -
Press Enter.
The CODESYS Development System is now connected to the MFN 100 and applications can be downloaded into the CODESYS runtime.
Downloading an application to the MFN 100
CODESYS applications can be loaded directly into the MFN 100. However, before downloading an application into the MFN 100 it needs to be free of errors.
The process of downloading an application is slightly different when downloading an entirely new application into the MFN 100 or updating an application that has already been downloaded into the MFN 100. Continue with Downloading an Updated Application to the MFN 100 further down below if an application is being updated.
Downloading a new Application to the MFN 100
After creating a project and finishing with programming, the CODESYS application can be downloaded into the MFN 100 directly.
- Open the CODESYS project to load into the MFN 100.
-
Click the Login symbol in the CODESYS menu bar.
-
Click Yes in the pop-up window.
-
The application is stopped now. Click the Play symbol in the CODESYS menu bar.
The application is now loaded to the MFN 100.
Downloading an updated application to the MFN 100
Updating an application after loading it into the MFN 100 requires another download into the MFN 100. The download process is slightly different from downloading a new application into the MFN 100.
- Stop the CODESYS application that has been loaded into the MFN 100 through the Local UI.
-
Click the Logout button in the CODESYS toolbar.
-
Expand Device (Nerve_MFN_100) > PLC Logic > Application.
- Double-click PLC_Program (PRG).
- Perform the changes.
-
Click the Login symbol in the CODESYS menu bar.
-
In the pop-up window, select one of the options.
Item Description Login with online change. The updated application will be loaded into the MFN 100. Variable values will not be reset. If the application was running before, it will be running after the download. Login with download. The updated application will be loaded into the MFN 100. Variable values will be reset. The application is stopped. Login without any change. The updated application will not be loaded into the MFN 100 but the code will keep the changes. -
Click OK.
The application is now loaded to the MFN 100.
Note
For more help with programming PLC applications in the CODESYS Development System go to help.codesys.com.
Allocating variables to inputs or outputs
After connecting new sensors and actuators, variables need to be assigned to the I/O channel in CODESYS.
- Open a CODESYS project.
- Expand Device (Nerve_MFN_100) > PLC Logic > Ethernet_1 > PN_Controller > siemenset200 (IM 155-6 PN ST V4.1) in the tree structure on the left.
- Double-click DI_8x24VDC_ST_V0_0_QI (...) for digital inputs.
Double-click DQ_8x24VDC_0_5A_ST_V0_0_QI (...) for digital outputs. -
Select PNIO Module I/O Mapping.
-
Fully expand the tree view.
-
Double-click the variable slot to assign.
Note
The inputs in this view do not match the physical inputs of the I/O module on the kit. The inputs here go from 0 to 7. The physical inputs go from 1 to 8. Therefore input 0 in this view represents the physical input 1 on the I/O module. This also applies to outputs.
-
Click the three dots next to the variable slot.
-
Expand Application > GVL in the new window.
-
Select the variable to assign.
Note
Make sure to select a variable of the same type as the input, i.e., a BOOL variable for a BOOL input or output.
-
Click OK.
Use the assigned variables to read data from connected sensors or to control actuator functionality.
Note
For more help with programming PLC applications in the CODESYS Development System go to help.codesys.com.