Microcontrollers - need some pointers regarding the basics

Have questions about a SparkFun product or board? This is the place to be.

Moderators: phalanx, TS-Tim

Post Reply
erik006
Posts: 8
Joined: Mon Dec 31, 2007 6:29 pm

Microcontrollers - need some pointers regarding the basics

Post by erik006 » Tue Jan 01, 2008 11:45 am

Hi All,

First, a little background: I've been experimenting off & on with microcontrollers & basic electronics for quite some time (a few years), but never had the time, money or knowledge to do any serious work. The most advanced circuits i've built to date are: controlling leds, 7-segment displays, temperature sensors, eeprom, etc. I don't have any (formal or informal) practical electronics training, so I'm probably missing many of the basic concepts.

Recently, I've decided to build my own simple robot. It will be controlled by a simple microcontroller (PIC16F877A), a L293D motor controller & use simple sensors (bump switches & sharp distance sensors) for object detection. This *should* be simple enough, yet i'm somewhat apprehensive about starting this project because i've always been plagued with the following problem: my PIC chips all seem to break.

Since my resources are quite limited, this is very frustrating and frankly, very discouraging. I'm curious if this is due to my lack of anti-static equipment, the lack of proper programming hardware, or some other cause.

Is this a normal occurrence for the rest of you? Any ideas what I can do to prevent further damage?

Kind regards,

Erik

User avatar
leon_heller
Support Volunteer
Posts: 5734
Joined: Sun May 01, 2005 11:20 am
Location: St. Leonards-on-Sea, E. Sussex, UK.

Post by leon_heller » Tue Jan 01, 2008 11:54 am

Get an ICD 2 or a PICkit 2, they simplify programming and debugging. As the chip remains in-circuit, it's not so likely to get damaged.

Leon
Leon Heller
G1HSM

Andrew02E
Posts: 141
Joined: Wed Sep 20, 2006 6:57 pm
Location: Sheboygan, WI
Contact:

Post by Andrew02E » Tue Jan 01, 2008 12:33 pm

What seems to 'break' about them? There are many ways a PIC can 'break'. Is there any pattern to when they stop functioning? Any similar scenarios that they give up in? Do they completely stop responding or do only certain pins stop functioning? Please add details, I'm sure we can all offer some good suggestions.
Also, I would guess that, although possible, it's not due to a lack of anti-static equipment (unless you rub your TV screen before you start working on it). I rarely handle my PIC projects with care and they've all survived.

erik006
Posts: 8
Joined: Mon Dec 31, 2007 6:29 pm

Post by erik006 » Tue Jan 01, 2008 1:07 pm

