Since the semester is fairly advanced and I need to prototype some of the ideas I have been having for the wooden toys, I decided to use a fan. I really like the idea of a toy that blows a gentle breeze to your face. Not only sweet but stimulating and relaxing to some extent.
The Fan
The fan is essentially a set of blades attached to a DC motor. They are often used to cool down electronic devices but in this case I am planing to give them a more pleasurable use. Depending on the kind of bearing they mount, they are more or less efficient, and more or less expensive. In this case, and thinking in small steps, I have chosen a fairly small model, reasonably powerful and that does not consume too much current (160mA). If the thing works well, I will think of buying a more efficient one, maybe under the 75 mA. has only 2 wires, one connected to VCC (5v in this case) and another to ground, and it only spins in one direction.
The Schematic
The circuit that drives the motor is relatively simple. However, there are a few important aspects to take into consideration now that we enter the world of actuators with this exercise. Some components that will play an important role are:
The Schematic
The circuit that drives the motor is relatively simple. However, there are a few important aspects to take into consideration now that we enter the world of actuators with this exercise. Some components that will play an important role are:
- Regulator: a component designed to automatically maintain a constant output voltage from a range of input voltages. Although the fan I am using works at 5V, it takes more current that the one the microcontroller can handle. Moreover, and thinking of the integration of the circuit in my prototypes, I want the board to be autonomous and therefore be able to power it with a battery. For those reasons the regulator becomes essential.
Capacitors are recommended both in the Input and the Output of the regulator, as show in the picture, to help filter and control the loop respectively. Moreover, a diode was placed at the exit of the regulator, avoiding back current flowing between OUT and GND when the board is powered through the AVRISP. This would cause the internal resistor to heat up in excess, and damages in the regulator might occur.
Regulators will burn if connected backwards! Neil recommends placing another diode before the regulator, but I opted for not doing it (one more component, more space, more cost...). Instead, I engraved a + and - symbol next to the connections, so I make sure I don't place the cables wrongly. It is also important to not connect the board to both battery and the ISP at the same time, or the regulator can burn.
Very important! Make sure that your regulator is able to handle the amount of current that your device need from the power source. I didn't...As a consequence of the use of the regulator, there are now two kinds of "power nets", one between the power source and the regulator (POWER), and another after the regulator (VCC). It is important to know to which power net every element should be connected to.
- MOSFET Type N: a transistor,
by far the most common in both digital and analog circuits, it requires very little current to turn on (less than 1mA), while being able to switch a huge amount of power (10 to 50A or more) with very little resistance. They can be N type (NMOS) or P type (PMOSF) depending on the type of semiconductor substrate they are made with.
In the case of the N-MOSFET, electricity will flow though a piece of semiconductor material (between the Drain and Source pins) when a voltage is applied to the Gate pin. The closer to 5v the difference is, the more current is enabled to flow. If the applied voltage is low, the current flowing is also low. If the applied voltage is higher, the current flowing is also higher. This way the speed of the fan can be controlled through PWM! In this case, the MOSFET is needed because the I/O pins of the ATTiny can only supply 40mA, and the fan needs 120mA to work, so the microcontroller only sends the instructions to turn ON and OFF the MOSFET, and the later drives all the needed current.
- ATTiny 45: small yet big enough for the current application. As can be seen in the schematics, pins 6 and 7 are given a double use! What a revelation! Apparently this is a very common practice when the use of the pins don't overlap. For instance, pin 6 has communication purposes (MISO) when the board is being loaded with the program; while driving the fan through the MOSFET when the board is functioning. In the case of pin 7, it works as receiver when the FTDI cable is plugged, and as Socket when the ISP is connected.
- Screw clamps: since I want to board to be integrated on a reliable prototype, I need some reliable mechanical connectors.
Other components that are equally important and should not be forgotten in any board are:
- Capacitor between VCC and GND: it compensates for the power drops and it has to be of 1µF at least. But some components like servo motors might require the use of bigger capacitors!
- Resistor (10KΩ) to VCC on RST pin of the microcontroler: it prevents the Reset value from floating.
- 2x3 pin header: for the programing through the ISP. Took me time to understand that pin headers are not for specific functions. they are group of cables (2x2, 2x3, 2x5…) that enable connections. It is the numbers of pins and its physicality that makes them more or less suitable for different application / connections.
- 6 pin single raw header: for the FTDI connection. Although it could be avoided in simple circuits where there are no sensors to be read, I included it anyway.
The FTDI cable could be used to program the circuit too, but this would require the installation of a software that "tricks" the USB connection and in line with Emma's opinion, I don't think is very wise to play around with such an important element as the USB connector of your computer.
The Board
After having made the Fabduino and a very simple shield last week, as well as the hello.echo board the week before, this was my real first board design. And I must say that the most difficult part by far was arranging the layout of the components, making sure the board is as small as possible and that I don't have to make use of any 0Ω resistor to bridge traces (although is not a sin, it should not be necessary in such a simple board). I constantly keep thinking on Neil's believe that one should be able to design and make a relatively simple board to test something within an hour. Well... not in my case. More like a day.
However, doing this exercise, I have noticed a couple of things that, however obvious they might seem, are handy to keep in mind for speeding up future board designs:
However, doing this exercise, I have noticed a couple of things that, however obvious they might seem, are handy to keep in mind for speeding up future board designs:
- Handy to send VCC and GND around, so all different components have easy access to them. Sometimes the airwires are confusing, asking you to connect all this spots that are far away in the board, when the only thing you need to do is to connect those to GND or VCC.
- Put components with lots of pins in an empty space. Microcontroller in the middle, for instance, and different components to the sides of the pins they are connected to.
- Connectors towards the edges for easy access.
- Always as a convention, pin 1 (dot) on the top left.
- Make the boards a bit less tight, specially if they are not final products, but prototypes. You can save a lot of time if you give yourself space to work comfortably in the board.
- Be a bit less perfectionist with corners, parallelism and equal distances. At least not until the layout is sketched.
It was time to mill another board. But before I had to struggle with finding the right footprint for the aforementioned regulator! How come is not included in any of the FabLab libraries? Or even worst,how can it appear when I call the libraries in the layout screen but not in the schematic!? I realized then that every component in an Eagle library consists of 2 elements: package and symbol, and that for whatever reason some manufacturers only provide one of them, which causes the specific component to only appear in the board layout or schematic screen.
I consider this a good moment to actually review some of the components that always give me trouble when it comes to choosing the right footprint (I always have to check back to previous assignments!). Here they are:
As it can be seen, the new board turn out a bit larger than the previous one (but still compact enough to fit into the stand alone prototype). Following you can find the milling files:
Program the board
Programming the board was, no reasons to lie, very straightforward. The code (find here) is as simple as writing an analog signal to the pin attached to the transistor, using the PWM values to regulate the speed of the fan between min. (0v) and max. (5v).
This time, and based on the previous experience with the ATMega, I was very careful to check the microcontroler as soon as it was installed together with the few components it needs to work. I checked the fuses and burned the boot loader. I did the first using the terminal and typing avrdude -c usbtiny -p t45, being t45 the code for the ATTiny45 microcontroller. Typing avrdude -c usbtiny the list of possible parts appear. Quite handy.
This time the experience was just the oposite: no hustle whatsoever. I plugged, and it worked. Period. I even checked whether the board would get too hot after a while, but it didn't seem to be the case.
Note from the future! Looking closely at how to drive a motor I found out that there are quite some components that are necessary to not burn the N-MOSFET (and eventually the microcontroller) that I didn't include in this design. It looked to easy right? that fan connected directly to the MOSFET. Find out which components were necessary and why here.
Workfiles
Añadir un comentario