I am using a Raspberry Pi 3B+ connected to a SparkFun Auto pHAT for driving two DC motors as wheels for my mobile robot project. For the power source, I hook both the raspberry pi and the pHAT to charging ports each. When I connect a DFRobot DC motor to the terminals, the motor test code from the Hookup Guide only seems to drive the motor at the 235-255 range, at lower speed values, the motor does not move at all. I need slower speeds for my project. All other pHAT functions like servo control and encoder reading work fine.
I’ve tested this for two raspberry Pis, two identical pHATs and different kinds of motors, the result is the same. Am I missing anything or should I switch to a different motor / motor controller?
The motor I’m using: https://wiki.dfrobot.com/Micro_DC_Motor … U__FIT0458
Installation guide code used to drive the motor
from __future__ import print_function
import time
import sys
import math
import qwiic_scmd
myMotor = qwiic_scmd.QwiicScmd()
def runExample():
print("Motor Test.")
R_MTR = 0
L_MTR = 1
FWD = 0
BWD = 1
if myMotor.connected == False:
print("Motor Driver not connected. Check connections.", \
file=sys.stderr)
return
myMotor.begin()
print("Motor initialized.")
time.sleep(.250)
# Zero Motor Speeds
myMotor.set_drive(0,0,0)
myMotor.set_drive(1,0,0)
myMotor.enable()
print("Motor enabled")
time.sleep(.250)
while True:
speed = 20
for speed in range(20,255):
print(speed)
myMotor.set_drive(R_MTR,FWD,speed)
time.sleep(.05)
for speed in range(254,20, -1):
print(speed)
myMotor.set_drive(R_MTR,FWD,speed)
time.sleep(.05)
if __name__ == '__main__':
try:
runExample()
except (KeyboardInterrupt, SystemExit) as exErr:
print("Ending example.")
myMotor.disable()
sys.exit(0)