So what I am trying to do is to get the motor to spin but I want to raspberry pi between the motor so I can spin it clockwise for 5 seconds and then spin it anti-clockwise for 5 seconds. But initially, I just want to make sure it works.
Here is my circuit: enter image description here
And here is the code I am running, should this code should output some voltage if I have a volt meter on the aout pins?
import RPi.GPIO as GPIO # Declare the GPIO settings GPIO.setmode(GPIO.BOARD) # set up GPIO pins GPIO.setup(19, GPIO.OUT) # Connected to AIN2 GPIO.setup(26, GPIO.OUT) # Connected to AIN1 # Drive the motor clockwise GPIO.output(26, GPIO.HIGH) # Set AIN1 GPIO.output(19, GPIO.LOW) # Set AIN2 # Wait 5 seconds time.sleep(5) GPIO.output(12, GPIO.LOW) # Set AIN1 GPIO.output(11, GPIO.LOW) # Set AIN2
- 1Frankly it is unclear what you actually have or are asking. List components and connections and preferably a circuit. Attempting to power a motor with a 9V battery is unlikely to work. With the wiring is is likely to be faulty use proper connections. None of the pins listed in your code seem to be connected. – Milliways 13 hours ago
- 1Why is a 9V battery no good? I will also address your other concerns now. Thanks so much for your answer though 🙂 – Patrick Hession 13 hours ago
- 1Those batteries are designed for low power electronic devices. They can’t supply sufficient current to run a motor. If it actually turns it won’t for long. – Milliways 13 hours ago
- 1Oh..the DRV8833 component wants power between 2v and 10v though.. – Patrick Hession 13 hours ago
- 1I have added some more info to my question now. Hope this helps 🙂 – Patrick Hession 13 hours ago
Rpi python DRV8833 motor driver setting up and troubleshooting a N20 DC motor driving problem
- I would suggest to do the hardware setup in Appendix A for preliminary testing.
- For this preliminary testing, no online Rpi and programming is need. We can do offline DC level signals input to DRV8833 and test one of the two outputs.
- We don’t even need any motor for testing.
- I would suggest the following wiring:4.1 Motor voltage 6V (or 9V)4.2 Status LED with serial current limiting resistor to simulate motor coil.4.2 Testing signals summary:
AIN1 - 5V, 0V AIN2 - 5V, 0V BIN1 - N.C. BIN2 - N.C nSleep - 5V, 0V nFault - N.C AOUT1 - serial current protecting resistor, to status LED Anode. AOUT2 - LED Cathode BOUT1 - N.C. BOUT2 - N.C. ASEN - Ground BSEN - Ground
- Testing procedure:5.1 Set nSleep to enable drv88335.2 By hand, use jumper wire to connect AIN1 to High (5V)5.3 By hand, use jumper wire to connect AIN2 to Low (0V)5.4 LED should be now switched on by DRV8833, implying that if motor is used instead of (or at the same time as) LED, current will pass motor coil, and motor would move in one directions (CW or CCW).5.5 Now connect AIN1 to Low, and AIN2 to High, LED should be switched off.5.6 Replace LED by motor. Motor should move (a) in one direction if AIN1, AIN2 are connected by jumper wires to High, Low, and (b) in opposite direction if AIN1, AIN2 are connected to Low High.5.7 Use a NE555 timer to generate 0.5Hz square pulse (1 second High, 1 second Low), motor should repeatedly move in one direction for 1 second, and opposite direction for 1 second.5.8 Use a NE555 timer to generate PWM signals, say 1kHz and different duty cycles, to adjust the speed of the motor, (or the brightness of the status LED). For this motor speed adjustment test, AIN1 is set to High or Low, AIN2 is connected to the PWM signal.5.8 Then test the OP’s python program in the question.
/ to continue, …
/ to continue, …
Appendix A – Suggested hardware setup for troubleshooting DRV8833
Appendix B – Spec of the OP’s N20 Motor
Note – Load current = 150mA, Stall current = 400mA
/ to continue, …
You need to do some more research.
I suggest you start with something simpler! Preferably light a few LEDs.
GPIO.setmode(GPIO.BOARD) BUT then use BCM numbering.
You DO NOT have a Gnd connection between the devices – this is ABSOLUTELY essential for all circuits.
You DO NOT have proper connections to the device. Sticking pins through the holes is not good enough! If you are lucky it may work, but then a loose connection may fry your Pi.
Better I suggest you try gpiozero which is simpler, is well documented and has good examples.
I do not know what a DRV8833 is or its connections. Maybe someone does, but YOU should supply this information.ShareEditFollowFlagedited 11 hours agoanswered 11 hours agoMilliways48.7k2424 gold badges8080 silver badges160160 bronze badges
- 1Great thanks for the help. Here is a link to the component I am using: adafruit.com/product/3297 – Patrick Hession 11 hours ago
- 1@PatrickHession DO NOT put detail in Comments. Edit your Question so others will see this. – Milliways 11 hours ago