The way they 'break' is my inability to program the chips after a few uses: Often the chips will still work (execute the code), and I can read the code from the PIC, but cannot program new code onto the PIC. (My current programmer give an error (for example: ROM programming error at address: 0x0000).

Although i've experienced other problem, this is currently occuring most often. The DIY K150 programmer gives me that error, but i've also tried in circuit programming with a CCS ICD-U40 to no avail.

Erik

User avatar
bigglez
Support Volunteer
Posts: 1553
Joined: Mon Sep 26, 2005 1:25 pm

Re: Microcontrollers - need some pointers regarding the basi

Post by bigglez » Tue Jan 01, 2008 11:36 pm

erik006 wrote:This *should* be simple enough, yet i'm somewhat apprehensive about starting this project because i've always been plagued with the following problem: my PIC chips all seem to break.
Erik,

Can you post a schematic of a project you've built that
broke? Did you repair it? If so, how?

Comments Welcome!
No Longer Sharing My ID
I'm over 13 & support COPPA regulations

User avatar
Chupa
Support Volunteer
Posts: 537
Joined: Tue Feb 20, 2007 11:22 pm
Location: Clearwater, FLORIDA!
Contact:

Post by Chupa » Tue Jan 01, 2008 11:43 pm

erik006 wrote:The way they 'break' is my inability to program the chips after a few uses: Often the chips will still work (execute the code), and I can read the code from the PIC, but cannot program new code onto the PIC. (My current programmer give an error (for example: ROM programming error at address: 0x0000).

Although i've experienced other problem, this is currently occuring most often. The DIY K150 programmer gives me that error, but i've also tried in circuit programming with a CCS ICD-U40 to no avail.

Erik
i started out with a K150 programmer. After looking back its a big mistake, but obviously dident know any better at the time. That programmer is not beginner friendly at all, or even advanced user friendly.

If i had to go back and do it again i would have wanted someone to insist to to me to learn how to do ICSP and use a PICKit 2. It integrates into MPLAB so nicely and later on when you start to catch on you can use it as a debugging tool. The best part is its only $35 http://search.digikey.com/scripts/DkSea ... G164120-ND as appose to the k150 which is like $50 or 60 if I remember correctly, but unfortunately it sounds like you already purchased that.

About your problem with breaking PICs. are you accidentally enabling code protection when you program your PICS? Cus that will cause them to act exactly as you describe.

TLDR: Get a PICkit 2. Learn how to implement ICSP with your circuit.
Paul "Chupa" Mac

Andrew02E
Posts: 141
Joined: Wed Sep 20, 2006 6:57 pm
Location: Sheboygan, WI
Contact:

Post by Andrew02E » Wed Jan 02, 2008 12:05 am

Chupa brings up a good point with the code protection. I started out with an EPIC programmer, and although it works very well, if you're not careful you can enable/disable all sorts of unwanted configuration settings. This obviously leads to undesired operation (or no operation at all). The point is: double check your programming configuration.

linuxguy
Posts: 245
Joined: Fri Feb 16, 2007 9:14 pm
Location: Beaverton, OR
Contact:

Post by linuxguy » Wed Jan 02, 2008 2:59 am

leon_heller wrote:Get an ICD 2 or a PICkit 2, they simplify programming and debugging. As the chip remains in-circuit, it's not so likely to get damaged.
I've never worked with the PICkit 2, but I got an Olimex ICD2. It just works, and has never given me any grief. I highly recommend this ICD2. It works great with MPLAB.

8-Dale
[url=http://www.thedynaplex.org]The Dynaplex Network[/url] - Linux, Robotics, and Open Source
[url=http://www.gentoo.org/]Kubuntu[/url] is my current Linux distribution. 73 from N7PKT!

edmoore
Posts: 40
Joined: Wed Jul 11, 2007 3:56 am

Post by edmoore » Wed Jan 02, 2008 4:55 am

Without wishing to be a pain, you might consider using an Atmega AVR instead of a PIC. There are many tired debates on avr vs pic, but my specific reasoning is that you say you want to really learn what's actually going on in the chips (among other things). The AVR Freaks forum has a beginners section with tutorials, including some absolutely fabulous ones by a user called abcminiuser, which very thoroughly but accessibly explain how the thing works from the registers onwards. I also think that AVRs are a little easier to understand if you're looking at the datasheet and want to understand the architecture, memory mapping and so on. Essentially, once you understand interrupts and timers, it's all down hill, and he explains them both particularly well.

If you're already comfortable with timers and the like, and navigating around the datasheets for your micro, then ignore the above as it'd only be teaching you to suck eggs.

The other advantage to keep you motivated is that avrfreaks is about the most active forum I've come across for this stuff, and the toolchain is completely free and the windows distribution is very well developed and usable.

edmoore
Posts: 40
Joined: Wed Jul 11, 2007 3:56 am

Post by edmoore » Wed Jan 02, 2008 4:55 am

Without wishing to be a pain, you might consider using an Atmega AVR instead of a PIC. There are many tired debates on avr vs pic, but my specific reasoning is that you say you want to really learn what's actually going on in the chips (among other things). The AVR Freaks forum has a beginners section with tutorials, including some absolutely fabulous ones by a user called abcminiuser, which very thoroughly but accessibly explain how the thing works from the registers onwards. I also think that AVRs are a little easier to understand if you're looking at the datasheet and want to understand the architecture, memory mapping and so on. Essentially, once you understand interrupts and timers, it's all down hill, and he explains them both particularly well.

If you're already comfortable with timers and the like, and navigating around the datasheets for your micro, then ignore the above as it'd only be teaching you to suck eggs.

The other advantage to keep you motivated is that avrfreaks is about the most active forum I've come across for this stuff, and the toolchain is completely free and the windows distribution is very well developed and usable.

erik006
Posts: 8
Joined: Mon Dec 31, 2007 6:29 pm

Post by erik006 » Wed Jan 02, 2008 6:58 am

Guys,

thanks for your answers, they are very much appreciated! I will look into getting an ICSP capable programmer, although it seems the ICD2 is a bit out of my reach (financially speaking).

Thanks again,

Erik

User avatar
Chupa
Support Volunteer
Posts: 537
Joined: Tue Feb 20, 2007 11:22 pm
Location: Clearwater, FLORIDA!
Contact:

Post by Chupa » Wed Jan 02, 2008 2:20 pm

erik006 wrote:Guys,

thanks for your answers, they are very much appreciated! I will look into getting an ICSP capable programmer, although it seems the ICD2 is a bit out of my reach (financially speaking).

Thanks again,

Erik
Yea thats why I suggested the PICKit 2. I went from a K150, to a $15 JDM off ebay, to an Olimex PIC Start +, and just recently got a PICkit 2 for debugging.
Paul "Chupa" Mac

Post Reply