Documentation
¶
Index ¶
- Constants
- Variables
- func ByteArrayToString(array []byte) string
- type Direction
- type DriverCommand
- type S42DDriver
- func (driver *S42DDriver) Close() error
- func (driver *S42DDriver) Connect() error
- func (driver *S42DDriver) FindMaxBottom() (int, error)
- func (driver *S42DDriver) GoHome() error
- func (driver *S42DDriver) MoveOneRotation(dir Direction, speed uint16) error
- func (driver *S42DDriver) ReadDistance() (float64, error)
- func (driver *S42DDriver) ResetCounters() error
- func (driver *S42DDriver) StartGoingDown(speed uint16) error
- func (driver *S42DDriver) StartGoingUp(speed uint16) error
- type ServoMessage
- type ServoMessageType
- type StepperDriver
Constants ¶
View Source
const DEFAULT_ACCELERATION uint8 = 0
View Source
const DOWNLINK_HEAD byte = 0xFA
View Source
const MAX_MOTOR_ACCELERATION = 255
View Source
const MAX_MOTOR_SPEED = 3000
View Source
const MOTOR_TOTAL_STEPS = 200 // 200 for 1.8
View Source
const SLAVE_ADDRESS byte = 0x01
View Source
const UPLINK_HEAD byte = 0xFB
Variables ¶
View Source
var S42DDriverConfig = serial.Config{ Name: "/dev/ttyUSB1", Baud: 115200, ReadTimeout: 3 * time.Millisecond, }
Functions ¶
func ByteArrayToString ¶
Types ¶
type DriverCommand ¶
type DriverCommand struct {
// contains filtered or unexported fields
}
type S42DDriver ¶
type S42DDriver struct {
SerialConfig *serial.Config
EncoderAddition uint // encoder value +/- for a full rotation
ScrewPitch uint // mm
StepsPerRotation uint // usually 200 without microsteps
StepsPerMm uint // steps_per_rotation / screw_pitch
// contains filtered or unexported fields
}
func (*S42DDriver) Close ¶
func (driver *S42DDriver) Close() error
func (*S42DDriver) Connect ¶
func (driver *S42DDriver) Connect() error
func (*S42DDriver) FindMaxBottom ¶
func (driver *S42DDriver) FindMaxBottom() (int, error)
func (*S42DDriver) GoHome ¶
func (driver *S42DDriver) GoHome() error
go to top of system. Note this resets all pulse counting
func (*S42DDriver) MoveOneRotation ¶
func (driver *S42DDriver) MoveOneRotation(dir Direction, speed uint16) error
func (*S42DDriver) ReadDistance ¶
func (driver *S42DDriver) ReadDistance() (float64, error)
this assumes we traveled in one direction from a 0 axis
func (*S42DDriver) ResetCounters ¶
func (driver *S42DDriver) ResetCounters() error
func (*S42DDriver) StartGoingDown ¶
func (driver *S42DDriver) StartGoingDown(speed uint16) error
func (*S42DDriver) StartGoingUp ¶
func (driver *S42DDriver) StartGoingUp(speed uint16) error
type ServoMessage ¶
type ServoMessage struct {
Type ServoMessageType
Data any
Message string
}
type ServoMessageType ¶
type ServoMessageType int
const ( ServoError ServoMessageType = iota // 0 ... ServoTravelMessage ServoEncoderMessage ServoPulseCountMessage )
type StepperDriver ¶
type StepperDriver interface {
Connect() error // initialize serial connection
GetCurrentDistanceTraveled() int // get distance traveled since counter started in mm
ResetCounters() error // resets pulse and distance counters
StartGoingDown() error // start motor going forward
StartGoingUp(speed uint16) error // start motor going in reverse
Stop() error // stop all movement
FindMaxBottom() (int, error) // find the maximum encoder value to the bottom of the system
GoHome(speed uint16) error // go to the very top of the system
}
This module contains the abstraction for interacting with a stepper motor and its driver board. Each concrete implementation of this interface for different driver boards should be in their own files.
Click to show internal directories.
Click to hide internal directories.