The George Washington University Electrical - PowerPoint PPT Presentation

About This Presentation
Title:

The George Washington University Electrical

Description:

Digital Sensor: The Bumper Sensor. Digital sensor: Returns ... Bumper connected to port // 13. If it is hit, sends. if (digital(13)= =1) // 1 to handyboard. ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 21
Provided by: tar8151
Category:

less

Transcript and Presenter's Notes

Title: The George Washington University Electrical


1
The George Washington University Electrical
Computer Engineering Department ECE 002
  • Dr. S. Ahmadi
  • Lab 1

2
Class Agenda
  • Digital Sensors
  • Analog Sensors
  • Light Sensors.
  • Optical Rangefinder Sensors.
  • Ultrasonic Sensors (Sonar).
  • Analog Sensor Characterization

3
(No Transcript)
4
Two Distinct Categories of Sensors
  • Digital and Analog
  • Digital sensors have two states 0 or 1
  • Analog sensors have a range of states depending
    on their input
  • Example
  • A door can be open or closed
  • What type of representation of the condition of
    the door is this?
  • How far the door is open (0 to 180 degrees!)
  • What type of representation of the condition of
    the door is this?

5
Hooking up Sensors to the Handyboard
Hook up additional Analog sensors To these ports
(20-23)
Hook up DIGITAL Sensors To these ports 7-15
Hook up ANALOG sensors To these ports (2-6)
6
Digital Sensor The Bumper Sensor
  • Digital sensor
  • Returns either a 0 or 1.
  • Connect to DIGITAL ports 7-15
  • Access with function digital(port)
  • 0 indicates switch is open (nothing has
    happened). Normally, switch will be 0.
  • 1 indicates switch is closed (Switch has been
    hit).

7
  • For more information on different digital sensors
    available to you, refer to the Botball Kit
    Documentation, slides 42, 43, 51.

8
Bumper Sensor Procedure and Test Code
  • / Program to beep if a bumper on port 13 has
    been hit. /
  • void main()
  • while(start_button()0) // Waits for user
    to press start button.
  • while(stop_button()0) // Keep program
    running until press stop button
  • printf(Switch on port 13 is open!\n)
  • // Bumper connected to port
  • // 13. If it is hit, sends
  • if (digital(13) 1) // 1 to handyboard.
  • printf(Switch on port 13 has been
    closed!\n)
  • beep()

9
Analog Sensors
  • Output a range of values, depending on the input
    read.
  • The main analog ports are ports 2 6, and ports
    20 23.
  • Actual ports that should be used will depend on
    the sensor being used.
  • The three main analog sensors that we will be
    using are the Light Sensor, the Optical
    Rangefinder Sensor and the Ultrasonic Sensor,
    also known as the Sonar.

10
Light Sensors
  • Access with function analog(port)
  • Connected to ports 2-6 or 20-23
  • Analog values range from 0 - 255.
  • A low value indicates bright light, and vice
    versa.

11
Optical Rangefinder Sensors
  • Access with function analog(port)
  • Connected to ports 16-19
  • Analog values range from 0 - 255.
  • Low values indicate far distance from an obstacle
  • High values indicate close proximity to an
    obstacle 4 inches

12
Ultrasonic Sensors (Sonar)
  • Connect red to upper deck board - port 0
  • Connect gray to Digital 7
  • Access with function sonar()
  • Returned value is distance in mm to closest
    object in field of view
  • Range is approximately 30-2000 mm
  • When objects are too close or too far, gives
    value of 32767

13
Sonar Sample Code
  • / Program that measures the sonar reading at
    different input values.
  • /
  • void main()
  • int range0
  • printf(\n Sensor Sample Program")
  • while(!start_button()) // Press Start Button
  • while(1) // Continue infinitely
  • sleep(0.5)
  • range sonar()
  • printf(\nOutput is d, range)

14
Analog Sensor Characterization
  • The purpose of this exercise is to tabulate the
    readings from the three different analog sensors
    mentioned, when different inputs are sensed
  • Light Sensor Using the attached color scale,
    move the light sensor along the sheet, and record
    the values read at different intervals.
  • Optical Rangefinder Using the provided boards,
    at different distances record the outputs read
    from the sensor.
  • Ultrasonic Sensor Similar to the Optical
    Rangefinder, record the output from the sensor at
    different input distances.

15
Light Sensor Color Scale
½
0
100
50
16
½
½
½
½
17
Lab Requirements
  • Collect Data for at least one sensor. (Data to
    be handed in at end of lab, and youll need it
    for your HW.)
  • FOR LIGHT SENSOR Take 10 equally spaced
    readings.
  • FOR SONAR SENSOR Take enough readings to
    characterize sensor (more when measurements are
    non-linear, less when data is predictable)
  • Insert the data into an Excel spreadsheet
  • Plot the data (X-axis for distance, Y-axis for
    sensor readings).
  • Email the spreadsheet to all group members to
    complete HW

18
Sensor Range
  • Sensors have an established operating range.
    Determine what this is for your sensor.
  • Choose your ten points so that they span the
    complete operating range of the sensor.

19
Example Plot of Sensor Characterization RANGE
FINDER SENSOR
20
Due in Lab Today
  • After tabulating the results, plot the graph for
    each sensor type, to see if the relationship
    turns out linear or not. Draw the curve to fit
    the graph.
  • Note To simplify your work, write a short
    program that can continually print out the
    reading of the sensor on the Handyboards display.
  • Take a look at HW1(Comprehensive Report on the
    Characterization of Robots Sensors), save your
    data/graphs for HW1.
Write a Comment
User Comments (0)
About PowerShow.com