Beginner in Programming

Electronics Computer Programming Q&A
Post Reply
TimG
Posts: 3
Joined: Sun Dec 04, 2005 1:01 am
Location: Missouri
Contact:

Beginner in Programming

Post by TimG »

Helo. I ahve been working on Electronic controls and ahve programmed pics every day but I have never set down to write a programe to run on a Pic. I am going to be using a pic16c84 in my project and I was wondering what type of language to write the code in before downloading into programmer. Is Basic the best and easiest to use?
Thanks Tim
Tim Greenlee
TimG
Posts: 3
Joined: Sun Dec 04, 2005 1:01 am
Location: Missouri
Contact:

Re: Beginner in Programming

Post by TimG »

Sorry everyone the ahve should be have. Big fingers do not work sometimes.
Tim
Tim Greenlee
JPKNHTP
Posts: 488
Joined: Wed Jun 29, 2005 1:01 am
Location: Missouri
Contact:

Re: Beginner in Programming

Post by JPKNHTP »

-JPKNHTP
-God Bless
bodgy
Posts: 1044
Joined: Tue Dec 04, 2001 1:01 am
Location: Australia
Contact:

Re: Beginner in Programming

Post by bodgy »

You might also like to look at XCSB - structured basic - so it looks a little like C but uses basic commands.

Some examples are on my website.

XCSB demo from

www.xcprod.com


Colin
On a clear disk you can seek forever.
User avatar
HighFrequency
Posts: 122
Joined: Sun Apr 17, 2005 1:01 am
Location: Victoria BC
Contact:

Re: Beginner in Programming

Post by HighFrequency »

I believe PICC Lite only allows you to use 25% of program memory though.
There is only one correct answer, mine.
JPKNHTP
Posts: 488
Joined: Wed Jun 29, 2005 1:01 am
Location: Missouri
Contact:

Re: Beginner in Programming

Post by JPKNHTP »

-JPKNHTP
-God Bless
User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Beginner in Programming

Post by philba »

There are three directions you can go: BASIC, C and ASM. There are other languages but those are the big 3. I'd stick with one of them as there will be much more help available.

ASM: not for the faint of heart. if you've never used ASM, I wouldn't recommend it. It is a very good thing to know as you will understand the chip architecture 100% better.

BASIC: lots of options here. BASIC is fairly easy to learn but runs out of gas pretty quick. low level manipulation can be clumsy and accurate timing is hard. The interpretted versions (like the basic stamp) are way slow. not a lot of standardization - code developed in one version can be a real PITA to move to a different one. Most BASICs have a decent library. The most popular, I think, is Pic Basic. I'm not aware of a free version.

C: can be harder to learn than BASIC. However, it gives you complete access to the underlying features. very good at bit manipulations and timing. IMO, it's worth the small extra effort to learn. There are a number of good to very good compilers - PICC, CCS, High Tech, Knudsen (cc5x), Microchip, mikorelectronka, ... They all have free trial versions with varying limitations. I use cc5x and like it but it's not as professional as PICC or others. Unless you have a strong reason to want BASIC or ASM, I'd recommend you use C.
TimG
Posts: 3
Joined: Sun Dec 04, 2005 1:01 am
Location: Missouri
Contact:

Re: Beginner in Programming

Post by TimG »

Thanks everyone for the info. I will check out all of the recomendations.
Tim
Tim Greenlee
pankau42
Posts: 5
Joined: Sat Dec 17, 2005 1:01 am
Location: Champaign, Illinois
Contact:

Re: Beginner in Programming

Post by pankau42 »

check out this site
http://www.mikroelektronika.co.yu/english/index.htm

they have some very nice compilers C, Basic, Pascal. I have used the C and Basic ones. The free version limits you to 2K of program memory but the chip you are using only has 2K right? Most of my projects have not even come close to exceeding those limits.
User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Beginner in Programming

Post by philba »

I've used MikroC and while it does have a nice library, the code generation is really poor. That 2K limit sounds good against CC5X's 1K limit until you actually look at the generated code. I ported my driveway sensor logger app from cc5x to MikroC, My 860 instruction app in cc5x was a 1.8K instruction app with MikroC. All things considered, I'll take the tighter code any day.

One thing about the MikroC libraries, they have nice documentation to show how to connect things up. For a beginner, it might be of some value.
developerzero
Posts: 4
Joined: Thu Dec 29, 2005 1:01 am
Contact:

Re: Beginner in Programming

Post by developerzero »

First: You should start with the pic16F84A instead of the pic16C84. It is a flash chip, instead of a OTP (One-Time Programmable) chip. This means you can write and rewrite it as many times as you want (rated up to around either 1000 or 10000 times).

Second: Check out Sample.Microchip.com for free samples to use as you are getting started (including free shipping). This is a great feature you should take advantage of from any company you plan on buying MicroControllers from. You can choose up to 4 different part numbers, and up to either 3 or 5 of each part (based on the part number), with a maximum of 2 samples per month. I would suggest you pick up a few different part numbers with different features (such as A/D and serial ports, but be sure to stick with 16F parts (Flash parts from the pic16 family)). And make sure you buy PDIP parts, and not surface-mount.

Finally: I would suggest the book "PIC Microcontrollers, an introduction to Microelectronics" (2nd) by Martin Bates (ISBN 0-7506-2627-0). It is a very good book that covers everything you need to know about PIC microcontrollers and is focused on the 16F84A. The programming is primarily in Assembly, but I would definately suggest you start with that because it tends to be faster, more efficient, and easier to optimize (plus it is free from Microchip with no limitations).

P.S. If you don't have a programmer yet, I suggest you pick up either a PicKit 1 or PicKit 2. The advantage of the PicKit 1 is that it is better integrated with MPLAB (MicroChip's development environment), although it is a little older. Also, there are several books that use it, (specifically, the book "123 PIC MicroController projects for the evil genius" by Myke Predko (which even has plans for installing a 14-pin ZIF socket for using the PicKit 1 as a programmer). There is also a coupon in the back good for 20% off the PicKit1.). The downside is it is (I believe) only compatible with PICs the have 14 or less pins, while PicKit 2 will work with up to 20 pins (I am just talking about the built-in socket size and PCB traces). The advantage of the PicKit 2 is that it can be used for ICSP (in-circuit Serial Programming), and it is newer (so MicroChip should (hopefully) be adding support for it in the MPLAB IDE soon.

If you have any questions, feel free to e-mail me.

<small>[ December 29, 2005, 09:25 PM: Message edited by: developerzero ]</small>
User avatar
philba
Posts: 2050
Joined: Tue Nov 30, 2004 1:01 am
Location: Seattle
Contact:

Re: Beginner in Programming

Post by philba »

Definitely use a flash (F) part.

Actually, I wouldn't use the 16F84, either. Its positively ancient. If you are using F84 circuits, the 16F628A is a direct replacement - a lot cheaper with more of everything. Any programmer that can't program it is basically useless.

If you aren't using F84 circuits, I'd go for the 16F88. A really nice little chip with ADC, serial I/O and lots of other goodies. Cheaper than the 16F84! The pin out is a bit different from the 628A (and 84). And, as I have said before, you can use a boot loader with it.

<small>[ December 30, 2005, 02:18 PM: Message edited by: philba ]</small>
seaviper
Posts: 1
Joined: Sat May 20, 2006 7:28 am
Location: FL
Contact:

Post by seaviper »

Check out "Programming and Customizing PICmicro Microcontrollers" by Predko, McGraw Hill. Pretty much everything you need to know to get started is in there. You can find it at B&N and Amazon, etc.

Personally I recommend programming with ASM first.
Patrick
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests