This functionality is only available for certain module packages.

You are here: Tutorial > EPLAN Electric P8 > Adding the schematic discipline to the mechatronic model > Use formulas for plugs, sockets, and PLC inputs

Use formulas for plugs, sockets, and PLC inputs

Before using the formula for calculating the plug parameter values, the fixed values have to be deleted first.

  1. In the Project Catalog open the Feeder component.
  2. Set the Option_Inspect_available parameter to true.
  3. Open the Mechatronic structure.
  4. For each sensor, delete the value of the IP parameter.

An abstract sensor is required so that the formula for the plug parameter has to be defined only in one location.

  1. In T_Mechatronic_ModularSystem, select the PLC_Inputs unit.
  2. From the popup menu, select New > ECAD > Fragment.

  1. In the Name field, enter the text abstract_Sensor.
  2. Select the Abstract check box.

Assign to the three sensors the abstract_Sensor class as the super class.

  1. Open Sensor_Pressure.

  1. In the Super class field, select abstract_Sensor.
  2. Repeat steps 1 and 2 for the other two sensors.

The abstract sensor requires a parameter that stores a list of sensors.

  1. Select the Parameter unit.
  2. Select New > Parameter in the shortcut menu.
  3. In the Name field, enter the text Sensors.
  4. From the Type field, select Collection.

To the abstract_Sensor class, the parameters IP, DT and Sensors are to be added. But the IP parameter has already been assigned to each sensor, which therefore brings up a prompt.

Assign to the abstract_Sensor class the parameters IP, DT, and Sensors.

  1. Open the abstract_Sensor class.
  2. Open the Parameters editor page.
  3. Add the parameters IP, DT and Sensors.
  4. Enter the following formula for the IP parameter:
='I' + ($Sensors.indexOf(origin.ifNull(this)) /8) + '.' + $Sensors.indexOf(origin.ifNull(this)).mod(8)

This formula combines the various parts of a plug parameter. As such, the letter “I” is assembled with two values that are separated by “.”. The first value is the position of the sensor in the list divided by 8. The second value is the position of the sensor in the list modulo 8.

  1. Enter the following formula for the Sensors parameter:
=mroot.rmos('T_Mechatronic_ModularSystem.ECAD.PLC_Inputs.abstract_Sensor')

This formula is used to determine a list of all subordinate components of the abstract_Sensor type.

The calculation of the socket parameters on the pages requires a parameter that contains the page number. Define the Page parameter of the String type, and assign this parameter to the abstract_Page page.

The parameter is inherited to the Page subclass. There, a formula is entered for the value of the Page and PageDescription parameters. Formulas are also entered for the socket parameters Input1 to Input8.

  1. In the Page unit, open the Page class.
  2. Open the Parameters editor page.
  3. Enter the following formula for the Page parameter:
=mroot.rmos('T_Mechatronic_ModularSystem.ECAD.Page.Page').indexOf(origin.ifNull(this))

This formula is used to determine a list of all subordinate components of the Page type, and in it the page’s own position.

  1. Enter the following formula for the PageDescription parameter:
=name

This formula determines the name of the page.

  1. Enter the following formulas for the parameters Input1 to Input8:
Name Value
Input1 ='I' + $Page + '.0'
Input2 ='I' + $Page + '.1'
Input3 ='I' + $Page + '.2'
Input4 ='I' + $Page + '.3'
Input5 ='I' + $Page + '.4'
Input6 ='I' + $Page + '.5'
Input7 ='I' + $Page + '.6'
Input8 ='I' + $Page + '.7'

These formulas are used to assemble the socket names on which the plugs of the sensors will fit later on. The socket name consists of the letter "I", the content of the Page parameter (here, 0 or 1), and the extension ".0" to ".7". In total, this produces the socket names I0.0 to I0.7 and I1.0 to I1.7.