Tag Archives: electronics

Learn from my AVR mistakes

I’m learning a lot programming in AVR C.  There’s are a few subtleties to watch out for, and some of them have had me banging my head against the wall for days.  This post is an attempt to prevent anyone else playing with AVR outside of AVR Studio (I’m using Linux and the command line) from having the same issues.

Sections for avr-objcopy

When you compile an AVR C program, you get object code, which you have to convert into HEX format to flash onto the chip.  You do this using avr-objcopy, and there are apparently several valid ways of doing it.  I recommend learning about what the -j and -R flags are doing when you come across tutorials with this command in them.  I was using one from a tutorial that looked like this:

avr-objcopy -j .text -O ihex some.o some.hex

That’s all fine and dandy except it only works for programs that don’t end up using the .data section of the object code! Now, this wouldn’t be a big deal if there were any warnings about this, but there aren’t – you just have to know to add a -j .data. A better solution, posted here by clawson, is to use the -R flag to remove parts you know you do not want. Here’s my current strategy:

avr-objcopy -R .fuse -R .lock -R .eeprom some.o some.hex

This fixed 2 separate problems when I did it, one with struct initialization and one with my LCD displaying block characters for strings but working for single characters.

LCDiesel: Yet another AVR HD44780 LCD library

I created an HD44780 LCD library for the AVR architecture today. There were a ton already, and mine is based off of one by Peter Fleury. I added a couple cool little features, and decided it needed to be on github to allow people to improve it and access it easier.

LCDiesel on Github

Here’s a quick code example using the library:

#include <avr/io.h>
#include <avr/pgmspace.h>
#include <util/delay.h>
#include "lcd.h"

// Include the chars we want
#include "chars.h"

int main(void)
    /* initialize display, cursor off */
    lcd_command(LCD_FUNCTION_4BIT_2LINES );

    // Testing if x,y are set wrong
    lcd_gotoxy(3, 1);

    // Load character
    lcd_custom_char_p(0x00, _char_open_rectangle);
    lcd_custom_char_p(0x01, _char_heart);

    // We better still be at 3, 1


See how easy it is to define custom characters? Cool, huh? I think so. The heart and rectangle bit vectors are in chars.h, and are only compiled in when they are defined, keeping code size down. Here’s how I have it hooked up on the breadboard (and the output of the program above):


2 Projects completed within 24 hours: USBtinyISP Kit

Well, it’s a kit, so it’s kind of cheating. The other project was the Theramin, which I worked on for days. Anyway, this is a cute little kit you can buy for about $22 that, once assembled, can program pretty much any Atmel microcontroller IC. It’s pretty cool – for real. Anyway, it only took about 45 minutes (I was being careful soldering, could have had it done in 20 if I was hurrying). I’m very happy with the result – it lights up when I plug it into USB, and avrdude can talk to it. Now I just have to build a little header for my chip, and I can start breadboarding with it. The header pins are in the mail!

Flickr Tag Error: Bad call to display set '72157625847794027'

Error state follows:

  • stat: fail
  • code: 95
  • message: SSL is required

Pocket Theramin: Project Complete!

I finally finished my second real electronic project: The Pocket Theramin. I made a few changes/improvements to the design found here, and I really like my result. The basic circuit is exactly the same, but I added an LED and a toggle switch so I can keep it together as one unit all the time.

Also, I discovered that MAKE: Electronics is an awesome book. I highly recommend purchasing yourself a copy.

Flickr Tag Error: Bad call to display set '72157625843821033'

Error state follows:

  • stat: fail
  • code: 95
  • message: SSL is required

MintyBoost XL: Almost Finished!

Well, I finally drilled my PCB for my MintyBoost XL last night, and it was a great success. If you need PCB drill bits, order them from stevie66 on ebay. I got various sizes from 50 to 85, but I found the 65 to be the most useful. I used it to drill all but the largest holes on the board.

