dmc4000

package
v0.42.0-rc0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package dmc4000 implements stepper motors behind a Galil DMC4000 series motor controller

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMotor

func NewMotor(ctx context.Context, c *Config, name resource.Name, logger logging.Logger) (motor.Motor, error)

NewMotor returns a DMC4000 driven motor.

Types

type Config

type Config struct {
	resource.TriviallyValidateConfig
	DirectionFlip    bool    `json:"dir_flip,omitempty"` // Flip the direction of the signal sent if there is a Dir pin
	MaxRPM           float64 `json:"max_rpm,omitempty"`
	MaxAcceleration  float64 `json:"max_acceleration_rpm_per_sec,omitempty"`
	TicksPerRotation int     `json:"ticks_per_rotation"`
	SerialDevice     string  `json:"serial_path"`     // path to /dev/ttyXXXX file
	Axis             string  `json:"controller_axis"` // A-H
	HomeRPM          float64 `json:"home_rpm"`        // Speed for Home()

	// Set the per phase current (when using stepper amp)
	// https://www.galil.com/download/comref/com4103/index.html#amplifier_gain.html
	AmplifierGain int `json:"amplifier_gain"`
	// Can reduce current when holding
	// https://www.galil.com/download/comref/com4103/index.html#low_current_stepper_mode.html
	LowCurrent int `json:"low_current"`

	// TestChan is a fake "serial" path for test use only
	TestChan chan string `json:"-"`
}

Config adds DMC-specific config options.

type Motor

type Motor struct {
	resource.Named
	resource.AlwaysRebuild

	Axis             string
	TicksPerRotation int

	MaxAcceleration float64
	HomeRPM         float64
	// contains filtered or unexported fields
}

Motor is a single axis/motor/component instance.

func (*Motor) Close

func (m *Motor) Close(ctx context.Context) error

Close stops the motor and marks the axis inactive.

func (*Motor) DoCommand

func (m *Motor) DoCommand(ctx context.Context, cmd map[string]interface{}) (map[string]interface{}, error)

DoCommand executes additional commands beyond the Motor{} interface.

func (*Motor) GoFor

func (m *Motor) GoFor(ctx context.Context, rpm, revolutions float64, extra map[string]interface{}) error

GoFor instructs the motor to go in a specific direction for a specific amount of revolutions at a given speed in revolutions per minute. Both the RPM and the revolutions can be assigned negative values to move in a backwards direction. Note: if both are negative the motor will spin in the forward direction.

func (*Motor) GoTo

func (m *Motor) GoTo(ctx context.Context, rpm, position float64, extra map[string]interface{}) error

GoTo instructs the motor to go to a specific position (provided in revolutions from home/zero), at a specific speed. Regardless of the directionality of the RPM this function will move the motor towards the specified target/position.

func (*Motor) Home

func (m *Motor) Home(ctx context.Context) error

Home runs the dmc homing routine.

func (*Motor) IsMoving

func (m *Motor) IsMoving(ctx context.Context) (bool, error)

IsMoving returns whether or not the motor is currently moving.

func (*Motor) IsPowered

func (m *Motor) IsPowered(ctx context.Context, extra map[string]interface{}) (bool, float64, error)

IsPowered returns whether or not the motor is currently moving.

func (*Motor) Jog

func (m *Motor) Jog(ctx context.Context, rpm float64) error

Jog moves indefinitely at the specified RPM.

func (*Motor) Position

func (m *Motor) Position(ctx context.Context, extra map[string]interface{}) (float64, error)

Position reports the position in revolutions.

func (*Motor) Properties

func (m *Motor) Properties(ctx context.Context, extra map[string]interface{}) (motor.Properties, error)

Properties returns the additional properties supported by this motor.

func (*Motor) ResetZeroPosition

func (m *Motor) ResetZeroPosition(ctx context.Context, offset float64, extra map[string]interface{}) error

ResetZeroPosition defines the current position to be zero (+/- offset).

func (*Motor) SetPower

func (m *Motor) SetPower(ctx context.Context, powerPct float64, extra map[string]interface{}) error

SetPower instructs the motor to go in a specific direction at a percentage of power between -1 and 1. Scaled to MaxRPM.

func (*Motor) SetRPM added in v0.29.0

func (m *Motor) SetRPM(ctx context.Context, rpm float64, extra map[string]interface{}) error

SetRPM instructs the motor to move at the specified RPM indefinitely.

func (*Motor) Stop

func (m *Motor) Stop(ctx context.Context, extra map[string]interface{}) error

Stop turns the power to the motor off immediately, without any gradual step down.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL