Where to learn how to code PICs

Thread Starter

Sigma229

Joined Apr 17, 2019
48
Hello Guys and Gals,

I have Programmer for PIC's but do not know any coding for PIC's or any coding at all for that matter.
I am unable to go out due to health so I want to learn coding for PIC's to make small projects for fun.
I know the circuits ok but not expert knowledge.

Where is a good location/website to learn to code for PIC's?
I purchased everything I need but it is the knowledge/coding that is my issue.

Thanks in advance
Sigma
 

MaxHeadRoom

Joined Jul 18, 2013
28,617
What language do you want to code in, there is Assembly and C as the two popular ones right now, even if coding in C, I would suggest getting a grounding in Assembly also.
The Picmicro site has some examples, there is also the Tutorial by Nigel Goodwin, the code is in Assembly but there is also C code versions/conversions for these out there on the web.
http://www.winpicprog.co.uk/pic_tutorial.htm
Max.
 
Last edited:

Thread Starter

Sigma229

Joined Apr 17, 2019
48
What language do you want to code in, there is assembly and C as the two popular ones right now, even if coding in C, I would suggest getting a grounding in Assembly also.
The Picmicro site has some examples, there is also the Tutorial by Nigel Goodwin, the code is in assembly but there is also C code versions/conversions for these out there on the web.
http://www.winpicprog.co.uk/pic_tutorial.htm
Max.
Hello Max,

Thanks for the fast reply to my question.

I was thinking learning C as it seems to be used the most from what I see on forum(s).
I will go to link provided and start there.
If I have to learn assembly language I will also do that.

I know it may sound stupid to buy everything I need before learning to code first.
But I thought for me it is better to learn and try at same time.
I learn more by hands on approach then reading alone.

Thanks for the help and info.
Sigma
 
Last edited:

JohnInTX

Joined Jun 26, 2012
4,787
You can do a lot of learning using MPLABX simulator. You'll need to learn the development environment (MPLABX) anyway so why not start there? It comes with a free assembler and XC8 compiler and full debugger. Write a few simple programs and use the debugger to step through the code, examine register values as you go etc. The skills you develop there will pay handsome dividends when you finally decide to run something on a chip.

When you move to hardware, consider one of the pre-built development boards from Microchip like Curiosity and Snap (no clones). These have resident debuggers and a current chip with all the debugging goodies you need. TMost of the boards have pinned out IO and accept the "Click" boards from Mikroelectronica to add all sorts of fun things without having to develop hardware.

If you don't have any programming experience, consider that programming is not the same as coding. Too many novices begin by throwing code at the chip without understanding how to approach a problem, dissect it into its constituent parts then solve each part logically. After that, you can proceed to generating the code. My personal belief is that the best programming tutor is a pencil and paper to flow out solutions to given problems.

PICs are maybe not the best place to start learning embedded programming because you're closer to the internals than on other platforms like Arduino or Cypress PSOC. But if you are willing to take the time to understand the peculiarities of the part, learn the development IDE and have the discipline to plan and drill down into the coded implementation of any given problem, you should be able to get up to speed.

We have lots of PIC guys here so help is readily available.

Have fun with your learning!
 

Thread Starter

Sigma229

Joined Apr 17, 2019
48
You can do a lot of learning using MPLABX simulator. You'll need to learn the development environment (MPLABX) anyway so why not start there? It comes with a free assembler and XC8 compiler and full debugger. Write a few simple programs and use the debugger to step through the code, examine register values as you go etc. The skills you develop there will pay handsome dividends when you finally decide to run something on a chip.

When you move to hardware, consider one of the pre-built development boards from Microchip like Curiosity and Snap (no clones). These have resident debuggers and a current chip with all the debugging goodies you need. TMost of the boards have pinned out IO and accept the "Click" boards from Mikroelectronica to add all sorts of fun things without having to develop hardware.

If you don't have any programming experience, consider that programming is not the same as coding. Too many novices begin by throwing code at the chip without understanding how to approach a problem, dissect it into its constituent parts then solve each part logically. After that, you can proceed to generating the code. My personal belief is that the best programming tutor is a pencil and paper to flow out solutions to given problems.

PICs are maybe not the best place to start learning embedded programming because you're closer to the internals than on other platforms like Arduino or Cypress PSOC. But if you are willing to take the time to understand the peculiarities of the part, learn the development IDE and have the discipline to plan and drill down into the coded implementation of any given problem, you should be able to get up to speed.

We have lots of PIC guys here so help is readily available.

Have fun with your learning!
Hello John,

First thanks for the quick response to my question, I appreciate it.

