Fixes #6: Motor doesn't stop when compressor stopped #7

Closed
namcho wants to merge 15 commits from bugfix/issue-6-motor-not-stopping into main
Owner

User Request: Motor doesn't stop when compressor stopped - motor speed stays at ~1500 RPM instead of dropping to 0

Main Agent Assessment: Bug

Changes Made:

  • Modified - Added in

Root Cause: When stop() was called via API, the physics engine's load_factor was never set to 0. The state machine transitioned to OFF but the physics kept running with the previous load_factor (e.g., 0.8).

Verification: All 183 unit tests pass.

Closes #6

**User Request:** Motor doesn't stop when compressor stopped - motor speed stays at ~1500 RPM instead of dropping to 0 **Main Agent Assessment:** Bug **Changes Made:** - Modified - Added in **Root Cause:** When stop() was called via API, the physics engine's load_factor was never set to 0. The state machine transitioned to OFF but the physics kept running with the previous load_factor (e.g., 0.8). **Verification:** All 183 unit tests pass. Closes #6
- Add modbus_server.py with base class using pymodbus
- Add modbus_rtu.py for serial RTU server
- Add modbus_tcp.py for TCP server
- Add modbus_commands.py with write handlers for registers 100-112
- Add unit tests (43 tests passing)
- Float values use IEEE 754 big-endian encoding
- State values map to CompressorState enum (0-9)
- Support callbacks for start/stop/alarm_reset/emergency_stop
- Motor speed now correctly uses slip formula: speed = synchronous_speed * (1 - slip)
- Light load = less slip = higher speed (closer to 1500 RPM)
- Heavy load = more slip = lower speed (e.g., 1470 RPM at rated load)
- Star mode voltage limits torque, not speed
- Updated test to expect correct slip-based behavior
- Added CCS3200 parameters to config (P002-P032, P226-P227):
  - Idle Pressure, Onload Pressure
  - Star Duration, Delta Transfer Time
  - Preheat Onload/Idle Time
  - Idle Working Time, Auto Waiting Delay
  - Working Mode, Idle Time S/D
- Updated PressureController with CCS3200 logic:
  - Uses idle_pressure_bar and onload_pressure_bar
  - Added auto_waiting_delay and idle_time_sd for energy saving
  - Returns STOP action for automatic mode
- Updated control.py to use new PressureController API
- All 183 tests passing
When stop() was called via API, the physics engine's load_factor
was never set to 0. The state machine transitioned to OFF but the
physics kept running with the previous load_factor (e.g., 0.8).

Fix: Added physics.set_load_factor(0) in CompressorEmulator.stop()
before setting _running=False.
Author
Owner

Issued fixed, TESTED by Namcho.

Issued fixed, TESTED by Namcho.
namcho closed this pull request 2026-03-21 20:27:21 +01:00

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
namcho/compressor-emulator!7
No description provided.