Skip to main content

Example: FlexibleDeviceGenerator

Product: CODESYS Application Composer

This example shows how devices can be automatically generated with the CODESYS Application Composer using flexible device mapping.

This function is employed when at the time the module is created, the hardware configuration cannot be defined yet or it should be designed to be modified later.

Description

The example describes a building which contains rooms. These rooms have switches and lights, each of which is available in two variants. The lights (blinking or steady) can be linked to switches or -buttons. A switch or-button can be linked to several lights. For example, if a light is equipped with both a switch and buttons, then the switch behaves as a main switch which must be pressed before the lights can be operated with the push-buttons. If only switches are installed, then these switch the referencing light. A blinking light automatically switches between on and off when it is switched on.

In the example, the entire communication network is designed to be flexible so that both fieldbus devices and the type of fieldbuses is determined by wildcard mapping. This makes it possible to replace the entire fieldbus or just individual parts.

. The sample project includes the following:
  • Module declarations

  • Function block declarations

  • Device tree

  • Module tree

_ex_ac_img_flexible_device_generator1.png

(1): Mapping of the demand properties of the device

For more information, see: Device Generator section.

By using flexible wildcards, it is necessary to map the installed devices to the last wildcards, which are nothing more than placeholders for specific device types. This is done during wildcard mapping before generator cycle by the CODESYS Application Composer. When the device generator is activated, the application code can be generated, including all necessary devices. You can automatically implement module I/Os using properties which are mapped to the channels of the devices. For this purpose, available matching properties of device channels are linked automatically to module I/Os. The applied properties are saved for each device description and define, if necessary, their own demand on properties.

Flexible and static device generation can be used simultaneously, for example if part of the devices is already known. Determining specific hardware will limit the flexibility of the device generator.

_ex_ac_img_flexible_device_generator2.png

After the bus system has been generated for the first time, you may need to adapt the communication settings. In this case, you can ignore the warning that you should not modify any files created by the CODESYS Application Composer. If no changes were made to the tree of module instances, then the following configuration of the communication system is possible:

  • Fieldbus: EtherCAT Master

  • Bus coupler: EK1100

  • Terminal input: EL1008

  • Terminal output: EL2004

The selected configuration can be changed at any time by means of the Wildcard selection menu item of the CODESYS Application Composer and generating again.

System requirements and restrictions

Programming system

CODESYS Development System (version 3.5.17.0 or higher)

Runtime system

CODESYS Control Win (version 3.5.17.0)

Add-on components

CODESYS Application Composer

Note

_example_icon.png DOWNLOAD Projects