stepper

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Speed20  = 20
	Speed40  = 40
	Speed60  = 60
	Speed80  = 80
	Speed100 = 100
)
View Source
const StepAngle float64 = 0.0883268076179

StepAngle = (Step angle / gear reduction ratio) = (5.625 / 63.68395)

Variables

View Source
var (
	Sequence28BYJ48 = [8][4]uint8{
		{1, 0, 0, 0},
		{1, 1, 0, 0},
		{0, 1, 0, 0},
		{0, 1, 1, 0},
		{0, 0, 1, 0},
		{0, 0, 1, 1},
		{0, 0, 0, 1},
		{1, 0, 0, 1},
	}
)

Functions

func GetSteps

func GetSteps(angle uint) uint

GetSteps returns steps count

func Wait

func Wait(t time.Duration)

Wait for given time.Duration

Types

type Direction

type Direction int8

Direction is used to give stepper motor direction (clockwise or counterclockwise)

const (
	DirectionClock        Direction = 1
	DirectionCounterClock Direction = -1
)

func (Direction) Float64

func (d Direction) Float64() float64

Float64 return value as float64

func (Direction) Int

func (d Direction) Int() int

Int return value as int

type OptFunc

type OptFunc func(options *Options)

func SetGPIOs

func SetGPIOs(pins [4]int) OptFunc

type Options

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

type Speed

type Speed uint8

Speed is the stepper motor speed, it ensures to use only allowed speed values

func (Speed) Float64

func (s Speed) Float64() float64

Float64 returns the speed value as a float64

func (Speed) Uint

func (s Speed) Uint() uint

Uint returns the speed value as an uint

type StepperMotor

type StepperMotor struct {
	*Options
}

func NewStepperMotor

func NewStepperMotor(opts ...OptFunc) *StepperMotor

NewStepperMotor StepperMotor constructor

func (*StepperMotor) GetCurrentPosition

func (s *StepperMotor) GetCurrentPosition() int

GetCurrentPosition returns s.currentPos value

func (*StepperMotor) GetNumOfSteps

func (s *StepperMotor) GetNumOfSteps() uint

GetNumOfSteps returns s.nSteps value

func (*StepperMotor) GetThreshold

func (s *StepperMotor) GetThreshold() uint

GetThreshold returns s.threshold value

func (*StepperMotor) IsRunning

func (s *StepperMotor) IsRunning() bool

IsRunning returns s.running value

func (*StepperMotor) Run

func (s *StepperMotor) Run(direction Direction, angle uint, speed Speed)

Run the stepper motor using given params (direction, angle and speed)

func (*StepperMotor) SetThreshold

func (s *StepperMotor) SetThreshold(threshold uint)

SetThreshold returns s.threshold value

Jump to

Keyboard shortcuts

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