-
Notifications
You must be signed in to change notification settings - Fork 0
Automatic Light
In the sub-projects we've put together so far we've looked at different ways of taking inputs and producing outputs. This allows for some interesting applications, but combining the two and using information from sensory input to produce output allows for the design of much more powerful systems.
Control Theory broadly formalizes methods for selecting the optimal input to a system to produce the desired output. Control Theory can be applied in the design of many different types of systems: Fly by wire systems in aeronautics, process control in pharmaceutical manufacture, robotic manipulation, city planning, pretty much anything that can be controlled and measured. Many modern system designs are engineered using control theory. Wikipedia article on Control Theory
So far, we've built the interface to produce light of varying intensity, and measure light with varying intensity. This sub-project will combine these two capabilities and design of a control system to create an automatic night-light.
We will start with what we built in Photodiode Response. Bend the LED and photodiode so that they are close together but pointing away from the board. Start by uploading the code to the board.
Looking at lines 37 and 38, you'll notice that two variables are set, "setpoint" and "k".
int setPoint = 20;
double k = 0.01;
Our control system uses proportional control. A common type of control system is a Proportional-Derivative-Integral, or PID controller. (see more on PID). The basic idea is to set a desired system state, or Set Point, and use the error between the desired state and current state estimated by the sensors to move the system towards the desired state. Often times, the system takes time to respond, and so we set a gain constant K to control how quickly the system moves towards the set point. Depending on the system, we may want to introduce the derivative of the error and integrated error in our desired control in order to dampen oscillations or overcome some constant bias. But enough theory.
In practice, proportional control works very well for automatic nightlights. By using proportional control, the light brightness will change smoothly depending on ambient light conditions. Go to a dark room and find some source of light like a lamp. Observe how the LED responds when under the lamp verses in a darker area of the room. Try making k smaller (like 0.001), and observe how response of the system changes. You can also change setPoint to control the threshold of ambient light that will cause the LED to turn on and off.
Some settings for k will create an unstable system, point the photodiode and LED at each other and see what happens when you change k. You may notice that the system oscillates at some frequency, turning the LED on and off. In such a system, oscillations can be dampened by applying filters, or the derivative and integral term.
In SLERP, we will use the LED and photodiode to determine solution saturation. We then will use this information in a control loop to add drink mix until the desired set point is reached. This requires actuation, which we will start next, before pulling everything back together! It may be useful to think about how a control system would work to mix our powdered drink. Unlike some other systems, a solution mixer cannot allow "overshoot" or extra powder to be added. Entropy has been introduced into the system, and it's very difficult to remove powder from a solution after it has already dissolved!