Archive for the ‘Microcontrollers’ Category


Welcome back to this fourth and final installment of the series. The first three parts should have been enough to get you off the ground, but a few more learning examples wouldn’t hurt. It’s also a good time to discuss some of the other things these little chips can do. Join me after the break to:

  • Expand the sample code, adding features to our simple program while I challenge you to write the code yourself.
  • Discuss AVR fuse bits, how to use them, and what to watch out for
  • Touch on some of the peripherals you’ll come across in these chips

As a grand flourish to the series, I’ve used the example hardware from this final part to build a bicycle tail light. Hopefully this will inspire you to create something much more clever.

Series roadmap:

 

[Pyra] was looking for a way to reprogram some ATtiny13 microcontrollers in a SOIC package. He’s re-engineering some consumer electronics so adding an ISP header to the design isn’t an option. He had been soldering wires to the legs of every chip but this is quite tedious. What he needs is an adapter that can make physical contact with the legs just long enough to program new firmware. After looking around he discovered that a PCI socket can be used as a progamming clip (translated). It shares the same pitch as a standard SOIC package but is not wide enough for the chip. He cut out 4 rows of the socket and the section of motherboard it was soldered to. Then he made a cut down the middle of the plastic and bent the two sections apart. The image above illustrates this, but not shown are the eight wires that he later added to connect to the device.

We wonder if this can be adapted to program SOIC parts without removing them from a circuit board. That would be a handy tool for finishing up the LED lightbulb hack.

 

[Joby Taffey] takes the prize for the first completed homebrew game for the IM-ME. Over the last few weeks we’ve seen [Travis Goodspeed] working with sprite graphics, and [Emmanuel Roussel] developing game music for the pink pager. But [Joby] didn’t really use either of those.

[Travis’] sprites were using a framebuffer that fills up a lot of valuable RAM. [Joby] decided to draw the room screens (all of them have been stitched together for the image above) as a one-time background image to keep the memory free. From there, the screen is updated in 8×8 blocks based on cursor movement. He also decided not to add music as he feels the high-pitched piezo is not capable making sound without driving everyone crazy.

Source code is available and for those of you who don’t own this pretty handheld, the game can also be compiled in Linux.

 

[Riley Porter] posted a picture of his EvalBot USB power hack. In the photo above we’ve put a box around D6 and D7. The development board ships with a 0 Ohm resistor in the D7 location, patching in power from the USB-B connector labeled USB DEVICE. He found that by moving that resistor to D6 he can power the board from the USB-B connector labeled ICDI.

That connector is the In-Circuit Debug Interface. TI sent us an EvalBot bundle so we pulled it out and tried it ourselves. If you plug in the ICDI it doesn’t power the board, and no USB devices register. Shorting the D6 pads changes this and the following USB device registers:

Bus 002 Device 062: ID 0403:bcd9 Future Technology Devices International, Ltd Stellaris Evaluation Board

So it looks like you need to have two USB connections or be using batteries in order to program the board via USB. The uC/OS-III hardcover book that ships with the EvalBot bundle includes board schematics. We took a look and were surprised to see that they show diodes installed on both pads. Rev A of the online schematics have been corrected, showing an omitted diode on D6 and the 0 Ohm resistor on D7. Images of both schematics are included after the break.

It would have been nice to see a selector switch installed here to give you a little more flexibility when prototyping.

Read the rest of this entry »

 

[Emmanuel Roussel] is coding a version of Tetris for the IM-ME. Before you get too excited, he hasn’t actually written the game yet, but instead started with the familiar theme music. The IM-ME has a piezo speak on board so it’s just a question of frequency and duration. [Emmanuel] developed an Open Office spread sheet that calculates each note’s frequency and the timer value needed to produce it. He then created a data type that stores a note and its duration and used an array of those structures to store the song. If you’ve ever wondered how to cleanly code music this is a wonderful example to learn from because right now the code doesn’t have anything other than that code to get in the way.

The ground work for this was established in the other hacks we’ve seen. Now we’re left wondering who will finish coding their game first. Will it be [Emmanuel’s] Tetris or[Travis’] Zombie Gotcha?

 

In the last installment of our tutorial series we built a simple circuit on a breadboard and programmed an ATmega168 to make it run. That proves that you know how to follow directions, but the eureka moments of doing everything yourself are on the way. This time around you will get down and dirty with the datasheet, learning where each line of the sample code came from, and give your recently installed compiler a test drive. We will:

  • Talk about bitwise operators and how they work when coding for microcontrollers
  • Discuss C code shorthand
  • Review the sample code from Part 2 and talk about what each line of code does
  • Learn to compile code

If this is the first you’ve heard about our AVR Programming series, head back to Part 1and start from the beginning. Otherwise, take a deep breath and we’ll being after the break.

Read the rest of this entry »

 

Here’s a study in sprite animations that [Travis Goodspeed] put together. He’s working with one of his favorites, the pink IM-ME device that he’s been hacking on for a whilenow. But if you don’t have this hardware that shouldn’t discourage you. There’s a lot to be learned from his methods which will translate to any microcontroller working with a graphic LCD.

He starts with a 24-bit PNM sprite that includes three frames of his desired animation. From there he needs a way to store the data for use with 8-bit microcontrollers. He chose to write a Perl script that will translate the image format into a 1-bit map. Each frame of the animation takes up a column width that is a multiple of 8 for easy retrieval by the processor. This translation into a C array, and the accompanying code that translates it into data for the frame buffer is the key to the animation process. What is he shooting for? A sprite-based video game on the handheld.