CIF 3

Initialization

When modeling the plants and requirements, you assume a certain initial state. That is, for each of the sensors and actuators, you assume an initial location. The initial state for the sensors and actuators of the four workstations are listed on their individual pages.

The hardware mapping files provided as part of the 4K420 course files contain hardware mappings. Each hardware mappings defines, among others, the initialization sequence of its workstation. The initialization sequence ensures that after initialization, the system will be in a state that corresponds to the initial state as provided on the pages for each of the four workstations.

Just before initialization, the hardware mapping turns on lamps 1, 2, and 3, to indicate it is initializing the system. Once initialization is successfully completed, all lamps are turned off, as the initial state of the lamps is off.

Initialization problems

Initialization may fail. If this happens, it will be indicated by animating the lamps. The first lamp (and only the first lamp) will be on, then the second lamp will be on, then the third lamp will be on, then the second lamp will be on again, and the cycle repeats. At this point, the only thing you can do, is to resolve the underlying cause of the initialization failure, and to reset TwinCAT.

One of the most common reasons for initialization failure is that the compressed air valve is closed (handle in the horizontal position). Obviously, to use the system, the power supplies (three in total for all four workstations) must be on, and the compressed air valve (one valve for all stations) must be opened (handle in the vertical position). If this is not the case, then certain actuators can’t be enabled, or won’t have any effect. This in turn means that initialization can’t continue to move a certain parts of the system to their proper initial positions, meaning that at the end of initialization certain sensors won’t have their proper initial values.

Another common reason is a sensor that is enabled, but that can not be disabled by means of any of the actuators. An example of this is a sensor that detects and input product, which can only be removed by the user. As long as the product remains at the input position, the sensor will remain on, and initialization will fail, if the sensor is supposed to be off in the initial state.

To figure out the actual sensor that is causing the initialization failure, do the following in TwinCAT:

  • See the TwinCAT FAQ for information on how to disable ‘inline monitoring’, to speed up the steps below. You only need to do this once, as the setting is global, and not project specific.
  • In the Solution Explorer, look for the project with name Untitled1.
  • In that project, look for a folder named POUs.
  • In that folder, look for a file named MAIN (PRG) and open it, by double clicking on it.
  • In the new tab, you’ll see a table at the top, with the current values of all the variables of the MAIN program.
  • Look for the state0 variable in the Expression column.
  • Expand the variable by clicking on the plus (+) icon to the left of the variable name.
  • Look for the variable whose name ends with init_err_sen_idx.
  • Check the value of that variable in the Value column. This value indicates the index of the sensor that failed to initialize properly.
  • Look up the sensor with that index on the page of your workstation.

The following screenshot gives an example:

../../_images/sshot_twincat_init_failure.png