The goal of this chapter is to build a solar tracker: a servomotor that turns an arm carrying two light sensors until the arm points at a light source, and that keeps following the source as it moves. The sensor is a photocell, a resistor whose resistance falls as more light falls on it. The ADC (analog-to-digital converter) measures voltages and not resistances, so the first job is an interface: a voltage divider that turns the photocell’s resistance into a voltage on an ADC pin. With two photocells on the servo’s arm, one on each side, the difference between their two voltages depends on which side the light is on, and a program we write turns that difference into a change in the servo’s command pulse. That program is a feedback loop. The servo has its own feedback loop inside it, and the tracker closes a second loop around the servo.
This chapter covers one class day. Before class, the reading introduces the photocell, the family of sensors that work the same way, the divider, the photocell’s datasheet, and what a solar tracker is. In class we’ll predict which way the divider’s voltage moves as the light changes, work through the photocell study from Lab 8, mount the photocells on the arm, discuss how the tracker’s feedback loop can be implemented, and start on the loop. Lab 8 is where you tune and demonstrate it. Section 14.3 collects the divider formula, the two-channel ADC read and the loop’s update rule for looking up later.
Explain what a CdS photocell is: a resistor whose resistance falls as more light falls on it, inexpensive, nonlinear, and so variable from unit to unit that it is used to compare light levels rather than to measure them.
Put a resistive sensor into a voltage divider, state the divider’s formula, and predict which way its output moves as the sensor’s resistance changes.
Read the photocell’s datasheet for what the tracker needs: the sensitivity as the slope of a log-log plot, the rise and fall times as a bound on how fast to sample, and the test conditions behind every number.
Design the tracker’s control loop from Lab 8’s description: the error, the update rule, its sign, its bounds, the sampling interval, and what a gain of 0.01 means in integer arithmetic.