Autonomous Gerbil Air Conditioning System
G1AGACS or AGACS 1.0
Sometimes Simply Represented by Brushless Motor Symbol
Fan Specific Symbol
G2AGACS or AGACS 2.0
Symbol Used in 3rd Gen AGACS
The resistor between the Arduino and the base of the power transistor serves to reduce the maximum current going to the base of the power transistor. See the long answer for more details.
G3AGACS or AGACS 3.0
3rd Gen AGACS Schematic
G3AGACS Arduino Sketch
G4AGACS or AGACS 4.0
Feature Driven Development
The graph shown above illustrates the desired performance for the AGACS 4.0. This new "feature" will "drive" the development of an updated Arduino sketch to be loaded to the Arduino Uno controller. Feature Driven Development (FDD) is a recognized software development approach outlined in more detail here.
The AGACS 4.0 will require control over the fan speed which implies we must control the voltage experienced by the fan. The Arduino can simulate analog voltage output with Pulse Width Modulation (PWM) however, since PWM is a truly a digital signal, it will mess with the digital circuitry inside the fan causing it not to work. We can use PWM to vary the average voltage seen by the fan but we must send it through a simple digital to analog converter first. The type of digital to analog converter we will use is called a first order low pass filter. Before we discuss the making of a first order low pass filter, we must first consider how PWM works.
Pulse Width Modulation (PWM)
Deriving the RMS Value for Pulse and Square Waves
The fans described in the graph below have an additional pin for fan speed control, unlike our fan. Once however, we have filtered the PWM signal to an analog signal we can expect similar performance.
Had we ever switch to a brush dc motor, we would need to consider fan stress due to a PWM fan speed control approach.
We must also change the pin we use to write to the base of our power transistor. We must do this because digital pin 13 can not perform a PWM write, also known as an analogWrite() command. We must use one of the digital pins with a little squiggly line in front. Those are the digital pins which can perform PWM.
Below are notes used to compute the linear model used in our C++ Arduino code to vary the fan speed in accord with our new feature graph.
Our first order low pass filter, which will act as a digital to analog converter, will be designed based upon:
So in practice, one way to design a filter is to decide on how rapidly you want to change the analogue output, then set the cut off frequency to be four times this rate. Four times is a design decision, based on what will really happen, there will be some delay but not so much, you can change this multiplying factor if you like. So, suppose you want to change the analogue output no faster than once per second, the cut off frequency could be set at a quarter of a second or 4Hz. Applying:-
RC = 1/2piF
You get a value for RC of 0.039, so you can substitute actual values of R and C to find what is practical. Start with a resistor value of 1K this needs a capacitor of 39uF, where as 10K would only require 3.9uF. These are not values of capacitors you can get, but 4.7uF and 47uF are. So lets chose them, and put them back into the design to see what our cut off frequency will actually be.
F = 1/2piRC
Gives 3.38Hz, you may consider this hi or low, if so start with a capacitor value you want, or you have, and see what the resistor value comes out at and choose the closest available value. When the real cut off frequency looks acceptable, the final thing to do is to see how much ripple will be on the signal.
Ripple is the vestiges of the PWM signal, and you can never completely remove it, just make it smaller. The default Arduino PWM frequency is 490Hz. so at this frequency the Xc for a 47uF capacitor is 6.9 Ohms. Apply this to the potential divider formula with 1K as R1 and 6.9R as R2. This gives a ratio of 0.00685, remember you started off with a 5V peak to peak signal, so you need to multiply this by five. This reveals you would get about 34mV of ripple. Is that enough or too much? Only you can tell, as you know what you are designing. If it is too much, then you could revisit the design considerations of the cut off frequency. If that is not an option the you can consider altering the PWM frequency of the Arduino to make it higher, alternatively you could use a higher order filter.