• AVR Freaks

Helpful ReplyHot!PIC microcontrollers starter: I want to learn how to program a PIC micro

Author
Marcus314
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2017/03/17 20:02:43
  • Location: 0
  • Status: offline
2017/06/05 19:07:18 (permalink)
0

PIC microcontrollers starter: I want to learn how to program a PIC micro

Good evening (or whatever time you are watching this). Before getting to the point I want to introduce myself to explain everything:
My name is Marco (but you can call me Marcus if you want). I'm a mechatronics engineering student from Mexico. I am in 6th semester and I'm very interested in electronics (since I was a kid). The point is the following: I was taking a course on microcontrollers at my university. This course was not a PIC microcontrollers but rather a LPCXpresso one and we were working with the LPC1769 development board. The problem is that first of all my teacher barely taught us anything about this board and how to program it (he even didn't attend class most of the time) yet he expected us to build very complex circuits (e.g. digital clocks, thermometers, LCD display, etc) and it was difficult for me to find any information about the LPC1769 and how to program it. Even if I dominate digital and analogue electronics (since I had to take them to be able to take the microcontrollers course); still I had problems since the material our teacher gave us from his Google Drive cloud folder was not easy to comprenhend. The projects he asked us to build using his code and electronic schematics were full of errors and most of the time my circuit didn't work. As a result I ended failing the course. I asked help on a teacher of mine who taught me the course on sensors and actuators and told me that starting microcontrollers with a LPC1769 board was like (in his own words) "trying to know how to fly a plane when you don't know how to drive" (he basically said that it was like trying to dominate something very hard without knowing easier stuff or the basics) so he recommended me for starting with microcontrollers the PIC microcontroller (many teachers in the university give the course on microcontrollers but they use different microcontrollers like the PIC microcontrollerZilog microcontroller, and the already mentioned LPC development board). My teacher is the only one who gives the course on LPCXpresso and he won't accept any other micro (he even failed a couple of students because he found that they had an Arduino board) so if I had known that he only used the LPC and that the PIC micro was better for newbies (excuse the word) on microcontrollers I would have better taken the course with another teacher. Well... the teacher on sensors and actuators also recommended me on using the PIC16F84A as the microcontroller to start. About other tools he told me to use Pickit 3 and MPLAB X (I have Windows 10). The problem now is the following. I've been looking for tutorials on YouTube about how to program PIC micros but most of them are using assembly language and I don't know nothing about this programming language. I'm better with C language and I have to tell that I'm good on it (not a professional; yet I know the basics) but still I have trouble on relating C programming to PIC microcontrollers. I'm very interested on learning to program PIC microcontrollers in C but I don't find any sort of material that would help me. All of them use either assembly or use C language but run into simulators (like Proteus) but I DON'T WANT TO USE SIMULATORS, I want to use a physical microcontroller on a breadboard and to put components for doing awesome stuff like small robots, clocks, and all those things our teacher from the LPC course told us to do but I was not able to. Any good book? Source material? Online course? Please I need help I'm desperate. I already bought the previously mentioned material if you are asking. Thanks. BTW. I'm new to the site.
#1
Eric Christenson
Super Member
  • Total Posts : 78
  • Reward points : 0
  • Joined: 2016/07/07 20:51:22
  • Location: 0
  • Status: offline
Re: PIC microcontrollers starter: I want to learn how to program a PIC micro 2017/06/06 21:06:02 (permalink)
+2 (2)
First, we aren't going to solve any of your political issues with your courses, just give the profs what they ask for and learn as much as you can in the process.   Assembly language is simply what your "C" language is transformed into, but written by hand with much greater effort, not to worry.  I have written quite a bit of microcontroller code professionally, and very little of it is in assembler.  If you need it, it's in the documentation.
 
All of the microcontroller systems you mention are conceptually quite similar -- the difference from programming the larger computers that you have programmed in "C" is that you have to transfer the result of translating the program onto the embedded microcontroller target.  Oh, and you need to know how that microcontroller is hooked up electronically to the world, too.
 
Start out with your favorite 8-bit PIC (there's a bunch of extra stuff to do on 16- and especially 32- bit devices that will get in the way for the time being), and purchase an evaluation board and a programmer for it.  Run the examples that come with it.  Then start changing those examples to do what you want.  Arduino? No problem, especially if you have friends already working with one.  The process is the same, the rules are just slightly different because adjustments have been made with casual programmers in mind.
 
The important thing here for you is to start out with something that is already working, and to make one change at a time until you have learned the ropes.  Once things start to work, make a point of understanding why you do what you do. 
 
post edited by Eric Christenson - 2017/06/06 21:13:29
#2
PStechPaul
Super Member
  • Total Posts : 2403
  • Reward points : 0
  • Joined: 2006/06/27 16:11:32
  • Location: Cockeysville, MD, USA
  • Status: offline
Re: PIC microcontrollers starter: I want to learn how to program a PIC micro 2017/06/06 21:53:51 (permalink)
+4 (4)
I was not familiar with the LPC1769 so I found this link:
http://www.embeddedartists.com/products/lpcxpresso/lpc1769_cmsis_xpr.php
 
It seems to be a relatively high-end product and possibly not well suited to a beginner, but generally you can easily build simple projects for a complex processor, and not vice-versa. It is an NXP Cortex microcontroller and thus not as familiar to many of us here on a Microchip forum. The Arduino is an Atmel AVR device and their chips are now part of the Microchip line, although perhaps not well supported (yet).
 
The PIC16F84A is a rather ancient device and I would not recommend it. It does not have any A/D or PWM, which are very useful. I like the 14 pin PIC16F684, but it is also old. Perhaps something like the PIC16F1614/18 would be a good device with very few limitations.
 
You might want to get the Microchip Curiosity board for about $20:
http://www.microchip.com/Developmenttools/ProductDetails.aspx?PartNO=DM164137
 
If you do choose a Microchip PIC, you will be sure to be able to get help here. Good luck with your education and projects.

 
#3
qhb
Superb Member
  • Total Posts : 9999
  • Reward points : 0
  • Joined: 2016/06/05 14:55:32
  • Location: One step ahead...
  • Status: offline
Re: PIC microcontrollers starter: I want to learn how to program a PIC micro 2017/06/06 21:57:02 (permalink)
+5 (5)
I would suggest you start here:
Particularly: Mid-Range PIC tutorials - FREE SAMPLE
You have to register, but the basic tutorials are free.
 
The free ones are based around the PIC12F629, which is a more modern PIC than the elderly PIC16F84.
You can either try to buy a PIC12F629, or just work out what the minor changes are to use a PIC16F84 instead.
 
 
#4
katela
Super Member
  • Total Posts : 1412
  • Reward points : 0
  • Joined: 2013/06/11 05:25:18
  • Location: South Africa
  • Status: offline
Re: PIC microcontrollers starter: I want to learn how to program a PIC micro 2017/06/07 01:36:09 (permalink)
+4 (4)
Start with Microchip curiosity board or any other good PIC board that you can afford in your area.
I would advice to learn using a new PIC model rather than old models which will limit you especially if you'd like to learn using MPLAB Code Configurator.
They are plenty of PIC tutorials online using C, your choices are very broad, I don't know why you said you can only find Assembly tutorials, the same goes for books as well. They are plenty. Try books by Prof Dogan Ibrahim. Most of his books are project oriented if it's what you are looking for.

Free online Microcontroller Tutorials and Projects for Hobbyists and students. From beginners to advanced. Website: www.studentcompanion.co.za
YouTube Tutorials: https://www.youtube.com/StudentCompanionSA
#5
Mysil
Super Member
  • Total Posts : 3358
  • Reward points : 0
  • Joined: 2012/07/01 04:19:50
  • Location: Norway
  • Status: offline
Re: PIC microcontrollers starter: I want to learn how to program a PIC micro 2017/06/07 04:22:08 (permalink)
+5 (5)
Hi,
If you try to run older tutorial examples, calling for:
#include <plib.h>
It may be easier to install an older version of XC8 compiler, XC8 v1.33,
instead of trying to use plib together with the latest version of XC8 compiler.
Different versions of the C compiler may perfectly well remain installed together.
There is selection in MPLAB X GUI, which version of the compiler to use.
 
PIC16F84A is a very obsolete device that cannot be debugged in hardware.
With ...84A, you have 2 alternatives:
A;  Write code without bugs.
B;  Use a simulator.
There must have been some time passed since your instructors were taking lessons themselves.
 
I suggest you try to locate a PIC16 device with digit '1' following the  letter 'F'
PIC16F1xxx  or PIC16F1xxxx.  Any of those will be good for your use.
Any PIC16F... device in PDIP package may be used on a solderless breadboard,
with connections to PICkit 3.
 
If you run into a PICkit 3 Debug Express, it is a package with a PICkit 3, USB cable and a small board, go for it.
The PICkit 3 may be used with practically any PIC device you are likely to find.
 
If you run into a PICkit 2 Starter Kit, it is what I started with, and still use for some purposes.
 
The Newest development boards: 'Curiosity ...' have a 'PICkit 3' built in (on the underside of the board),
then you do not need a separate PICkit 3.
 
Regards,
   Mysil
#6
Eric Christenson
Super Member
  • Total Posts : 78
  • Reward points : 0
  • Joined: 2016/07/07 20:51:22
  • Location: 0
  • Status: offline
Re: PIC microcontrollers starter: I want to learn how to program a PIC micro 2017/06/07 19:14:41 (permalink)
+4 (4)
For Marcus, I suggest:  Go simple, go complete, go current. 
That is, a curiosity board is a good starter, especially with the Pickit3 integrated (so it's complete), and go current, that is, don't fool with obsolete chips.
 
Once you have that working, you can start to build the hardware you want and start upgrading the CPU when you find it's not easy to do whatever you have in mind.  Stepwise refinement is the key.
 
P.S. When you don't have a debugger, and you don't have working code, you find a way to make a "print" statement work -- whether through the UART or simply toggling an extra bit and watching it on the oscilloscope.   It also severely increases your test requirements, since everything has to be tested carefully before deciding its complete, and that kind of discipline is hard to do!
 
#7
RISC
Super Member
  • Total Posts : 5379
  • Reward points : 0
  • Status: offline
Re: PIC microcontrollers starter: I want to learn how to program a PIC micro 2017/06/10 15:12:07 (permalink)
+1 (1)
Hi,
I also suggest to start with a Curiosity board.
As far as PIC / MPLAB X tutorials are concerned you probably want to check out the developerhelp website :
http://microchipdeveloper.com/
Regards
 
#8
asWINth
Life is all 0s & 1s
  • Total Posts : 18
  • Reward points : 0
  • Joined: 2016/10/31 03:46:41
  • Location: 0
  • Status: offline
Re: PIC microcontrollers starter: I want to learn how to program a PIC micro 2018/09/29 22:08:51 (permalink) ☄ Helpfulby curlywurly 2019/02/07 09:51:59
+1 (1)
Just do not confuse yourself much, as Eric said "Go simple, Go complete and go current". Once you start learning micro controllers there is no saturation for it. As a beginner what you have to learn is how to interpret data from a datasheet and use it in your program. 
Be it a simple 8-bit AVR or a complex 32-bit ARM the underlying principle is the same. Also for a beginner the LPC1629 seems to be a bit too much. When you are learning things on your own then internet is your best friend, so select an MCU which has good community support. 
I always recommend the PIC16F877A MCU from microchip because you IDE,compiler and IPE is totally free and is more than enough for beginners. Also this MCU has all basic modules like ADC,PWM and also communications protocols like SPI, IIC, USART etc. And the main part is it has good community support so you can get help online easily. 
Hope I have convinced you enough. 
 I am posting the list of tutorials in ascending order below to help yourself. 
  1. Getting started with PIC Microcontroller: Introduction to PIC and MPLABX
  2. Writing Your First Program with PIC Microcontroller and Setting up Configuration Bits
  3. LED Blinking with PIC Microcontroller
  4. LED Blinking Sequence using PIC Microcontroller
  5. Understanding Timers in PIC Microcontroller with LED Blinking Sequence
  6. LCD Interfacing with PIC Microcontroller using MPLABX and XC8
  7. Display Custom Characters on 16x2 LCD using PIC Microcontroller and XC8
  8. 7 Segment Display Interfacing with PIC Microcontroller
  9. Using ADC Module of PIC Microcontroller with MPLAB and XC8
  10. Generating PWM using PIC Microcontroller with MPLAB and XC8
  11. Interfacing Servo Motor with PIC Microcontroller using MPLAB and XC8
  12. UART Communication using PIC Microcontroller
  13. Interfacing Bluetooth Module HC-06 with PIC Microcontroller
  14. Interfacing ESP8266 with PIC16F877A Microcontroller
  15. How to Send E-mail using PIC Microcontroller and ESP8266
  16. How to Save Data using EEPROM in PIC16F877A Microcontroller
  17. How to Use Interrupts in PIC16F877A Microcontroller
  18. GSM module Interfacing with PIC Microcontroller - Make and Receive Calls
  19. SPI communication with PIC
  20. I2C communication with PIC
I wrote these tutorials a long time back and they all use MPLABX and XC8 compiler, feedbacks are most welcomed  
#9
NKurzman
A Guy on the Net
  • Total Posts : 17847
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: offline
Re: PIC microcontrollers starter: I want to learn how to program a PIC micro 2018/09/29 22:25:38 (permalink)
0 (4)
That is a year old post.
The PIC16F877A is a 15 year old chip. Great in its time. But there are better choices these days. But IF there are current tutorials it would not be a waste as starter PIC.
#10
curlywurly
New Member
  • Total Posts : 4
  • Reward points : 0
  • Joined: 2018/12/28 10:40:49
  • Location: 0
  • Status: offline
Re: PIC microcontrollers starter: I want to learn how to program a PIC micro 2019/02/07 10:15:06 (permalink)
0
Thanks asWINth for the really useful links. I wish I had seen them when I was first getting into PIC programming. 
 
As for the comment about the PIC16F877A, yes - it is old, but there are more modern equivalents which are pin for pin compatible.
 
Also, there are some cheap Pic demo boards out there for a PIC16F877A - such as this one
https://github.com/CurlyWurly-1/BK300-Pic16f877A-development-Board-Examples
 
Its great that someone can just buy a £20 board, and with a little self study (as per your guides), someone can quickly go from ground zero to working programs, which is how it should be. 
#11
crosland
Super Member
  • Total Posts : 1624
  • Reward points : 0
  • Joined: 2005/05/10 10:55:05
  • Location: Warks, UK
  • Status: online
Re: PIC microcontrollers starter: I want to learn how to program a PIC micro 2019/02/07 13:06:03 (permalink)
+1 (1)
curlywurly
TIts great that someone can just buy a £20 board, and with a little self study (as per your guides), someone can quickly go from ground zero to working programs, which is how it should be. 

It's great that someone can answer these old unanswered posts.
#12
aamir_uetn
New Member
  • Total Posts : 10
  • Reward points : 0
  • Joined: 2013/07/24 18:28:08
  • Location: 0
  • Status: offline
Re: PIC microcontrollers starter: I want to learn how to program a PIC micro 2019/08/25 21:01:22 (permalink)
-1 (1)
#13
Jump to:
© 2019 APG vNext Commercial Version 4.5