Powered by Invision Power Board


Forum Rules Forum Rules (Please read before posting)
Pages:12 ( Go to first unread post ) Reply to this topicStart new topicStart Poll

> Getting Started With PIC Microcontrollers, For those who have no idea how to start
CPW1992
Posted: February 01, 2006 12:01 am
Reply to this postQuote Post


Newbie
**

Group: Members+
Posts: 18
Member No.: 3,850
Joined: December 16, 2005




When it comes to learning how to use microcontrollers, MANY people have absolutely no idea how to start. I had this problem when I began and I have had other people PM me and ask me about it, too. Here is some information that should help you begin:

Here are the steps in programming a microcontroller:

Step 1. Write the code. To write the code, you will need to find an IDE (integrated development environment) that is easy to use and supports the language you want to use. The most commonly used languages for microcontrollers are probably C and BASIC. I program in BASIC and therefore I don't know much about programming microcontrollers in any other language. I would suggest writing the code in BASIC, as it is quite simple. I downloaded an IDE for use with BASIC, and it makes things really quite easy! Here's the link: Proton IDE Lite

Step 2. Compile the code into assembly code. No matter what language you write the program in, the code will have to be turned into assembly code eventually. You can write the assembly code right from the start, but I do not recommend this as it is somewhat difficult if you are just beginning. To compile the code, you will need a compiler. Most IDE's (such as Proton IDE) come with a compiler, so this step is fairly easy. Look in the help file of the IDE for specifics on how to use the compiler. Usually you just have to click a button, and the IDE will create an assembly file (.asm) in the same folder as the code file.

