Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/raspberrypi-go-drivers/l293d
Allows to use a L293D chip and control 2 (or 1) associated DC motors
https://github.com/raspberrypi-go-drivers/l293d
go golang l293d l298n raspberry-pi raspberrypi-drivers robotics
Last synced: 26 days ago
JSON representation
Allows to use a L293D chip and control 2 (or 1) associated DC motors
- Host: GitHub
- URL: https://github.com/raspberrypi-go-drivers/l293d
- Owner: raspberrypi-go-drivers
- License: mit
- Created: 2020-12-18T21:21:28.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-26T14:28:30.000Z (about 4 years ago)
- Last Synced: 2023-07-26T15:14:01.649Z (over 1 year ago)
- Topics: go, golang, l293d, l298n, raspberry-pi, raspberrypi-drivers, robotics
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# L293D
[![Go Reference](https://pkg.go.dev/badge/github.com/raspberrypi-go-drivers/l293d.svg)](https://pkg.go.dev/github.com/raspberrypi-go-drivers/l293d)
![golangci-lint](https://github.com/raspberrypi-go-drivers/l293d/workflows/golangci-lint/badge.svg)
[![Go Report Card](https://goreportcard.com/badge/github.com/raspberrypi-go-drivers/l293d)](https://goreportcard.com/report/github.com/raspberrypi-go-drivers/l293d)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)The L293D chip allows to control 2 DC motors using 2 PWM pins and 4 other pins
## Documentation
For full documentation, please visit [![Go Reference](https://pkg.go.dev/badge/github.com/raspberrypi-go-drivers/l293d.svg)](https://pkg.go.dev/github.com/raspberrypi-go-drivers/l293d)
## Quick start
```go
import (
"fmt"
"os"
"time""github.com/raspberrypi-go-drivers/l293d"
"github.com/stianeikeland/go-rpio/v4"
)func main() {
err := rpio.Open()
if err != nil {
os.Exit(1)
}
defer rpio.Close()
chip := l293d.NewL293D()
pinEnableA := uint8(12) // PWM compatible
pin1a := uint8(17)
pin2a := uint8(27)pinEnableB := uint8(13) // PWM compatible
pin1b := uint8(23)
pin2b := uint8(24)
motor1, err := chip.NewMotor(1, pinEnableA, pin1a, pin2a)
if err != nil {
fmt.Println("impossible to create new motor")
}
motor2, err := chip.NewMotor(2, pinEnableB, pin1b, pin2b)
if err != nil {
fmt.Println("impossible to create new motor")
}
// Looks like motors are not running correctly below some speed percentage
// I experienced it below 50%
// Set motor1 speed to 65%
motor1.SetSpeed(65)
// Set motor2 speed to 80%
motor2.SetSpeed(80)
time.Sleep(3 * time.Second)
motor1.SetSpeed(0)
motor2.SetSpeed(0)
}
```## Datasheet
L293D datasheet: https://www.ti.com/lit/ds/symlink/l293.pdf
## First glance at L293D
```
______________
1,2EN --| |-- Vcc1
| |
1A --| |-- 4A
| |
1Y --| |-- 4Y
| |
GND --| |-- GND
| |
GND --| |-- GND
| |
2Y --| |-- 3Y
| |
2A --| |-- 3A
| |
Vcc2 --|______________|-- 3,4EN
```Pins | Description
--------|---------------------
1,2EN | Enable inputs 1 & 2
1A | Input 1 for motor 1
2A | Input 2 for motor 1
1Y & 2Y | To motor 1
Vcc2 | 5V to 36V input for motors
3,4EN | Enable inputs 3 & 4
3A | Input 1 for motor 2
4A | Input 2 for motor 2
3Y & 4Y | To motor 2
Vcc1 | 5V input for chip (can be taken from Raspberry Pi)Action (identical for 3,4) | 1,2EN | 1A | 2A | Comments
-----------------------------|--------|------|-------|---------------------------------
Rotation | high | high | low |
Reverse rotation | high | low | high |
Rotation speed | PWM | - | - |
Quick stop | low | - | - | 1A and 2A state doesn't matter
Free rotation | high | low | low | or high/highTo control speed, a PWM signal have to be sent to pins 1,2EN for motor 1 and 3,4EN for motor 2
## Raspberry Pi compatibility
This driver has has only been tested on an Raspberry Pi Zero WH using integrated bluetooth but may work well on other Raspberry Pi having integrated Bluetooth
## License
MIT License
---
Special thanks to @stianeikeland
This driver is based on his work in [stianeikeland/go-rpio](https://github.com/stianeikeland/go-rpio/)