Presentation is loading. Please wait.

Presentation is loading. Please wait.

The George Washington University Electrical & Computer Engineering Department ECE 002 Dr. S. Ahmadi Class 1.

Similar presentations


Presentation on theme: "The George Washington University Electrical & Computer Engineering Department ECE 002 Dr. S. Ahmadi Class 1."— Presentation transcript:

1 The George Washington University Electrical & Computer Engineering Department ECE 002 Dr. S. Ahmadi Class 1

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

3

4 Digital Sensors Review Digital Sensors: –Can only return two values, a ‘0’ or a ‘1’: –‘0’ indicates switch is open (Nothing has happened), –‘1’ indicates the switch has been closed. –Includes such devices as switches or bumpers. Digital sensors are connected to ports 7 – 15 on the handyboard. Are accessed using the function digital(port#).

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

6 Sample Digital Sensor Code Connect a digital sensor, either a bumper or a switch, to one of the digital ports (7 through 15). Here we will use port 9. Start a new program: // Program to test if digital sensor working. void main() { while(1) // Loop forever. { if(digital(9)==1) //If switch on port 9 HIT, execute this code. { beep(); }

7 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.

8 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.

9 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

10 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

11 Sonar Sample Code /% Program that measures the sonar reading at different input values. %/ void main() { int range=0; 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); }

12 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.

13 Light Sensor Color Scale 50% 0%100% ½”

14

15 Lab Requirements Collect Data for at least one sensor. (Data to be handed in at end of lab, and you’ll 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

16 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.

17 Example Plot of Sensor Characterization – RANGE FINDER SENSOR

18 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.


Download ppt "The George Washington University Electrical & Computer Engineering Department ECE 002 Dr. S. Ahmadi Class 1."

Similar presentations


Ads by Google