Step 3. Assemble the code to create a .hex file. After you have written the code and compiled it, you will need to create a .hex file that the PIC microcontroller can use. This is done using an assembler. The Proton IDE comes with a built in assembler, but sometimes you may need a separate assembler (if your IDE doesn't come with one). A good one to use is the MPASM Assembler.

Step 4. Load the code onto the microcontroller. This is done through an interface board called a programmer and an application that can send information to the programmer. With this application, you open the .hex file you created in Step 3. Then, as long as the programming board is connected properly, all you need to do then is click a button and the program will be loaded onto the microcontroller. It usually takes a few seconds.


That all may seem like a lot, but it is really not that complicated. You write the code, click a button to compile it, click another button to assemble it (with some IDE's such as the Proton IDE, you click a button and it takes care of both the compiling and assembling at once), and finally open the .hex file with another program (sometimes the IDE can do this step, too), click a button, and you're done!

Here is what I would suggest you do to help you get started:
Purchase the PICkit 1 8/14-Pin FLASH Starter Kit from Mouser.com. It is very inexpensive ($36) and can do everything you need to do to program PICMicro's. If you want to program in BASIC (which I highly suggest), download Proton IDE Lite (19MB, link mentioned earlier). The PICKit gives you an assembler (not used with Proton IDE because Proton IDE has its own), a programmer (interface board) and an application that works with the programmer, along with two microcontrollers to play with. MPLAB (an IDE for writing in C) is also included but you do not need it if you are programming in BASIC.

If you have any questions, feel free to ask! biggrin.gif
PM
Top
Topher
Posted: March 29, 2006 04:54 am
Reply to this postQuote Post


Sr. Member
*****

Group: Trusted Members
Posts: 362
Member No.: 4,477
Joined: March 06, 2006




Just wanted to bump this up and suggest it be made a sticky. Im getting started with PICs and really wish I would have seen this earlier. It would have saved my and other peoples time.
PMEmail PosterUsers Website
Top
kl27x
Posted: April 04, 2006 04:58 pm
Reply to this postQuote Post


Forum Addict ++
*******

Group: Spamminator Taskforce
Posts: 4,269
Member No.: 4,223
Joined: February 06, 2006




This is very helpful info. One correction: I believe MPLAB is a free IDE for writing in assembler, not C. Also, Proton Lite BASIC Compiler is free, but is limited to 50 lines of code, and it only works for on four chips, but still seems like a nice way to get your feet wet. If anyone knows of other free compilers/trials, please add them to this post!
PMEmail Poster
Top
Geek
Posted: April 05, 2006 09:06 am
Reply to this postQuote Post


Moderator
Group Icon

Group: Moderators
Posts: 9,943
Member No.: 62
Joined: July 23, 2002




QUOTE (Topher @ Mar 28 2006, 08:54 PM)
Just wanted to bump this up and suggest it be made a sticky.

Good idea. There's good info here smile.gif


--------------------
-= Gregg =-
"Ratings are for transistors.....tubes have guidelines"
(please do not PM me for advice. Non-forum business messages will be ignored)
PMUsers Website
Top
saveme
Posted: April 16, 2006 12:51 pm
Reply to this postQuote Post


Newbie
**

Group: Members+
Posts: 10
Member No.: 4,103
Joined: January 23, 2006




there is a C compiler called mikroC which works for all pics and is available as a demo version with the only limitation being that hex output is limited to 2k of program words.
all in all it is user friendly and a better choice for first timers who are writing small programs.
The site also has an online ebook on the pic which is pretty good...wish i had known this earlier myself
PMEmail Poster
Top
kl27x
Posted: May 04, 2006 01:40 am
Reply to this postQuote Post


Forum Addict ++
*******

Group: Spamminator Taskforce
Posts: 4,269
Member No.: 4,223
Joined: February 06, 2006




Woohoo! There's a free MikroBASIC compiler, too! It works on nearly all chips, including the 16F84A and 877A.

http://www.mikroelektronika.co.yu/english/...basic/index.htm
PMEmail Poster
Top
mravenca
Posted: June 25, 2006 11:14 pm
Reply to this postQuote Post


Sr. Member
*****

Group: Trusted Members
Posts: 339
Member No.: 1,899
Joined: January 25, 2005




It should not be such a big problem to build my own pic programmer.. Which I have come to after a short browsing and checking prices of the commercial ones. Here is a link at page with instructions how to build such a programmer, I haven't tried it yet and do not guarantee anything:)
http://www.bobblick.com/techref/projects/p...og/picprog.html
wink.gif


--------------------
---
Programmer is a machine that turns coffee and cigarettes into software
PMEmail PosterUsers WebsiteICQ
Top
mravenca
Posted: June 25, 2006 11:20 pm
Reply to this postQuote Post


Sr. Member
*****

Group: Trusted Members
Posts: 339
Member No.: 1,899
Joined: January 25, 2005




But I still miss a smart PIC tutorial. Need comparing of the possibilities of the current types. I would like one with flash memory, so I could make experiments without hazard biggrin.gif Since I responsibly choose a proper type, I can decide what programmer do I need. If you have some useful link, please post it here. I have been searching few hours and did not find useful consistent information.


--------------------
---
Programmer is a machine that turns coffee and cigarettes into software
PMEmail PosterUsers WebsiteICQ
Top
HOTDROCKS
Posted: June 25, 2006 11:26 pm
Reply to this postQuote Post


Forum Addict
******

Group: Trusted Members
Posts: 614
Member No.: 1,268
Joined: September 14, 2004




QUOTE
Need comparing of the possibilities of the current types


On the microchip site they have this information all laid out in a table...

As for the possibilities that is up to you and what you decide to do with the chip...

You will find out that there are obviously more popular chips, and most people stick to them as newbies... If you want to just play around with one chip nothing is saying you can't take a 40 pin PIC and make it blink a single LED, and then build from there with lots of room for growth...
PMEmail Poster
Top
mravenca
Posted: June 25, 2006 11:33 pm
Reply to this postQuote Post


Sr. Member
*****

Group: Trusted Members
Posts: 339
Member No.: 1,899
Joined: January 25, 2005




Yeah, I did not notice this>
http://www.microchip.com/stellent/idcplg?I..._PAGE&nodeId=74
So it surely indicates I should finally get some sleep:+))
Thank you


