GithubHelp home page GithubHelp logo

raspberrypi-go-drivers / l293d Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 6 KB

Allows to use a L293D chip and control 2 (or 1) associated DC motors

License: MIT License

Go 100.00%
raspberry-pi raspberrypi-drivers robotics go golang l293d l298n

l293d's Introduction

L293D

Go Reference golangci-lint Go Report Card License: 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

Quick start

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/high

To 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

l293d's People

Contributors

bbayszczak avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

dobredodo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.