Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bearing-analyzer

An automated bearing inspection rig: a stepper-motor stage rotates a ball bearing in front of a Basler industrial vision camera, the operator GUI drives the capture cycle, and a labelled pattern-recognition layer processes the resulting images.

Originally built over 2023 and 2024 as a six-month industrial engineering internship deliverable. Published here in white-label form: the branding, captured data, and operational logs have been removed, and the system architecture and code are intact.


What the system does

  1. The operator launches the Tkinter GUI, names a new bearing inspection run, and configures the capture parameters.
  2. The motor controller (CamMotor3.py) communicates with a TMC stepper driver over a serial link, configures the driver into StealthChop mode for quiet, low-vibration operation, and rotates the bearing stage through a configurable sequence of angular positions.
  3. At each position the GUI triggers the Basler camera via the pypylon library and stores the resulting frame in a per-run directory under Bearings/.
  4. After capture, labelledPAN.py runs the labelled pattern-analysis pipeline over the captured frames and writes results back to the GUI.
  5. Every action (GUI events, motor commands, camera triggers, errors) is timestamped and written to logs.txt so the operator can reconstruct a run.

The end result is an unattended capture cycle for a bearing that previously required manual operator intervention at each rotation step.


Architecture

+----------------------+
|  GUI.py (Tkinter)    |
|  - run configuration |
|  - capture pipeline  |
|  - threaded workers  |
|  - log display       |
+----------+-----------+
           |
           |  imports
           v
+----------+-----------+        +-----------------------+
| CamMotor3.py         |        | labelledPAN.py        |
| - serial protocol    |        | - frame post-process  |
| - TMC stepper driver |        | - labelled pattern    |
|   (StealthChop mode) |        |   analysis            |
| - Basler camera      |        +-----------+-----------+
|   capture (pypylon)  |                    |
+----------+-----------+                    |
           |                                |
           v                                v
   Serial / USB to stage          Per-run image directory
   + Basler camera over USB           (./Bearings/<run>/)

All file paths (logs, asset directory, per-run bearing storage) are computed relative to the script location, so the project can be relocated wherever the operator needs it.


File layout

bearing-analyzer/
├── CamMotor3.py       # Motor + camera control (~180 LOC)
├── GUI.py             # Tkinter operator interface (~800 LOC)
├── labelledPAN.py     # Labelled pattern analysis pipeline (~400 LOC)
├── Assets/
│   ├── Program_BG.jpg # GUI background (generic bearing render)
│   ├── Run_icon.png   # Button icon
│   └── Logo.png       # (optional) drop your own 250x129 logo here
├── requirements.txt
├── LICENSE
└── README.md

A Bearings/ directory is created at first run for captured-frame storage. logs.txt is generated by the GUI.


Hardware assumed

The code was developed against:

  • Basler USB3 industrial camera with the official pypylon SDK
  • Trinamic TMC-series stepper driver speaking the standard TMCL serial protocol (the protocol bytes are written explicitly in CamMotor3.py, no driver library)
  • A custom mechanical stage with 3D-printed fixtures to mount the bearing under inspection

If you swap any of these, expect CamMotor3.py to be the file that changes most.


Quick start

pip install -r requirements.txt
python GUI.py

You will need:

  • A Basler camera connected and visible to the Pylon Viewer (pypylon builds on the Pylon SDK).
  • A serial port reachable by pyserial with a TMC stepper driver on the other end. The default serial parameters live near the top of CamMotor3.py.
  • (Optional) Drop a Logo.png into Assets/ if you want the GUI's top-right corner to show one; otherwise it falls back to a blank canvas.

What was removed for this public release

  • The original company logo in Assets/. Replaced with an optional Logo.png fallback.
  • The Bearings/ directory of captured frames from real operation. Empty.
  • logs.txt with operational timestamps. Will regenerate on first run.
  • __pycache__/ Python bytecode artifacts.
  • The Bearing Analyzer (2).zip backup snapshot.

The 800-line Tkinter GUI, the 180-line motor / camera controller, and the 400-line analysis pipeline are unchanged from the original (apart from the single line that loaded the company logo).


License

MIT. See LICENSE.


Author

Hashem Touqan · LinkedIn · github.com/HTouqan

About

Automated industrial bearing inspection rig: Tkinter operator GUI, TMC stepper motor control, Basler camera capture, labelled pattern-analysis pipeline

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages