# dipto9999/reflow_oven_controller architecture

> Architecture diagram of the GitHub repository dipto9999/reflow_oven_controller, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dipto9999/reflow_oven_controller
- Repository: https://github.com/dipto9999/reflow_oven_controller

## Overview

##### Project Type and Purpose
- This is an embedded control system with a companion data‐processing application.
- The primary function is to run a reflow soldering process on a microcontroller‐controlled oven (N76E003), implement a finite state machine for safe temperature profiling, and capture real‐time temperature data on a host machine.
- A secondary function is to postprocess and archive run data in CSV form and optionally in a GCP data bucket.

##### File Structure Analysis
- Top level:
– Firmware/ : 8051 ASM source, peripheral include files, build/flash tasks, Python validation script.
– Data_Processing/ : Python app (app.py), GCP upload/download modules, Logbook CSV outputs, requirements.txt.
– Schematics/ : KiCad schematic and PCB files, backups.
– Documents/, Report/ : Design docs, reports, figures, LaTeX sources.
- Key patterns:
– Firmware separates peripherals into .INC modules (ADC.INC, PWM.INC, SERIAL.INC).
– MAIN.ASM implements the FSM controller.
– Data_Processing uses a Python MVC‐like UI/backend with pandas and GCP scripts.
- Configuration/Build:
– Firmware/.vscode/tasks.json defines compile (a51.exe) and flash (ISPN76E003.exe) commands.
– Data_Processing/requirements.txt lists Python dependencies.

##### README Insights
- Describes an electronic circuit with op‐amp and ADC feeding a thermocouple and room temp sensor.
- Highlights a finite state machine for reflow profile control.
- Details GCP bucket integration for CSV uploads and downloads.

a. Main Components
– Hardware Layer: thermocouple + op‐amp circuit, room‐temp sensor (LML335), oven heating element, MOSFET/driver for heater.
– Microcontroller: N76E003 (8051 core) with ADC peripheral, PWM output, serial UART. FSM runs in MAIN.ASM.
– Firmware Modules:
· ADC module (ADC.INC)
· PWM control (PWM.INC)
· Serial comms (SERIAL.INC)
· Math utilities (MATH32.INC)
– Host Application: Python app (app.py) for real‐time plotting, logging to CSV (Logbook).
– Cloud Backend: GCP Storage bucket accessed via uploading.py and downloading.py.
– User Interface: GUI in Python or CLI for controlling session and viewing state transitions.

b. Relationships & Data Flows
– Sensors → ADC → MCU (digital temperature values)
– MCU FSM → PWM → Heater → Temperature changes
– MCU FSM → UART → Host App receives state & temp messages
– Host App → pandas → CSV files in Logbook
– Host App → uploading.py → GCP bucket (upload)
– downloading.py ↔ GCP bucket → local CSV for analysis

c. Architectural Patterns & Principles
– Finite State Machine (FSM) in firmware: clear state transitions for preheat, soak, reflow, cool-down.
– Modular firmware: separate peripheral libraries for maintainability.
– Layered design: hardware abstraction on MCU, transport layer via UART, application logic in Python.
– Data persistence and cloud integration for scalability and post‐hoc analytics.

