All About Circuits Forum  

Go Back   All About Circuits Forum > Software, Microcomputing, and Communications Forums > Embedded Systems and Microcontrollers

Notices

Embedded Systems and Microcontrollers Discussion forum for projects and working with embedded systems and microcontrollers (FPGAs, PICs, AVRs). Get help with hardware issues and embedded programming.

Reply   Post New Thread
 
Thread Tools Display Modes
  #1  
Old 03-28-2009, 09:12 AM
thatoneguy's Avatar
thatoneguy thatoneguy is offline
Senior Member
 
Join Date: Feb 2009
Location: Midwest USA
Posts: 1,117
Blog Entries: 1
Default Which uC (Microcontroller)? - discussion

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.
Reply With Quote
  #2  
Old 03-28-2009, 09:29 AM
leftyretro's Avatar
leftyretro leftyretro is offline
Senior Member
 
Join Date: Nov 2008
Location: Hercules, Ca. (SF Bay Area)
Posts: 394
Default

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
__________________
Measurement changes behaviour
Reply With Quote
  #3  
Old 03-28-2009, 12:04 PM
hgmjr's Avatar
hgmjr hgmjr is online now
Super Moderator
 
Join Date: Jan 2005
Location: Tennessee, USA (GMT-5)
Posts: 7,146
Blog Entries: 11
Default

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
Reply With Quote
  #4  
Old 03-28-2009, 01:36 PM
jpanhalt jpanhalt is offline
E-book Developer
 
Join Date: Jan 2008
Location: Ohio, USA(GMT-5)
Posts: 2,567
Default

Good comments, and I agree with virtually everything, except for parts of the first statement:

Quote:
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
Reply With Quote
  #5  
Old 03-28-2009, 04:54 PM
thatoneguy's Avatar
thatoneguy thatoneguy is offline
Senior Member
 
Join Date: Feb 2009
Location: Midwest USA
Posts: 1,117
Blog Entries: 1
Default

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.
Reply With Quote
  #6  
Old 03-28-2009, 07:13 PM
hgmjr's Avatar
hgmjr hgmjr is online now
Super Moderator
 
Join Date: Jan 2005
Location: Tennessee, USA (GMT-5)
Posts: 7,146
Blog Entries: 11
Default

Is there a free assembly language software development program for the 16F84? Something like ATMEL's AVRSTUDIO4 for example.

hgmjr
Reply With Quote
  #7  
Old 03-28-2009, 07:20 PM
russ_hensel russ_hensel is offline
Senior Member
 
Join Date: Jan 2009
Location: South Dartmouth Ma
Posts: 470
Default

For more info on selection ( and you can add info there as well ) see:

http://www.opencircuits.com/Microcontroller
Reply With Quote
  #8  
Old 03-28-2009, 07:56 PM
jpanhalt jpanhalt is offline
E-book Developer
 
Join Date: Jan 2008
Location: Ohio, USA(GMT-5)
Posts: 2,567
Default

Quote:
Originally Posted by hgmjr View Post
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
Reply With Quote
  #9  
Old 03-28-2009, 09:33 PM
thatoneguy's Avatar
thatoneguy thatoneguy is offline
Senior Member
 
Join Date: Feb 2009
Location: Midwest USA
Posts: 1,117
Blog Entries: 1
Default

Quote:
Originally Posted by hgmjr View Post
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
Reply With Quote
  #10  
Old 03-28-2009, 10:18 PM
hgmjr's Avatar
hgmjr hgmjr is online now
Super Moderator
 
Join Date: Jan 2005
Location: Tennessee, USA (GMT-5)
Posts: 7,146
Blog Entries: 11
Default

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
Reply With Quote
Reply   Post New Thread

Bookmarks

Tags
,

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Microcontroller to Laptop through RS232-USB Converter Rickson Embedded Systems and Microcontrollers 0 02-26-2009 04:25 PM
Atmel AT89C51 Microcontroller Project Lanz Homework Help 5 01-26-2009 01:02 AM
Need help choosing microcontroller CanElec Embedded Systems and Microcontrollers 13 11-26-2008 11:31 PM
PLEASE READ - Posting Questions in the Embedded Systems and Microcontroller Forum Dave Embedded Systems and Microcontrollers 0 08-17-2006 05:25 PM


All times are GMT. The time now is 10:31 PM.


User-posted content, unless source quoted, is licensed under a Creative Commons Public Domain License. Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.