Similar Microcontrollers to Arduino/Atmega??

Hi, I'm new to this forum and somewhat new to the Arduino. I'm a computer science major so I've spent quite some time programming and within the last 3 months or so have branched off from single-purpose IC's to the Arduino board. I have to say that I absolutely love it!! The IDE works perfect with much of my programming knowledge in C++ and Processing. In recent, i've been branching off and seeing what other microcontrollers exist for the purpose of custom, standalone projects that I build. I calculated that if I was to write a program on the Arduino Board and then pop out the Atmega chip and insert it into a custom PCB it'd cost me about $12, before I add all the other components of the project.

I started looking into the PIC microcontrollers because of how much cheaper they are and have been reading some text (The PIC Microcontroller: Your personal Introductory Course) and am finding that the language the PIC's are programmed in (I actually haven't been able to get a solid answer on this) is ridiculous. Perhaps I haven't been programming long enough, but it's some type of lower-level language and is absurd.

My question is, are there anymore microcontrollers (preferably DIP's) that have a similar "style" to the Arduino and Atmega chip as far as programming is concerned?? Can they handle in-circuit programming like the PIC's can? (I think that's the coolest feature of these chips). Are there any PIC's that are compatible with other IDE's (i'm assuming another boot-loader is pre-programmed into them) similar to the Arduino IDE? Thanks guys. -Joe

There's the PICAXE, which is, I believe, PIC chips but with a bootloader and a nice programming interface. I'm never worked with them, but I've heard great reviews.

I'm wondering - where did you get the $12 figure from?

By my calculation, it'd be

$4.98 AVR ATMega328P
$0.54 Ceramic Resonator, 16 MHz
$0.09 10 kiloohm resistor
$0.09 330 ohm resistor
$0.62 LED
$0.33 28 pin IC socket
$1.76 1x40pin male header strip
Total: $8.41

And this assumes you don't already have the various passives. It's quite well under your $12.00 original estimate. If you get rid of the LED and run off the internal RC oscillator, it'll be only $7.16, and the second one will be able to use the same header strip as the first (you won't use all of them).

A picaxe would be about the same price, I guess, but you'd need to learn the environment (and you still need the piles of passive components).

EDIT: An Arduino is just an AVR with a bootloader - it supports ICSP programming too, but most people are happy with bootloading. Like an AVR, a PIC is programmed in hex. What you're looking for is a C/C++ compiler - for PIC, these are usually expensive (~$100, if I remember correctly), for good ones, whereas Atmel provides the avr-gcc compiler for free.

WizenedEE: ah, I've heard of PICAXE and was just assuming it was a newer version of the PIC microcontroller (i guess it is in some respects). I will definitely look into it!

Aeturnalus: I added $4 for the PCB. Most places that i've looked charge $6 alone for the Atmega328/168 with the Arduino Bootloader. Where do you normally shop cause your prices seem good. I usually use futurlec but they always mess something up or take a month. Anyway, thanks for letting me know about the compiler (i figured there was a solution like that); but short of spending $100 on a C/C++ Compiler, what are my options??

Thanks for the speedy replies guy!!!

Get it without the bootloader, and use your Arduino to simulate an ICSP programmer (ArduinoISP sketch in examples) and flash the bootloader on. I usually shop at Digikey, and of course, quantity pricing will make it much cheaper. Mouser is also an option - basically big electronics suppliers are more reliable, even if their websites are somewhat painful. Since you already have an Arduino, its ability to replace an external AVR in-circuit programmer can be used to drop prices for yourself =).

The PCB is a universal cost - I don't think you can really avoid it. It's also not going to get any cheaper - a PICAXE is actually slightly more expensive than an Arduino for the same capabilities, due to markup premiums and suchlike.

Regarding the compiler: If you use PICAXE, you'll need to live with BASIC, otherwise you don't get to use the bootloader (thereby defeating the whole point of the PICAXE). For C/C++, you'll need to buy an external hardware programmer, and there are a number of limited free C/C++ compilers for PIC (they're all crippled in some way or another, but you can often live without half the memory or no libraries or etc).

You can also look into the ATTiny series, which the Arduino libraries have been ported to (I forget which ones). You'll need to use the Arduino board you have as an external ISP for these, as they don't have bootloaders (as far as I know), but they're cheaper than the ATMega series.

hmmm...very interesting. I was looking through my stockpile of stuff and realized I have two starter kits for the PICAXE (8-pin and 20-pin i believe) so that's where I'll start (guess i was drunk that night and ordered the wrong book, though probably not a bad idea to have a reference-book). I'll probably order this book: Programming and Customizing the PICAXE Microcontroller 2/E (Programmable Controllers Series) and see where that takes me (the reviews say there's some errors, but it has its uses). If you or anyone has a better suggestion about learning tools or anything, feel free to let me know. In the meantime, i'm just reading online about all the above-mentioned microcontrollers. THANKS GUYS!!!

