Mapping Hardware Structures in the Device Tree

Mapping a standard controller with fieldbus in the device tree

You map the hardware that you wish to control with your application in the Devices view (device tree). To do this you insert device objects, which represent the real devices in the network, in a tree structure that shows the hierarchy of the control network concerned. These are, for example, objects for a PLC, for fieldbuses or for logical devices.

Below you will map hardware containing a standard PLC and a standard fieldbus.

  1. Select the command File ‣ New Project.

  2. In the dialog box New Project, select the template Standard project.

  3. In the dialog box Standard Project, select the device CODESYS Control Win V3.

    CODESYS inserts the object Device (CODESYS Control Win V3) in the device tree under the root node and below it the node PLC Logic, which always provides a programmable device object. Below PLC Logic there is already an object inserted, Application, and below that the objects Library Manager, PLC_PRG and Task Configuration.

  4. Select the entry Device (CODESYS Control Win V3) and select the command Add device in the context menu.

    The dialog box Add Device offers a selection of the devices installed on your system. ‘Installed on the system’ means that CODESYS has received a device description for the respective hardware. You can thus use the device object and the associated configuration editor in the project.

  5. Select one of the offered control devices, for example CAN-bus, and click on the button Add device.

    The object CAN-bus appears in the device tree indented under Device (CODESYS Control Win V3). The dialog box Add device remains opened. If you now select the new CAN-bus entry, it automatically offers the objects that are insertable under it.

  6. Select, for example, CANopen Device from the category ‘Local Device’.

    CANopen_Device is inserted indented under CAN-bus in the device tree.

  7. Do you want to add a different device to the one you added before? Select the device entry and select the command Update device in the context menu.

    The dialog box Update Device appears. It corresponds to the dialog box Add Device used before. You can select another device, which is then inserted in the tree in place of the previous one.

Scanning the current hardware and adopting devices into the project

You can determine the devices in the network of the hardware environment (scan) and adopt the devices found into the device tree of your project. If the scan function is permanently implemented in the PLC, you can perform the scan without further preparations. For this purpose CODESYS briefly establishes a connection to the controller. If the scan function is provided in a library, the device that includes the library must be inserted in the device tree and a login to the controller executed. Only then can the library be placed on the controller, making scanning possible.

Scanning is started with the command Scan for Devices. It refers to the controller that is currently selected in the device tree and linked to the project. For example, you can select an inserted PROFINET IO controller and use the command to determine the I/O devices and I/O modules assigned to it.

Requirement: you have a project with a device configuration. The communication settings are correct. Gateways and hardware are running.

  1. Select a control device object in the device tree.

  2. Select the command Scan for Devices in the context menu.

    CODESYS establishes the connection to the hardware. The dialog box Scan for Devices appears. Depending on the type of device it offers different functions. However, a table always appears showing the devices found in the hardware: device name, type of device, station name, etc. Regarding this, please see the online help for the respective device editor.

  3. So that the list displays only devices found that you do not yet have in the device configuration of your project, activate the option Show differences to project.

  4. In order to adopt a device into the device tree of the project, select the entry in the table and click on the button Copy to project. All devices found are adopted if you do not select an entry.

    The corresponding entries are inserted in the device tree.

See also

Checking the controller configuration with the help of the ‘Online configuration mode’

With CODESYS you can test the correct wiring of the I/Os and the fieldbus of your target system, without having to develop a real application for the controller and loading it to the controller beforehand. This is interesting for the initial commissioning phase. Use the ‘Simple online configuration mode’ for this. If there is already an application on the controller, you can optionally also use the ‘Advanced online configuration mode’ if the device supports this. This allows you to read device parameters without having to log in with the application concerned from CODESYS.

Simple online configuration mode:

You create an implicit application with the command Online configuration mode in the context menu of the PLC object in the device tree. CODESYS automatically loads the application to the PLC and, via the application, automatically initializes all I/Os once. The application is called HiddenOnlineConfigModeApp. It is displayed in the device editor of the PLC in the Applications tab. You can use it to operate the I/Os with the following functions as in normal online mode:

  • Read I/Os
  • Write outputs
  • Diagnosis (in the tree and on the status page)
  • Scan (of the current hardware)
  • Interactive online functions, if supported (for example, writing asynchronous messages)

Note

:strong:Writing and forcing in the I/O mapping

In online configuration mode the writing and forcing of values in the dialog box I/O mapping works differently to the way it works in real online mode. CODESYS writes the outputs into the I/O mapping table immediately after insertion. There is no Prepared value column; instead, you change the initial values directly after a double-click on the column Current value.

Testing the I/O access with the help of the simple online configuration mode:

Requirement: you have created a standard project with a device configuration in which you have configured an I/O mapping. In a program block you make read or write accesses to inputs or outputs of the hardware in order to check their wiring. The connection to the PLC of the hardware is configured in the communication settings. The PLC is running.

  1. Select the PLC object in the device tree.

  2. Select the command Online configuration mode in the context menu.

    CODESYS links to the controller and the PLC object in the tree is given a green background.

  3. Double-click on the PLC object in the device tree in order to open the device editor. Select the tab Applications.

  4. Click on the button Update list.

    HiddenOnlineConfigModeApp appears in the window Applications on the controller.

  5. Start your program and check the behavior of the inputs and outputs.

Advanced online configuration mode (parameter mode):

If there is already a ‘real’ application on the controller and the device supports the ‘Advanced online configuration mode’, you can also optionally select the ‘Parameter mode’ after the command Online configuration mode. Then you can read the parameters of the real application on the controller without having to carry out a standard login and – if compilation information is missing – having to download this application again. You can see the parameters in the Configuration tab of the device editor. The parameter mode prevents the inadvertent changing of the data on the controller; the applications remain untouched. Writing of the parameters is possible only if the driver supports it.

Setting up parameter mode for reading the device parameters:

Requirement: there are already one or more applications on the target device. The target device supports the advanced online configuration mode. You have opened the project containing these applications. You wish to look at the device parameters without having to log in to the controller. The connection to the PLC of the hardware is configured in the communication settings. The PLC is running.

  1. Select the PLC object in the device tree.

  2. Select the command Online configuration mode in the context menu.

    CODESYS links to the controller and the PLC object in the tree is given a green background. The dialog box Select configuration mode appears with a display of the application(s) on the PLC.

  3. Select the desired application and click on the button Parameter mode.

    CODESYS checks whether the application in the project corresponds to the application on the PLC.

  4. If CODESYS does not signal an error regarding the correspondence of the applications to each other, open the Configuration tab of the PLC device editor.

    You can read the device parameters.

See also

‘Configuration matching’

This function is available only for PROFINET IO bus systems!

With the help of the command Configuration matching you match the local configuration settings of a PROFINET IO slave object in the project to those of a corresponding device in the linked hardware. ‘Matching’ in this case means overwriting. The search for an appropriate device takes place on the basis of the device ID and the vendor ID.

  1. Configure the communication settings in the device editor of the PROFINET IO slave.

  2. In offline mode, select the device object in the device tree for which the matching is to take place.

  3. Select the command Configuration matching in the context menu.

    The dialog box Scan for Devices appears. CODESYS searches for suitable devices in the hardware and lists the devices found in the dialog box.

  4. For demonstration only: click on the button Devices used.

    The dialog box no longer displays the devices that you are already using in the project. The identification takes place on the basis of the station name.

  5. Start the search by actuating the button Scan for Devices. In the list of the devices found, select the device whose configuration settings are to overwrite those existing in the project. Click on the button Copy to project.

    The settings of the device in the project now correspond precisely to those of the real device. Sub-device objects are not removed by the action.

See also