Professional Documents
Culture Documents
About
Links
pdfcrowd.com
Search
Recent Posts
Easy WiFi Set Up for
Raspberry Pi
CamJam Ed Kit #3
Robotics, building a sub
A6 Robot
Micro Pi Noon at the
Raspberry Birthday
Bash
Pi Wars Line
Following and 3 Point
Turn
4Borg Time Lapse Build
Video
Recent Comments
pdfcrowd.com
Tom on About
Brian on About
from the above quote, rules out using a tactile sensor, so using a
micro switch and/or pressure sensor is not possible, so that
leaves the choice of using a range finder sensor, measuring the
distance your robot travelled from the start line ( Dead
reckoning ) or image processing. The below methods, dont allow
open in browser PRO version
Archives
pdfcrowd.com
for drift. Drift is where your robot will not move in a straight line,
and is caused by at least one or all of the following; poorly
matched motors, surface conditions, an uneven surface and
wheels slipping. First let go over the pros and cons of each
method and types of sensors.
May 2016
February 2016
November 2015
October 2015
September 2015
August 2015
Categories
Blogging
Cannybots
Making
Micro Pi Wars
NeoPixals
Oops
PiBorg
showing position of laser pointers, camera. plus positions of a
robot approaching the wall and final position.
Pimoroni
PiWars
Raspberry Pi
pdfcrowd.com
Raspberry Pi
Raspbian
Robotics
Sonic Pi
Meta
Log in
Entries RSS
Comments RSS
WordPress.org
pdfcrowd.com
Sensor: Encoder
pdfcrowd.com
the wheel slips during your run, you will lose accuracy
pros: cost, simple to program, you may already be using
encoders for the 3-point turn challenge
cons: accuracy, repeatability for increased accuracy you may
need to use an arduino or some other microcontroller
pdfcrowd.com
pdfcrowd.com
pdfcrowd.com
pdfcrowd.com
My Solution
pdfcrowd.com
pdfcrowd.com
pdfcrowd.com
The above has proved that the sensor and ADC board are
connected and working OK.
Lets run through the problem for stopping the robot from hitting
the wall.
1. start moving robot
2. check the sensor and stop robot if target has been been
reached
and using simple pseudo code
START MOTORS
open in browser PRO version
pdfcrowd.com
READ SENSOR
IF SENSOR VALUE <= TARGET THEN STOP MOTORS
SENSOR VALUE = 0
TARGET = 10cm
SET MOTORS TO 10%
WHILE SENSOR VALUE <= TARGET
READ SENSOR
STOP MOTORS
now for the python code, I just showing the control loop, and not
included the setting up of the Adafruit ADS1015 ADC
stopValue = 0.8
volts = 0
open in browser PRO version
pdfcrowd.com
try:
volts = adc.readADCSingleEnded(0, gain, sps) / 1000 # read the sensor
while volts < stopValue:
DIABLO.SetMotors(-0.1) # set the both motor to 10% in reverse
volts = adc.readADCSingleEnded(0, gain, sps) / 1000 # read the sensor
print(volts)
print "%.6f" % (volts)
time.sleep(0.01) # pause the loop for 1/100 of a second.
except KeyboardInterrupt:
# User has pressed CTRL+C
DIABLO.MotorsOff()
# Turn both motors off
print 'Ctl C been pressed'
DIABLO.MotorsOff()
# Turn both motors off
print 'Stop!!!!'
if you have read the above code, I dont start the motors until, the
distance has been check first, just in case the code is running
when the robot is next to the wall, we dont want it hit wall by
accident. I have updated the pseudo code to show this.
pdfcrowd.com
SENSOR VALUE = 0
TARGET = 10cm
WHILE SENSOR VALUE <= TARGET
SET MOTORS TO 10%
READ SENSOR
STOP MOTORS
and the full code is here, including setting up the Adafruit ADC
breakout board
#!/usr/bin/env python
# coding: Latin-1
# Stop robot from hitting wall!
# Import library functions we need
import Diablo
import time, signal, sys
from Adafruit_ADS1x15 import ADS1x15
open in browser PRO version
pdfcrowd.com
pdfcrowd.com
adc = ADS1x15(ic=ADS1115)
# Setup the Diablo
DIABLO = Diablo.Diablo()
# Create a new Diablo object
DIABLO.Init()
# Set the board up (checks the board is connected)
DIABLO.ResetEpo()
# Reset the stop switch (EPO) state
# if you do not have a switch across the two pin header then fit the jumper
pdfcrowd.com
pdfcrowd.com
pdfcrowd.com