Which uC (Microcontroller)? - discussion

Thread Starter

thatoneguy

Joined Feb 19, 2009
6,359
Many threads end up with a recommendation of "Use a uC". When all you have is a uC, everything starts looking like a nail with a "$1 uC hammer". I've seen many LED circuits built with a uC when $0.20 logic ICs fit the application better, uC's are often used because of the internal clock for delays.

That being said, most replies will STILL involve a microcontroller solution, and here is the reason:

People just starting in electronics want to do some VERY advanced projects. Compared to what was commonly available 20 years ago and 'just starting', what somebody new to electronics can DIY is nothing short of amazing. This is where uC's often find a home, doing jobs they sometimes aren't optimal, but are easy to use and ge the job done. They frequently play the role of steady state machine, where CPLD/FPGA is better suited, but not easier to implement.

uCs vs Discrete Logic:
The downside of microcontrollers or logic arrays is found when you dig out a widget you made a few years ago, then do something that lets the magic smoke out, the exact code isn't usually still in your mind, rarely still on the hard drive. Whereas 74xx and 4xxx series Logic ICs are easily replaced by numbers.

Why not state machines?
I'd guess about half or more of the projects I've seen microcontrollers used for are simple state machines, without the need for "actual processing". FPGA is quickly becoming the leader in consumer products due to programming being as simple to program/reprogram (hardware wise) as an AVR, with the availability of up to hundreds of I/O. The downside: Steep learning curve, not breadboard friendly due to pin count, and expense. Development tools and the 'chips' themselves are not in the uC price range (The development software and hardware easily hit 3 and 4 digit costs). In addition, "discrete logic" needs to be understood very well to have a working, efficient solution. FPGA's do not have "instruction sets", they are simply huge arrays of "blank gates" that can be configured to do a huge variety of tasks, from a grey-code to 7 segment decoder to PONG with VGA output.

What about Basic Stamps, Why do all schools have them if they aren't used?
For the price of a Basic Stamp ][, you can get the complete PIC starter set, and a license for BoostC or BoostBasic.
Speed- 40,000 basic instructions per second for BS ][, 4 Million instructions per second with a native PIC. Most of the time lag is token fetch/decode/load/run from EEPROM in the BS ][.
As for schools: They are re-usable and very easy to use, they also get huge discounts from the company that makes them.
"Stamps" are very easy to use on a breadboard, program and reprogram while learning about microcontrollers.

Basic Stamp Problem:
You need to buy a complete development system for each "built project" when using Basic Stamps.
With PIC or AVR, you only need the $0.50-$9 uC, since all the development tools aren't part of the chip, as they are with stamps. This makes discrete uCs the only financially viable choice if creating a permanent design.

Basic Stamps are good for learning how uC's work, but when actually building something, use a real uC. Spend the money saved for a nicer case or extra servos. :) The PicBasic Pro compiler, which is created by the same group that created the Basic Stamp, is available as a standalone compiler for many PIC uCs. This gives the easy language combined with the low cost of hardware.

When just starting, having to buy things yourself, but don't want to be overwhelmed (mentally or financially), I'd suggest the AVR based Arduino board. All the features and more, and faster, compared to a BS ][, for a price less than a BS I, though they still have the "unit cost" if used in a design.

PIC or AVR?
I didn't want to touch this one, but I may as well.

I'm partial to PIC. Most AVR development tools are free, most aren't with PIC. PIC has a wider range of "on chip" peripherals, including Full Speed USB, not available on AVR at this moment.

Cost of a PIC and comparable AVR are about the same, as far as processors themselves go.

Speed is about the same, though edged towards AVR. Most applications don't need real speed, as most of it is 'wasted' in delay loops anyway. Both are faster than the business computers of the 80's.

If working in C, the difference between them is small, if the cost of the compiler is ignored. The PIC Compilers often have simulation built in, something GCC doesn't have. AVR has the benefit of generally all having the same "API", or programming. PIC, due to thier wide variey of features, sometimes do not support certain operations in hardware. Usually, it's money saved to not have that operation.

If working in assembly: Atmel AVR wins. Microchip has kept the instruction set the same, so has some rather 'archaic' methods of doing things.

Support: Also a tie.

In the end: It doesn't often matter. I've used ATMega48's and was happy with them. I've used many more different PICs and was happy with them as well, for getting the job done.

In the end: Choose one (actual Device, not manufacturer), and learn it well. I'd suggest something along the lines of an 18F2520 or similar, or ATMega48 for "General Purpose". When a different hardware unit is needed (More I/O, Intterupts, PWM, ADC, SPI, I2C, USB, USART), those can be added with a different uC later, but for a "working stock", I find a general purpose work great for most projects.

Please comment! I wrote this in a hurry, and most likely have a few things wrong. I believe Atmel was working on a USB interface, but haven't paid attention lately. Also, the "Recommended uCs" list changes continually as new families and features arrive. The two above are from around summer of '08. Also, at the rate FPGA is growing in the hobby world, portions of this post will most likely "expire" by July of 2009.
 

leftyretro

Joined Nov 25, 2008
395
Nice write up, I enjoyed reading your opinions. For beginners, as important if not more so then the chip model or manufacture used is the documentation and support software avalible. I can only really comment on the two 'systems' I've used so far and I thought they were both good entries into the world on microporcessors.

Picaxe series. Most likely the lowest cost entry system for a complete functional system. Not the fastest system by any means but designed for classroom instruction with very young students. Basic is the language used and there is a nice users forum avalible to help people get started.

Arduino series. This is what I've been using for the last six months and I still think it's one of the best ways to get started. Best bang for the buck and it makes learning C/C++ not the hurdle it might have been prior for new people just starting with microprocessors. Check out the newest Arduion MEGA model. http://arduino.cc/en/Main/ArduinoBoardMega

Lefty
 

hgmjr

Joined Jan 28, 2005
9,027
Interesting writeup.

I am very familiar with AVR and the free software development tools specifically AVRSTUDIO and WINAVR. I am less familiar with PIC. I would be interested in knowing if there are any corresponding free development software packages. If so, I would like to download them and get more familiar with the PIC assembly language programming.

hgmjr
 

jpanhalt

Joined Jan 18, 2008
11,087
Good comments, and I agree with virtually everything, except for parts of the first statement:

People just starting in electronics want to do some VERY advanced projects. Compared to what was commonly available 20 years ago and 'just starting', what somebody new to electronics can DIY is nothing short of amazing. This is where uC's often find a home, doing jobs they sometimes aren't optimal, but are easy to use and ge the job done.
Maybe it is just my generation. I didn't grow up with computers. I had hammers, nails, glue, etc. I built, crashed, modified, and rebuilt until it worked.

Thus, when I rekindled my interest in electronics, it was natural to start with analog. In fact, I will still test something in analog (like timing with a NE555) before going to a uC. At least that way, I can tell with my fingers whether it is working or getting too hot. My experience with uC's is that they don't give time to get hot. They die too quickly when given wrong voltages.

As for starting out and wanting to do something "advanced," I simply don't understand that attitude. Although, I am sure it exists. I think just getting something to work, advanced or not, is much more fun.

As for the starting device, I think something with lots of example programs on the Internet and in tutorials is good, particularly if the person has very limited programming experience. For that reason, I think it is good that this forum doesn't immediately jump on people who propose to use the 16F84/84A.

John
 

Thread Starter

thatoneguy

Joined Feb 19, 2009
6,359
When "we" grew up, home computers were non-existent, or a build it yourself Sinclair for younger old people. LED's didn't exist. Today, it seems most want a switch mode power supply, RS-232 connection to a system, a robot, or similar within a month of learning about transistors.

As far as the recommended uC, the16F84 is a solid platform with tons of code, and recommended. However, an AVR is much simpler to use, has USART, PWM, and 10 bit ADC harware, as C is free for AVR, and PIC C is only free for the 18xxxx series, which is why I suggested the 18F2520. Deciding to use the 16F84 first is also fine, as there is a LOT of example assembly code existing for a variety of projects, but bit-banging routines are required for most interfacing.
 

hgmjr

Joined Jan 28, 2005
9,027
Is there a free assembly language software development program for the 16F84? Something like ATMEL's AVRSTUDIO4 for example.

hgmjr
 

jpanhalt

Joined Jan 18, 2008
11,087
Is there a free assembly language software development program for the 16F84? Something like ATMEL's AVRSTUDIO4 for example.

hgmjr
Don't know about Atmel's studio. I started with MPLab (free, current version 8.x) and have never needed anything else. You can do simulation, step, timings, change digital inputs, watch outputs, etc. It disassembles. It is not an emulator. John
 

Thread Starter

thatoneguy

Joined Feb 19, 2009
6,359
Is there a free assembly language software development program for the 16F84? Something like ATMEL's AVRSTUDIO4 for example.

hgmjr
MPLAB's IDE is a full environment. As stated above, available for free from Microchip.

I have to ask "Are You Sure?". One reviewer put it best with the statement: "Programming a PIC in assembly is like stabbing yourself in the face, only harder".

The reason for that statement is the fact all data must go through the working register (w).

So instead of:
MOV KNIFE, FACE

on a PIC it is:
MOVLW KNIFE
MOVWF FACE

That has made it to nearly every review around. Though there are benefits to this, such as re-use of the contents of w.

The other "pain" is the banks, reminiscent of 64k pages in MS-DOS. Not a big problem until working with interrupts. Some of this has been slightly alleviated with the 18F series, prior to that, compilers were/are expensive.

Two excellent AND affordable development environments are BoostC/Basic/C++ and for starting out using BASIC, the BEST Visual programming/simulation environment (graphical view of everything) is Oshonsoft IDE for PIC and AVR
 

hgmjr

Joined Jan 28, 2005
9,027
Your sentiments echo those of others that have bemoaned the challenge of assembly language programming of PICs. I have not had the fortune or perhaps more accurately stated misfortune of programming PICs in assembly langauge. I am to count my blessing if some are to be believed.

It was suggested by a highly respected colleague at my place of work that I look into AVR when I lamented that I wanted to do some embedded design using one of the new generation of microcontrollers.

I have spent the last four years learning about them. It has been a most rewarding association.

hgmjr
 

KMoffett

Joined Dec 19, 2007
2,918
Since this is an open discussion of microprocessor options, I'll throw this in. I started out with Basic Stamps that were easy to use, but the price made simple projects, like those the might somehow use a couple of 555's, prohibitive. So, I switched to using PICAXE's. http://www.rev-ed.co.uk/picaxe/ They were designed for middle and high school classrooms like the Stamps.

Microchip PICs with a burned-in interpreters.
Comes in a variety for flavors from an 8-pin to 40-pin, starting at about $3.50US
Programming is in PBASIC.
Free downloadable program editor.
Programming from a PC only requires a three-wire serial cable and two resistors.
Extensive downloadable manuals
Editor includes a built-in program simulator.
Very active, and "civil", support Forum.

These are slower than raw PICs with compiled programs, but work great for about 90% ("43.7% of all statistics are made up on the spot" ;) ) of what low end hobbyists use microprocessors for.