--------------------
---
Programmer is a machine that turns coffee and cigarettes into software
PMEmail PosterUsers WebsiteICQ
Top
kl27x
Posted: June 26, 2006 02:05 pm
Reply to this postQuote Post


Forum Addict ++
*******

Group: Spamminator Taskforce
Posts: 4,269
Member No.: 4,223
Joined: February 06, 2006




The Bob Blick-designed Tait Classic Programmer than MRAVENCA linked is the schematic that I used. I am having fair success with it, with some problems. I use IC-PROG. A few tips:

In hardware menu, select "Tait Serial Programmer" in the programmer menu.

Invert MCLR and VCC

If you use XP, make sure to go to options > misc and enable windowsnt/2000 driver, and that you have the driver downloaded into the same folder as the exe.

If you build it as an ICSP, like I did, make sure you keep clock and data lines separated, or they will interefere with each other. I experienced this, firsthand. If you use a ribbon cable, put the ground wire in between them. If you use ethernet cable, like I did, put your data and ground on a twisted pair and clock somewhere else. Don't make the ICSP cable overly long.

If you are designing your own pcb, or you are using protoboard, I have discovered you can GREATLY simplify the trace layout by installing the buffer chip UPSIDE DOWN!!!

If you get frequent errors, go to options > programming and enable "verify during programming." This will in the least save you time, and seems to improve performance for me.

I have noticed that with longer programs, I see more errors. I am pretty sure that were a program long enough, my original setup would never have been able to program it, error-free, as the likely-hood of an error somewhere along the line would approach 100%. I would estimate this to be within 2k words, or so. This might be because I used ethernet cable for ICSP; dunno, really. I am not sure if tweaking has completely fixed this or not, because after doing the above steps, I finally got a longer program to install properly onto my pic, and I'm not gonna mess with it, again, until I figure out how to hook up my LCD. smile.gif

**Edit: Errors were due to a faulty laptop parallel port. Works perfectly with other computers.
PMEmail Poster
Top
kl27x
Posted: August 01, 2006 03:40 am
Reply to this postQuote Post


Forum Addict ++
*******

Group: Spamminator Taskforce
Posts: 4,269
Member No.: 4,223
Joined: February 06, 2006




I'm sure someone has probably posted this before. But I'm pretty excited to find this free programming software: PICPgm Programmer

It supports a few different chips. Plus it can be configured to work with any programmer, because you can configure the port pins any way you see fit.

The only downside is the config bits aren't named, so you have to know your bits.
PMEmail Poster
Top
fenugrec
Posted: August 01, 2006 02:33 pm
Reply to this postQuote Post


Sr. Member
*****

Group: Trusted Members
Posts: 491
Member No.: 5,637
Joined: July 13, 2006




Rread and read and read the datasheet for your PIC... even if you're programming in basic or C.
PMUsers Website
Top
draget
Posted: August 12, 2006 08:43 am
Reply to this postQuote Post


Forum Addict ++
*******

Group: Cleanup Taskforce
Posts: 6,323
Member No.: 1,770
Joined: December 31, 2004




If you are an aussie might I recommend http://www.altronics.com.au/index.asp?area=item&id=K9505 . I bought mine at Jaycar, works nicely with my pentium 4s onboard serial.
PMEmail PosterUsers Website
Top
rick
Posted: January 03, 2007 11:32 pm
Reply to this postQuote Post


Newbie
*

Group: Members+
Posts: 1
Member No.: 7,672
Joined: January 03, 2007




Is the PICkit 2 the place to start now ? I am a total newbie.
http://www.jameco.com/webapp/wcs/stores/se...roductId=697338
PMEmail Poster
Top
draget
Posted: January 04, 2007 04:10 am
Reply to this postQuote Post


Forum Addict ++
*******

Group: Cleanup Taskforce
Posts: 6,323
Member No.: 1,770
Joined: December 31, 2004




QUOTE (rick @ Jan 3 2007, 11:32 PM)
Is the PICkit 2 the place to start now ? I am a total newbie.
http://www.jameco.com/webapp/wcs/stores/se...roductId=697338

Sure
PMEmail PosterUsers Website
Top
CPW1992
Posted: February 09, 2007 03:38 am
Reply to this postQuote Post


Newbie
**

Group: Members+
Posts: 18
Member No.: 3,850
Joined: December 16, 2005




Wow, I haven't been on here in about a year. I never realized this topic was stickied and had so many replies. I'm glad the information helped people.

I haven't done much microcontroller stuff in a while, but hopefully sometime soon I will get back into them.

As for the PICKIT 2, I think that's what I meant to type in the first post, but for some reason I put 1. I'm pretty sure I have the 2 version, though.
PM
Top
tanahguan
Posted: August 22, 2007 06:15 am
Reply to this postQuote Post


Member
****

Group: Trusted Members
Posts: 170
Member No.: 6,250
Joined: September 04, 2006




Microchip have a free version C compiler for their PIC18 series. Its called MPLAB C-18 compiler... search under Developement tools in their website
PMEmail Poster
Top
FunnyNYPD
Posted: November 11, 2007 12:04 am
Reply to this postQuote Post


Jr. Member
***

Group: Trusted Members
Posts: 58
Member No.: 11,897
Joined: November 10, 2007




PICKit 2 used to be a very good programmer, now it supports debugging with MPLAB 7.62 and MPLAB 8.0.

For most of the PIC16s and PIC18s, PICKit2 function all-most identical as the ICD2 on programming and debugging.

I own both ICD2 and PICkit2. Both are great products. Would recommend both.

As a matter of fact, my colleages did a enhanced version of PICkit2 clone a while ago. Now it has been on production for three months. Our design fully implemented microchip recommended schematic and all Microchip posted hardware fixes. It also includes an enhanced feature: a dedicated power supply (just like the ICD2). Most of the components are SMD.

The PICkit2 DIY board is on sale as less as US$5, and components kit are also available for people who would like to enjoy the fun. thumbsup.gif

An anouncement has been posted on EDAboard forum (schematic, asembly drawing, test result, etc are all posted on my own web and the EDAboard forum):
http://www.edaboard.com/ftopic273287.html

Here is one picture:
user posted image
And This picture illustrates the size of our PICKit2 design with the newest ICD2
user posted image
PICkit 2 bare PCB design:
user posted image

This post has been edited by FunnyNYPD on February 06, 2008 07:37 pm


--------------------
Funny N.
PMEmail PosterUsers Website
Top
FunnyNYPD
Posted: February 06, 2008 07:41 pm
Reply to this postQuote Post


Jr. Member
***

Group: Trusted Members
Posts: 58
Member No.: 11,897
Joined: November 10, 2007




my experience with Microchip C18 is horrible. Lots of bugs and code size is huge compare with Hi-tech PICC.


--------------------
Funny N.
PMEmail PosterUsers Website
Top
gramo
Posted: November 22, 2008 03:05 am
Reply to this postQuote Post


Forum Addict
******

Group: Trusted Members
Posts: 625
Member No.: 8,536
Joined: March 06, 2007




QUOTE (FunnyNYPD @ November 21, 2008 05:39 pm)
BB0703+128K and BB0703+256K

