The George Washington University Electrical Computer Engineering Department

  • Slides: 18
Download presentation
The George Washington University Electrical & Computer Engineering Department ECE 1020 Dr. S. Ahmadi

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

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

 • Arduino !

• Arduino !

Two Distinct Categories of Sensors • Digital and Analog • Digital sensors have two

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

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 p. H 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. •

Analog Sensors • Output a range of values, depending on the input read. • The main analog ports are A 0…. 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 : qrd 1114

Light Sensors • The sensor : qrd 1114

Optical Rangefinder Sensors (Proximity Sensor) • The Sensor : sharp 2 y 0 a

Optical Rangefinder Sensors (Proximity Sensor) • The Sensor : sharp 2 y 0 a 21

Ultrasonic Sensors (Sonar) • The sensor: sfr 04

Ultrasonic Sensors (Sonar) • The sensor: sfr 04

Sonar Sample Code int trigger. Pin = 8; //to send a trigger pulse to

Sonar Sample Code int trigger. Pin = 8; //to send a trigger pulse to sonar sensor int data. Read. Pin = 11; //read the length of echo(PWM) void setup() { Serial. begin(9600); pin. Mode(trigger. Pin, OUTPUT); pin. Mode(data. Read. Pin, INPUT); } void loop() { digital. Write(trigger. Pin, HIGH); delay. Microseconds(20); //send a high pulse for 20 us digital. Write(trigger. Pin, LOW); Serial. println(pulse. In(data. Read. Pin, HIGH)); //read the duty cycle of high pulse delay(50); //repeat after 50 ms }

Analog Sensor Characterization • The purpose of this exercise is to tabulate the readings

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 read. Pin = 0; //analog read pin void setup() {

Light Sample Code int read. Pin = 0; //analog read pin void setup() { Serial. begin(9600); pin. Mode(read. Pin, INPUT); } void loop() { Serial. println(analog. Read(read. Pin)); delay(50); }

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

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

Lab Requirements • Collect Data for at least one sensor. (Data to be handed

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 nonlinear, 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

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

Example Plot of Sensor Characterization – RANGE FINDER SENSOR

Due in Lab Today • After tabulating the results, plot the graph for each

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.