Flickr Tag Error: Call to display photo '5394561101' failed.

Error state follows:

  • stat: fail
  • code: 95
  • message: SSL is required

Once that was done, I soldered it all together. It came out very nicely. I struggled the most with the mint tin!

Flickr Tag Error: Call to display photo '5395156442' failed.

Error state follows:

  • stat: fail
  • code: 95
  • message: SSL is required

I hooked it up and tested the input: about 2.3v. Then, I carefully tested the USB output power pins: 5.03V! This thing works beautifully.

Flickr Tag Error: Call to display photo '5395157098' failed.

Error state follows:

  • stat: fail
  • code: 95
  • message: SSL is required

I found an issue with my implementation of this project, though. The LT1303 IC doesn’t support current above 200mA, so my phone rejects the charge after about 5 seconds. I found out you can request samples directly from Linear, so I’ll be trying out a 1302, and perhaps redesigning the board to use a newer generation chip I’m sampling from Linear Technology.

Overall, this is great for the intermediate electronics nerd who wants to take a circuit from board layout in Eagle to working semi-professional product! I had a lot of fun doing it, and making small modifications will be even more fun.

Making my own PCBs

I’ve always wanted to make my own PCB, so today is a special day for me.

This is for the MintyBoost XL, which is totally awesome. Now I just have to etch it, drill it, and solder all these little components onto it…

I used the instructions found here to create this little gem. They are very good, but I modified the method slightly. Instead of taping crap down, you just heat up the board like he says, carefully stick the paper to it toner side down, and start ironing for a few minutes, pushing hard and using the tip of the iron to go over every everything nice and hard. Also, cleaning is key – I used some 220 grit sandpaper and then acetone with a paper towel, and it turned out great.

The schematic is available here. All credit really goes to Robert Hunt though – it’s his design. Also, here’s my slightly modified parts list I ordered from Digikey for this project:

2 490-5401-ND CAP CER 0.1UF 50V Y5V RAD

Total parts cost: $11.87.

Not too bad for a little DIY and fun. Board cost a few pennies.


I got tired of waiting for my FeCl in the mail, so I used some awesome instructions to take Muriatic Acid (also known as Hydrochloric Acid) from Lowes and Hyrdrogen Peroxide and mix ’em together with the PCB to etch it, and also yield a byproduct of Cupric Chloride, which is also a reusable etchant itself! And it did a fantastic job:

I made sure to find plastic containers that don’t react or melt when exposed to the acid – my tray was from Walmart and is PVC and my container for the leftover acid was an HDPE milk jug. So far, so good!

Geomagnetic Superstorm?

From a recent edition of [CQ]() I was reading today…

Projecting the Impact of a Geomagnetic “Superstorm”
Posted: Jan 23, 2009

As the sun begins to rouse from its prolonged quiet period at the bottom of the sunspot cycle, hams around the world are looking forward to the next solar peak and the big band openings on HF and VHF that will accompany it. But a big solar peak can also result in big solar flares, followed by big geomagnetic storms here on Earth. And that has some researchers working for the National Academy of Sciences very worried. Their report, funded by NASA and released in mid-January, looks at the potential impact of a “super solar flare” followed by an extreme geomagnetic storm. According to NASA, the researchers looked at a huge geomagnetic storm that took place in 1921 (estimated to be 10 times stronger than the 1989 storm that left six million people in Quebec without power for nine hours). They then modeled its likely effects on the modern power grid.

Conclusion: the electrical power distribution system is likely to collapse across the eastern one-third of the U.S. as well as the Pacific Northwest, leaving more than 100 million people without power! Projected economic impact is some 20 times greater than that caused by Hurricane Katrina.

So enjoy those sunspots, but just hope the sun doesn’t get carried away with itself!

Source is [here](http://newsvc.cq-amateur-radio.com/) if you go to “View All.”

That’s scary stuff! Let’s hope it doesn’t cause too much harm.