SparkFun Auto pHAT not driving DC motors properly

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)

Show the wiring setup and specifically how it’s being powered…that motor wants a decent amount of power, and so does the 3B+ (especially if usb attachments are being used, etc)

Powering both, and mounting the pHat on the 3B+ won’t work well…the Pi will be trying to power it, it will be trying to power the Pi. Normally you’d just power the pHat, let it power the Pi, then separately power the motor

Also: is the motor under load (like, is it mounted on a wheel with a bot platform attached)? Or are you testing it spinning freely?

Hi, this bottom pic was the original wiring - I originally tested this with servo motors which didn’t work with just the USB on the pi, so I plugged in the USB-C port on the auto pHAT also. The servos work but either option didn’t power the DC motors.

I read this post earlier before I could get the chance to get pictures. I tested with just the USB-C port on the pHAT as suggested, and the result with the DC motor (no load, but has a hall sensor) is still the same. There is no voltage output at the MTR terminal for speeds below 235 on the multimeter. By separately powering the motor, do you mean soldering wires to the MTR and GRD ports at the side of the shield? Would this be enough to power 2 servos and 2 DC motors at the same time?

I’m also attaching sensors using another shield (GROVE Base Hat) as shown, what GPIO pins do you say the auto pHAT is using? So I make sure theres no conflicts with the other hat

I am having exactly the same problem with Sparkfun Qwiic Motor Driver. Nothing happens until the speed gets to around 235. The batteries in the black case give around 5.7V to the input. The output voltage is 0 until the speed increases to 233 when it suddenly switches to 5.6V. I am using the same example code as artdeitech. Anyone have any ideas what is going on with this?

The arduino library https://github.com/sparkfun/SparkFun_Se … orTest.ino is working correctly for me; I’m going to guess that there’s some issue with the “255” and the “20” in the python code somehow getting screwy (255 - 20 = 235)

Create an issue here https://github.com/sparkfun/Qwiic_SCMD_Py/issues to see about getting the python code looked at