l293x

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2021 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package l293x provides a driver to the L293/L293D H-bridge chip typically used to control DC motors.

Datasheet: https://www.ti.com/lit/ds/symlink/l293d.pdf

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

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

Device is a motor without speed control. a1 and a2 are the directional pins. en is the pin turns the motor on/off.

func New

func New(direction1, direction2, enablePin machine.Pin) Device

New returns a new Motor driver for GPIO-only operation.

func (*Device) Backward

func (d *Device) Backward()

Backward turns motor on in backward direction.

func (*Device) Configure

func (d *Device) Configure()

Configure configures the Device.

func (*Device) Forward

func (d *Device) Forward()

Forward turns motor on in forward direction.

func (*Device) Stop

func (d *Device) Stop()

Stop turns motor off.

type PWM

type PWM interface {
	Configure(config machine.PWMConfig) error
	Channel(pin machine.Pin) (channel uint8, err error)
	Top() uint32
	Set(channel uint8, value uint32)
	SetPeriod(period uint64) error
}

PWM is the interface necessary for controlling the motor driver.

type PWMDevice

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

PWMDevice is a motor with speed control. a1 and a2 are the directional GPIO pins. en is the PWM pin that controls the motor speed.

func NewWithSpeed

func NewWithSpeed(direction1, direction2 machine.Pin, spc uint8, pwm PWM) PWMDevice

NewWithSpeed returns a new PWMMotor driver that uses an already configured PWM channel to control speed.

func (*PWMDevice) Backward

func (d *PWMDevice) Backward(speed uint32)

Backward turns motor on in backward direction at specific speed as a percentage.

func (*PWMDevice) Configure

func (d *PWMDevice) Configure() error

Configure configures the PWMDevice. Note that the PWM interface and channel must already be configured, this function will not do it for you.

func (*PWMDevice) Forward

func (d *PWMDevice) Forward(speed uint32)

Forward turns motor on in forward direction at specific speed as a percentage.

func (*PWMDevice) Stop

func (d *PWMDevice) Stop()

Stop turns motor off.

Jump to

Keyboard shortcuts

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