And there is also this from MicroChip:
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2095&param=en553910

Jim

JimG:
And there is also this from MicroChip:
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2095&param=en553910

Jim

I'm looking more for a single DIP IC that I can program and play around with, and then solder the IC into a PCB with whatever else is required for the project and be able to go back and program it, in-curcuit (ICSP), not a platform like the Arduino Board or Freeduino. -Joe

The Picaxe is a good system but it's nowhere near as versatile as an AVR or PIC, mostly because of the interpreted BASIC. That arguably makes it easier to use for a beginner but also limits what it can do.

However you may not reach those limits, it depends on what you want to do. I've seen some pretty fair projects done with Picaxes.


Rob

You can get C compilers for PICs. The newer PICs even use gcc, just like the AVR in Arduino.
But I'm not convinced that PICs are so much cheaper than the AVR once you get to similar specifications. $4 AVR vs $3 PIC. Hmmph.

thanks for all the input guys!! I'll probably tinker around with the PICAXE's a bit, but in the end, I think i'll just stick with the AVR Atmega and burn the bootloader for free using my Arduino board. -Joe

joebro391:
...[snip]...I'm a computer science major so I've spent quite some time programming...[snip]...and am finding that the language the PIC's are programmed in (I actually haven't been able to get a solid answer on this) is ridiculous. Perhaps I haven't been programming long enough, but it's some type of lower-level language and is absurd.

[raises an eyebrow]

If what you are seeing is assembler...then I am left wondering just what it is they are teaching "computer science majors"...?

I suggest that if you don't understand how a CPU fundamentally works down to the "bare metal" - then you really don't have an understanding of how a CPU works; I would also be very hesitant at calling you a computer scientist, as well.

I don't say this to be rude or mean, by the way - but I am questioning, again - what you are being taught (or not, as the case may be)? Maybe you just started your degree, but prior to this you had been programming without understanding the lower-level basics (registers, program counters, flag registers, addressing, stacks, etc).

Regardless - don't discount it as "absurd" - it is anything but; in fact, it is the fundamental way in which a computer (well, CPU) works.

I am now left wondering whether Church/Turing are ever brought up in computer science studies nowadays (among the names of many other great people who laid the foundations of computer science - a knowledge of whom which will benefit any student studying compsci).

Maybe I'm just "old" and need to go back to fiddling with an Apple IIe ROM monitor...

:slight_smile:

cr0sh:
I don't say this to be rude or mean, by the way - but I am questioning, again - what you are being taught (or not, as the case may be)? Maybe you just started your degree, but prior to this you had been programming without understanding the lower-level basics (registers, program counters, flag registers, addressing, stacks, etc).

