Code and Life

Programming, electronics and other cool tech stuff

Supported by

Supported by Picotech

Fast DDS with ATmega88

I’m planning to make some RFID hacking in near future using 150 kHz tags. Since I don’t have a signal generator, I decided to go where quite many people have gone before and build myself one, more specifically a DDS. Instead of just taking a complete project from the net, I thought this would be a good way to learn a bit of AVR assembly programming, and manual D/A (digital to analog) conversion using R-2R ladders. Here’s what I built:

I’m skipping the schematic to save some time – basically it’s a ATmega88 with 6-pin programming header, power, a 16 MHz crystal (other frequencies also work, lfuse for this setup if 0xFF) and a red LED that is not used. The R-2R ladder is wired with white jumper wires to PB0-PB5 (it’s a 6-bit DAC) so that PB0 is the “least significant bit” and PB5 the most significant one. Read on for details.

Read post

Weller Magnastat Autopsy and Repair

Immediately after soldering together my USB password thingy, my solder iron, the family heirloom Weller Magnastat stopped working. Some investigation showed that the base station was providing 24V AC voltage just fine, so I decided to unassemble the handpiece to see if something could be done. Here’s what I found:

It turned out my iron was salvageable; read on to learn a bit about the Magnastat and how I was able to repair mine.

Read post

DIY USB password generator

Having done half a dozen V-USB tutorials I decided it’s time to whip up something cool. As USB keyboards were an area untouched, I decided to make a small USB HID keyboard device that types a password stored in EEPROM every time it’s attached. A new password can be generated just by tabbing CAPS LOCK a few times (4 times to start password regeneration and one tab for each password character generated, 10 is the default password length). Below you can see the device in action:

The place I work at requires me to change my password every few months so this would be one way to skip remembering a new password altogether (as long as I remember to write it down before regenerating a new one so password can be changed :).

What is inside?

The device is powered with a simplified version of the hardware I used in my ATtiny85 USB tutorial – I stripped away the LCD, reset pullup and both capacitors. If you’re better in cramming components inside enclosures I suggest adding at least a 0.1 uF capacitor between VCC and GND, but it seems to work fine even without it:

Read post

DIY resistor folder for 9.90€

If you’ve done even a bit of electronics, the chances are that you’ve already amassed a hefty collection of resistors. Buying them is fun but finding the right values from a stack of resistors is not. I noticed that you can buy actual “resistor folders” with nice labels and the full E24 series of 1500 resistors for $100. I already had resistors so I decided to make my own folder with less expense.

I walked into the nearest book store and quickly found a promising offering: 10 transparent plastic sheets of “collectible card holders” for about 3€. Any store having binders and associated supplies will probably have something similar. I also bought a thin A4 binder and 200+ label stickers for about 9.90€ total (about 1:1 to dollar prices). Here’s what I came home with (already added the stickers):

Each sheet had 9 pockets so for 3€ I get storage for 90 values, and 10-20 resistors fit into a pocket without making the page too heavy. I labeled the first 72 based on my E12 series and that left me with 2 extra pages for “exotic” resistor values. Here’s the first page of E12:

Read post

V-USB: Outputting Data with usbFunctionRead()

I promised to commenter Marek to post an example of using usbFunctionRead() to return larger amounts of data. So building upon the ATtiny85 version we made in last part, let’s add one more command to usbtest.exe:


#define USB_DATA_LONGOUT 5

// [...] Change the buffer size in main():
    char buffer[2048];

// [...] Add the following in the if-else structure in main():

    } else if(strcmp(argv[1], "longout") == 0) {
        nBytes = usb_control_msg(handle, 
            USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, 
            USB_DATA_LONGOUT, 0, 0, (char *)buffer, sizeof(buffer), 5000);
        printf("Received %d bytes: %s\n", nBytes, buffer);
    }

Now let’s tell V-USB that we’re implementing usbFunctionRead() and doing transfers of more than 254 bytes in usbconfig.h:

Read post

7 Segment Multiplexing With ULN2003 & PNP Transistors

The reason a started my electronics hobby was that I wanted to build a chess clock. Lacking a proper LCD display, I chose to multiplex several 7-segment displays. Most sources in the net did not specify hardware at all, and those that did were driving the segments with a 74HC595 shift register and using NPN transistors to enable one common cathode display at a time. However, if you look at 74HC595 specs you’ll notice that it’s not designed to source the amount of current that is required to drive several multiplexed 7-segment displays. It might work, but no one can say for how long!

It took me a while to find a good, inexpensive and readily available alternative. I finally found it in ULN2003, which is inexpensive darlington array that can drive 500 mA from each of its pins. So I decided to write a little tutorial on 7 segment multiplexing that walks through all the needed hardware and software in detail. Here’s what we’ll build (click for a larger image):

For this tutorial I assume you know how to connect ATtiny2313 to a programmer and flash it with custom software. You’ll learn as much in IMakeProjects.com’s AVR tutorial. You’ll also need the following components:

Read post