ATMEGA8-16PU for small projects - experiences?

So I've got a few LED based projects that are truly very rudimentary, mostly PWM color mixing of RGB LED's and fading.. consequently the need for code space and such on a microcontroller to do the job is quite minimal, far less than the 32k of a 328, or the 16K of a 168. There's simply no reason to dedicate the resources (and cost) of a full blown arduino (or even a boarduino) at a cost of about $12. I've wanted to try an alternate processor in the AVR line, and after a quick perusal of ebay, found that ATMEGA8-16PU sell for $1.45 each including shipping, about a third of the price of the 328.

I ordered a couple, and as usual, they will take a while to get here from China. In the meantime, I'll research out the differences- which at face value, seem primarily to be just the memory sizes in flash and eeprom, and 1k of SRAM rather than 2k. I even see some old references, where if I am not mistaken, it looks as if in the beginning of the Arduino project the ATMEGA8 was one of the supported processors directly. I am planning on using the Arduino as a programmer, and may skip the bootloader entirely. It looks like this should be a direct drop-in replacement for a 328 for small projects that don't need as much memory.

I've wondered about the resonator/xtal.. as I understand it's possible to use the ATMEGA's internal oscillator as a clock source, removing the need for that component.. I have wondered who has done that, and what issues were encountered. I would assume there's a fuse bit change and some header entries to be changed to accomodate the timing changes, but I would think other than a less accurate clock (and slower, isn't it?) there's not a lot of drawback to using the internal oscillator if the criticality of the timing accuracy is just PWM.

Basically, what I am asking is where are the "gotchas" going to be that I am not anticipating? Or is it going to be as easy as it SEEMS it should be?

I think the '8 has two fewer PWM outputs.

You know, I was considering that since I use my stuff for photography, I really might "roll my own" (though I think it may have already been done by others too) in terms of the PWM and do it in software (probably shifting the data out) rather than the lower PWM frequency that is implemented onboard in hardware. If I basically make it a freewheeling "fast as you can go" timing, with adjustments and whatever being handled via an interrupt the inherent flicker in PWM might be less of a problem for photography. PWM is one very clear demonstration of how different your eyes are from a camera! With an internal PWM frequency of less that 500Hz, there's problems.. but with a freewheeling PWM in relatively tight code, I would think tens of kilohertz ought to be possible without too much pain..

@condemned (aka batsocks) wrote a good article about a software driven alternative to PWM. Let me see if I can find it ... There it is...

There are a couple of extra differences. For instance not all of the interrupts available on the 168/328 are available, most notable the interrupt for the Watchdog Timer is not there. As I recall there were a couple of other difference, but I don't remember them. You are correct; however, the earliest arduino's did use the ATmega8. Last version was the Arduino NG Rev C which was also the first to begin using the ATmega168

That is what I had hoped to hear. What about using the oscillator rather than the xtal? Unless I am mistaken, then all that wil be required for minimalist Arduino hardware is a couple of caps.

Since it is just for LED dimming, using logic MOSFETs, I'm shooting for cheapest possible....

Yes, I believe you can use the internal oscillator with no external components, though you may want a cap or two for power decoupling. If you do use the Arduino IDE to program you will need either an ISP connection or a serial converter connection. And of course you will need to create an entry in your boards.txt file for the programming method with speed, fuses, etc...

Don't know if any of the newer bootloaders work with the '8, but you should be able to find one from the Arduino NG series that serves.

It looks like there may be a Lilypad setup which might work without much modification.. using the internal 8mHz oscillator. That will take care of most of the worries right there. As most of the stuff I am considering doing is so simplistic, things like fewer timers really ought not to complicate things too greatly.. I hope... I'll update this thread as I actually put hands on the chips and give it a try. At under a buck fifty for a ATMEGA8, and a couple of pennies each for two caps.. a two dollar arduino implementation would be awesome for really small stuff!

I have a couple of USB to Serial TTL modules around, I also have a USB-ISP programmer from ebay I have not actually used yet. I'm thinking that's going to be the choice, either that, or I'll use the ISP sketch and do it that way, assuming that the implementation I am going for doesn't have a need for serial.

Hi,
I have a really nice project using an ATMega8 to provide active yaw control in an RC Car, I am using about 6 (Serial and Servo Library mostly) of the available 8K. The other limitations are as already stated, less hardware PWM channels and no pin change interrupts so if you need more than two interrupts its not a good choice.

I have also used an 8 in my RC Arduino robot and I have another in an Audino -

http://code.google.com/p/tinkerit/wiki/Auduino

If you can build an Arduino for 2 dollars, you really need to build an Audino.

Unfortunately ATMega8's cost me about 5 dollars in Dubai, if I could get them for 1.50 I would be even happier with them.

Duane B

rcarduino.blogspot.com

Well, the ATMEGA8's are finally here (the tradeoff for cheap parts from china is waiting a month for them to arrive).
I didn't see your post.. here is the vendor I got them from (two for now), but there are several others with similar pricing:

http://www.ebay.com/itm/260964533478?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649#shId

I'm getting a cup of coffee and a breadboard, going to see if I can use the "Arduino NG or older" setup...

Hi,

Here is my latest application of an 8 -

I have about 500 bytes left to add some new features.

Duane B

rcarduino.blogspot.com

Okay.. got it to work. Here's how:

I used my Duemilanove running the ArduinoISP sketch and the version with no crystal, using the internal 8MHz clock. After searching around a bit, I found this core and edit setup which worked perfectly in Arduino 1.01:

http://todbot.com/blog/2009/05/26/minimal-arduino-with-atmega8/

I burned the bootloader, then for giggles popped the atmeg328 out of the Arduino and popped in the atmega8. I changed the board to reflect the mega8 in the IDE, and compiled and downloaded "blink". Perfect. I now have the atmega8 just running blink on a breadboard, with a resistor and LED on digital13 and no other external components.

If they are running side by side, you can watch the led's slowly drift in and out of synchrony due to the inaccuracy of the RC clock vs a crystal... but I can declare success.. the uberminimal Arduino for $1.45 is a reality!

Bookmarked, I have not tried using the internal oscillator yet, but as you say, it save a few cents and a bit of room.

Thanks

Duane.

Rather than the older ATMEGA8, it may be better to use the ATMEGA88 (or even 48), which are identical cores to the 168/328 used in the Arduino's. The newer versions are identical except for flash and ram. The 88 is a direct replacement for the older ATMEGA8

The price isn't much different from what you found for the older ATMEGA8, from Mouser they are $1.75 a piece in single quantities, or $1.61 each for 10, or $1.49 each for 25...

Right, but then you are adding in shipping for a bit more.. quite a bit more per chip if you are buying small quantities. I do think that they may be available through the same kind of vendors as the atmega8, so I would suspect the pricing is similar. I think it really boils down to deciding whether or not the reduced shipping time is worth the increased shipping cost. If I had to pay four dollars shipping for two chips, a two dollar shipping charge per chip nearly triples the cost. If I bought ten however, it only amounts to forty cents per chip. Especially when dealing with shipping charges, buying in volume really does make sense.

I've now taken one of the bootloaded chips and soldered it into a perfboard with a 7805 for power, three logic level MOSFETs with 91 ohm gate resistors, and a pc817 optoisolator with a 470ohm resistor for current limiting. I added the optoisolator because the board may end up with several different end uses, including a shutter release, something I prefer to isolate from my meatball hardware. Added a pushbutton to ground the reset line (manual) and then used my Duemilanove without a chip in it merely as a serial connection to a header on the atmega8 board.

Cranked up the IDE, chose ATMEGA8 no crystal setup, and easily downloaded an RGB fade sketch I wrote... hooked up my 5m RGB strip (24 watts per channel, for a total of 72 watts) and it works like a charm!

I have a usb-to-serial cable around, so I don't have to chop my Arduino each time I want to update.. I declare the effort a success, and was MUCH less of a nightmare than I had thought it would likely be! I think I may set up the other to use USBASP as the downloader, no need for the serial connection, really..

focalist:
I've wanted to try an alternate processor in the AVR line, and after a quick perusal of ebay, found that ATMEGA8-16PU sell for $1.45 each including shipping, about a third of the price of the 328.

Depends where you get the 328. Current prices for ATmega328P-PU from Mouser

Pricing (USD)
1: $2.50
10: $2.08
25: $1.95
100: $1.80

I've used m328Ps for several projects with the internal 8MHz oscillator. Works great, less filling :wink: