Giter Club home page Giter Club logo

dfrobot_raspberrypi_motor's Introduction

DFRobot_RaspberryPi_Motor

This RaspberryPi motor-driving board can communicate with RaspberryPi via IIC.
It can control the motor to rotate forward and reserve, and rotation speed.
The control command is IIC command and the drive command is PWM signal.
The single-channel maximum operate current is 1.2A. The input port is compatible with GPIO port.
With 2 independent output channels and 2 encoder ports, it can control 2 DC-motors or 2 motors with encoder.
Application: RaspberryPi smart car, DIY tank, DIY micro-fish...

Physical product drawing

SKU: DFR0592

Table of Contents

Summary

Provide a Raspberry Pi library for the DC Motor Driver HAT modules.

  1. Two DC motors with encoder control or normal DC motors.
  2. Get motors speed form encoder.
  3. PWM frequency set.
  4. PWM duty set.

Installation

This Sensor should work with DFRobot_RaspberryPi_DC_Motor on RaspberryPi.
Run the program:

python DC_Motor_Demo.py

Methods

  def begin(self):
    '''!
      @brief    Board begin
      @return   Board status
    '''

  def set_addr(self, addr):
    '''!
      @brief Set board controler address, reboot module to make it effective
      @param address   Address to set, range in 1 to 127
    '''

  def set_encoder_enable(self, id):
    '''!
      @brief Set dc motor encoder enable
      @param id   Encoder list, items in range 1 to 2, or id = self.ALL
    '''
  
  def set_encoder_disable(self, id):
    '''!
      @brief Set dc motor encoder disable
      @param id  Encoder list, items in range 1 to 2, or id = self.ALL
    '''

  def set_encoder_reduction_ratio(self, id, reduction_ratio):
    '''!
      @brief Set dc motor encoder reduction ratio
      @param id                Encoder list, items in range 1 to 2, or id = self.ALL
      @param reduction_ratio   Set dc motor encoder reduction ratio, range in 1 to 2000, (pulse per circle) = 16 * reduction_ratio * 2
    '''

  def get_encoder_speed(self, id):
    '''!
      @brief Get dc motor encoder speed, unit rpm
      @param id   Encoder list, items in range 1 to 2, or id = self.ALL
      @return  List of encoders speed
    '''

  def set_moter_pwm_frequency(self, frequency):
    '''!
      @brief Set dc motor pwm frequency
      @param frequency   Frequency to set, in range 100HZ to 12750HZ, otherwise no effective (actual frequency) = frequency - (frequency % 50)
    '''

  def motor_movement(self, id, orientation, speed):
    '''!
      @brief Motor movement
      @param id            Motor list, items in range 1 to 2, or id = self.ALL
      @param orientation   Motor orientation, self.CW (clockwise) or self.CCW (counterclockwise)
      @param speed         Motor pwm duty cycle, in range 0 to 100, otherwise no effective
    '''

  def motor_stop(self, id):
    '''!
      @brief Motor stop
      @param id   Motor list, items in range 1 to 2, or id = self.ALL
    '''

  def detecte(self):
    '''!
      @brief    If you forget address you had set, use this to detecte them, must have class instance
      @return   Board list conformed
    '''

Compatibility

  • RaspberryPi Version
Board Work Well Work Wrong Untested Remarks
RaspberryPi2
RaspberryPi3
RaspberryPi4
  • Python Version
Python Work Well Work Wrong Untested Remarks
Python2
Python3

History

  • 2019/03/16 - Version 1.0.0 released.
  • 2022/04/19 - Version 1.0.1 released.

Credits

Written by tangjie([email protected]), 2022. (Welcome to our website)

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.