180 likes | 197 Views
The George Washington University Electrical & Computer Engineering Department ECE 1020. Dr. S. Ahmadi Lab 1. Class Agenda. Digital Sensors Analog Sensors Light Sensors. Optical Rangefinder Sensors. Ultrasonic Sensors (Sonar). Analog Sensor Characterization. Arduino !.
E N D
The George Washington University Electrical & Computer Engineering Department ECE 1020 Dr. S. Ahmadi Lab 1
Class Agenda • Digital Sensors • Analog Sensors • Light Sensors. • Optical Rangefinder Sensors. • Ultrasonic Sensors (Sonar). • Analog Sensor Characterization
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?
Digital Sensors • A digital sensor is an electronic or electrochemical sensor, where data conversion and data transmission are done digitally. • Sensors are often used for analytical measurements, i.e. the measurement of chemical and physical properties of liquids. • Typical measured parameters are pH value, conductivity, oxygen, redox potentials and others. Such measurements are used in the industrial world and give vital input for process control.
Analog Sensors • Output a range of values, depending on the input read. • The main analog ports are A0….7 • Ports to be used can be programmed by the user. • 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.
Light Sensors • The sensor : qrd1114
Optical Rangefinder Sensors(Proximity Sensor) • The Sensor : sharp 2y0a21
Ultrasonic Sensors (Sonar) • The sensor: sfr04
Sonar Sample Code inttriggerPin = 8; //to send a trigger pulse to sonar sensor intdataReadPin = 11; //read the length of echo(PWM) void setup() { Serial.begin(9600); pinMode(triggerPin, OUTPUT); pinMode(dataReadPin, INPUT); } void loop() { digitalWrite(triggerPin, HIGH); delayMicroseconds(20); //send a high pulse for 20 us digitalWrite(triggerPin, LOW); Serial.println(pulseIn(dataReadPin, HIGH)); //read the duty cycle of high pulse delay(50); //repeat after 50ms }
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.
Light Sample Code int readPin = 0; //analog read pin void setup() { Serial.begin(9600); pinMode(readPin, INPUT); } void loop() { Serial.println(analogRead(readPin)); delay(50); }
Light Sensor Color Scale ½” 100% 0% 50%
½” ½” ½” ½”
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
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.
Example Plot of Sensor Characterization – RANGE FINDER SENSOR
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 HW#1(Comprehensive Report on the Characterization of Robot’s Sensors), save your data/graphs for HW#1.