Skip to content
PDF

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.

  1. Start the CODESYS Development System.
  2. Go to Tools > Device Repository.

    !Device repository

  3. Click Install.

    !Install device description

  4. Go to the directory of the previously downloaded device description.

  5. Select the device description of the MFN 100.
  6. Click Open.
  7. 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.

!Device description installed

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.

!Missing libraries error message

  1. Open or create a CODESYS project.
  2. If the error message about missing libraries appears, click OK.
  3. Double-click Library Manager in the tree view on the left.
  4. Click Download missing libraries.

    !Library Manager

  5. Click Download in the new window.

    !Downloading libraries

  6. Click Close when the download is finished.

  7. 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.

  1. Click Tools > Device Repository.
  2. Click Download missing descriptions.

    !Missing device descriptions

    Note

    If no device descriptions of generic devices are missing, the button for downloading missing descriptions will not appear.

  3. Click Download in the new window.

  4. 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.

  1. Start CODESYS
  2. Go to File > New Project.
  3. Click Standard project on the right side among the templates.
  4. Enter a name for the project.
  5. Choose a Location where the project will be saved.
  6. Click OK to save the project.

    !New Project

  7. Select Nerve_MFN_100 (TTTech) as the device.

    !MFN 100

  8. Click OK.

The result is an empty project that is open in the main view of CODESYS.

!Empty Project

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.

  1. Start CODESYS.
  2. Go to File > Open Project.
  3. Select the download location of the default applications.
  4. Select the application to work with.

    !Default Applications

  5. 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.

  1. Open or create a CODESYS project.
  2. Double-click Device (Nerve_MFN_100) in the tree view on the left.
  3. Go to Communication Settings > Scan network....

    !Scan network

  4. Select the MFN 100 (here nerve-rtvm [XXXX.XXXX]) in this window.

    !nerve-rtvm

    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.

  5. 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.

  1. Double-click Device (Nerve_MFN_100) in the tree view on the left.
  2. Go to Communication Settings in the middle of the window.
  3. Enter 172.20.2.2:11740 in the text box under the device on the right.

    !Connecting manually

  4. 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.

  1. Open the CODESYS project to load into the MFN 100.
  2. Click the Login symbol in the CODESYS menu bar.

    !Login symbol

  3. Click Yes in the pop-up window.

    !Confirm application download

  4. The application is stopped now. Click the Play symbol in the CODESYS menu bar.

    !Play symbol

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.

  1. Stop the CODESYS application that has been loaded into the MFN 100 through the Local UI.
  2. Click the Logout button in the CODESYS toolbar.

    !Logout button

  3. Expand Device (Nerve_MFN_100) > PLC Logic > Application.

  4. Double-click PLC_Program (PRG).
  5. Perform the changes.
  6. Click the Login symbol in the CODESYS menu bar.

    !Login symbol

  7. In the pop-up window, select one of the options.

    !Pop-up window 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.
  8. 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.

  1. Open a CODESYS project.
  2. 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.
  3. Double-click DI_8x24VDC_ST_V0_0_QI (...) for digital inputs.
    Double-click DQ_8x24VDC_0_5A_ST_V0_0_QI (...) for digital outputs.
  4. Select PNIO Module I/O Mapping.

    !Variable Allocation

  5. Fully expand the tree view.

  6. 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.

  7. Click the three dots next to the variable slot.

    !Ellipsis menu

  8. Expand Application > GVL in the new window.

    !Global Variables

  9. 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.

  10. 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.