me@michellealzoladesign.com

Mon - Fri: 8AM - 5PM MDT

Introduction

Manufacturing processes generate large volumes of data from different stages and components, which require effective monitoring and analysis. In this article, we’ll explore how to build a real-time factory process monitoring system using Python, Tkinter, SQLite, and data visualization libraries. Our solution will demonstrate how to handle large datasets, filter data based on time ranges, and visualize key metrics using a GUI application.

Data source: Multi-stage continuous-flow manufacturing process (kaggle.com)

Problem Statement

The factory collects continuous data from various sources, including ambient conditions, machine properties, and stage outputs. This data is stored in CSV files, making it difficult to quickly query specific time intervals or visualize trends. We aim to build a system that reads this data, stores it in an SQLite database, allows time-based queries, and visualizes the results through an easy-to-use graphical user interface (GUI).

Solution Overview

The solution involves the following key components:

  1. Reading CSV Data: Load the data from CSV files and parse it into relevant categories like ambient conditions, machine properties, and stage outputs.
  2. Storing Data in SQLite: Store the parsed data in an SQLite database for efficient querying and retrieval.
  3. Building a Tkinter GUI: Provide a user-friendly interface to filter data based on time ranges and specific parameters.
  4. Visualizing Data: Use Matplotlib to create dynamic plots that show real-time trends in the factory process.

Project Structure

The project is split into 5 main components. Each component is designed to be modular and easily extendable.

  • factory_data.py, ambient_conditions.py, machine_properties.py and stage_outputs.py: Contain the classes responsible for handling data storage and retrieval from the SQLite database. The classes are designed with inheritance in mind, allowing easy extension as more data categories are introduced.
  • main_gui.py: Implements the Tkinter-based GUI for interacting with the system. The GUI provides options to load data, filter it by time, select specific parameters, and visualize the results.

Data Models with Inheritance and SQLite Integration

We define a base class called FactoryData, which handles the common operations such as creating tables, inserting data, and querying data. Specific subclasses, like AmbientConditions, MachineProperties, and StageOutputs, extend this base class to define operations specific to each data category.

Tkinter GUI for Data Filtering and Visualization

The Tkinter GUI allows users to load CSV data, filter it based on a time range, and select specific parameters to visualize. The interface includes dropdowns, date entry fields, and buttons to interact with the data.

Database Integration

We use SQLite as the database to store and query the data. This allows us to easily filter large datasets and retrieve the relevant records without performance issues. The database is created and managed by the FactoryData class, ensuring all subclasses can use common methods for querying and data storage.

Running the Application

  1. Run main_gui.py to launch the Tkinter application.
  2. Load your dataset using the “Load CSV” button, filter the data by time, and select the desired parameter to visualize.

Conclusion

This project demonstrates how to build a real-time factory process monitoring system using Python, Tkinter, and SQLite. The modular design with class inheritance makes it easy to extend and adapt the solution to different manufacturing processes. By integrating a database, we ensure that large datasets can be handled efficiently, providing real-time insights through dynamic data visualization.

Recommended Articles