Vim Colorschemes with Putty aka. GUI vs. xterm-color256

256 color Vim in Putty

I made a big step in coding geekdom this summer by upgrading the most low-level part of my programming workflow. It started when I got frustrated with Mac keyboard shortcuts on Scandinavian keyboard layout (they Just Don’t Work for most apps), and switched to US layout in coding. Once I made that transition, I started thinking that maybe I could improve my coding speed a bit more, and see what all the fuzz is about Vim.

The greatness of Vim in coding comes from the fact that Vim has separate modes for editing text, and navigating around. While not editing, all normal keys become powerful commands, and you can do text manipulation like duplicating lines, indenting sections etc. without ever leaving this “normal mode”.

Well, Vim is great, but an additional bonus to its power is the fact that almost every *nix system has it preinstalled. So even if I’m not on my own computer, I can just launch an SSH client and use Vim to edit the piece of code I’m working on. No need to compromise. Except color schemes, which I just couldn’t get working over Putty. Today I solved that puzzle after one and half hours of googling, and thought to share the findings, maybe someone will find this the next time they face the problem.
Continue reading Vim Colorschemes with Putty aka. GUI vs. xterm-color256

Safe Return-to-Owner Keytag

Safe key return via mail forwarding

Something else than electronics this time: A real life hack for your keychain to make it possible for a finder to contact you in case you lose it, while maintaining full anonymity. There are commercial alternatives, but I already need the red plastic piece for shopping cart locks and decided two tags would waste valuable pocket estate.

Using my own phone number or e-mail was out of question, because they would easily lead to my home address. So I chose a very simple, free “public email” provider, Spambog. The service treats email addresses more like web URLs so there’s no expiration or need for password protection, but if you choose a too simple alias, chances are that someone else might choose to use it, too!

Spambog offers a nice RSS and URL options to follow the e-mail (no forwarding, though, but you should only receive 0-1 emails ever so who cares). And even if someone did choose the same alias, the only drawback would be the possibility of a random person receiving the same “I found your keys!” mail, and chances are they don’t live nearby and do robbing houses as side job.

DIY ATtiny45/85 ISP Header

ATtiny ISP header in practice

A quick weekend tip for a change, I thought to share a nice small soldering project will make programming ATtiny45 and ATtiny85-based projects a flash:

Basically I took a piece of veroboard, soldered some extra long pin headers on the bottom so it will form a tent of sorts above a ATtiny45/85 attached to a breadboard project. Then I soldered a 6-pin header to attach the ISP programming cable to, and used short pieces of jumper wire to route the header pins to correct ATtiny85 pins.

Now whenever I need to flash a ATtiny45/85 project sitting on a breadboard, I can just put this on top of that and never need to look up the pin layout again!

DIY ISP header closeup

You can click the images for larger versions. I’ve also been quite busy with my PS/2 projects, so I have some nice material to share regarding that when I have some free time again in my hands!

Minimal PS/2 Keyboard on ATtiny2313

AVR PS/2 keyboard

I recently got myself a mechanical keyboard (to be precise, a Happy Hacking Keyboard Professional 2). One side effect of this switch was, that the new keyboard no longer works with simple passive PS/2 adapter. And the only type of input my current motherboard can be configured to power up on is spacebar from a PS/2 keyboard.

Well, I had read from somewhere that PS/2 protocol is not too complex, so I decided to find out if I could make a simple gadget that would send spacebar keypress over PS/2 when a switch was toggled. That turned out to be quite easy (with some limitations, read the end of this post to find out more).

PS/2 basics

The Wikipedia page for PS/2 connector already looked promising – there are GND and VCC pins straight available, and only two additional (open collector type) lines are needed for data and clock lines. Communication is bi-directional with the keyboard providing clock signal and sending end toggles data line while the receiving end listens.
Continue reading Minimal PS/2 Keyboard on ATtiny2313

Tips and Tricks: Flashing already soldered MCUs

I have been wanting to try this one out ever since I soldered together my USB password generator six months ago, just to realize that I would’ve actually liked to make a few changes to the firmware. The problem with my design was, that I had managed to pack everything so tightly, that there was no hope of reaching the ATtiny85 pins via normal methods to reprogram it.

I initially tried to use a 8-pin DIP socket and press it against the MCU, but it soon became apparent, that I could not keep it stable for all the pins to keep contact long enough. Lacking proper microhooks, I had to postpone the idea shown in the above photo until I just recently put my hand on this set of IC hooks from SparkFun.

