For the assignment I have decided to try a piezoelectric disc as an input device, a very simple sensor able to measure vibration from the environment, by transforming changes in pressure into electric charge. I am hoping to be able to prototype some magic interactions with wood, such a knocking, and being able to sense this knocking is crucial to be able to do something with it.
FabKit v0.4 (also called Fabduino)
Since I will eventually be prototyping different kinds of interactions and the ATTiny processors are fairly restrictive in terms of memory and number of pins, Emma proposed me to make the so called FabKit or FabArduino, a FabLab Arduino design and improved by the Fablab community, which includes an ATMega 328P instead. (More or less) detailed instructions can be found in this link.
I thought that instead of modifying the given layout to include all the elements needed to read from a piezo, it would be intelligent to have the standard FabDuino made, so I can quickly design and make shields myself that I can attach to it and will allow me to use different kinds of sensors without the need of a breadboard. I knew it wasn't the fastest option, but probably the most intelligent thinking about the future of my current Final Master Project.
These are the schematic, final layout and milling files for the Modela:
These are the schematic, final layout and milling files for the Modela:
What I envisioned to be a fairly simple task (just making the FabDuino that someone else had designed and offered as open source) turned out to be tricky and time consuming due to different aspects.
- First of all, I had to do some adjustments in the given board layout, since the given design included very close traces (the ATMega has very small legs!), not suitable to be milled out with the end mills available at the FabLab (1/64 inch.). Using the given png files, I rendered the path using the Fab Modules (software developed by Neil Gershenfeld for the machines used in the FabLab) to be able to see from the simulation where the paths were too close. Based on that I had to make some magic to give enough space between the traces, but I managed. The fact that the Modela Rules gives so many errors still when checking the final layout, that has actually been successfully milled (almost), makes me think that this Design Rules Check is only partially trustworthy and should only be used as a reference,
- I did find a couple of interrupted traces in places where the 1/64 inch. endmil could not enter, but they where easy to solve with the scalpel. The above attached milling file is exported after I fixed this two errors on the eagle file.
- I also substituted the pins for the FTDI cable (SMD) for some through hole single row pins, which I can stick in and bend over the board, something that I like better than the surface mounted version.
- I struggled for a while with an airwire in the Eagle file provided that turned out not to be a problem even if it remained unconnected. Somehow a redundant connection next to the switch (see pictures below).
- Soldering the microcontroller wasn't easy this time, because the ATMega has truly small legs. The way it worked best for me was to apply one dot of tin, approach the microcontroller while heating up this leg, and once partially fixed, then adjust the position until all the legs are well aligned. Another option could have been to put a bit of tin in every trace / leg, and approach the component as you heat up with the hot gun.For the rest of the legs, simply put a drop of tin on the tip of the iron and gently approach until the drop touches the leg and sticks to both the trace and the leg (in the best case scenario).
The final result was pretty neat, although the position of the switch makes it not very "shield" friendly. I opted for installing female headers like the ones that can be found on the Arduino UNO, so both standard cables and other shields that I might design can safely fit.
1Knock shield
I started with a 1 piezo shield, but the intention in the future would be to make a shield that can host a few piezo so I can sense the direction from which the vibration is coming. I'll see. As for now the design of the shield was very simple, basically including only a safety resistor between GND and the input; and a screw clamp (I don't like to be fearing that the eventual prototype won't work because the cable connection is week).
Programming the board
Programming the board
The new Arduino IDE (10.6) has brought significant difference when it comes to adding a custom board to the collection of boards available under Tools > Boards. Whereas before it was as easy as creating a text file called boards.txt within the Hardware folder as explained in the tutorial (Documents > Arduino > Hardware > "Your board" > boards.txt), for Arduino 1.5 and beyond the architecture is different and at least 3 different files are needed: boards.txt, platform.txt and programmers.txt (see this other tutorial).
Being this option too complex for me, I opted for installing an old version of the Arduino IDE (1.0) and having the board "installed" as explained earlier. Another option was to select Arduino Nano in the board menu, since it uses the same microcontroller (ATMega 328).
Now, the biggest problem (still unsolved) came when trying to burn the bootloader. I tried all three different options stated before hand but I kept having the same error.
Initialization failed, rc=-1
Double check connections and try again, or use -F to override this check.
A typical error message that pops up when there is a communication problem between the ISP and the board, mostly due to the fact that there is a short, some cable is in the wrong position or, as it was the case with me, the microcontroller does not respond.
After more than an hour troubleshooting with Emma, we came to the conclusion that the ATMega was broken, and although it was a big endeavor, I managed to removed and solder up to 2 new ones without removing any of the other components. I even broke a trace and had to improvise a solution with a piece of wire (see pictures below), and had a lot of troubles with not soldering pairs of legs together, which I did many times and had to fix with both the tin pump and the copper wire.
However, the solution didn't work and although the chip responded this time to the call in the terminal (see picture below), the bootloader appeared to be impossible to burn, which moreover cause the ruin of the 3rd microcontroller.
Note from the future: as it turned out, the only problem was... that I forgot to press the reset button when burning the bootloader! Such a silly mistake when it seems to be a common instruction appearing in every tutorial. I also substituted the 20MhZ regulator with a 16MhZ regulator to make sure everything was as similar to the Arduino UNO as possible (although at this point I don't know if it would have worked using the 20MhZ resonator and pressing the button).
CONCLUSIONS: always try to check the board and program it before you solder all the components. The only pins you need are the important 6: VCC, GND, SCK, RST, MISO AND MOSI (some of the are connected to more than one pin). At least, after all the hustle, I have learned really well how to search for troubles!
Alternative solution
Since the most challenging part for me is actually the code, I decided to try to work it out anyway by wiring the piezo to an Arduino UNO as seen in the following picture.
The code is simple (you can find it here). It reads the input from the sensor and turns it into volts to be shown on the serial monitor, sending a "Knock" message if the measured voltage raises over an programmed threshold. Some of the new elements I have use are:
- AnalogRead: reads the value form a pin that allows analog input (ADC Analog to Digital Converter). When using Arduino UNO, this pins don't need to be defined as INPUTS, since they are so by default, not being able to do anything else.
- Float: a data type for floating-point numbers, used to approximate analog and continuous values because they have greater resolution than integers.
- Float(): converts a value to the float data type.
Workfiles
- FabKit schematic
- FabKit layout
- FabKit milling file
- FabKit cutting file
- FabKit BOM
- Knock shield schematic
- Knock shield layout
- Knock shield milling file
- Knock shield cutting file
- Knock shield BOM
- Knock shield code
Añadir un comentario