As for MPLABX simulator and non-demo version is that the best to use?

My programmer comes with its own software which is why I ask.
I have a TL866II Plus programmer from http://www.autoelectric.cn/EN/TL866_MAIN.html
It can handle 1000's of chips as shown here http://www.autoelectric.cn/MiniPro/TL866II_List.txt

I also do have I think 3 Arduino's I purchased 1-2 years ago as I played with them a bit.
I did some online projects I found online with all steps to see what they were like.

I will do any and all steps that you and other have suggested I do.
Since I have unlimited time to learn I can do 16 hours plus a day to learn code & other since I sleep next to nothing.

I went all out and spent $$$ buying almost everything I need from chips, soldering iron's, variable power supply, wire, project boards and tons of other items. Only thing I dont have yet is a hot air station.

So i will do everything I can to learn programming suggested.

Thanks for your help and suggestions.
Sigma
 

jpanhalt

Joined Jan 18, 2008
11,087
In my mind there is a clear distinction between a programmer (hardware) and code development. A programmer is hardware. You do not need that for code development. In fact, some simulators will even simulate doing stuff like writing to a display or flashing an LED.

True, it is fun to watch your first LED flashing or see "Hello World" on a display. But hardware is not necessary to develop code.

As for programmers (hardware), some chips don't even require that. You can use the same PC on which you develop code to program. Other chips (e.g., early and mid-range PIC chips), require a programmer, but clones of the Microchip products that do that are cheap. Even hobbyist programmers from Microchip are not that expensive.
 

Thread Starter

Sigma229

Joined Apr 17, 2019
48
In my mind there is a clear distinction between a programmer (hardware) and code development. A programmer is hardware. You do not need that for code development. In fact, some simulators will even simulate doing stuff like writing to a display or flashing an LED.

True, it is fun to watch your first LED flashing or see "Hello World" on a display. But hardware is not necessary to develop code.

As for programmers (hardware), some chips don't even require that. You can use the same PC on which you develop code to program. Other chips (e.g., early and mid-range PIC chips), require a programmer, but clones of the Microchip products that do that are cheap. Even hobbyist programmers from Microchip are not that expensive.
Hello jpanhalt,

Thanks for the fast reply to my question.

I knew there was a difference but did not realize there were simulators.
I also did not know about clones of microchip products.

I was able to put predefined code on chips about 2 years ago using an older model TL866CS programmer.
Not my own code but a copy and paste of code to do an old online project i found once.
Cost was never really a problem until I was unable to work.
So as said I have tons of items, from led's, caps, resistors, dozens of different microchips and so much more.

My only problem has been trying to learn how to code and good sites to learn it so I can use code i write to put on chips.

Thanks for your info and help.
Sigma
 

JohnInTX

Joined Jun 26, 2012
4,787
As for MPLABX simulator and non-demo version is that the best to use?
I think so. The chip programmer you reference is just that, a blaster. It takes a .HEX file from your assembler / compiler and programs the chip. Fine enough but if when something does not work, then what? Program and pray isn't what you want. You want to use something that allows you to step through the code one line at a time, set a breakpoint at a point of interest and display all of the internals of the chip, ports, internal RAM, EEPROM etc. right there on the PC screen. As I noted, you can get a lot done using the simulator.
Get MPLABX here:
https://www.microchip.com/mplab/mplab-x-ide
MPLABX comes standard with MPASM, the PIC assembler and simulator.
Get XC8, the free 8 bit C compiler, here:
https://www.microchip.com/mplab/compilers
To move to hardware, get a Curiosity board:
https://www.microchip.com/DevelopmentTools/Listing/31241075-647e-4383-b559-5573db019895
Those come ready to run right out of the box, you don't even need a power supply for most things. These come with a debugger interface on the board so you can set breakpoints, inspect registers, step code on the actual PIC hardware. As I noted, Curiosity boards also accept Click add-on boards from Mikroelectronika
https://www.mikroe.com/click

Also check out:
https://microchipdeveloper.com/

That's what I would recommend as a development suite. Start with a simple task just to get your feet wet and to get comfortable with MPLABX - count to 10 in some RAM location maybe. Explore the debug features of MPLABX. When you are ready, try a few other simple codes to see how you do. Once you are comfy with your development environment, have at it.

Have fun!
 
Last edited:

Thread Starter

Sigma229

