[personal profile] chebe
More assembly, and time to make things happen.

Following a simplified version of the Furlexa motor instructions, the next step is to solder the Adafruit Motor driver board to both the Pi/Speaker pHAT (directly on the appropriate header pins) and to Furby/Gizmo.

The connections being;
MOTOR (left) red -> MOTORA left
MOTOR (right) black -> MOTORA right
RPi #7 (white) -> PWMA
RPi #15 (yellow) -> AIN2
RPi #16 (green) -> AIN1
RPi #13 (blue) -> STBY
RPi #6 GND (black) -> GND
RPi #4 5V (ref) -> Vcc

Battery pack (red) -> Vmotor +
Battery pack (black) -> Vmotor -

There is a nice clear diagram to help us out.



Adafruit motor driver board all wired up
Photo by [personal profile] chebe





Raspberry Pi Zero W and Speaker pHAT board all wired up to motor driver board
Photo by [personal profile] chebe





Motor driver board patched in to Furby/Gizmo motor
Photo by [personal profile] chebe



It is important to remember that there are two power sources; micro-usb powering the RPi, and an independent power supply directly into the Vmotor pins. Eventually these last should be hooked up to/through the battery pack (if you want), but for right now I have them wired through a breadboard and 5V breadboard power supply in turn plugged directly into mains.

To test, create a python script, say /home/pi/motor/motor.py with contents;
#!/usr/bin/env python

import time
import RPi.GPIO as GPIO

# Declare the GPIO settings
GPIO.setmode(GPIO.BOARD)

STBY_PIN = 13
PWMA_PIN = 7
AIN1_PIN = 16
AIN2_PIN = 15

# set up GPIO pins
GPIO.setup(PWMA_PIN, GPIO.OUT)
GPIO.setup(AIN2_PIN, GPIO.OUT)
GPIO.setup(AIN1_PIN, GPIO.OUT)
GPIO.setup(STBY_PIN, GPIO.OUT)


# Drive the motor clockwise
GPIO.output(AIN1_PIN, GPIO.HIGH)
GPIO.output(AIN2_PIN, GPIO.LOW)

# Set the motor speed
GPIO.output(PWMA_PIN, GPIO.HIGH)

# Disable standby
GPIO.output(STBY_PIN, GPIO.HIGH)

# Wait 5 seconds
time.sleep(5)


# Drive the motor counter-clockwise
GPIO.output(AIN1_PIN, GPIO.LOW)
GPIO.output(AIN2_PIN, GPIO.HIGH)

# Set the motor speed
GPIO.output(PWMA_PIN, GPIO.HIGH)

# Disable standby
GPIO.output(STBY_PIN, GPIO.HIGH)

# Wait 5 seconds
time.sleep(5)


# Reset all GPIO pins by setting them to LOW
GPIO.output(PWMA_PIN, GPIO.LOW)
GPIO.output(AIN2_PIN, GPIO.LOW)
GPIO.output(AIN1_PIN, GPIO.LOW)
GPIO.output(STBY_PIN, GPIO.LOW)


Run with python /home/pi/motor/motor.py, and Gizmo does a little dance. This is a very rough kind of control as the motor just cycles through actions endlessly. The original circuit board had ways to detect where in the cycle everything was (the Motor control LED we removed), but we'll have to guess.



Complete test circuit
Photo by [personal profile] chebe




Part 1 | Part 2 | Part 3 | Part 4 | Part 5