Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8621

Automation, sensing and robotics • RPi 5 + L298N + encoder — how to build a speed controller in Python? (overhead crane)

$
0
0
Hi, I’m building an overhead crane driven by Raspberry Pi 5 (Bookworm, Python 3.11). I’m a beginner with controllers and RPi5 GPIO.
Drives: L298N + Pololu 37Dx65L 24 V 1000 RPM DC motor with encoder (CPR=64) and 10.1:1 gearbox, Pololu #4699.
Wiring is OK — the motors move and the encoders count. I want to implement a speed PI/PID controller in Python (Δticks/Δt → PI/PID → PWM on ENA/ENB).
Right now, my programs only compile with lgpio; I’m not sure if that’s the best choice on RPi 5. Ultimately I need a controller for every motor, but I’ll start with one axis (X).

I’m looking for concrete pointers/links:

Which libraries on RPi 5 for encoder A/B interrupts and stable (hardware) PWM for L298N?

Minimal end-to-end Python example: encoder → speed → PI/PID → PWM + brief CSV logging.

Practical PI/PID tuning tips (start-up offset, time window, filtering, anti-windup).

Thanks!

Statistics: Posted by KrlKrl — Tue Sep 16, 2025 8:17 pm



Viewing all articles
Browse latest Browse all 8621

Trending Articles