Ken
 

Salgat

Joined Dec 23, 2006
218
AVR Studio using the GCC compiler has perfectly fine simulation/debugging features, I used it a lot when programming for my monochrome GLCD (with JTAGICE II :D). I really like AVRs, easy to use, have a lot of general purpose registers, and have full featured dev tools for everything. That and well, it can run at lower frequencies than PICs for the same performance (which is a huge bonus if you make commercial products). I haven't worked with PICs though, so I can't fairly say which is better.
 

Thread Starter

thatoneguy

Joined Feb 19, 2009
6,359
Your sentiments echo those of others that have bemoaned the challenge of assembly language programming of PICs. I have not had the fortune or perhaps more accurately stated misfortune of programming PICs in assembly langauge. I am to count my blessing if some are to be believed.

It was suggested by a highly respected colleague at my place of work that I look into AVR when I lamented that I wanted to do some embedded design using one of the new generation of microcontrollers.

I have spent the last four years learning about them. It has been a most rewarding association.

hgmjr
Actually, once you know PIC assembly, it isn't so bad. Just don't switch between platforms frequently! Once you have it all figured out, it is pretty straightforward, especially with macros. You haven't lived until you've tried it!

On the PicAxe, I've heard some great things about them, just haven't played with one myself, so can't give a solid review. There is too much Arduino speak on the net for the Dwarven PicAxe to get much airtime, but I'm glad it was mentioned! The price sounds acceptable!
 

RiJoRI

Joined Aug 15, 2007
536
The reason for that statement is the fact all data must go through the working register (w).

So instead of:
MOV KNIFE, FACE

on a PIC it is:
MOVLW KNIFE
MOVWF FACE
The same thing was needed for the 8080, 8085, Z80, 6809, 6805, 6502, 8051, COP-8, and other micros, I am sure. As to the banking "problem," I've built commercial projects with RAM and/or ROM banking, and have not really had a problem. Yeah, it takes a little more thought, but that's why we get the "big bucks," right? ;)

--Rich
 

Thread Starter

thatoneguy

Joined Feb 19, 2009
6,359
The same thing was needed for the 8080, 8085, Z80, 6809, 6805, 6502, 8051, COP-8, and other micros, I am sure. As to the banking "problem," I've built commercial projects with RAM and/or ROM banking, and have not really had a problem. Yeah, it takes a little more thought, but that's why we get the "big bucks," right? ;)

--Rich
People do get "spoiled" sometimes, and expect the "easiest way" to be used on all platforms, even though the capabilities are wildly different.

I'm still fond of the days when very 'advanced' programs used about 2k of memory. Now, an equivalent program in Windows is a few hundred k to 1MB.
 

alank2

Joined Jul 14, 2009
26
Hi,