d. Key Technologies & Frameworks
– 8051 ASM toolchain (a51.exe, ISPN76E003.exe)
– KiCad for electronics schematics/board design
– Python with pandas, PySerial, Google Cloud Storage client
– GCP Storage bucket as external service

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Hardware Layer
    subgraph "Hardware Layer"
        sensor1[/"Thermocouple + OpAmp"/]:::hardware
        sensor2[/"LML335 Room Temp Sensor"/]:::hardware
        heater[[Heater Element + MOSFET Driver]]:::hardware
    end

    %% MCU & Firmware
    subgraph "MCU & Firmware"
        MCU(("N76E003 MCU\n8051 Core")):::hardware
        subgraph "Firmware Modules"
            FSM["Finite State Machine Controller\n(MAIN.ASM)"]:::firmware
            ADC["ADC Peripheral Module\n(ADC.INC)"]:::firmware
            PWM["PWM Control Module\n(PWM.INC)"]:::firmware
            UART["Serial Communication Module\n(SERIAL.INC)"]:::firmware
            MATH["Math Utilities Module\n(MATH32.INC)"]:::firmware
            LCD["LCD Driver Module\n(LCD_4BIT.INC)"]:::firmware
        end
        FSM -->|"uses"|ADC
        FSM -->|"uses"|PWM
        FSM -->|"uses"|UART
        FSM -->|"uses"|MATH
        FSM -->|"uses"|LCD
        ADC --> MCU
        PWM --> MCU
        UART --> MCU
    end

    %% Host Application
    subgraph "Host Application"
        App["Python App\n(app.py)"]:::host
        SerialListener["Serial Listener"]:::host
        DataProc["Data Processor"]:::host
        StorageMgr["Storage Manager"]:::host
        Logbook["Local CSV Logbook\n(Logbook/)"]:::host
        UploadCli["GCP Upload Module\n(uploading.py)"]:::host
        DownloadCli["GCP Download Module\n(downloading.py)"]:::host
        Req["Python Dependencies\n(requirements.txt)"]:::host

        App -->|"UART serial"| SerialListener
        SerialListener -->|"parsed data"| DataProc
        DataProc -->|"DataFrame"| StorageMgr
        StorageMgr -->|"writes CSV"| Logbook
        DataProc -->|"send to GCP"| UploadCli
        UploadCli -->|"upload CSV"| Bucket
        DownloadCli -->|"download CSV"| Bucket
        DownloadCli -->|"CSV files"| Logbook
    end

    %% Cloud Services
    subgraph "Cloud Services"
        Bucket[(GCP Storage Bucket)]:::cloud
    end

    %% Development & Deployment
    subgraph "Development & Deployment"
        Tasks["Build & Flash Tooling\n(.vscode/tasks.json,\n__a51.bat, a51.exe,\nISPN76E003.exe)"]:::dev
        ValScript["Temperature Validation Script\n(Multimeter_Temp.pyw)"]:::dev
        Schematics["KiCad Schematics & PCB\n(schem.kicad_sch,\nschem.kicad_pcb)"]:::dev
    end

    %% Data Flows
    sensor1 -->|"Analog voltage"| ADC
    sensor2 -->|"Analog voltage"| ADC
    MCU -->|"PWM signal"| heater
    MCU -->|"UART serial"| App
    Tasks -.-> MCU

    %% Click Events
    click FSM "https://github.com/dipto9999/reflow_oven_controller/blob/main/Firmware/MAIN.ASM"
    click ADC "https://github.com/dipto9999/reflow_oven_controller/blob/main/Firmware/ADC.INC"
    click PWM "https://github.com/dipto9999/reflow_oven_controller/blob/main/Firmware/PWM.INC"
    click UART "https://github.com/dipto9999/reflow_oven_controller/blob/main/Firmware/SERIAL.inc"
    click MATH "https://github.com/dipto9999/reflow_oven_controller/blob/main/Firmware/MATH32.INC"
    click LCD "https://github.com/dipto9999/reflow_oven_controller/blob/main/Firmware/LCD_4BIT.INC"
    click Tasks "https://github.com/dipto9999/reflow_oven_controller/blob/main/.vscode/tasks.json"
    click Tasks "https://github.com/dipto9999/reflow_oven_controller/blob/main/Firmware/__a51.bat"
    click Tasks "https://github.com/dipto9999/reflow_oven_controller/blob/main/Firmware/a51.exe"
    click Tasks "https://github.com/dipto9999/reflow_oven_controller/blob/main/Firmware/ISPN76E003.exe"
    click ValScript "https://github.com/dipto9999/reflow_oven_controller/blob/main/Firmware/Multimeter_Temp.pyw"
    click App "https://github.com/dipto9999/reflow_oven_controller/blob/main/Data_Processing/app.py"
    click Logbook "https://github.com/dipto9999/reflow_oven_controller/tree/main/Data_Processing/Logbook/"
    click UploadCli "https://github.com/dipto9999/reflow_oven_controller/blob/main/Data_Processing/uploading.py"
    click DownloadCli "https://github.com/dipto9999/reflow_oven_controller/blob/main/Data_Processing/downloading.py"
    click Req "https://github.com/dipto9999/reflow_oven_controller/blob/main/Data_Processing/requirements.txt"
    click Schematics "https://github.com/dipto9999/reflow_oven_controller/blob/main/Schematics/schem.kicad_sch"
    click Schematics "https://github.com/dipto9999/reflow_oven_controller/blob/main/Schematics/schem.kicad_pcb"

    %% Styles
    classDef hardware fill:#a8d5e2,stroke:#1f618d,color:#1b2631
    classDef firmware fill:#add8e6,stroke:#1b4f72,color:#1b2631
    classDef host fill:#f5b041,stroke:#b9770e,color:#1b2631
    classDef cloud fill:#d2b4de,stroke:#6c3483,color:#1b2631
    classDef dev fill:#d5dbdb,stroke:#424949,color:#1b2631
```
