tic

package
v3.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package tic interfaces with Tic Stepper Motor Controllers via I²C.

More Details

See https://www.pololu.com/category/212/tic-stepper-motor-controllers for more details about the device range.

Product Pages

Tic T500: https://www.pololu.com/product/3134

Tic T834: https://www.pololu.com/product/3132

Tic T825: https://www.pololu.com/product/3130

Tic T249: https://www.pololu.com/product/3138

Tic 36v4: https://www.pololu.com/product/3140

Example
// Make sure periph is initialized.
if _, err := host.Init(); err != nil {
	log.Fatal(err)
}

// Open default I²C bus.
bus, err := i2creg.Open("")
if err != nil {
	log.Fatalf("failed to open I²C: %v", err)
}
defer bus.Close()

// Create a new motor controller.
dev, err := tic.NewI2C(bus, tic.Tic36v4, tic.I2CAddr)
if err != nil {
	log.Fatal(err)
}

// Set the current limit with respect to the motor.
if err := dev.SetCurrentLimit(1000 * physic.MilliAmpere); err != nil {
	log.Fatalf("failed to set current limit: %v", err)
}

// The "Exit safe start" command is required before the motor can move.
if err := dev.ExitSafeStart(); err != nil {
	log.Fatalf("failed to exit safe start: err %v", err)
}

// Set the target velocity to 200 microsteps per second.
if err := dev.SetTargetVelocity(2000000); err != nil {
	log.Fatalf("failed to set target velocity: err %v", err)
}

// Use a ticker to frequently send commands before the timeout period
// elapses (1000ms default).
ticker := time.NewTicker(900 * time.Millisecond)
defer ticker.Stop()

// Stop after 3 seconds.
stop := time.After(3 * time.Second)

for {
	select {
	case <-stop:
		return
	case <-ticker.C:
		// Any command sent to the Tic will reset the timeout. However,
		// this can be done explicitly using ResetCommandTimeout().
		if err := dev.ResetCommandTimeout(); err != nil {
			log.Fatalf("failed to reset command timeout: %v", err)
		}
	}
}
Output:

Index

Examples

Constants

View Source
const (
	ResetCausePowerUp        = 0
	ResetCauseBrownout       = 1
	ResetCauseResetLine      = 2
	ResetCauseWatchdog       = 4
	ResetCauseSoftware       = 8
	ResetCauseStackOverflow  = 16
	ResetCauseStackUnderflow = 32
)
View Source
const (
	OffsetOperationState        offset = 0x00 // uint8 return type
	OffsetMiscFlags1            offset = 0x01 // uint8 return type
	OffsetErrorStatus           offset = 0x02 // uint16 return type
	OffsetErrorsOccurred        offset = 0x04 // uint32 return type
	OffsetPlanningMode          offset = 0x09 // uint8 return type
	OffsetTargetPosition        offset = 0x0A // int32 return type
	OffsetTargetVelocity        offset = 0x0E // int32 return type
	OffsetStartingSpeed         offset = 0x12 // uint32 return type
	OffsetSpeedMax              offset = 0x16 // uint32 return type
	OffsetDecelMax              offset = 0x1A // uint32 return type
	OffsetAccelMax              offset = 0x1E // uint32 return type
	OffsetCurrentPosition       offset = 0x22 // int32 return type
	OffsetCurrentVelocity       offset = 0x26 // int32 return type
	OffsetActingTargetPosition  offset = 0x2A // int32 return type
	OffsetTimeSinceLastStep     offset = 0x2E // uint32 return type
	OffsetDeviceReset           offset = 0x32 // uint8 return type
	OffsetVoltageIn             offset = 0x33 // uint16 return type
	OffsetUpTime                offset = 0x35 // uint32 return type
	OffsetEncoderPosition       offset = 0x39 // int32 return type
	OffsetRCPulseWidth          offset = 0x3D // uint16 return type
	OffsetAnalogReadingSCL      offset = 0x3F // uint16 return type
	OffsetAnalogReadingSDA      offset = 0x41 // uint16 return type
	OffsetAnalogReadingTX       offset = 0x43 // uint16 return type
	OffsetAnalogReadingRX       offset = 0x45 // uint16 return type
	OffsetDigitalReadings       offset = 0x47 // uint8 return type
	OffsetPinStates             offset = 0x48 // uint8 return type
	OffsetStepMode              offset = 0x49 // uint8 return type
	OffsetCurrentLimit          offset = 0x4A // uint8 return type
	OffsetDecayMode             offset = 0x4B // uint8 return type
	OffsetInputState            offset = 0x4C // uint8 return type
	OffsetInputAfterAveraging   offset = 0x4D // uint16 return type
	OffsetInputAfterHysteresis  offset = 0x4F // uint16 return type
	OffsetInputAfterScaling     offset = 0x51 // uint16 return type
	OffsetLastMotorDriverError  offset = 0x55 // uint8 return type
	OffsetAGCMode               offset = 0x56 // uint8 return type
	OffsetAGCBottomCurrentLimit offset = 0x57 // uint8 return type
	OffsetAGCCurrentBoostSteps  offset = 0x58 // uint8 return type
	OffsetAGCFrequencyLimit     offset = 0x59 // uint8 return type
	OffsetLastHPDriverErrors    offset = 0xFF // uint8 return type
)
View Source
const I2CAddr uint16 = 0x0E

