• Home
  • Microcontrollers & Physical Computing
  • Robotics
· Robotics · 3Pi · Sensors ·

3pi Sensor Eval

This is a project to explore how the IR sensors on the Pololu 3pi robot work. There some basic questions that come to mind when using the sensors. What can they see? What diference do the emitters make? How does ambient light affect them? How fast can it return readings?

What can the sensors see?

The sensors on the 3pi measure the amount of infrared-light that is reflected off of the surface they are on. The system works with an element that conducts electricity in proportion to the amount of light that it sees. In the robot this is connected to a capacitor. To take a reading the robot charges the capacitor an measures how long it takes to discharge through the IR sensor. If the robot is over a white area there is a lot of light hitting the sensor. That leads to a lot of electricity flowing through the sensor and the capicitor discharges quickly. On a dark area there is not much light, there is not much electricity flowing and the capacitor discharges very slowly. The longest time the robot will wait for the capacitor to discharge is set by the statement that initalizes the robot. That looks like this pololu_3pi_init(2000); In this case the maximum reading on a dark surface will be 2000. The readings from the sensors will be small if there is a lot of light and big if there is not much light. The result is that the sensor is measuring the darkness of the surface they are on.

The two graphs below plot the reading of one sensor as the robot moves across a line. The 'Forward' graph plots the readings as the robot moves forward across the line. In this case the row of sensors is parallel to the line as it crosses. The 'Sideways' graph shows the readings as the robot moves sideways across the line where the sensors are perpendicular to it. The robot cannot move this way itself, but is something like the robot moving across the line at a small angle. The two graphs show that as the robot gets closer to the line the readings get higher.

What difference do the emitters make?

The devices used for sensors on the 3pi have an IR emitter as well as a sensor. That is very useful in cases where there is not a lot of IR light. The emitters are wired together on the robot. They are all either on or off. That means that a sensor will be seeing reflected light both from it's emmiter and also from the emitters that are close to it. The light from multiple emitters can make a big difference in the results. The emitters are placed in an arc along the front of the robot. That alignment will affect how the extra light changes the sensor readings. The area that sensor is able to see light reflected light from will match the alignment of the sensors and there will be more light reflected to the middle sensors.

This multiple emitter stuff can be confusing. One way to understand how it affects the sensor readings is to make measurements. We can take a series of measurements as we move the robot across a line. If we do that both moving the robot so that the row of sensors goes across the line parallel (all the sensors go across the line at the same time) and perpendicular (the sensors cross one at a time). We would want to run both tests two ways. One set would be where the robot is unmodified. The second would be where only one emitter is working. The easiest way to do that would be to block the light from all the sensors except the one being tested. It is fairly easy to cover all but one sensor. For these tests all but the center sensor was covered. This means four tests. The robot moving forward across the line with the emitters shielded and unshielded and the same two tests with the robot moving sideways.

The results of these tests can be seen in the two graphs. When the emitters are shielded, the direction of motion does not really matter. The curves for the shielded tests are the same in both directions. The area the sensor is measuring is a circle as shown in the Sense Area graphic. The solid black dot is the sensor and the red circle is the area the senser sees.

The direction of motion does matter when the emitters are unshielded. Looking at the two unshielded curves we need to remember that high readings mean less light. When the robot goes forward across the line the light from multiple sensors does not matter much. That is because the sensor and the nearby emitters are all approaching the line at the same time. There is quite a bit of difference when the robot moves sideways. This is where the sensor and the nearby emitters cross the line one at a time. Since the light from the nearby emitters will be reflecting off of a wider area, the area the sensor sees will be wider. On the Sense Area graphic this is shown as the red ellispe. The solid black dot is the sensor and the hollow dots are the nearby emitters. Since the line is narrower then the sense area, the readings never get to the maximum value.

How does ambient light affect the sensors?

The sensors measure infra-red light. In most cases, there will not be much of that in an area away from direct sunlight. One way to measure ambient infra-red light is to take a reading with the emitters turned off. When I have done this with the robot on a white surface I have gotten readings that indicate very little light was hitting the sensors. Readings on the same surface with the emitters on show that a lot of light was hitting the sensors. Readings taken in direct sunlight with the robot on the same surface show no difference whether the emitters are on or off. One conclusion would be that for readings inside ambient light does not really matter and outside it is all that matters.

How fast can it return readings?

Read Mode & Sense rates Combined mode does double work, delivers half the rate
When the robot is doing line-following of some sort the rate that it can take readings is important. If we know how many readings are taken in a second and how far the robot moves in a second we can figure how many readings per unit of distance. More reading is always better.

There are several functions in the Pololu AVR Library that will return sensor readings. The three main choices are an uncalibrated reading of the sensors, a calibrated reading of the sensors and a function that returns a value the indicates where the robot is in relation to the line.

The uncalibrated read function reads all five sensors at once and just returns the values in an array. This function does not need any previous actions to make it ready for use. It is simplest and quickest way to get values from the sensors.

The calibrated read reads all five sensors and returns a normalized set of values. It does this by comparing the readings with a stored set of maximum and minimum values. If the value of a sensor is at or lower then the minimum the returned value will be 0. If it is at or higher then the maximum the return will be 2000. A calibration routine to find the maximum and minimum values should be run before this function is used. It is a little extra work but the calibrated values get rid of some problems that can come up with raw sensor values. This function uses three variations of emitter settings. The sensors can be either on or off for two of the variations. The third is both on and off. This third choices uses twice the time to read the sensors because it does both of the first two.

The line function returns a single number. The number will be between 0 and 4000 with 2000 indicating that the sensor is directly over the line. This function gets the sensor readings it uses from the calibrated read and uses the same three variations.

Having said all of that it is time to talk about the rate the robot can read the sensors.

UncalibratedCalibratedLine Read
Emitters On1190962910
Emitters Off119011621137
Emitters Off & On593527511

How was all of this measured?

The measurements for this page were made with a program written to use the sensor routines of the Pololu library that was created for this robot. The source code for the program can be downloaded from this site (3pi_sense_test.c).

The program is a simple state-machine using a simple menu structure on the robot. When the program is started the LCD will display " INIT " on the first line and "Cal (b)" on the second. The robot is waiting for a button press. It will calibrate the sensors if the B button is pressed or continue without calibration if A or C is pressed. Then the robot will go into an infinite loop based on the main menu. In the top level of the menu the robot displays "Main Menu" and "C Im M" while waiting for a button press. The "C" is for the count menu that will be done if the A button is pressed. The "Im" is the sense mode menu and button B. The "M" is for the sensor monitor and button C. The sensor monitor continuously reads and displays the value from the center sensor. The count menu will display "Count M" and "S KS L" then wait for a button press. All three options will count the number of readings the robot can make in one second. Button A will do uncalibrated reads, button B will do calibrated reads and C will use the line read function. The sense mode menu will display "SMo Menu" on the first line. The second line will indicate what mode the sensors reading routines will use. An "I+ (c)" on the second line means that the emitters will be on for readings, "I- (c)" means they will be off and "Ib (c)" means that readings will be taken for both cases and averaged. From here a press of button A or B will return to the main menu. Pressing button C will allow a change of modes where A will set emitters on, B will set them off and C will set the mode that averages both.

· Home · Microcontrollers & Physical Computing · Robotics ·
This is a project of George Eggleston(Class of 76). You can reach me at george@[The hostname of this website].
Gig_Em