The huge potential of the Digital Twin and its benefits in use cases such as virtual commissioning or reconfiguration planning for production systems is often described and well known. One reason that the usage of Digital Twins is becoming increasingly important are current trends, such as individualized mass production, which lead to more frequent reconfigurations of production systems or require higher flexibility. At the same time, many production systems have been in productive use for some time, so-called brownfield systems. Most of them do not have a Digital Twin, but would benefit from one, if available. However, the creation of a Digital Twin is a significant additional effort, due to the creation of the underlying models and the relations between them. Some promising approaches for the creation of domain-specific models already exist, which can be used for the creation of the unconnected parts of a Digital Twin. However, there are still few results for the creation of inter-domain relations, which cause problems in the creation of Digital Twins. This paper therefore presents a methodology for the automated reconstruction of functional relations as well as the separation of functionally related component groups of the plant and its software. For this purpose, the methodology imports the native PLC code via XML, extracts the relevant information from the code and enriches the resulting information model with explicit information about implicit relations in the code. Based on this, various elements of the PLC code are analyzed and the relationship of individual mechatronic components, that are available as signals, are examined and quantified. Thus, a part of the required relations for a Digital Twin is recognized automatically. The methodology and its benefits for the Digital Twin creation is presented and explained using a modular production system with several manufacturing stations as a proof-of-concept.