Skip to main content

A Python library for controlling the Cytron SmartDriveDuo 30A motor controller

Project description

SmartDriveDuo Python Library

A Python library for controlling the Cytron SmartDriveDuo 30A motor controller.

Installation

  1. Install the required dependencies:
pip install -r requirements.txt

Usage

Here's a basic example of how to use the library:

from smartdriveduo import SmartDriveDuo

# Initialize the motor controller
# You can specify a different port and baudrate if needed
motor = SmartDriveDuo(port="/dev/ttyUSB0", baudrate=115200)

try:
    # Control both motors together
    motor.set_motors(speed=50)  # Set both motors to 50% speed forward
    time.sleep(2)
    
    # Control individual motors
    motor.set_left(speed=30)  # Set left motor to 30% speed forward
    motor.set_right(speed=40, direction=True)  # Set right motor to 40% speed reverse
    time.sleep(2)
    
    # Control both motors separately
    motor.set_motors_mixed(
        left_speed=40,
        right_speed=50,
        left_direction=False,
        right_direction=True
    )
    time.sleep(2)
    
    # Stop the motors
    motor.stop()
    
finally:
    # Always close the connection when done
    motor.close()

Features

  • Control both motors simultaneously or individually
  • Set motor speed (0-63)
  • Control motor direction (forward/reverse)
  • Automatic speed range validation
  • Clean connection handling

Methods

  • set_motors(speed, direction=False): Control both motors together
  • set_motors_separate(left_speed, right_speed, left_direction=False, right_direction=False): Control both motors with separate speeds and directions
  • set_left(speed, direction=False): Control the left motor
  • set_right(speed, direction=False): Control the right motor
  • stop(): Stop both motors
  • close(): Close the serial connection

Notes

  • Speed values are automatically clamped to the valid range (0-63)
  • Direction is False for forward, True for reverse
  • Always call close() when you're done to properly clean up the connection

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smartdriveduo-1.0.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smartdriveduo-1.0.0-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file smartdriveduo-1.0.0.tar.gz.

File metadata

  • Download URL: smartdriveduo-1.0.0.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for smartdriveduo-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e82a4b7297d20bb0e526610e4ecebc472ea6b9f871cef31ad21b8038f9ef92ce
MD5 d72ccedd0d3063f6709b945efc221dfd
BLAKE2b-256 65f33dc450c0d948015f82bc083ffb1cab416b6bfaf59c93bd995732ba7627f1

See more details on using hashes here.

File details

Details for the file smartdriveduo-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: smartdriveduo-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for smartdriveduo-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1fdba6bf950cfd563ccf5f2f9fd2e27228aa42941a8d816c579307d7bcb78012
MD5 c30b18475f28e61c08ea98c5de1040b8
BLAKE2b-256 fc517afa5072c7dfa20a2a62125fd0715248ba51d4706a437d6d481e5a2227d6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page