I'd really like to get into figuring out how to build a project with a uC and have some questions.

I don't have any uC experience, but I have messed around with electronics here and there and want to figure out a uC type project. I am very familiar with C/C++ and like the flexbility and speed of it. I'd also like to make a project that communicates via USB.

Questions:

1. I didn't see Cypress PSoD mentioned - where do these fit in with the current discussion?

2. Do most people develop using a board like the arduino mega listed on page 1? It looks very convenient to be able to obtain a uC in board form with headers, etc., especially for a small singular type project. Do all manufacturers offer boards like this as well as chips only, or do some manufactures make boards more available than others?

3. Given my info above, where do you think I should start? I would like to get into it as cheaply as possible, but not so cheap that I'm not getting into the right thing...

Thanks,

Alan
 

millwood

Joined Dec 31, 1969
0
4 Million instructions per second with a native PIC.
most pics run at 4mhz, and 1 instruction per 4 cycles making it about 1mips. however, that's just half of the story since it is a risc architecture it usually takes more risc instructions to complete the job of one cisc instruction. so comparing mips may be misleading.

for what we hobbyist do, something like a pic is like sufficient 90% (or 99%) of the time. for me, if I could utilize more than 50% of the power in a 12f675, I would be very delighted, :).
 

millwood

Joined Dec 31, 1969
0
I'd also like to make a project that communicates via USB.
if so, you may look into a chip with hardware support for usb - not necessary but helps on programming.

2. Do most people develop using a board like the arduino mega listed on page 1?
I acutally do more of my programming in IDEs that I use. after they are reasonably bug free, I simulate it in Proteus. After that, I run it on a dev board.

Do all manufacturers offer boards like this as well as chips only, or do some manufactures make boards more available than others?
pretty much so.

3. Given my info above, where do you think I should start?
I would start with a more capable chip. Personally I find the ARM chips quite appealing, especially the arm7 chips - lots of code available, or the cortex-m3 chips (newer, and cheaper variant).

the dev boards for arm7 are cheap and available everywhere. cortex-m3 chips aren't as plentiful and finding sample code can be daunting and frustrating.
 

THE_RB

Joined Feb 11, 2008
5,438
most pics run at 4mhz, and 1 instruction per 4 cycles making it about 1mips. however, that's just half of the story since it is a risc architecture it usually takes more risc instructions to complete the job of one cisc instruction. so comparing mips may be misleading.

for what we hobbyist do, something like a pic is like sufficient 90% (or 99%) of the time. for me, if I could utilize more than 50% of the power in a 12f675, I would be very delighted, :).
Well I don't agree with your first statement. :) Almost every PIC sold now is at least 20MHz capable which is 5 MIPS. Many are better, in the 18F series many are 32-40MHz (8-10 MIPS).

I do agree wholeheartedly with your second statement, re the part utilising the entire power of a micro. Beginners using sloppy code and mis-managing peripherals tend to like the idea of "this micro is better 'cos it's got more MIPS" etc, but most of the pro's have to design things to a manufacturing budget, which means using smaller/cheaper/less pins/less MIPS micros and usually legacy micros that are also used on other products in their line so the manufacturer has cost savings from bulk ordering more of the same cheap micro... So they tend to get good at getting some pretty impressive performance from limited micro hardware.

When evaluating micros one of the most valuable things is the ability to get it doing a lot of difficult tasks simultaneously on a very limited MIPS budget and limited RAM, which comes from years of experience and years of valuable legacy code from doing similar things with that micro in previous projects.

It's easy to say the new whizzbang mipper is "better" because it has a bit more of this and that... But there are costs of stocking a new micro, learning a new micro and ironing out its idiosyncracies, getting new production programming hardware to program the new micro for production, adapting tested and proven code that was already very fast on a cheaper micro etc etc.

So where a beginner might think a micro is "better" because it's a fraction faster and has a bit more ram and some kid is saying how cool it is on a forum, someone who has been doing this for more years might see a micro as "better" because they have a wealth of experience with that micro in code examples and proven systems, because they CAN do the task with it even though it's pushing the limit, because it's 50 cents cheaper, or maybe because they have 7,500 of them sitting on a shelf near the cat. :)

Hmmm, did I just say that bigger faster newer micros are better for dumb kid beginners and slow old cheap clunky micros are better for seasoned pro's? Kinda surprised myself there, but there's a lot of truth in it.
 
I think it is worth noting that in my experience I have noticed hobbyists tend to prefer the AVR series from Atmel and industry professionals tend to prefer the PIC series from microchip. Most of the information you will find online will tell you that "AVR is better than PIC" without giving much explanation, but after having formal training on PIC micros I find them easier to use than AVR.
 
Top