How jrbynum/rpm_ac_motor_controller works
1. This repository is an embedded motor-controller project, not a typical software app. The core runtime is Arduino-style C++ firmware for an AC motor control system, with a separate Eagle schematic/board layout for the supporting shield hardware.
2. The main control problem is a closed loop: a reflective optical sensor measures motor RPM, an LM135 measures temperature, and the firmware uses PID-based feedback to regulate motor speed. The system also displays RPM and temperature on an LCD for local monitoring.
3. The actuation path is hardware-driven. A zero-crossing circuit plus a triac control AC power to the motor. The target speed comes either from a 10K potentiometer on the shield or from an external PWM input, which the readme notes could come from Mach3. That makes the controller compatible with both manual and external machine-control sources.
4. The firmware is organized into a small set of focused source files under RPM_TEST/source:
- RPM_TEST_main.cpp is the application entry point and top-level orchestration.
- startup.cpp likely handles initialization of pins, timers, peripherals, and interrupt setup.
- isrs.cpp isolates interrupt service routines for sensor timing, zero-crossing events, or other real-time signals.
- calculations.cpp contains the measurement and control math, such as RPM computation, temperature conversion, and PID-related logic.
- diagnostics.cpp likely handles LCD output and any status/debug reporting.
- rpm_test_main.h ties the modules together through shared declarations and configuration.
5. The important data flow is sensor-to-control-to-actuator:
- optical sensor pulse timing becomes RPM,
- temperature sensor voltage becomes temperature,
- setpoint comes from pot or PWM input,
- control logic computes the output command,
- zero-cross/triac circuitry applies that command to motor power,
- LCD reports the current state.
6. Interrupts are a key architectural boundary. Because RPM and AC phase timing are time-sensitive, the system likely relies on ISRs for accurate edge/crossing capture rather than polling. That means isrs.cpp is part of the real-time layer, while calculations.cpp and diagnostics.cpp run in the less time-critical foreground loop.
7. The project has both firmware and hardware design artifacts. The Schematic/ folder contains an Eagle board and schematic named AC Motor Control Shield, indicating the electronics are intended as an Arduino shield. This matters architecturally because the firmware assumptions are tightly coupled to the shield’s pinout and signal conditioning circuits.
8. The system boundary is mostly local and embedded: no network stack, database, or cloud service is present. External dependencies are limited to the Arduino runtime environment and the PID library mentioned in the readme.
9. From a diagramming perspective, the major blocks to draw are:
- human/operator inputs: pot and optional PWM source,
- sensing inputs: optical RPM sensor and LM135 temperature sensor,
- embedded controller: Arduino firmware with interrupts, calculation, diagnostics, and PID,
- power stage: zero-cross circuit and triac,
- outputs: motor speed and LCD status display.
10. The repository is also historical and development-oriented: the readme says the Eagle shield layout was added for development in 2013. So the hardware design files are not just documentation; they are part of the implementation boundary for the controller.
Main entry points: AC Motor Control Shield.sch Shield PCB · RPM_TEST_main.cpp Main · calculations.cpp Math · startup.cpp Startup
Components 16
Firmware
Arduino-style motor-control runtime
- Main · Top-level orchestration and control loop
RPM_TEST/source/RPM_TEST_main.cpp - Startup · Pins, timers, peripherals, and interrupts setup
RPM_TEST/source/startup.cpp - ISRs · Interrupt handlers for RPM and AC timing events
RPM_TEST/source/isrs.cpp - Math · RPM, temperature, and PID-related calculations
RPM_TEST/source/calculations.cpp - Display · LCD output and diagnostic reporting
RPM_TEST/source/diagnostics.cpp - Shared API · Shared declarations and configuration across modules
RPM_TEST/source/rpm_test_main.h - PID lib · PID control library used by the firmware
Hardware
Shield schematic and power/sensing circuits
- Pot Input · 10K potentiometer target-speed input
- PWM Input · Optional external PWM setpoint source, e.g. Mach3
- RPM Sensor · Reflective optical sensor for motor speed feedback
- Temp Sensor · Temperature measurement for thermal feedback
- LCD · Local display for RPM and temperature
- Zero Cross · Zero-crossing detection for AC phase control
- Triac Stage · AC power switching stage driving the motor
- Motor · AC motor being regulated
- Shield PCB · Arduino shield schematic and board layout
Schematic/AC Motor Control Shield.sch
Connections 24
- Pot Input → Main: setpoint · Manual speed command
- PWM Input → Main: setpoint · External speed command
- RPM Sensor → ISRs: pulses · Speed feedback timing edges
- Temp Sensor → Math: reading · Temperature measurement input
- ISRs → Math: timing data · Captured pulse and phase timing data
- Math → Main: feedback · Computed RPM, temperature, and control output
- Main → Triac Stage: drive · Actuation command to power stage
- Zero Cross → ISRs: crossings · AC phase reference events
- Triac Stage → Motor: power · Controlled AC delivery to the motor
- Math → LCD: status · Current RPM and temperature display values
- Main → Display: reporting · Foreground diagnostics and UI updates
- Startup → ISRs: configures · Interrupt and timing setup
- Startup → Zero Cross: enables · Zero-cross sensing initialization
- Startup → RPM Sensor: enables · RPM sensor initialization
- Startup → Temp Sensor: enables · Temperature input initialization
- Shared API → Main: declares · Shared interfaces for the application
- PID lib → Math: control law · PID logic used in calculations
- Shield PCB → Pot Input: contains · Shield hardware includes the potentiometer input
- Shield PCB → PWM Input: supports · Shield/interface accommodates external PWM input
- Shield PCB → RPM Sensor: routes · Sensor interface and conditioning on the shield
- Shield PCB → Temp Sensor: routes · LM135 conditioning on the shield
- Shield PCB → Zero Cross: routes · Zero-cross detection circuitry on the shield
- Shield PCB → Triac Stage: hosts · Triac power-control circuitry on the shield
- Shield PCB → LCD: supports · Local display interfacing