Sorry dude, I guess I was just frustrated at the time I made the post haha. I'm still reading the book and getting the hang of it, it's just obviously not as convenient as the compiler used on the Arduino (that I'm much more comfortable and familiar with). And you're right, when I said I was a CS major, I've only taken a few entry classes and so far only learned C++ in class. I read Getting Started with Processing and I read a text book on Visual Basic. All my work prior to these courses (this past year) has been with single purpose IC's (no programmable microcontrollers).

But as to your question: No, aside from the current book I'm reading on PIC's, I've never heard of program counters and flag registers (though we have reached them in the book, just not into too much detail yet). We dealt with addressing in my C++ class, but have not done any work as far as microcontrollers in class or compilers/assemblers.

So honestly, i'm still a noob...just not a helpless noob haha. I'm still learning :wink:

-Joe

You are probably seeing how real persons do it, in Arduino you can also do "ridiculous" things as well...
Things like this:
THis is a blinky with direct port manipulation and no Arduino functions, just the bare metal, this compiles to something smaller than 200bytes, and not 1K or wathever it eats in Arduino.

#include <avr/io.h>
#define F_CPU 16000000UL
#include <util/delay.h>


int main(void){		



DDRB |= (1<<PB5);

while(1){
	PORTB |= (1<<PB5);
	_delay_ms(1000);
	PORTB &= ~(1<<PB5);
	_delay_ms(1000);
	}

}

This is how you do some pwm:

void timer0_init(void){

	TCCR0A = ((1<<COM0B1)|(1<<WGM00)|(1<<COM0A1));	//Phase correct pwm, mode 1

	TCCR0B = ((1<<CS01)|(1<<CS00));



}



void timer2_init(void){

	TCCR2A = ((1<<WGM00)|(1<<COM2A1));

	TCCR0B = ((1<<CS01)|(1<<CS00));

	}



void update_pwm(uint8_t red, uint8_t green, uint8_t blue){



	OCR0A = green;

	OCR0B = blue;

	OCR2A = red;



}

This is how you use the adc, portguese commentaries, sorry:

void adc_init(void){



	ADCSRA |= ((1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0));	//16Mhz/128 = 125Khz

	ADMUX |= (1<<REFS0);				//Referencia de 5v

	ADMUX &= ~(1<<REFS1);

	ADCSRA |= (1<<ADEN);				//Adc ligada

	ADCSRA |= (1<<ADSC);				//Fazer uma primeira conversão para iniciar o circuito e porque é a mais lenta

}



uint16_t read_adc(uint8_t channel){

	ADMUX &= 0xF0;						//Limpa o canal anterior

	ADMUX |= channel;					//Define o novo canal a ler do ADC

	ADCSRA |= (1<<ADSC);				//Inicia uma nova conversão

	while(ADCSRA & (1<<ADSC));			//Espera que a conversão seja feita

	return (ADCL + (ADCH<<8));						//Retorna o valor do ADC

}

Its no non-sense its register manipulation, non sense is using an Arduino and thinking that its all ponnies and rainbows and that everyone doing bare metal is just non-sense.

In my opinion the 8bit family from Microchip is just way to bad, to limited and just a wrong architecture, but their 16biters like PIC24 and dsPic are just awesome and the PIC32 is even better.

You can download free compilers from microchip and start codding or you can keep using Arduino and have an heart attack when you learn assembly lol.

:fearful:

This is embedded programming, you see. It's not as easy as it looks. Since you're a CS major, I'd suggest you spend the time to go and look at the Arduino core's source code - it's really a useful learning experience. You may also find it more comfortable to code in a standard environment (IDE or otherwise) - setting one up is also beneficial to understanding how Arduino provides the extra layer of abstraction that makes everything seem so easy.

That's done it Senso, you've scared joebro right off now :slight_smile:

Joe, this is the "bare metal" we've been talking about. The beauty of the Arduino system is that you can start off being protected from all that stuff, for example the above ADC read is simply

x = analogRead(pin_number);

This is very similar to and just as easy as the Picaxe.

As you get more comfortable with the environment you can usually make things more efficient buy working directly with the hardware as Senso has done.


Rob

This thread has been really informative. right now, the plan is to just read as many books as I can and learn as many microcontrollers/IDE's as I can so I'm not limited ("oh crap, i can't make my project cause i only have PIC's, no Atmega's" <== this would be noob-ish). Does anyone have some solid texts I could get from Amazon or online and read??

So far I have read/am reading/have coming (regarding microcontrollers):

Arduino: Getting Started With Arduino (Read), Beginning Arduino (Coming), Arduino Quick-Start Guide (Coming), Getting Started With Processing (not arduino, but helped with many graphics-oriented projects) (Read)

PIC: The PIC Microcontroller: Your Personal Introductory Course (Reading)

Considering Buying: Wireless Sensor Networks, Interactivity, Arduino Microcontroller Processing for Everyone!, Customizing the PICAXE Microcontroller 2/E (Programmable Controllers Series).

What else should I be acquiring??? What will eventually (over the course of the next few years) turn me into a real solid microcontroller user??? I'm ready for suggestions!! -Joe

From the thread "Other ways to blink" http://arduino.cc/forum/index.php/topic,4114.0.html

void setup()   {

  asm volatile ("  sbi %[portdir], %[lbit]  \n"    // Set bit direction
      "3: "                                        // main loop label
      "   sbi %[port], %[lbit] \n"                 //  Turn on.
      "    clr r16  \n"
      "    clr r17  \n"
      "    ldi r18, 81  \n"   // 100 * 256
      "1:"  // 1st delay loop label
      "        dec r16  \n"
      "        brne 1b  \n"
      "      dec r17    \n"
      "      brne 1b    \n"
      "    dec r18      \n"
      "    brne 1b      \n"
      
      "    cbi   %[port], %[lbit] \n"             // Turn off.
      
      "    clr r16  \n"
      "    clr r17  \n"
      "    ldi r18, 81  \n"
      "2:"  // 2nd delay loop label
      "        dec r16  \n"
      "        brne 2b  \n"
      "      dec r17    \n"
      "      brne 2b    \n"
      "    dec r18      \n"
      "    brne 2b      \n"
      
      "    rjmp 3b  \n"
      :
      : [portdir] "I" (_SFR_IO_ADDR(LEDPORT_DIR)),
        [port] "I" (_SFR_IO_ADDR(LEDPORT)),
      [lbit] "I" (LEDBIT)
      );
}

So there's more than one way to skin a cat.

I don't think you'll win over many beginners with that code though :slight_smile:


Rob