I see your really trying to push the PK2 clone in here, my 2c - considering the legit PICKit 2 is $34.95 assembled, and also has the peace of mind its backed by Microchip (the guys that make PIC's)... Well it kinda doesn't matter what else you say from there.

You said that you get a valuable lesson with the DIY kit.. Soldering seems to be the only gain with your clone, you might however have the likely chance of fault finding your programmer when it doesn't work dry.gif I'd much prefer the reliability of a 'built by manufacture' backed with a warranty

All that aside, the legit PK2 casing is so much more suave then your bulky game cartridge contraption biggrin.gif

user posted image


You can get it here from Microchip, and all the relevant info such as supported devices (pretty much all PIC's) and the such can be found on the site too


--------------------
digital-diy.com - Hobby microcontroller projects and tutorials. Assembly, PICBasic and C examples.
PMEmail PosterUsers Website
Top
FunnyNYPD
Posted: November 22, 2008 05:26 am
Reply to this postQuote Post


Jr. Member
***

Group: Trusted Members
Posts: 58
Member No.: 11,897
Joined: November 10, 2007




QUOTE
I'd much prefer the reliability of a 'built by manufacture' backed with a warranty

Really? Do they carry any warranty on PICKit 2? I am not aware of that.
I knew ICD2 has life-time free exchange service, not sure Microchip PICkit 2 has the same. At least it wasn't publicly published as the ICD2 free exchange service.

The Microchip PICkit2 schematic is a very good design. However Microchip's hardware design isn't so good.

As far as I knew on the "reliability", That might not be so true because Microchip hardware design team seems having pushed some of the hardware component too close to its limit.

Check out Microchip Forum, you will find the something like:

Pump Your PICkit 2's VPP



--------------------
Funny N.
PMEmail PosterUsers Website
Top
FunnyNYPD
Posted: November 22, 2008 05:30 am
Reply to this postQuote Post


Jr. Member
***

Group: Trusted Members
Posts: 58
Member No.: 11,897
Joined: November 10, 2007




as of the Microchip reliability,
QUOTE
a 1/2W minimum resistor is needed, ... be placed from pin 2 to pin 3 of the unpopulated J1 footprint along the edge of the PICkit 2 PCB.  This may be easier than trying to use the R34 pads.

here is another example on how good is the hardware design:
Microchip Issues on Programmer-to-Go



This post has been edited by FunnyNYPD on November 22, 2008 05:32 am


--------------------
Funny N.
PMEmail PosterUsers Website
Top
FunnyNYPD
Posted: November 22, 2008 05:36 am
Reply to this postQuote Post


Jr. Member
***

Group: Trusted Members
Posts: 58
Member No.: 11,897
Joined: November 10, 2007




Here is another good example on " the reliability of a 'built by manufacture' backed with a warranty "

On microchip PICkit 2, if you need 256K EEPROM for Programmer-to-go, you need do the following hardware hack, all by yourself:

QUOTE
1 Open the PICkit 2 case by prying it apart with a small flat screwdriver at the three indentations
along the seam at a long edge of the case.
2 Remove the 24LC512 serial EEPROMs at reference designators U3 and U4 from the PCB.
3 Lift the A2 pins of two 24LC1025-I/SM serial EEPROMs so they do not contact the circuit
board pad when placed on the PCB.
4 Solder the two 24LC1025 EEPROMs in place at U3 and U4 on the PICkit 2 PCB.
5 Solder a wire from the lifted A2 pin to the VCC pin on both 24LC1025 EEPROMs.


Here is the family of BB0703, which includes the BB0703+256K:
user posted image


--------------------
Funny N.
PMEmail PosterUsers Website
Top
gramo
Posted: November 24, 2008 07:19 am
Reply to this postQuote Post


Forum Addict
******

Group: Trusted Members
Posts: 625
Member No.: 8,536
Joined: March 06, 2007




I could have sworn that I replied to your posts earlier, but I can't see it here huh.gif

I'm actively against clones not only because I'm tired of getting emails from people who have issues with there home made jobs, but also because I've been bitten by poor quality boards in the past.

Like I said, for $34.95 completely built and around $12 shipping (that was to Australia), the original PK2 wins hands down. I simply take my laptop with me when I want to program on site anyhow, yet to run into any issues with the USB supply voltage that you make sound like a major flaw..

Not only all that, but clones hinder the development of the real deal, comes hand in hand with piracy at the end of the day.


--------------------
digital-diy.com - Hobby microcontroller projects and tutorials. Assembly, PICBasic and C examples.
PMEmail PosterUsers Website
Top
0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
0 Members:

Topic OptionsPages:12 Reply to this topicStart new topicStart Poll

 


:: support us ::




ElectronicsSkin by DutchDork & The-Force