ams

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package ams implements the AMS_AS5048 encoder

Package ams is Linux-only

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// We include connection type here in anticipation for
	// future SPI support
	ConnectionType string `json:"connection_type"`
	*I2CConfig     `json:"i2c_attributes,omitempty"`
}

Config contains the connection information for configuring an AS5048 encoder.

func (*Config) Validate

func (conf *Config) Validate(path string) ([]string, error)

Validate checks the attributes of an initialized config for proper values.

type Encoder

type Encoder struct {
	resource.Named
	// contains filtered or unexported fields
}

Encoder is a struct representing an instance of a hardware unit in AMS's AS5048 series of Hall-effect encoders.

func (*Encoder) Close

func (enc *Encoder) Close(ctx context.Context) error

Close stops the position loop of the encoder when the component is closed.

func (*Encoder) Position added in v0.2.50

func (enc *Encoder) Position(
	ctx context.Context, positionType encoder.PositionType, extra map[string]interface{},
) (float64, encoder.PositionType, error)

Position returns the total number of rotations detected by the encoder (rather than a number of pulse state transitions) because this encoder is absolute and not incremental. As a result a user MUST set ticks_per_rotation on the config of the corresponding motor to 1. Any other value will result in completely incorrect position measurements by the motor.

func (*Encoder) Properties added in v0.2.50

func (enc *Encoder) Properties(ctx context.Context, extra map[string]interface{}) (encoder.Properties, error)

Properties returns a list of all the position types that are supported by a given encoder.

func (*Encoder) Reconfigure

func (enc *Encoder) Reconfigure(
	ctx context.Context,
	deps resource.Dependencies,
	conf resource.Config,
) error

Reconfigure reconfigures the encoder atomically.

func (*Encoder) ResetPosition

func (enc *Encoder) ResetPosition(
	ctx context.Context, extra map[string]interface{},
) error

ResetPosition sets the current position measured by the encoder to be considered its new zero position.

type I2CConfig

type I2CConfig struct {
	I2CBus  string `json:"i2c_bus"`
	I2CAddr int    `json:"i2c_addr"`
}

I2CConfig stores the configuration information for I2C connection.

func (*I2CConfig) ValidateI2C

func (cfg *I2CConfig) ValidateI2C(path string) error

ValidateI2C ensures all parts of the config are valid.

Jump to

Keyboard shortcuts

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