DMC4000 | Motor Component

DMC4000

Note

A private module exists that supports the DMC4000 motor controller. If you would like to use this controller with Viam, contact Viam support.

The DMC4000 model supports stepper motors controlled by DMC-40x0 series motion controllers.

Whereas a basic low-level stepper driver supported by the gpiostepper model sends power to a stepper motor based on PWM signals from GPIO pins, the DMC40x0 motion controller has many motion control features. When using it, you do not need to configure a board component because it handles computation and signal creation on the motion controller itself.

The DMC-40x0 controller can drive a variety of motor types, but the built-in Viam implementation supports only stepper motors at this time. You can drive other types of motors with Viam and the DMC-40x0 controller by creating a modular resource to add support for it.

{
  "components": [
    {
      "name": "<your-motor-name>",
      "model": "DMC4000",
      "api": "rdk:component:motor",
      "attributes": {
        "amplifier_gain": <int>,
        "low_current": <int>,
        "ticks_per_rotation": <int>,
        "serial_path": "<string>",
        "controller_axis": "<your-motion-controller-axis-label>",
        "home_rpm": <int>,
        "max_rpm": <float>,
        "max_acceleration_rpm_per_sec": <float>
      },
      "depends_on": []
    }
  ]
}

Example configuration for a stepper motor controlled by a DMC-40x0 motion controller:

{
  "components": [
    {
      "name": "my-dmc-motor",
      "model": "DMC4000",
      "api": "rdk:component:motor",
      "attributes": {
        "amplifier_gain": 3,
        "low_current": 1,
        "ticks_per_rotation": 200,
        "serial_path": "/dev/serial/by-path/usb-0:1.1:1.0",
        "controller_axis": "A",
        "home_rpm": 70,
        "max_rpm": 300
      },
      "depends_on": []
    }
  ]
}

The "serial_path" filepath used in this example is specific to serial devices connected to Linux systems. The "serial_path" filepath on a macOS system might resemble "/dev/ttyUSB0" or "/dev/ttyS0".

The following attributes are available for DMC4000 motors:

Name Type Required? Description
amplifier_gain int Required Set the per phase current (when using stepper amp).
low_current int Required Reduce the hold current.
ticks_per_rotation int Required Number of full steps in a rotation. 200 (equivalent to 1.8 degrees per step) is very common. If your data sheet specifies this in terms of degrees per step, divide 360 by that number to get ticks per rotation.
serial_path string Optional The full filesystem path to the serial device, starting with /dev/. To find your serial device path, first connect the serial device to your machine, then:
- On Linux, run ls /dev/serial/by-path/* to show connected serial devices, or look for your device in the output of `sudo dmesg
controller_axis string Required Physical port label (A-H); select which “axis” the motor is wired to on the controller.
home_rpm int Required Set speed in revolutions per minute (RPM) that the motor will turn when executing a Home() command (using DoCommand()).
dir_flip bool Optional Flip the direction of the signal sent if there is a DIR pin.
max_rpm float Optional Set a limit on maximum revolutions per minute that the motor can be run at.
max_acceleration_rpm_per_sec float Optional Set the maximum revolutions per minute (RPM) per second acceleration limit.

Refer to your motor and motor driver data sheets for specifics.

Extended API

The DMC4000 model supports additional methods that are not part of the standard Viam motor API:

Home

Run the DMC homing routine.

Parameters:

Raises:

For more information on do_command, see the Python SDK Docs.

my_motor = Motor.from_robot(robot=robot, name='my_motor')

# Home the motor
home_dict = {
  "command": "home"
}
await my_motor.do_command(home_dict)

Parameters:

Returns:

For more information, see the Go SDK docs on Home and on DoCommand.

// Home the motor
resp, err := myMotorComponent.DoCommand(ctx, map[string]interface{}{"command": "home"})

Jog

Move the motor indefinitely at the specified RPM.

Parameters:

Raises:

my_motor = Motor.from_robot(robot=robot, name='my_motor')

# Run the motor indefinitely at 70 rpm
jog_dict = {
  "command": "jog",
  "rpm": 70
}
await my_motor.do_command(jog_dict)

Parameters:

Returns:

For more information on the Go SDK Docs on Jog and on DoCommand.

// Run the motor indefinitely at 70 rpm
resp, err := myMotorComponent.DoCommand(ctx, map[string]interface{}{"command": "jog", "rpm": 70})

Raw

Send raw string commands to the controller.

Parameters:

Raises:

my_motor = Motor.from_robot(robot=robot, name='my_motor')

raw_dict = {
  "command": "raw",
  "raw_input": "home"
}
await my_motor.do_command(raw_dict)

Parameters:

Returns:

For more information, see the Go SDK Docs on Raw and on DoCommand.

resp, err := myMotorComponent.DoCommand(ctx, map[string]interface{}{"command": "jog", "raw_input": "home"})