Skip to content

DFRobot/DFRobot_RaspberryPi_Motor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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(jie.tang@dfrobot.com), 2022. (Welcome to our website)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages