Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lifting-motor

Rust driver for the ADORA lifting (leadscrew) motor.

The motor speaks a Modbus-RTU-like protocol over a serial port (/dev/ttyACM0 @ 19200 baud) or over UDP (192.168.1.30:1232, Ethernet gateway). The crate provides both a library API and a standalone CLI.

Usage

As a library

use lifting_motor::{LiftingMotor, UdpTransport};

let transport = UdpTransport::open("192.168.1.30", 1232)?;
let mut motor = LiftingMotor::new(transport);
motor.init()?;                 // enable Modbus, enable motor, set speed/accel
motor.set_position_mm(500.0)?; // move to 500 mm
motor.set_position_mm(0.0)?;   // ALWAYS home to zero on first use!

As a CLI

# UDP gateway mode
lifting-motor --mode udp read
lifting-motor --mode udp pos 500
lifting-motor --mode udp zero

# Serial mode
sudo chmod 777 /dev/ttyACM0
lifting-motor --mode serial --serial-port /dev/ttyACM0 watch 90

# Interactive shell (run `init`, `read`, `pos <mm>`, `zero`, `quit`)
lifting-motor --mode udp

Position window (environment variables)

Millimetre commands are clamped to a configurable window before being sent: values below the minimum go to the minimum, values above the maximum go to the maximum. Defaults: min 250 mm, max 700 mm.

Variable Meaning Default
LIFTING_MOTOR_MIN_MM lower bound of the position window 250
LIFTING_MOTOR_MAX_MM upper bound of the position window 700
LIFTING_MOTOR_MIN_MM=100 LIFTING_MOTOR_MAX_MM=600 lifting-motor --mode udp pos 800
# 800 -> clamped to 600 mm

Programmatically, use [LiftingMotor::with_position_limits].

Motor characteristics

Parameter Value
Supply voltage 24 V
Encoder counts per revolution 32768
Screw travel per revolution 0.63636364 mm
Stroke 700 mm (1100 revolutions, raw limit 36044800)

Position conversions truncate towards zero, matching the behaviour of the np.int32(...) / int(...) conversions used in the original tooling.

Protocol

  • Frame layout: [slave 0x01, function, data..., crc_hi, crc_lo]
  • 0x03 read registers (0x0016, 2 words) → global position
  • 0x7B set absolute position (signed 32-bit big endian)
  • 0x06 write register for initialization:
    • 00 00 enable Modbus
    • 00 01 enable motor
    • 00 03 13 88 acceleration 5000
    • 00 02 05 DC speed 1500

The CRC is always computed dynamically as standard Modbus CRC16 (e.g. 01 06 00 01 00 0119 CA); nothing is hardcoded.

Building for the Jetson Orin (aarch64)

Cross compiling requires a sysroot providing libudev for the target; the simplest and most reliable option is to build directly on the Jetson:

cargo build --release
./target/release/lifting-motor --mode serial read

See .cargo/config.toml for the optional cross-compile setup.

Safety

  • First use: always send position 0 first and verify the screw is at the zero point (closest to the chassis/motor side) before any motion.
  • The motor runs at 24 V with a 700 mm stroke; software clamping is the only protection, there are no physical limit switches.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages