Using motor controller 29 and 393 motor with raspberry pi

Hey i connected a motor controller 29 to my raspberry pi and used PWM to get it to go forwards and back and everything in between. My issue is whenever there is a force applied to the motor, such as a hand stopping a wheel from turning, the motor sends power, then stops, and continues to repeat this until the force is removed. Do you know what could be causing this on and off pattern and how i could possibly fix it? The frequency of the PWM is at 50hz, duty cycle at 10 percent, and pulse width at 0.0020 seconds for full forward.

What are you using to power the motors? If you’re just getting power from one of the pins on the Pi, you’re drawing way more current than the Pi can supply.

I’m using a 9 volt battery sharing a ground with the pi

I use the VEX motors with the Raspberry Pi and they work great. Make sure the PWM signal ranges from 1-2ms with a scope. Please provide a wiring diagram.

Here is somewhat of a wiring diagram. Its not a true one but it shows all of the connections. Thanks
Screen Shot 2015-11-27 at 3.03.29 PM.png

Here is the Python3 code I just ran a test with on my RPi 2 with the Adafruit PWM hat::

#code to write to the 16 channel Adafruit PWM
#used a scope to confirm 1.0, 1.5, and 2.0ms for rev, off, and fwd
import time
import smbus
bus = smbus.SMBus(1)
bus.write_byte_data(0x40,0x00,0x10) #sleep mode
bus.write_byte_data(0x40,0xfe,0x7E) #set to 50Hz(79 calc, 7E measured)
bus.write_byte_data(0x40,0x00,0x00) #wake up
bus.write_byte_data(0x40,0x01,0x04) #output enable
#reverse
bus.write_byte_data(0x40,0x06,0x00) #PWM 01 config
bus.write_byte_data(0x40,0x07,0x00) #PWM 01 config
bus.write_byte_data(0x40,0x08,0xCC) #PWM 01 full rev LSB is CC measured
bus.write_byte_data(0x40,0x09,0x00) #PWM 01 full rev MSB is 00 measured
time.sleep(3)
#off
bus.write_byte_data(0x40,0x06,0x00) #PWM 01 config
bus.write_byte_data(0x40,0x07,0x00) #PWM 01 config
bus.write_byte_data(0x40,0x08,0x32) #PWM 01 off LSB is 32 measured
bus.write_byte_data(0x40,0x09,0x01) #PWM 01 off MSB is 01 measured
time.sleep(2)
#forward
bus.write_byte_data(0x40,0x06,0x00) #PWM 01 config
bus.write_byte_data(0x40,0x07,0x00) #PWM 01 config
bus.write_byte_data(0x40,0x08,0x98) #PWM 01 full fwd LSB is 98 measured
bus.write_byte_data(0x40,0x09,0x01) #PWM 01 full fwd MSB is 01 measured
time.sleep(3)
#off
bus.write_byte_data(0x40,0x06,0x00) #PWM 01 config
bus.write_byte_data(0x40,0x07,0x00) #PWM 01 config
bus.write_byte_data(0x40,0x08,0x32) #PWM 01 off LSB is 32 measured
bus.write_byte_data(0x40,0x09,0x01) #PWM 01 off MSB is 01 measured