Skip to content

feat: add Leadshine DM2J stepper motor driver#2

Open
ZiWei09 wants to merge 1 commit into
mainfrom
feat/leadshine-dm2j-driver
Open

feat: add Leadshine DM2J stepper motor driver#2
ZiWei09 wants to merge 1 commit into
mainfrom
feat/leadshine-dm2j-driver

Conversation

@ZiWei09
Copy link
Copy Markdown
Owner

@ZiWei09 ZiWei09 commented Apr 9, 2026

Summary

  • Add Leadshine (雷赛) DM2J series integrated stepper motor driver (unilabos/devices/motor/leadshine_dm2j.py)
  • Add motor device registry YAML with DM2J and ZDT X42 definitions (unilabos/registry/devices/motor.yaml)
  • RS485 Modbus RTU communication via pymodbus, supporting position control (PR immediate trigger), speed control (JOG), homing, enable/disable, position read/clear, and alarm management

Details

The DM2J driver supports models: DM2J-RS522 / RS542 / RS556 / RS570

Key design decisions:

  • Position control: Uses PR path 0 immediate trigger mode (write 8 registers to 0x6200-0x6207) for maximum flexibility
  • Speed control: Uses RS485 JOG commands with a background keepalive thread (40ms interval, manual requires <50ms)
  • Serial defaults: Even parity + 2 stop bits to match factory configuration (configurable)
  • Thread safety: All Modbus R/W protected by RLock; background polling for status/position

Test plan

  • Verify Python syntax: python -c "import ast; ast.parse(open('unilabos/devices/motor/leadshine_dm2j.py').read())"
  • Verify YAML: python -c "import yaml; yaml.safe_load(open('unilabos/registry/devices/motor.yaml'))"
  • Hardware test with DM2J-RS542: run python unilabos/devices/motor/leadshine_dm2j.py
  • Verify Uni-Lab-OS integration: configure experiment with motor.leadshine_dm2j device type

🤖 Generated with Claude Code

Add driver for Leadshine (雷赛) DM2J series integrated stepper motor
controllers. Communicates via RS485 using standard Modbus RTU protocol.

Features:
- Position control via PR immediate trigger mode
- Speed control via JOG with background keepalive thread
- Homing, enable/disable, position read/clear, alarm management
- Background polling for status and position updates
- Thread-safe Modbus communication with pymodbus

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant