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...
Product Link (https://www.dfrobot.com/product-1911.html)
SKU: DFR0592
Provide a Raspberry Pi library for the DC Motor Driver HAT modules.
- Two DC motors with encoder control or normal DC motors.
- Get motors speed form encoder.
- PWM frequency set.
- PWM duty set.
This Sensor should work with DFRobot_RaspberryPi_DC_Motor on RaspberryPi.
Run the program:
python DC_Motor_Demo.py
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
'''
- RaspberryPi Version
Board | Work Well | Work Wrong | Untested | Remarks |
---|---|---|---|---|
RaspberryPi2 | √ | |||
RaspberryPi3 | √ | |||
RaspberryPi4 | √ |
- Python Version
Python | Work Well | Work Wrong | Untested | Remarks |
---|---|---|---|---|
Python2 | √ | |||
Python3 | √ |
- 2019/03/16 - Version 1.0.0 released.
- 2022/04/19 - Version 1.0.1 released.
Written by tangjie([email protected]), 2022. (Welcome to our website)