This is a cape for the Raspberry Pi that contains helpful inputs for robotic systems control. It has a dual H-Bridge motor driver, dual encoder readers, and a 10-bit ADC.
- ADC (SPI0):
CS=26 DI=19 (MOSI) DO=21 (MISO) SCK=23
The ADC can easily be controlled using the Adafuit MCP3008 library. https://learn.adafruit.com/raspberry-pi-analog-to-digital-converters/mcp3008.
To use this library, enable SPI using sudo raspi-config.
Then, in the python code provided by Adafruit, comment out the "Software SPI Configuration" and enable "Hardware SPI Configuration" with the pins specified above.
IN_LOW1=16 IN_LOW2=15 IN_LOW3=13 IN_LOW4=11 PWM_LOW_A=33 PWM_LOW_B=12
- Encoder Readers (SPI1):
MOSI=38 MISO=35 SCK=40 CS1=36 CS2=37
To enable SP1, go to /boot/config.txt and add
This enables SPI1 with 2CS pins, and selects GPIO pins 16 and 26 as the CS pins.
To enable SPI0, just
go to interfacing and enable SPI.
Code for ADC at http://raspberrypi-aa.github.io/session3/spi.html
Code for the motor driver:
import RPi.GPIO as GPIO import time from time import sleep GPIO.setmode(GPIO.BOARD) // setup BBB GPIO pins GPIO.setup(12, GPIO.OUT) GPIO.setup(33, GPIO.OUT) GPIO.setup(16, GPIO.OUT) GPIO.setup(15, GPIO.OUT) GPIO.setup(13, GPIO.OUT) GPIO.setup(11, GPIO.OUT) pwm1 = GPIO.PWM(33, 1000) pwm2 = GPIO.PWM(12, 1000) GPIO.output(16, GPIO.LOW) time.sleep(4) // TURN LEFT def Left(): GPIO.output(11, GPIO.HIGH) GPIO.output(13, GPIO.LOW) GPIO.output(15, GPIO.LOW) GPIO.output(16, GPIO.HIGH) pwm1.start(90) pwm2.start(90) // GO BACK def Back(): GPIO.output(11, GPIO.LOW) GPIO.output(13, GPIO.HIGH) GPIO.output(15, GPIO.LOW) GPIO.output(16, GPIO.HIGH) pwm1.start(90) pwm2.start(90) def Forward(): GPIO.output(11, GPIO.HIGH) GPIO.output(13, GPIO.LOW) GPIO.output(16, GPIO.LOW) GPIO.output(15, GPIO.HIGH) pwm1.start(90) pwm2.start(90) print "running" Left() time.sleep(4) Back() time.sleep(4) Forward() time.sleep(4) pwm1.stop(pwm1) pwm2.stop(pwm2) GPIO.cleanup()
Encoder readers code can be found below in the robot code section
Analog Sound Board
- The analog sound board, designed by Mauricio de Oliveira with PCB layout by Colin Zyskowski, consists of a preamp
- with AC- or DC-coupled outputs, a signal summer and subtractor, an envelope detector, and a threshold detector. The center of the board contains a patching
- section that allows any stage of the board to be routed to any other. The purpose of the board is to perform analog signal analysis and
- to easily interface with digital micro-controllers.
- Envelope Detector:
- Robot Code
- As of 03/16/16
- The following code is the present state of programming for the sound-detecting robots.
- The code consists of two main parts right now - a server and a client. The robot runs the
- client code that sends information regarding it's position and physical/sonic environment
- to the server. The server then creates a graphic map of that robot's environment. The
- third bit of code is the module for the HMC5883l magnetometer that is being incorporated
- into the odometry system for the robot. So far, everything runs in Python on a Beaglebone Black.