DC Motor Driver HAT for Raspberry Pi: No power to motors..
![userHead](https://dfimg.dfrobot.com/dfPortrait2.png)
Hey there! I've been trying all day to get your demo code to run for the DC Motor Hat on my Raspberry Pi Model A. I have I2C enabled, and the code runs, but I'm getting no actual power to the motors. I've tried with and without external power, but still nothing. What am I doing wrong?
The code is from DFRobot_RaspberryPi_Motor repository, and I'm trying to run the DC_Motor_Demo.py library. I've got two DC Motors plugged in (no encoders) and I've updated the demo file to disable encoders.
The code is from DFRobot_RaspberryPi_Motor repository, and I'm trying to run the DC_Motor_Demo.py library. I've got two DC Motors plugged in (no encoders) and I've updated the demo file to disable encoders.
2020-06-23 09:10:44 I've confirmed the voltage of the motor to be between 6 and 9V. I'm currently supplying 9V, at 1.76A. There's no voltage measured across the motor screw terminals when I run the demo code.
macgeoffrey123
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
2020-06-23 09:10:44 I've confirmed the voltage of the motor to be between 6 and 9V. I'm currently supplying 9V, at 1.76A. There's no voltage measured across the motor screw terminals when I run the demo code.
macgeoffrey123
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
2020-06-20 01:09:24 Hi! yes, my code is currently this:
# -*- coding:utf-8 -*-
'''
# DC_Motor_Demo.py
#
# Connect board with raspberryPi.
# Make board power and motor connection correct.
# Run this demo.
#
# Motor 1 will move slow to fast, orientation clockwise,
# motor 2 will move fast to slow, orientation count-clockwise,
# then fast to stop. loop in few seconds.
# Motor speed will print on terminal
#
# test motor: https://www.dfrobot.com/product-634.html
#
# Copyright [DFRobot](http://www.dfrobot.com), 2016
# Copyright GNU Lesser General Public License
#
# version V1.0
# date 2019-3-26
'''
import time
from DFRobot_RaspberryPi_DC_Motor import DFRobot_DC_Motor_IIC as Board
board = Board(1, 0x10) # Select bus 1, set address to 0x10
def board_detect():
l = board.detecte()
print("Board list conform:")
print(l)
''' print last operate status, users can use this variable to determine the result of a function call. '''
def print_board_status():
if board.last_operate_status == board.STA_OK:
print("board status: everything ok")
elif board.last_operate_status == board.STA_ERR:
print("board status: unexpected error")
elif board.last_operate_status == board.STA_ERR_DEVICE_NOT_DETECTED:
print("board status: device not detected")
elif board.last_operate_status == board.STA_ERR_PARAMETER:
print("board status: parameter error, last operate no effective")
elif board.last_operate_status == board.STA_ERR_SOFT_VERSION:
print("board status: unsupport board framware version")
if __name__ == "__main__":
board_detect() # If you forget address you had set, use this to detected them, must have class instance
# Set board controler address, use it carefully, reboot module to make it effective
'''
board.set_addr(0x10)
if board.last_operate_status != board.STA_OK:
print("set board address faild")
else:
print("set board address success")
'''
while board.begin() != board.STA_OK: # Board begin and check board status
print_board_status()
print("board begin faild")
time.sleep(2)
print("board begin success")
# board.set_encoder_enable(board.ALL) # Set selected DC motor encoder enable
board.set_encoder_disable(board.ALL) # Set selected DC motor encoder disable
board.set_encoder_reduction_ratio(board.ALL, 43) # Set selected DC motor encoder reduction ratio, test motor reduction ratio is 43.8
board.set_moter_pwm_frequency(1000) # Set DC motor pwm frequency to 1000HZ
while True:
for duty in range(5, 95, 10): # slow to fast
board.motor_movement([board.M1], board.CW, duty) # DC motor 1 movement, orientation clockwise
board.motor_movement([board.M2], board.CCW, duty) # DC motor 2 movement, orientation count-clockwise
time.sleep(1)
speed = board.get_encoder_speed(board.ALL) # Use boadrd.all to get all encoders speed
print("duty: %d, M1 encoder speed: %d rpm, M2 encoder speed %d rpm" %(duty, speed[0], speed[1]))
for duty in range(95, 5, - 10): # fast to low
board.motor_movement([board.M1], board.CW, duty) # DC motor 1 movement, orientation clockwise
board.motor_movement([board.M2], board.CCW, duty) # DC motor 2 movement, orientation count-clockwise
time.sleep(1)
speed = board.get_encoder_speed(board.ALL) # Use boadrd.all to get all encoders speed
print("duty: %d, M1 encoder speed: %d rpm, M2 encoder speed %d rpm" %(duty, speed[0], speed[1]))
print("stop all motor")
board.motor_stop(board.ALL) # stop all DC motor
print_board_status()
time.sleep(4)
I've currently wired up two regular DC motors to the M1 and M2 negative and positive terminals. I've tried running the code with and without external power. The Raspberry Pi is on 5V, and I was using a 9V Battery as the external power supply.
macgeoffrey123
# -*- coding:utf-8 -*-
'''
# DC_Motor_Demo.py
#
# Connect board with raspberryPi.
# Make board power and motor connection correct.
# Run this demo.
#
# Motor 1 will move slow to fast, orientation clockwise,
# motor 2 will move fast to slow, orientation count-clockwise,
# then fast to stop. loop in few seconds.
# Motor speed will print on terminal
#
# test motor: https://www.dfrobot.com/product-634.html
#
# Copyright [DFRobot](http://www.dfrobot.com), 2016
# Copyright GNU Lesser General Public License
#
# version V1.0
# date 2019-3-26
'''
import time
from DFRobot_RaspberryPi_DC_Motor import DFRobot_DC_Motor_IIC as Board
board = Board(1, 0x10) # Select bus 1, set address to 0x10
def board_detect():
l = board.detecte()
print("Board list conform:")
print(l)
''' print last operate status, users can use this variable to determine the result of a function call. '''
def print_board_status():
if board.last_operate_status == board.STA_OK:
print("board status: everything ok")
elif board.last_operate_status == board.STA_ERR:
print("board status: unexpected error")
elif board.last_operate_status == board.STA_ERR_DEVICE_NOT_DETECTED:
print("board status: device not detected")
elif board.last_operate_status == board.STA_ERR_PARAMETER:
print("board status: parameter error, last operate no effective")
elif board.last_operate_status == board.STA_ERR_SOFT_VERSION:
print("board status: unsupport board framware version")
if __name__ == "__main__":
board_detect() # If you forget address you had set, use this to detected them, must have class instance
# Set board controler address, use it carefully, reboot module to make it effective
'''
board.set_addr(0x10)
if board.last_operate_status != board.STA_OK:
print("set board address faild")
else:
print("set board address success")
'''
while board.begin() != board.STA_OK: # Board begin and check board status
print_board_status()
print("board begin faild")
time.sleep(2)
print("board begin success")
# board.set_encoder_enable(board.ALL) # Set selected DC motor encoder enable
board.set_encoder_disable(board.ALL) # Set selected DC motor encoder disable
board.set_encoder_reduction_ratio(board.ALL, 43) # Set selected DC motor encoder reduction ratio, test motor reduction ratio is 43.8
board.set_moter_pwm_frequency(1000) # Set DC motor pwm frequency to 1000HZ
while True:
for duty in range(5, 95, 10): # slow to fast
board.motor_movement([board.M1], board.CW, duty) # DC motor 1 movement, orientation clockwise
board.motor_movement([board.M2], board.CCW, duty) # DC motor 2 movement, orientation count-clockwise
time.sleep(1)
speed = board.get_encoder_speed(board.ALL) # Use boadrd.all to get all encoders speed
print("duty: %d, M1 encoder speed: %d rpm, M2 encoder speed %d rpm" %(duty, speed[0], speed[1]))
for duty in range(95, 5, - 10): # fast to low
board.motor_movement([board.M1], board.CW, duty) # DC motor 1 movement, orientation clockwise
board.motor_movement([board.M2], board.CCW, duty) # DC motor 2 movement, orientation count-clockwise
time.sleep(1)
speed = board.get_encoder_speed(board.ALL) # Use boadrd.all to get all encoders speed
print("duty: %d, M1 encoder speed: %d rpm, M2 encoder speed %d rpm" %(duty, speed[0], speed[1]))
print("stop all motor")
board.motor_stop(board.ALL) # stop all DC motor
print_board_status()
time.sleep(4)
I've currently wired up two regular DC motors to the M1 and M2 negative and positive terminals. I've tried running the code with and without external power. The Raspberry Pi is on 5V, and I was using a 9V Battery as the external power supply.
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
2020-06-20 01:09:24 Hi! yes, my code is currently this:
# -*- coding:utf-8 -*-
'''
# DC_Motor_Demo.py
#
# Connect board with raspberryPi.
# Make board power and motor connection correct.
# Run this demo.
#
# Motor 1 will move slow to fast, orientation clockwise,
# motor 2 will move fast to slow, orientation count-clockwise,
# then fast to stop. loop in few seconds.
# Motor speed will print on terminal
#
# test motor: https://www.dfrobot.com/product-634.html
#
# Copyright [DFRobot](http://www.dfrobot.com), 2016
# Copyright GNU Lesser General Public License
#
# version V1.0
# date 2019-3-26
'''
import time
from DFRobot_RaspberryPi_DC_Motor import DFRobot_DC_Motor_IIC as Board
board = Board(1, 0x10) # Select bus 1, set address to 0x10
def board_detect():
l = board.detecte()
print("Board list conform:")
print(l)
''' print last operate status, users can use this variable to determine the result of a function call. '''
def print_board_status():
if board.last_operate_status == board.STA_OK:
print("board status: everything ok")
elif board.last_operate_status == board.STA_ERR:
print("board status: unexpected error")
elif board.last_operate_status == board.STA_ERR_DEVICE_NOT_DETECTED:
print("board status: device not detected")
elif board.last_operate_status == board.STA_ERR_PARAMETER:
print("board status: parameter error, last operate no effective")
elif board.last_operate_status == board.STA_ERR_SOFT_VERSION:
print("board status: unsupport board framware version")
if __name__ == "__main__":
board_detect() # If you forget address you had set, use this to detected them, must have class instance
# Set board controler address, use it carefully, reboot module to make it effective
'''
board.set_addr(0x10)
if board.last_operate_status != board.STA_OK:
print("set board address faild")
else:
print("set board address success")
'''
while board.begin() != board.STA_OK: # Board begin and check board status
print_board_status()
print("board begin faild")
time.sleep(2)
print("board begin success")
# board.set_encoder_enable(board.ALL) # Set selected DC motor encoder enable
board.set_encoder_disable(board.ALL) # Set selected DC motor encoder disable
board.set_encoder_reduction_ratio(board.ALL, 43) # Set selected DC motor encoder reduction ratio, test motor reduction ratio is 43.8
board.set_moter_pwm_frequency(1000) # Set DC motor pwm frequency to 1000HZ
while True:
for duty in range(5, 95, 10): # slow to fast
board.motor_movement([board.M1], board.CW, duty) # DC motor 1 movement, orientation clockwise
board.motor_movement([board.M2], board.CCW, duty) # DC motor 2 movement, orientation count-clockwise
time.sleep(1)
speed = board.get_encoder_speed(board.ALL) # Use boadrd.all to get all encoders speed
print("duty: %d, M1 encoder speed: %d rpm, M2 encoder speed %d rpm" %(duty, speed[0], speed[1]))
for duty in range(95, 5, - 10): # fast to low
board.motor_movement([board.M1], board.CW, duty) # DC motor 1 movement, orientation clockwise
board.motor_movement([board.M2], board.CCW, duty) # DC motor 2 movement, orientation count-clockwise
time.sleep(1)
speed = board.get_encoder_speed(board.ALL) # Use boadrd.all to get all encoders speed
print("duty: %d, M1 encoder speed: %d rpm, M2 encoder speed %d rpm" %(duty, speed[0], speed[1]))
print("stop all motor")
board.motor_stop(board.ALL) # stop all DC motor
print_board_status()
time.sleep(4)
I've currently wired up two regular DC motors to the M1 and M2 negative and positive terminals. I've tried running the code with and without external power. The Raspberry Pi is on 5V, and I was using a 9V Battery as the external power supply.
macgeoffrey123
# -*- coding:utf-8 -*-
'''
# DC_Motor_Demo.py
#
# Connect board with raspberryPi.
# Make board power and motor connection correct.
# Run this demo.
#
# Motor 1 will move slow to fast, orientation clockwise,
# motor 2 will move fast to slow, orientation count-clockwise,
# then fast to stop. loop in few seconds.
# Motor speed will print on terminal
#
# test motor: https://www.dfrobot.com/product-634.html
#
# Copyright [DFRobot](http://www.dfrobot.com), 2016
# Copyright GNU Lesser General Public License
#
# version V1.0
# date 2019-3-26
'''
import time
from DFRobot_RaspberryPi_DC_Motor import DFRobot_DC_Motor_IIC as Board
board = Board(1, 0x10) # Select bus 1, set address to 0x10
def board_detect():
l = board.detecte()
print("Board list conform:")
print(l)
''' print last operate status, users can use this variable to determine the result of a function call. '''
def print_board_status():
if board.last_operate_status == board.STA_OK:
print("board status: everything ok")
elif board.last_operate_status == board.STA_ERR:
print("board status: unexpected error")
elif board.last_operate_status == board.STA_ERR_DEVICE_NOT_DETECTED:
print("board status: device not detected")
elif board.last_operate_status == board.STA_ERR_PARAMETER:
print("board status: parameter error, last operate no effective")
elif board.last_operate_status == board.STA_ERR_SOFT_VERSION:
print("board status: unsupport board framware version")
if __name__ == "__main__":
board_detect() # If you forget address you had set, use this to detected them, must have class instance
# Set board controler address, use it carefully, reboot module to make it effective
'''
board.set_addr(0x10)
if board.last_operate_status != board.STA_OK:
print("set board address faild")
else:
print("set board address success")
'''
while board.begin() != board.STA_OK: # Board begin and check board status
print_board_status()
print("board begin faild")
time.sleep(2)
print("board begin success")
# board.set_encoder_enable(board.ALL) # Set selected DC motor encoder enable
board.set_encoder_disable(board.ALL) # Set selected DC motor encoder disable
board.set_encoder_reduction_ratio(board.ALL, 43) # Set selected DC motor encoder reduction ratio, test motor reduction ratio is 43.8
board.set_moter_pwm_frequency(1000) # Set DC motor pwm frequency to 1000HZ
while True:
for duty in range(5, 95, 10): # slow to fast
board.motor_movement([board.M1], board.CW, duty) # DC motor 1 movement, orientation clockwise
board.motor_movement([board.M2], board.CCW, duty) # DC motor 2 movement, orientation count-clockwise
time.sleep(1)
speed = board.get_encoder_speed(board.ALL) # Use boadrd.all to get all encoders speed
print("duty: %d, M1 encoder speed: %d rpm, M2 encoder speed %d rpm" %(duty, speed[0], speed[1]))
for duty in range(95, 5, - 10): # fast to low
board.motor_movement([board.M1], board.CW, duty) # DC motor 1 movement, orientation clockwise
board.motor_movement([board.M2], board.CCW, duty) # DC motor 2 movement, orientation count-clockwise
time.sleep(1)
speed = board.get_encoder_speed(board.ALL) # Use boadrd.all to get all encoders speed
print("duty: %d, M1 encoder speed: %d rpm, M2 encoder speed %d rpm" %(duty, speed[0], speed[1]))
print("stop all motor")
board.motor_stop(board.ALL) # stop all DC motor
print_board_status()
time.sleep(4)
I've currently wired up two regular DC motors to the M1 and M2 negative and positive terminals. I've tried running the code with and without external power. The Raspberry Pi is on 5V, and I was using a 9V Battery as the external power supply.
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)
2020-06-18 00:21:16 Hey there! I've been trying all day to get your demo code to run for the DC Motor Hat on my Raspberry Pi Model A. I have I2C enabled, and the code runs, but I'm getting no actual power to the motors. I've tried with and without external power, but still nothing. What am I doing wrong?
The code is from DFRobot_RaspberryPi_Motor repository, and I'm trying to run the DC_Motor_Demo.py library. I've got two DC Motors plugged in (no encoders) and I've updated the demo file to disable encoders.
macgeoffrey123
The code is from DFRobot_RaspberryPi_Motor repository, and I'm trying to run the DC_Motor_Demo.py library. I've got two DC Motors plugged in (no encoders) and I've updated the demo file to disable encoders.
![userHeadPic](https://dfimg.dfrobot.com/dfPortrait2.png)