internal fragmentation

a personal journal of hacking, science, and technology

Thing 23: Trivial granola

Fri, 27 Feb 2009 15:54 by mpm in Uncategorized (link)

Not electronics, but another thing I’ve been experimenting with. This is a granola recipe reduced to its bare minimum for ease of preparation.

Preheat oven to 200°F
In a large pot, mix 1/4 cup each of sugar, cooking oil and maple syrup
Add 1/2tsp salt (optional)
Heat on stove until bubbly
Reduce heat and fold in 4 cups rolled oats
Place pot in oven for 1 hour

If you’re the type of person who likes to ruin things with raisins (and we are, but we ate them already), add 1/2 cup of ’em when you’re finished.

Miscellania

11:55 by mpm in Uncategorized (link)

Mercurial code freeze

10:23 by mpm in Uncategorized (link)

Mercurial has now entered a code freeze in preparation for next week’s 1.2 release. This is going to be be a few days later than hoped as there were some issue with getting Windows test releases built that needed sorting out. Ahh, Windows..

Thing 22: Rescuing Angela’s flash data

Wed, 25 Feb 2009 01:39 by mpm in Uncategorized (link)

Some students sat down across from me today at the coffee shop and one of them managed to break her flash drive while trying to transfer some files. Some panic ensued, as the drive apparently contained the only copy of her class project. After watching much fiddling, I offered to take a look at it. The connector was quite loose. I pried it open and as I suspected all the connector pins were pulled right off the board.

I tried aligning the pins and applying pressure across them to get the drive to mount, but no joy. Its LED blinked, but Linux wasn’t detecting a new USB device. Stiffer measures were called for. I took it home and fired up the soldering iron.

I could tell that simply resoldering the connectors wasn’t going to work, otherwise my first attempt would have succeeded. Copper pads had been pulled off and I was going to need to make some brand new connections. I pulled out some 30 gauge wire-wrap wire and proceeded to strip, flux, and tin all the leads. Hopefully I wouldn’t melt or burn anything else on this board in the process.

All hooked up but again: no joy. Not even a flashing LED. So I unsolder everything, wick up as much solder as I can, take some close-up photos and poke around with a multimeter and determine that three of four pads are no longer connected to the controller chip. The copper they pulled up had broken the trace to the pad.

This was going to be tricky. I was going to have to solder wires directly onto the controller chip’s legs, which were even smaller than the thinnest wire I have, not to mention much smaller than my cheapo soldering iron. I call Angela to let her know the prognosis was not good.

It was pretty hard to see even in macro photos which pins the broken pads were leading to so I found a datasheet for the flash controller (Phison PS2231) on the net and double checked. Vcc (pad 1) to rightmost pin, and data in and out to pins 5 and 6. Right next to each other and crossing. Fun fun fun!

I set about refluxing and retinning all of my leads and putting a bit of flux on the chip leads as well. Then I soldered the leads on. Vcc was easiest – I set the lead against the outside edge of the first leg and touched the iron above the lead end for about a second and it stuck. Next, I touched the third lead to the solder pad at the bottom of leg five and again briefly heated it to get another fragile connection. Lead two I attached to the upper shoulder of pin 6 to get maximal distance from the previous connection.

I carefully maneuvered my laptop into position to plug it in without disturbing the fragile connections.. and it worked! Drive mounted properly and all files recovered. Not bad for a software guy.

Then I got to explain to an art student what Linux was and what the difference was between megabytes and gigabytes.

Minimal I²C interface

Tue, 24 Feb 2009 03:32 by mpm in Uncategorized (link)

Phillip Burgess has a clever approach to interfacing with external 2C devices from your laptop: just plug them into your VGA port. The DDC channel that the monitor uses to report its available display modes is just a subset of I2C. Even if you have no idea what I’m talking about, be sure to check out his fabulous compatibility chart.

This suggests another super-cheap method for programming AVRs. Use one AVR as an I2C slave, and allow the master (ie the laptop) to send down commands to drive its four remaining pins, which are attached to the appropriate pins on the device to be programmed. This is significantly easier than USB and available on most machines, though not without some software compatibility issues mentioned above.

Thing 21: Spider cable

03:04 by mpm in Uncategorized (link)

Today’s hack is an in-circuit programmer for breadboards. All my photos of my breadboard thus far have been cluttered with the programming wires. This arachnid-looking contraption lets me easily remove all that clutter. See my note on programmers from yesterday for the pin-out. Here’s the spider cable with its victim:

An IC test clip would also do the job, of course, but I don’t have any.

Three simple programmers for ATtiny MCUs

Mon, 23 Feb 2009 02:12 by mpm in Uncategorized (link)

Method 1: The simplest method is the so-called ‘DAPA’ programmer, which directly controls the programming pins via a PC parallel port. For this to work, you must have a ‘real’ parallel port, and not a USB adapter.

Name ATiny25 pin Parallel pin
MOSI 5 2
MISO 6 11
SCK 7 1
RESET 1 16
GND 4 18

This programmer can be built for under $2. All you need is a parallel port connector, some wire, and a standard DIP socket (I just use a solderless breadboard). You can add Vcc from the parallel port as well, but it’s a bit simpler and safer to use an external power supply.

Method 2: In a similar vein is the DASA device. This works by bit-banging the programming lines through the control lines on a standard RS-232 port. Generally, this will work with a USB serial adapter. It needs extra hardware to adapt from RS-232 to ‘TTL’ levels. The simplest way to do this is with zener diodes. See Lady Ada’s MiniPOV for an example (upper left part of the circuit).

Method 3: If you can stand to order and wait for and build a kit, you might want to check out USBtinyISP ($22), which is about the cheapest USB design available. It’s based on an ATtiny 2313 driven by a 12MHz crystal, but it should be possible to do this with an 8-pin ATtiny with no crystal.

RSS link fixed

01:43 by mpm in Uncategorized (link)

A redirection bug was keeping the RSS 2.0 links in the header from working, now fixed.

Thing 20: Proton nanokernel

Sat, 21 Feb 2009 02:55 by mpm in Uncategorized (link)

Today’s thing is a kernel-like infrastructure. It provides:

  • serial I/O
  • timer initialization
  • event scheduling and clock incrementing
  • I/O pin helpers
  • sleep and powersaving
  • ADC and temperature reading
  • debug value logging
  • pseudo-RNG with persistent seed
  • hardware RNG
  • boot counting
  • oscillator and temperature calibration storage

It also has some convenience macros:

  • aliases for common types (u8, u16, etc.)
  • physical pin number macros (P1, P2, etc.)
  • hex character generation
  • shorthand for bit generation (eg B(P1))
  • This framework greatly simplifies a lot of the techniques from my earlier projects. The demo blinks two LEDs with independent timer events, while the main thread writes out serial data. When it receives a character via serial, it echos back its hex value.

    There’s of course a lot more to do here. In particular, the timer management code is a bit too slow to run at 57.6kHz without interfering with the serial receive side – I’ve had to bump it down to 38.4. And the assembly that GCC generates for (1 << y) here (used for toggling pins) is quite sad. If I want to make this faster, I'll have to give in and hand-code some assembly. I'll also probably want to add some generic code for managing LED PWM via charlieplexing or the like.

    Proton source is here (as a single header file)
    and a basic demo is here.

Elsewhere

Fri, 20 Feb 2009 16:26 by mpm in Uncategorized (link)
Older Posts »