Expanding PLC Code Generator with reading/writing to the internal tags for S7 target types
“The PLC code generator generates PLC code that reads input values from external inputs and writes output values to external outputs.” (source: https://eclipse.dev/escet/cif/tools/plcgen/index.html ). However, it is useful that the generated PLC code can also read input values and write output values to the internal tags.
When the generated code can work with internal tags it is possible to move some of the functionality outside of the generated code. This new functionality can be used to build the communication with safety software or to move specific functionality to dedicated (standard) and already tested functions.
To achieve this new feature the following solution has been proposed:
- The generated PLC code can interact only with the already declared tags in the existing Data Blocks (DB). The generated code will provide no new tag or DB declaration.
- The name of the tag and the name of the DB where the tags is already declared is provided as an input for the code generator.
- The internal tags will be read at the beginning of MAIN after “Read input from sensors” is carried out but before “Initialize state”.
- The data will be written to the internal tags at the end of MAIN, after the while-loop but before “Write output to actuators” is carried out.
- The responsibility for the checking if the internal tags (in generated code) are truly already declared in S7 project has been placed with TIA Portal. This check is performed by the command “compile”.
Addresses #679