Thursday, June 27, 2013

Sometimes Hacking IS Better

Embarrassing.

It took all of ten minutes to run a wire from my computer's headphone jack to an Arduino, hook up the strand of LEDs I have wrapped around the monitor (via a TIP120), and throw a bit of software together to blink the one in reaction to the other.

But I wanted something neater.  I wanted it bulletproof.  At the moment, I've managed to make something full of holes.  Instead of being bombproof, it looks like a bomb.  From a cheap movie.



A day or two to get it all working on breadboard; LM368 amplifier, LM741 balanced input stage, two trim pots for gain and DC offset, and another of those ubiquitous 7805 voltage regulators.

Of course when time came to put it in a box I tried to be fancy.  And thus blew a full day on just that.  Adafruit Altoids-sized perma-proto board.  Not quite enough room for jacks so I stuck Euro-strips on the outside of the mint tin.

First problem; the TO-220 style heat sink was too big to close the lid on.  I may hit five amps on this (I suspect it will be more like two amps in practice but I'm trying to play safe, right?)  So the box is without a lid.  And the components got even more cramped.

Second problem; I bricked both my ATtiny45's, and there isn't a simple way to port Arduino code (or use the Arduino IDE) on my one remaining AVR; a venerable ATtiny13.

I have some ATtiny85's on order (more 8 pin dips that will run at 8 MHz on internal oscillator).  In the meantime I had to get the rest of the circuit running, so I strung wires to an Arduino that very much doesn't fit in the box.

(This may still be a problem; the code will need adapting for even the ATtiny85's.  I might need to program in C anyhow.  But I lost my old AVR toolkit in a computer crash, and the new one seems to make it much more roundabout -- in the interest of "better and more efficient," of course! -- to access the registers.  Plus, I never did figure out how to work the ADC, which turns out to be rather more complex than doing PWM and other timer interrupts.)

Oh, and although it worked fine on the breadboard, the balanced input stage refused to work in the box.  And I rebuilt a duplicate on the breadboard and patched it in and it still doesn't work.  So I gave up and jumpered over it.

Which means at this stage, I could have just popped a shield on an Arduino and been done.  Not like I'm really going to need this specific circuit again, right?



It also struck me, as I was setting trim pots and juggling op-amps, that I could have just done the whole thing analog at this point.  I did it in digital because that gave me the ability to do signal processing in code; control the dwell time and so forth.  Except I'm learning that the audio signal varies so widely, software adjustment isn't sufficient.  I needed to have analog real-time adjustments (aka trim pots -- even if one of them is fed into an ADC port in order to set an offset number).

So no pictures for this entry.  I'm too embarrassed by the thing.  Pics after I've patched it up into something nicer.



So my other show-off project before tomorrow's meeting is to fake up the first DuckNode.  One problem; the only analog accelerometer I have is on my POV stick, and I don't want to take that apart just yet.  So I may have to wire up the I2C accelerometer, adapt the code to a friendly I2C library...and THEN wire the analog one on to an XBee.

The big question is whether I can remember what I'm doing fast enough to adapt my work-in-progress Processing framework to detect the remote accelerometer.  I could use another weekend to work on this!

No comments:

Post a Comment