So, this is going to get strange if I’m blogging about things I’ve already blogged about. I’m reaching pretty far back, but I think this is still new to the world. A while back I designed some boards, which I know is very uncharacteristic of me but I did it and they worked fine. I was surprised it worked the first time considering I took the schematic for the arduino pro mini, the adafruit wave shield, and a stripped down example circuit for the TPA3116D2DAP. I’m going to say right now that this audio chip is just silly, especially for my design. This chip can run in stereo or mono mode, and in mono and properly heatsunk it can drive 100W of power. I am using it basically at the lowest end of the power curve, at 5 volts where my power supply sits and that puts out about 3 or 4 watts of power. If I was using about 12 volts it’s be a lot more efficient, but I really don’t care that much about efficiency. Prototyping that chip was fun, and in the end I looked at the example circuit for the output and figured that since I didn’t stock any inductors they must not be all that important and I omitted them. Whether or not you agree with the logic, the circuit worked beautifully. To solder it to a board I put a square of 9 vias and used it as a heat transfer pipe to melt the solder on the power dissipation/ground pad on the bottom of the chip (all you need is a pencil iron, it can solder anything if you’ve got the finesse).
Building your own power amp with these chips is really easy and I highly recommend them in new designs. Given that my debate was over how to match the power of an lm386 at 9v with a different audio amp at 5v I think I succeeded. The rest of the board layout went well. I used a full size SD slot because it’s easier to get full to micro adapters than the other way around. I broke out all the pins in a square around the package since I didn’t want to bother with the arduino pinout. The FTDI header is upside down because it was easier to wire that way, there was no provision made for the height of the capacitors but they lay flat just fine, and the switch footprint doesn’t match because I didn’t trust the measurements the manufacturer gave and didn’t have time to get them here to measure myself. All that being said, the boards worked beautifully the second time. The first time I found that I got the atmega328 not the atmega328p. Basically it means that you have to either rewrite the definition to include this fact or run -F in your avrdude command. I copied the pro mini config file and tweaked one value to create a new board definition.
The wave shield and library are a little… primitive. Don’t get me wrong, it’s fantastic but it basically hasn’t changed since the arduino was through-hole. The whole thing relies on just moving chunks of WAV file to the ADC at a regular rate set by the interrupts. There’s basically no more smarts to it than that. This means a low part count, very common parts, and editing the library is easy for newbies to coding.
In addition to this I added a lipo charger (which does not work if you attempt to charge and use it at the same time, from the same source, without diodes) and a lipo fuel gauge. The fuel gauge may just be a watchdog that monitors the voltage but it’s easier than writing the algorithm myself. Now I’m up to: arduino, SD input, amplified sound output, battery, charger, monitor. That’s a pretty self-contained system. Now on to the tasks I can preform!
The plan was to make the elevator make a sound when moving. tapping into it wouldn’t be an option because this was actually entered in a hackathon in college and telling them I did that wouldn’t go over well. I tried discretised integration, I can’t sample fast enough to make an integrator that doesn’t drift. I thought about using an analog accelerometer and op-amps but I didn’t have any and then I’d be tuning drift with trimpots instead of #defines. I could also design a completely analog self-zeroing system but I’m lazy and didn’t have the parts at the time. What I did was implement acceleration bump sensor. I’d sense a blip either up or down and assume I was in motion for the rest of the time until I felt a bump in the other direction. This works except I make too many assumptions about how long and intense the bump will be. There’s play in the elevators I used so jumping on the elevator without it moving is enough to set it off. I did, however tune it so that with no overly strong exceptions it would work consistently. I think a gyro would have made this more robust but, say it with me: I didn’t have one at the time. It’s easy to implement something if you have all the right parts, the challenge is in the hack.
Here’s the video
Here’s the code
Here’s the board
Here’s the pictures