I2CAddr is the default I²C address for the Tic.

View Source
const InputNull uint16 = 0xFFFF

InputNull represents a null or missing value for some of the Tic's 16-bit input variables.

Variables

View Source
var (
	// ErrConnectionFailed is returned when the driver fails to connect.
	ErrConnectionFailed = errors.New("failed to connect to Tic")

	// ErrInvalidSetting is returned when you provide an invalid value.
	ErrInvalidSetting = errors.New("invalid setting")

	// ErrUnsupportedVariant is returned when a method or setting isn't
	// supported by the Tic variant.
	ErrUnsupportedVariant = errors.New("invalid command for Tic variant")

	// ErrIncorrectPlanningMode is returned when you call a method that isn't
	// compatible with the Tic's current planning mode.
	ErrIncorrectPlanningMode = errors.New("incorrect planning mode")
)

Functions

This section is empty.

Types

type AGCBottomCurrentLimit

type AGCBottomCurrentLimit uint8

AGCBottomCurrentLimit describes the possible Active Gain Control bottom current limit percentages.

const (
	AGCBottomCurrentLimitP45 AGCBottomCurrentLimit = 0
	AGCBottomCurrentLimitP50 AGCBottomCurrentLimit = 1
	AGCBottomCurrentLimitP55 AGCBottomCurrentLimit = 2
	AGCBottomCurrentLimitP60 AGCBottomCurrentLimit = 3
	AGCBottomCurrentLimitP65 AGCBottomCurrentLimit = 4
	AGCBottomCurrentLimitP70 AGCBottomCurrentLimit = 5
	AGCBottomCurrentLimitP75 AGCBottomCurrentLimit = 6
	AGCBottomCurrentLimitP80 AGCBottomCurrentLimit = 7
)

type AGCCurrentBoostSteps

type AGCCurrentBoostSteps uint8

AGCCurrentBoostSteps describes the possible Active Gain Control current boost steps values.

const (
	AGCCurrentBoostStepsS5  AGCCurrentBoostSteps = 0
	AGCCurrentBoostStepsS7  AGCCurrentBoostSteps = 1
	AGCCurrentBoostStepsS9  AGCCurrentBoostSteps = 2
	AGCCurrentBoostStepsS11 AGCCurrentBoostSteps = 3
)

type AGCFrequencyLimit

type AGCFrequencyLimit uint8

AGCFrequencyLimit describes the possible Active Gain Control frequency limit values.

const (
	AGCFrequencyLimitOff    AGCFrequencyLimit = 0
	AGCFrequencyLimitF225Hz AGCFrequencyLimit = 1
	AGCFrequencyLimitF450Hz AGCFrequencyLimit = 2
	AGCFrequencyLimitF675Hz AGCFrequencyLimit = 3
)

type AGCMode

type AGCMode uint8

AGCMode describes possible Active Gain Control modes.

const (
	AGCModeOff       AGCMode = 0
	AGCModeOn        AGCMode = 1
	AGCModeActiveOff AGCMode = 2
)

type DecayMode

type DecayMode uint8

DecayMode describes the possible decay modes. These are valid for the Tic T825, T834 and 36v4 only.

const (
	// DecayModeMixed specifies "Mixed" decay mode on the Tic T825 and
	// "Mixed 50%" on the Tic T834.
	DecayModeMixed DecayMode = 0
	// DecayModeSlow specifies "Slow" decay mode.
	DecayModeSlow DecayMode = 1
	// DecayModeFast specifies "Fast" decay mode.
	DecayModeFast DecayMode = 2
	// DecayModeMixed50 is the same as Mixed, but better expresses your
	// intent if you want to use "Mixed 50%" mode on a Tic T834.
	DecayModeMixed50 DecayMode = 0
	// DecayModeMixed25 specifies "Mixed 25%" decay mode on the Tic T834 and
	// is the same as Mixed on the Tic T825.
	DecayModeMixed25 DecayMode = 3
	// This specifies "Mixed 75%" decay mode on the Tic T834 and is the same as
	// Mixed on the Tic T825.
	DecayModeMixed75 DecayMode = 4
)

