Tuesday, January 31. 2012
I use a Linux box with a cheap (but extended-range) bluetooth dongle to monitor the invertor for my solar panels, and also my central heating monitor. This is fine, except that occasionally the bluetooth dongle seems to crash, and it needs to be physically unplugged to recover. Since there doesn't seem to be any comprehensive way to do this through software (you can reset the device, but it doesn't perform a power interruption so doesn't recover it sufficiently), I decided to make a little hardware dongle to do it for me.
The design is extremely simple - just use an ATTiny to periodically (perhaps once a day) interrupt the 5V USB line. All other USB lines (data +/-, GND) pass straight through. Rather than power the attached device directly from an ATTiny I/O pin (which can only source ~40mA) I drive the attached device's power line through a PNP transistor (in this case rated at ~ 200mA, which is enough for my purposes, but 500mA would be needed for general purpose USB loads).
Continue reading "Automatic USB disconnector"
Monday, January 30. 2012
Here's something to aspire to - being able to wring miracles out of the ATTiny as well as this guy: Electronic Lives Manufacturing.
Using just an ATTiny45 and a loudspeaker, he's able to produce a full, polyphonic musical box using wavetable synthesis, capable of playing tunes with over 300 notes. It's a far cry from those musical greetings cards inserts, which are usually just monophonic square wave tone generators and a piezo transducer.
To achieve the necessary speed and compactness (just 4KB of flash space), it's all written in AVR assembler. I'm not sure I've got time, or room in my head, to learn yet another assembler instruction set, but this is certainly some pretty serious inspiration to get the most of these amazing little chips.
Given that I've got ATTiny85s, with double the flash space, I'd quite like to tinker and add some simple extra functionality to this (e.g. deep sleep mode, playing one cycle of the tune for each press of the reset button; and my own choice of tune) but that might have to wait a while.
Sunday, January 29. 2012
Having captured audio over a microphone, and converted to a voltage suitable for the Arduino ADC, the next challenge is capturing the analogue data and converting it into an estimation of the frequency of the current note being heard. That's a fairly tricky problem, as it turns out.
Firstly, the default Arduino analogRead() function is way too slow. At 100 microseconds per read, that's a maximum sample rate of 10kHz - and even that is only possible when tight-looping doing reads, and nothing else. According to Nyquist's theorem, at a bare minimum I need to be able to sample at at least twice the highest note's fundamental frequency, which is probably going to be about 1kHz, so double up to 2kHz. I'd ideally like to sample at least 5-6 times the highest fundamental, and calculating the incoming frequency requires some maths too. So, I decided to look into alternative approaches.
A naive approach to frequency counting is to count zero-crossings in a given direction - i.e. observe the waveform, and everytime it goes from negative to positive, increment a counter. Counting the number of crossings in a given time directly gives you the frequency. It turns out that both the ATTiny85 and the ATmega328 (Arduino) chips both contain an analogue comparator, hooked up in such a way that zero crossing counting can be done extremely efficiently.
Continue reading "Instrument Tuner - Zero Crossing analysis"
Saturday, January 28. 2012
I've been experimenting with creating some sort of instrument tuning helper device, as it seemed like a good mix of analog and digital, as well as a useful thing to have around the house after the arrival of a Ukulele shortly after Christmas.
More on the trials and tribulations at the code level later, but I thought I'd experiment with the Fritzing circuit design package as a means of recording my more complex circuits, starting with the AF input stage for the tuner. At first glance, Fritzing seems like everything I need:
- It can handle breadboard representations - in fact, you can enter your circuit via the breadboard view and it will automatically generate a schematic and PCB design, if you want them.
- The output looks nice
- It seems popular
- It's free!
Continue reading "Instrument Tuner - Audio Input Stage"
Thursday, January 26. 2012
Most recent first... Yesterday it occurred to me that I haven't ever played with servo motor control, despite having received one in my Sparkfun starter kit.
Since I'd just received a Wii Nunchuck breakout adapter from ThingM Labs, I figured I'd kill two birds with one stone and have a bash at controlling a servo with a nunchuck.
The circuit couldn't be much simpler, just connect the servo power to 0V, 5V and digital pin 9, and plug the breakout board (after soldering on a simple 4-pin header) into analogue pins A2-A5:
Continue reading "Servo toy"
Thursday, January 26. 2012
Gosh. It seems like forever since I blogged here. And that's maybe because it is.
I've discovered a new playground recently with Arduino, and the world of physical computing, and so it seemed worthwhile to start recording some of my adventures.
Arduino is an incredibly easy way to prototype embedded computing hardware - sometimes known as physical computing, because it's all about the process of interfacing microcontrollers with the physical world. Once upon a time, prototyping such hardware required a lot of knowledge, equipment, money and effort - so although I was capable of doing it, I rarely bothered. But Arduino changes all that - making it trivial to run software within gadgets, and to develop intelligent hardware that can easily interface to a standard PC.
Arduino consists of an IDE, a standardised hardware platform, and a set of libraries, all of which are open source. If you've never tried it, then I urge you to give it a go - you can buy a starter kit that will give you weeks of fun, for less than £50, and it's a completely open-ended hobby.
Anyway, this section of the blog will be used to document some of my Arduino projects, and the lessons that I've learnt along the way. That's assuming that I can tear myself away from playing for long enough to type things up...!
|