Joined Apr 17, 2019
48
I think so. The chip programmer you reference is just that, a blaster. It takes a .HEX file from your assembler / compiler and programs the chip. Fine enough but if when something does not work, then what? Program and pray isn't what you want. You want to use something that allows you to step through the code one line at a time, set a breakpoint at a point of interest and display all of the internals of the chip, ports, internal RAM, EEPROM etc. right there on the PC screen. As I noted, you can get a lot done using the simulator.
Get MPLABX here:
https://www.microchip.com/mplab/mplab-x-ide
MPLABX comes standard with MPASM, the PIC assembler and simulator.
Get XC8, the free 8 bit C compiler, here:
https://www.microchip.com/mplab/compilers
To move to hardware, get a Curiosity board:
https://www.microchip.com/DevelopmentTools/Listing/31241075-647e-4383-b559-5573db019895
Those come ready to run right out of the box, you don't even need a power supply for most things. These come with a debugger interface on the board so you can set breakpoints, inspect registers, step code on the actual PIC hardware. As I noted, Curiosity boards also accept Click add-on boards from Mikroelectronika
https://www.mikroe.com/click

Also check out:
https://microchipdeveloper.com/

That's what I would recommend as a development suite. Start with a simple task just to get your feet wet and to get comfortable with MPLABX - count to 10 in some RAM location maybe. Explore the debug features of MPLABX. When you are ready, try a few other simple codes to see how you do. Once you are comfy with your development environment, have at it.

Have fun!
Hello John,

Wow, thanks for all the info with the links.
I will go to site links and buy it all just so I have it.

I will continue to all other supplied info from you and others to learn code as well.

Thanks
Sigma
 

JohnInTX

Joined Jun 26, 2012
4,787
I will go to site links and buy it all just so I have it.
"That would be a mistake", said the man with cabinets full of obsolete equipment, some of it unopened. Just buy what you need to get started. By the time you are hurting for something more, there likely will be newer, better stuff. I would consider an RS232 Click board so that you can communicate with a PC using a terminal emulator.
 

Thread Starter

Sigma229

Joined Apr 17, 2019
48
"That would be a mistake", said the man with cabinets full of obsolete equipment, some of it unopened. Just buy what you need to get started. By the time you are hurting for something more, there likely will be newer, better stuff. I would consider an RS232 Click board so that you can communicate with a PC using a terminal emulator.
Hello John,

Ok thanks for the additional info.
I will do as you suggested and only buy what i need to get started.

Thanks
Sigma
 

djsfantasi

Joined Apr 11, 2010
9,156
On another note, sometimes you can make a test circuit with extra parts for a one-off device. Or if you are familiar with microprocessors, you can code your own test device. Both approaches are “good enough”. If you find yourself depending on them or need better accuracy, then buy an additional piece of equipment. I made a good enough “oscillope” with an Arduino and a laptop, capturing data with a serial console and graphing it with Excel. I also made a digital analyzer with a TTL 7447 (?), a 7-segment display and several grip clips.
 

jpanhalt

Joined Jan 18, 2008
11,087
"That would be a mistake", said the man with cabinets full of obsolete equipment, some of it unopened. Just buy what you need to get started. By the time you are hurting for something more, there likely will be newer, better stuff. I would consider an RS232 Click board so that you can communicate with a PC using a terminal emulator.
That should be a sticky. Countless threads have wanted advice on "what to buy to start a lab." I couldn't agree more that you buy what you need, and if you don't lose interest, the rest will take care of itself.
 

Thread Starter

Sigma229

Joined Apr 17, 2019
48
On another note, sometimes you can make a test circuit with extra parts for a one-off device. Or if you are familiar with microprocessors, you can code your own test device. Both approaches are “good enough”. If you find yourself depending on them or need better accuracy, then buy an additional piece of equipment. I made a good enough “oscillope” with an Arduino and a laptop, capturing data with a serial console and graphing it with Excel. I also made a digital analyzer with a TTL 7447 (?), a 7-segment display and several grip clips.
Hello djsfantasi,

Thanks for the information and help.

Everything I want to do is for fun personal usage.

For example:
I want to make a circuit that is very small to do the following:

Use a magnetic momentary switch to toggle a relay from open to closed and then touch magnet to switch again to toggle from closed to open.
But I want it so when I touch magnet to switch that it wont allow the switch to work/sense for at least 5 seconds.
So I dont do a double touch by mistake.
i know how to do it with relay and timer but that would be to large for what i want to use it for at home.
The relay would handle 20A @ 120v or 10a @12vdc (i have not decided yet).

That is just one project I want to do and I know using a PIC would really cut down on size.
I guess I could use an Arduino for it but saving them for other more complex projects I want to do later.

Anyways thanks for the help and info.
Sigma
 
Top