The five IC hooks came one hook short of the six needed by the ISP header, but fortunately/unfortunately one of the pins was impossible to access even with these tiny hooks, so I manually held a yellow jumper wire against the MISO pin while running avrdude. Did it work? Look for yourself:

Definitely not rocket science, but for $4.95, I’d say it’s a pretty good deal!

Repairing a Shuttle motherboard with new capacitors

Just a short post today, in case this will save someone’s day like it did my friend’s. He has a small Shuttle PC setup that suddenly stopped working about three weeks ago – the machine seemed to power up, but no picture came to screen. After some googling, he found out that the motherboard of this specific MB+case combo sometimes dies because of failed capacitors. And indeed, the biggest caps on the MB seemed to have a slight bulge on the top. So he called me if I could help him to replace them, to see if that would help.

The first thing to do was of course procure similar caps. The possibly failed models were three 1500 uF, 10V caps, so I got four new ones to replace them.

Removing the old caps

The first task was to remove the old capacitors from the motherboard. Because we wouldn’t be needing them, we used some force and cutters to first remove the capacitors themselves, and then set out to remove the legs with a solder iron. Unfortunately, the lead-free solder had a melting point beyond the number 7 tips of my Weller Magnastat, and no amount of heating was able to remove the legs!
Continue reading Repairing a Shuttle motherboard with new capacitors

World’s Simplest Logic Analyzer for $5

Today’s post documents my recent hack that may just be the world’s simplest logic analyzer. More accurately, it is a circuit consisting of a 74HC126 quad buffer chip and R-2R resistor network (eleven 330 ohm resistors) that acts as a D/A converter, enabling one to analyze four logic lines with a single channel digital oscilloscope and $5 in parts!

With the circuit described below and an entry level USB scope like the PicoScope 2204, bursts of data can be captured at 10 MSps (million samples per second), and continuous capture rates of 2.5 MSps are possible, the length of the capture only limited by your PC’s memory. This is obviously much better than recently covered Bus Pirate’s 1 MSps for 4 ms!

Even higher throughput can be achieved with better scopes, although the A/D conversion requires several consecutive samples at same logic level, which means that a 100 MHz scope with 200 MSps capture rate should generally be able to analyze logic operating at ~40 MHz speeds. At such speeds, a fast buffer chip and D/A converter is naturally needed as well.

Above you can see an example of SD card traffic analyzed using my circuit – the full capture was 10 million samples which enabled me to capture all the traffic generated by my SD tutorial project without any additional triggering. Read on for details of the hack. A lot of effort has been made to keep the material very accessible and informative to electronics beginners, too. In the end of the article, source code for PicoTech 2000 series is included, and it can easily be adapted for any scope that can transfer captured waveforms to PC (in the simplest form by reading waveforms from a CSV file).

How It Works

Basic idea is to connect 4 logic lines to a D/A converter, that will transform the binary 1/0 values (represented by VCC and GND voltage levels, respectively) into a 16-step analog waveform. Because input lines cannot be directly connected to the R-2R resistor network that is used to do the D/A conversion, a 4-line buffer chip is used in between to provide high impedance inputs that do not interfere with the logic being analyzed.

Continue reading World’s Simplest Logic Analyzer for $5

Handy Pinout Reference Sheet

Just thought to share a quick tip today. I’ve noticed that when doing work with AVR MCU’s, I’m using ATtiny2313, ATmega88 and ATtiny45/85 for 99 % of the time. I got tired of opening the Atmel data sheets every time when swapping a new chip into a breadboard, so I constructed a real cut’n’paste reference sheet by gluing the relevant portions on a piece of rigid cardboard:

I even used a piece of paper to mark the 6-pin header pinout, it’s a real time-saver! And thanks to the cardboard back, it’s easy to keep below my LCD monitor and pull out every time I need it. Additional idea would be to leave some white space around the pinouts and laminate it with clear contact paper, so I could doodle project-specific notes with a water-based marker and clean it after I don’t need them anymore!

Oh, and as you can see, I’m using a Mac this time to do some flashing. I installed the excellent Crosspack for Mac from Obdev guys. It’s a streamlined way to install avrdude and avr-gcc on a Mac, and now I can take my electronics hobby with me when I’m traveling. :)