PDA

View Full Version : [Question(s)] What library for use with an ATmega168?



JoeStrout
09-27-2008, 10:59 PM
Our local club is currently defining a kit based on a bare (28-pin DIP package) ATmega168. (We like the idea of cutting our teeth on a $2.50 chip rather than even a $20 controller board.) We're programming them with AVR-GCC (on a mixture of Mac, Windows, and Linux boxes). I've gotten to the blinky-light stage and am ready to take it further.

So I'm looking around for a decent library to avoid reinventing the wheel when it comes to essentials like PWM, servo control, serial ports, I2C, etc. I've found three decent-looking possibilities:

1. Procyon AVRlib (http://www.mil.ufl.edu/%7Echrisarnold/components/microcontrollerBoard/AVR/avrlib/). But note that the link here doesn't seem to be to the author's original site; that one is down, and discussions I've found here and there seem to indicate that this library is no longer being maintained, and may not compile cleanly with recent versions of AVR-GCC.

2. Orangutan-lib (http://orangutan-lib.sourceforge.net/). Looks perfect, except that we're using just the bare chip, not the Orangutan. How much grief is that going to cause me? (Keep in mind that I'm a newbie at embedded development, and may not understand what seems like a simple and obvious problem to you guys.)

3. Pololu AVR C/C++ library (http://www.pololu.com/docs/0J20). Looks very recent and well-documented, but also seems very Orangutan/3pi specific, and doesn't seem to include any servo functions or serial communications.

So... what would you recommend in my situation?

Thanks,
- Joe

lnxfergy
09-28-2008, 02:58 AM
You could also use the Arduino environment... just burn the bootloader on your chip and provide a level-shifted serial port:

www.arduino.cc

-Fergs

Adrenalynn
09-28-2008, 04:31 AM
Yupppers - that was going to be my suggestion too, Fergs. That also opens-up the "processing" language as well.

JoeStrout
09-28-2008, 07:55 AM
Yes, I should have mentioned that we're aware of Arduino, but our current goal is to work directly in C.

Any suggestions on C libraries for that?

Thanks,
- Joe

lnxfergy
09-28-2008, 10:31 AM
Another option (not really a library though), is to reuse code from the Seattle Robotics Workshop program:

http://seattlerobotics.org/WorkshopRobot/index.php

-Fergs

wireframewolf
09-28-2008, 02:27 PM
I can't tell you what general purpose library to use, but I can show you this: http://www.obdev.at/products/avrusb/index.htm

That is basically a firmware library that allows you to make a fully functioning USB device out of an atmega and a couple cheap RC components. I used this and an atmega168 to make a USB (rather than serial) microcontroller for my robot. There are a bunch of community examples, and you can check to see what other kinds of general atmega libraries they're using. If you have any other questions, ask away and I will try to answer them :)

JonHylands
09-29-2008, 07:41 AM
My brother Dave has a pretty good environment set up for programming ATmegas in general. I use 168's with it all the time.

http://svn.hylands.org/

It also has library code for ARM-level devices, and a lot of the code is shared.

Delays, Timers, UARTs, A/D, PWM, Servos, LCD, etc.

wireframewolf
09-29-2008, 03:36 PM
You know, I forgot to mention this before... but rather than using the Arduino and its environment, if you want to work in direct C like I do, sometimes I'll take a piece of code from the arduino library and hack it a little bit (like servo libraries or whatever) to make it work with my code. This is kind of nice because there's a lot of reusable code in those files.