Structure Of The "Main.py" Script File; Main.py" Script File During Operation - Siemens SIMATIC S7-1500 Manual

Hide thumbs Also See for SIMATIC S7-1500:
Table of Contents

Advertisement

6.2.2.3

Structure of the "main.py" script file

The structure of the "main.py" script file is described by way of example below. This structure
can be modified as needed depending on the application.
Structure
The "main.py" script file consists of 3 blocks:
• Import statement to reference libraries
• Functions
User-specific functions that can be modified and used are also provided.
• Script for operation
Initialization of camera, video pipeline, etc.
Subsequent function calls which are repeated in a loop:
– Fetch image
– Image pre-processing
– Transfer image to the neural network and start inference
– Process results
– Save image
– Data exchange with the CPU
6.2.2.4

"main.py" script file during operation

After the initialization, the script runs through the specified steps.
The script is stopped when
• the power supply to the TM NPU is interrupted.
• an exception in the script is not caught.
• the module is reset by a new parameter assignment.
Example operation: Programmed loop
• The CPU triggers the TM NPU via the process image.
• An image is fetched from the camera.
The original image data (RAW) is saved on the SIMATIC Memory Card or sent to the FTP
server via the FTP client.
• The image is pre-processed by the video pipeline.
The pre-processing normalizes the image data and changes the size to enable processing
by the neural network.
• The inference is queried.
• The results are prepared.
• The results are sent to the PLC via the process image.
Technology Module TM NPU
Equipment Manual, 07/2023, A5E46384784-AC
Programming
6.2 Sequence and procedures
37

Advertisement

Table of Contents
loading

This manual is also suitable for:

Simatic et 200mp

Table of Contents