Assignment 13

Going The Distance


Purpose

This assignment will introduce you to using the oA2D object available on the OOPic. The oA2D object is an 8-bit analog to digital (A/D) converter. You will use the A/D converter with the Sharp GP2D12 IR or Sharp GP2D120 IR ranging module. This sensor takes a continuous distance reading and reports the distance as an analog voltage with a distance range of 10cm (~4") to 80cm (~30") for the GP2D12 and 4cm (~1.5") to 30cm (~12") for the GP2D120. The interface is 3-wire with power, ground and the output voltage.

Materials

Hookup Diagrams

Setup for the OOPic and GP2D12[0] is shown in the figures below.

OOPic Hookup Detail (click to enlarge)

GP2D12

GP2D120

Tech Note

Connections

The setup uses one of the OOPic I/O ports (3) and the +5-volt and ground connection. The relation between the ports and pins are as follows:

OOPic Pin

Name

Function

Sensor connection

1

+5v + 5 Volts regulated connect to 5-volt buss (pin 3 GP2D12[0])

2

GND

Ground

Connect to ground buss (pin 2 GP2D12[0])

7

I/O 3 I/O Line 3
A2D 3
connect to pin 1 GP2D12[0]

Assignment Part A

Using the GP2D12[0] Communications Example below, you will accumulate some data characterizing the response of the IR detector. A form is available here to record you results. Use a meter stick and solid surface to assess the IR sensor at different distances.

Assignment Part B

Using the GP2D12[0] Communications Example as a starting point, modify the OOPic and VB programs to perform the following task:

Many robot creators use IR detectors so that robots may follow walls or avoid obstacles. Using the data from part A, modify the code in the VB and OOPic programs OOPicIRTalker so that the display shows "on track" when the sensor is between 6 to 10 inches from an obstacle and displays "off track" when the sensor detects a distance outside the range.

Save the OOPic program as assign13.osc and the VB project as assign13.

GP2D12[0] Communications Example

This example has an OOPic program and a Visual Basic program. By using these programs together you can assess the response of the Sharp IR sensor. The VB program communicates with the OOPIc and displays the voltage values associated with the sensor.

OOPicIRTalker

OOPicIRTalker

Serial Communications

This is a simple example that may be used to troubleshoot PC and OOPic communications.

OOPicTalker

OOPicTalker

What Youll Turn In

The form from part A and a diskette with your name, course number, assignment number. The diskette should contain the files assign13.osc and the VB project as assign13..