type Dev

type Dev struct {
	// contains filtered or unexported fields
}

Dev is a handle to a Tic motor controller device.

func NewI2C

func NewI2C(b i2c.Bus, variant Variant, addr uint16) (*Dev, error)

NewI2C returns an object that communicates with a Tic motor controller over I²C.

The default address is tic.I2CAddr.

func (*Dev) ClearDriverError

func (d *Dev) ClearDriverError() error

ClearDriverError attempts to clear a motor driver error.

This function sends a "Clear driver error" command to the Tic. For more information, see the Tic user's guide.

func (*Dev) Deenergize

func (d *Dev) Deenergize() error

Deenergize de-energizes the stepper motor coils.

This function sends a De-energize command to the Tic, causing it to disable its stepper motor driver. The motor will stop moving and consuming power. The Tic will set the "Intentionally de-energized" error bit, turn on its red LED, and drive its ERR line high. This command also sets the "Position uncertain" flag (because the Tic is no longer in control of the motor's position).

Note that the Energize command, which can be sent with Energize(), will undo the effect of this command (except it will leave the "Position uncertain" flag set) and could make the system start up again.

func (*Dev) Energize

func (d *Dev) Energize() error

Energize sends the Energize command.

This function sends an Energize command to the Tic, clearing the "Intentionally de-energized" error bit. If there are no other errors, this allows the system to start up.

func (*Dev) EnterSafeStart

func (d *Dev) EnterSafeStart() error

EnterSafeStart sends the "Enter safe start" command.

This command has no effect if safe-start is disabled in the Tic's settings.

This command causes the Tic to stop the motor and set its safe start violation error bit. An "Exit safe start" command is required before the Tic will move the motor again.

See the Tic user's guide for information about what this command does in the other control modes.

func (*Dev) ExitSafeStart

func (d *Dev) ExitSafeStart() error

ExitSafeStart sends the "Exit safe start" command.

This command causes the safe start violation error to be cleared for 200 ms. If there are no other errors, this allows the system to start up.

func (*Dev) GetAGCBottomCurrentLimit

func (d *Dev) GetAGCBottomCurrentLimit() (AGCBottomCurrentLimit, error)

GetAGCBottomCurrentLimit gets the Active Gain Control bottom current limit.

This is only valid for the Tic T249.

func (*Dev) GetAGCCurrentBoostSteps

func (d *Dev) GetAGCCurrentBoostSteps() (AGCCurrentBoostSteps, error)

GetAGCCurrentBoostSteps gets the Active Gain Control current boost steps.

This is only valid for the Tic T249.

func (*Dev) GetAGCFrequencyLimit

func (d *Dev) GetAGCFrequencyLimit() (AGCFrequencyLimit, error)

GetAGCFrequencyLimit gets the Active Gain Control frequency limit.

This is only valid for the Tic T249.

func (*Dev) GetAGCMode

func (d *Dev) GetAGCMode() (AGCMode, error)

GetAGCMode gets the Active Gain Control mode.

This is only valid for the Tic T249.

func (*Dev) GetActingTargetPosition

func (d *Dev) GetActingTargetPosition() (uint32, error)

GetActingTargetPosition gets the acting target position, in microsteps.

This is a variable used in the Tic's target position step planning algorithm, and it could be invalid while the motor is stopped.

This is mainly intended for getting insight into how the Tic's algorithms work or troubleshooting issues, and most people should not use this.

func (*Dev) GetAnalogReading

func (d *Dev) GetAnalogReading(pin Pin) (uint16, error)

GetAnalogReading gets the analog reading from the specified pin.

The reading is left-justified, so 0xFFFF represents a voltage equal to the Tic's 5V pin (approximately 4.8 V).

Returns tic.InputNull if the analog reading is disabled or not ready.

Example:

reading, err := dev.GetAnalogReading(tic.PinSDA)
if reading != tic.InputNull && reading < 32768 {
	// The reading is less than about 2.4 V.
}

func (*Dev) GetCurrentLimit

func (d *Dev) GetCurrentLimit() (physic.ElectricCurrent, error)

GetCurrentLimit gets the stepper motor coil current limit.

This is the value being used now, which could differ from the value in the Tic's settings.

func (*Dev) GetCurrentPosition

func (d *Dev) GetCurrentPosition() (int32, error)

GetCurrentPosition gets the current position of the stepper motor, in microsteps.

Note that this just tracks steps that the Tic has commanded the stepper driver to take, which could be different from the actual position of the motor.

func (*Dev) GetCurrentVelocity

func (d *Dev) GetCurrentVelocity() (int32, error)

GetCurrentVelocity gets the current velocity of the stepper motor, in microsteps per 10000 seconds.

Note that this is just the velocity used in the Tic's step planning algorithms, and it might not correspond to the actual velocity of the motor.

func (*Dev) GetDecayMode

func (d *Dev) GetDecayMode() (DecayMode, error)

GetDecayMode gets the current decay mode of the stepper motor driver.

Example:

mode, err := dev.GetDecayMode()
if mode == tic.DecayModeSlow {
 	// The Tic is in slow decay mode.
}

func (*Dev) GetDeviceReset

func (d *Dev) GetDeviceReset() (ResetCause, error)

GetDeviceReset gets the cause of the controller's last full microcontroller reset.

Example:

reset, err := dev.GetDeviceReset()
if reset == tic.ResetCauseBrownout {
	// There was a brownout reset - the power supply could not keep up.
}

The Reset command (Reset()) does not affect this variable.

func (*Dev) GetEncoderPosition

func (d *Dev) GetEncoderPosition() (int32, error)

GetEncoderPosition gets the raw encoder count measured from the Tic's RX and TX lines.

func (*Dev) GetErrorStatus

func (d *Dev) GetErrorStatus() (uint16, error)

GetErrorStatus gets the errors that are currently stopping the motor.

Each bit in the returned register represents a different error. The bits are defined by the tic.ErrorBit constants.

Example:

 status, err := dev.GetErrorStatus()
 if status&(1<<tic.ErrorBitLowVin) != 0 {
		// Handle loss of power.
	}

HasError may be used instead to check for specific errors.

func (*Dev) GetErrorsOccurred

func (d *Dev) GetErrorsOccurred() (uint32, error)

GetErrorsOccurred gets the errors that have occurred since the last time this function was called.

Note that the Tic Control Center constantly clears the bits in this register, so if you are running the Tic Control Center then you will not be able to reliably detect errors with this function.

Each bit in the returned register represents a different error. The bits are defined by the tic.Errorbit constants.

Example:

errors, err := dev.GetErrorsOccurred()
if errors&(1<<tic.ErrorBitMotorDriverError) != 0 {
	// Handle the motor driver error.
}

func (*Dev) GetInputAfterAveraging

func (d *Dev) GetInputAfterAveraging() (uint16, error)

GetInputAfterAveraging gets a variable used in the process that converts raw RC and analog values into a motor position or speed. This is mainly for debugging your input scaling settings in RC or analog mode.

A value of tic.InputNull means the input value is not available.

func (*Dev) GetInputAfterHysteresis

func (d *Dev) GetInputAfterHysteresis() (uint16, error)

GetInputAfterHysteresis gets a variable used in the process that converts raw RC and analog values into a motor position or speed. This is mainly for debugging your input scaling settings in RC or analog mode.

A value of tic.InputNull means the input value is not available.

func (*Dev) GetInputAfterScaling

func (d *Dev) GetInputAfterScaling() (int32, error)

GetInputAfterScaling gets the value of the Tic's main input after scaling has been applied.

If the input is valid, this number is the target position or target velocity specified by the input.

func (*Dev) GetInputState

func (d *Dev) GetInputState() (InputState, error)

GetInputState gets the current state of the Tic's main input.

Example:

state, err := dev.GetInputState()
if state == tic.InputStatePosition {
 	// The Tic's input is specifying a target position.
}

func (*Dev) GetLastHPDriverErrors

func (d *Dev) GetLastHPDriverErrors() (uint8, error)

GetLastHPDriverErrors gets the "Last HP driver errors" variable.

Each bit in this register represents an error. If the bit is 1, the error was one of the causes of the Tic's last motor driver error.

This is only valid for the Tic 36v4.

func (*Dev) GetLastMotorDriverError

func (d *Dev) GetLastMotorDriverError() (MotorDriverError, error)

GetLastMotorDriverError gets the cause of the last motor driver error.

This is only valid for the Tic T249.

func (*Dev) GetMaxAccel

func (d *Dev) GetMaxAccel() (uint32, error)

GetMaxAccel gets the maximum acceleration, in microsteps per second per 100 seconds.

This is the current value, which could differ from the value in the Tic's settings.

func (*Dev) GetMaxDecel

func (d *Dev) GetMaxDecel() (uint32, error)

GetMaxDecel gets the maximum deceleration, in microsteps per second per 100 seconds.

This is the current value, which could differ from the value in the Tic's settings.

func (*Dev) GetMaxSpeed

func (d *Dev) GetMaxSpeed() (uint32, error)

GetMaxSpeed gets the current maximum speed, in microsteps per 10000 seconds.

This is the current value, which could differ from the value in the Tic's settings.

func (*Dev) GetOperationState

func (d *Dev) GetOperationState() (OperationState, error)

GetOperationState gets the Tic's current operation state, which indicates whether it is operating normally or in an error state.

Example:

state, err := dev.GetOperationState()
if state != tic.OperationStateNormal {
	// There is an error, or the Tic is starting up.
}

For more information, see the "Error handling" section of the Tic user's guide.

func (*Dev) GetPinState

func (d *Dev) GetPinState(pin Pin) (PinState, error)

GetPinState gets the current state of a pin, i.e. what kind of input or output it is.

Note that the state might be misleading if the pin is being used as an I²C or serial pin.

Example:

state, err := dev.GetPinState(PinSCL)
if state == tic.PinStateOutputHigh {
	// SCL is driving high.
}

func (*Dev) GetPlanningMode

func (d *Dev) GetPlanningMode() (PlanningMode, error)

GetPlanningMode returns the current planning mode for the Tic's step generation code.

This tells us whether the Tic is sending steps, and if it is sending steps, tells us whether it is in Target Position or Target Velocity mode.

Example:

mode, err := dev.GetPlanningMode()
if mode == tic.PlanningModeTargetPosition {
	// The Tic is moving the stepper motor to a target position, or has
    // already reached it and is at rest.
}

func (*Dev) GetRCPulseWidth

func (d *Dev) GetRCPulseWidth() (uint16, error)

GetRCPulseWidth gets the raw pulse width measured on the Tic's RC input, in units of twelfths of a microsecond.

Returns tic.InputNull if the RC input is missing or invalid.

Example:

width, err := dev.GetRCPulseWidth()
if width != tic.InputNull && width > 1500*12 {
	// Pulse width is greater than 1500 microseconds.
}

func (*Dev) GetSetting

func (d *Dev) GetSetting(offset offset, length uint) ([]uint8, error)

GetSetting gets a contiguous block of settings from the Tic's EEPROM.

The maximum length that can be fetched is 15 bytes.

This library does not attempt to interpret the settings and say what they mean. If you are interested in how the settings are encoded in the Tic's EEPROM, see the "Settings reference" section of the Tic user's guide.

func (*Dev) GetStartingSpeed

func (d *Dev) GetStartingSpeed() (uint32, error)

GetStartingSpeed gets the starting speed in microsteps per 10000 seconds.

This is the current value, which could differ from the value in the Tic's settings.

func (*Dev) GetStepMode

func (d *Dev) GetStepMode() (StepMode, error)

GetStepMode gets the current step mode of the stepper motor.

Example:

mode, err := dev.GetStepMode()
if mode == tic.StepModeMicrostep8 {
 	// The Tic is currently using 1/8 microsteps.
}

func (*Dev) GetTargetPosition

func (d *Dev) GetTargetPosition() (int32, error)

GetTargetPosition gets the target position, in microsteps.

This is only possible if the planning mode from GetPlanningMode() is tic.PlanningModeTargetPosition.

func (*Dev) GetTargetVelocity

func (d *Dev) GetTargetVelocity() (int32, error)

GetTargetVelocity gets the target velocity, in microsteps per 10000 seconds.

The default step mode is 1 microstep = 1 full step.

This is only possible if the planning mode from GetPlanningMode() is tic.PlanningModeTargetVelocity.

func (*Dev) GetTimeSinceLastStep

func (d *Dev) GetTimeSinceLastStep() (uint32, error)

GetTimeSinceLastStep gets the time since the last step, in timer ticks.

Each timer tick represents one third of a microsecond. The Tic only updates this variable every 5 milliseconds or so, and it could be invalid while the motor is stopped.

This is mainly intended for getting insight into how the Tic's algorithms work or troubleshooting issues, and most people should not use this.

func (*Dev) GetUpTime

func (d *Dev) GetUpTime() (time.Duration, error)

GetUpTime gets the time since the last full reset of the Tic's microcontroller, in milliseconds.

A Reset command (Reset()) does not count.

func (*Dev) GetVoltageIn

func (d *Dev) GetVoltageIn() (physic.ElectricPotential, error)

GetVoltageIn gets the current measurement of the VIN voltage, in millivolts.

func (*Dev) GoHomeForward

func (d *Dev) GoHomeForward() error

GoHomeForward tells the Tic to start its homing procedure in the forward direction.

See the "Homing" section of the Tic user's guide for details.

func (*Dev) GoHomeReverse

func (d *Dev) GoHomeReverse() error

GoHomeReverse tells the Tic to start its homing procedure in the reverse direction.

See the "Homing" section of the Tic user's guide for details.

func (*Dev) Halt

func (d *Dev) Halt() error

Halt stops the motor abruptly without respecting the deceleration limit.

Halt implements conn.Resource.

func (*Dev) HaltAndHold

func (d *Dev) HaltAndHold() error

HaltAndHold stops the motor abruptly without respecting the deceleration limit.

This function sends a "Halt and hold" command to the Tic. Besides stopping the motor, this command also sets the "Position uncertain" flag (because the abrupt stop might cause steps to be missed), sets the "Input state" to "halt", and clears the "Input after scaling" variable.

func (*Dev) HaltAndSetPosition

func (d *Dev) HaltAndSetPosition(position int32) error

HaltAndSetPosition stops the motor abruptly without respecting the deceleration limit and sets the "Current position" variable, which represents where the Tic currently thinks the motor's output is.

This function sends a "Halt and set position" command to the Tic. Besides stopping the motor and setting the current position, this command also clears the "Position uncertain" flag, sets the "Input state" to "halt", and clears the "Input after scaling" variable.

func (*Dev) HasError

func (d *Dev) HasError(bit ErrorBit) (bool, error)

HasError returns true if the Tic is in the error state described by the given error bit.

Example:

 isLowVin, err := dev.HasError(tic.ErrorBitLowVin)
 if isLowVin {
		// Handle loss of power.
 }

func (*Dev) IsDigitalReading

func (d *Dev) IsDigitalReading(pin Pin) (bool, error)

IsDigitalReading gets a digital reading from the specified pin.

Returns true for high and false for low.

func (*Dev) IsEnergized

func (d *Dev) IsEnergized() (bool, error)

IsEnergized returns true if the motor driver is energized (trying to send current to its outputs).

func (*Dev) IsForwardLimitActive

func (d *Dev) IsForwardLimitActive() (bool, error)

IsForwardLimitActive returns true if one of the forward limit switches is active.

func (*Dev) IsHomingActive

func (d *Dev) IsHomingActive() (bool, error)

IsHomingActive returns true if the Tic's homing procedure is running.

func (*Dev) IsPositionUncertain

func (d *Dev) IsPositionUncertain() (bool, error)

IsPositionUncertain gets a flag that indicates whether there has been external confirmation that the value of the Tic's "Current position" variable is correct.

For more information, see the "Error handling" section of the Tic user's guide.

func (*Dev) IsReverseLimitActive

func (d *Dev) IsReverseLimitActive() (bool, error)

IsReverseLimitActive returns true if one of the reverse limit switches is active.

func (*Dev) Reset

func (d *Dev) Reset() error

Reset sends the Reset command.

This command makes the Tic forget most parts of its current state. For more information, see the Tic user's guide.

func (*Dev) ResetCommandTimeout

func (d *Dev) ResetCommandTimeout() error

ResetCommandTimeout prevents the "Command timeout" error from happening for some time.

The Tic's default command timeout period is 1000 ms, but it can be changed or disabled in the Tic Control Center.

This function sends a "Reset command timeout" command to the Tic.

func (*Dev) SetAGCBottomCurrentLimit

func (d *Dev) SetAGCBottomCurrentLimit(limit AGCBottomCurrentLimit) error

SetAGCBottomCurrentLimit sets the Active Gain Control bottom current limit.

This is only valid for the Tic T249.

func (*Dev) SetAGCCurrentBoostSteps

func (d *Dev) SetAGCCurrentBoostSteps(steps AGCCurrentBoostSteps) error

SetAGCCurrentBoostSteps sets the Active Gain Control current boost steps.

This is only valid for the Tic T249.

func (*Dev) SetAGCFrequencyLimit

func (d *Dev) SetAGCFrequencyLimit(limit AGCFrequencyLimit) error

SetAGCFrequencyLimit sets the Active Gain Control frequency limit.

This is only valid for the Tic T249.

func (*Dev) SetAGCMode

func (d *Dev) SetAGCMode(mode AGCMode) error

SetAGCMode sets the Active Gain Control mode.

This is only valid for the Tic T249.

func (*Dev) SetCurrentLimit

func (d *Dev) SetCurrentLimit(limit physic.ElectricCurrent) error

SetCurrentLimit sets the stepper motor coil current limit. If the desired current limit is not available, this function uses the closest current limit option that is lower than the desired one.

Example:

err := dev.SetCurrentLimit(500 * physic.MilliAmpere)

This command temporarily sets the stepper motor coil current limit of the driver. The provided value will override the corresponding setting from the Tic’s non-volatile memory until the next Reset command or power cycle.

This function sends a "Set current limit" command to the Tic. For more information about this command and how to choose a good current limit, see the Tic user's guide.

func (*Dev) SetDecayMode

func (d *Dev) SetDecayMode(mode DecayMode) error

SetDecayMode sets the stepper motor driver's decay mode.

Example:

err := dev.SetDecayMode(DecayModeSlow)

The decay modes are documented in the Tic user's guide.

func (*Dev) SetMaxAccel

func (d *Dev) SetMaxAccel(accel uint32) error

SetMaxAccel sets the maximum acceleration, in units of steps per second per 100 seconds.

Example:

err := dev.SetMaxAccel(10000) // 100 steps per second per second

This function sends a "Set max acceleration" command to the Tic. For more information, see the Tic user's guide.

func (*Dev) SetMaxDecel

func (d *Dev) SetMaxDecel(decel uint32) error

SetMaxDecel sets the maximum deceleration, in units of steps per second per 100 seconds.

Example:

err := dev.SetMaxDecel(10000) // 100 steps per second per second

This function sends a "Set max deceleration" command to the Tic. For more information, see the Tic user's guide.

func (*Dev) SetMaxSpeed

func (d *Dev) SetMaxSpeed(speed uint32) error

SetMaxSpeed sets the maximum speed, in units of steps per 10000 seconds.

Example:

err := dev.SetMaxSpeed(5550000) // 555 steps per second

This function sends a "Set max speed" command to the Tic. For more information, see the Tic user's guide.

func (*Dev) SetStartingSpeed

func (d *Dev) SetStartingSpeed(speed uint32) error

SetStartingSpeed sets the starting speed, in units of steps per 10000 seconds.

Example:

err := dev.SetStartingSpeed(500000) // 50 steps per second

This function sends a "Set starting speed" command to the Tic. For more information, see the Tic user's guide.

func (*Dev) SetStepMode

func (d *Dev) SetStepMode(mode StepMode) error

SetStepMode sets the stepper motor's step mode, which defines how many microsteps correspond to one full step.

Example:

err := dev.SetStepMode(tic.StepModeMicrostep8)

This function sends a "Set step mode" command to the Tic. For more information, see the Tic user's guide.

func (*Dev) SetTargetPosition

func (d *Dev) SetTargetPosition(position int32) error

SetTargetPosition sets the target position of the Tic, in microsteps.

This function sends a "Set target position" to the Tic. The Tic will enter target position planning mode and start moving the motor to reach the target position.

func (*Dev) SetTargetVelocity

func (d *Dev) SetTargetVelocity(velocity int32) error

SetTargetVelocity sets the target velocity of the Tic, in microsteps per 10000 seconds.

The default step mode is 1 microstep = 1 full step.

This function sends a "Set target velocity" command to the Tic. The Tic will enter target velocity planning mode and start accelerating or decelerating to reach the target velocity.

func (*Dev) String

func (d *Dev) String() string

String returns the device name in a readable format.

String implements conn.Resource.

type ErrorBit

type ErrorBit uint32

ErrorBit describes the Tic's error bits. See the "Error handling" section of the Tic user's guide for more information about what these errors mean.

const (
	ErrorBitIntentionallyDeenergized ErrorBit = 0
	ErrorBitMotorDriverError         ErrorBit = 1
	ErrorBitLowVin                   ErrorBit = 2
	ErrorBitKillSwitch               ErrorBit = 3
	ErrorBitRequiredInputInvalid     ErrorBit = 4
	ErrorBitSerialError              ErrorBit = 5
	ErrorBitCommandTimeout           ErrorBit = 6
	ErrorBitSafeStartViolation       ErrorBit = 7
	ErrorBitErrLineHigh              ErrorBit = 8
	ErrorBitSerialFraming            ErrorBit = 16
	ErrorBitRxOverrun                ErrorBit = 17
	ErrorBitFormat                   ErrorBit = 18
	ErrorBitCRC                      ErrorBit = 19
	ErrorBitEncoderSkip              ErrorBit = 20
)

type InputState

type InputState uint8

InputState describes the possible states of the Tic's main input.

const (
	// The input is not ready yet. More samples are needed, or a command has not
	// been received yet.
	InputStateNotReady InputState = 0
	// The input is invalid.
	InputStateInvalid InputState = 1
	// The input is valid and is telling the Tic to halt the motor.
	InputStateHalt InputState = 2
	// The input is valid and is telling the Tic to go to a target position,
	// which you can get with GetInputAfterScaling().
	InputStatePosition InputState = 3
	// The input is valid and is telling the Tic to go to a target velocity,
	// which you can get with GetInputAfterScaling().
	InputStateVelocity InputState = 4
)

type MotorDriverError

type MotorDriverError uint8

MotorDriverError describes the possible motor driver errors for the Tic T249.

const (
	MotorDriverErrorNone            MotorDriverError = 0
	MotorDriverErrorOverCurrent     MotorDriverError = 1
	MotorDriverErrorOverTemperature MotorDriverError = 2
)

type OperationState

type OperationState uint8

OperationState describes the possible operation states for the Tic.

const (
	OperationStateReset             OperationState = 0
	OperationStateDeenergized       OperationState = 2
	OperationStateSoftError         OperationState = 4
	OperationStateWaitingForErrLine OperationState = 6
	OperationStateStartingUp        OperationState = 8
	OperationStateNormal            OperationState = 10
)

type Pin

type Pin uint8

Pin describes a Tic control pin.

const (
	PinSCL Pin = 0
	PinSDA Pin = 1
	PinTX  Pin = 2
	PinRX  Pin = 3
	PinRC  Pin = 4
)

type PinState

type PinState uint8

PinState describes a Tic's pin state.

const (
	PinStateHighImpedance PinState = 0
	PinStateInputPullUp   PinState = 1
	PinStateOutputLow     PinState = 2
	PinStateOutputHigh    PinState = 3
)

type PlanningMode

type PlanningMode uint8

PlanningMode describes the possible planning modes for the Tic's step generation code.

const (
	PlanningModeOff            PlanningMode = 0
	PlanningModeTargetPosition PlanningMode = 1
	PlanningModeTargetVelocity PlanningMode = 2
)

type ResetCause

type ResetCause uint8

ResetCause describes the possible causes of a full microcontroller reset for the Tic.

type StepMode

type StepMode uint8

StepMode describes how many microsteps add up to one fulls step.

const (
	// StepModeFull is 1 microstep per step.
	StepModeFull StepMode = 0
	// StepModeHalf is 2 microsteps per step.
	StepModeHalf StepMode = 1
	// StepModeMicrostep4 is 4 microsteps per step.
	StepModeMicrostep4 StepMode = 2
	// StepModeMicrostep8 is 8 microsteps per step.
	StepModeMicrostep8 StepMode = 3
	// StepModeMicrostep16 is 16 microsteps per step. Valid for Tic T834, Tic
	// T825 and Tic 36v4 only.
	StepModeMicrostep16 StepMode = 4
	// StepModeMicrostep32 is 32 microsteps per step. Valid for Tic T834, Tic
	// T825 and Tic 36v4 only.
	StepModeMicrostep32 StepMode = 5
	// StepModeMicrostep2_100p is 2 microsteps per step at 100% coil current.
	// Valid for Tic T249 only.
	StepModeMicrostep2_100p StepMode = 6
	// StepModeMicrostep64 is 64 microsteps per step. Valid for Tic 36v4 only.
	StepModeMicrostep64 StepMode = 7
	// StepModeMicrostep128 is 128 microsteps per step. Valid for Tic 36v4 only.
	StepModeMicrostep128 StepMode = 8
	// StepModeMicrostep256 is 256 microsteps per step. Valid for Tic 36v4 only.
	StepModeMicrostep256 StepMode = 9
)

type Variant

type Variant string

Variant represents the specific Tic controller variant.

const (
	TicT825 Variant = "Tic T825"
	TicT834 Variant = "Tic T834"
	TicT500 Variant = "Tic T500"
	TicT249 Variant = "Tic T249"
	Tic36v4 Variant = "Tic 36v4"
)

Jump to

Keyboard shortcuts

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