PIC Programming?

Non-tube amp discussion to discuss music, girls, life, etc.

Moderators: pompeiisneaks, Colossal

Post Reply
User avatar
JazzGuitarGimp
Posts: 2357
Joined: Mon Jul 23, 2012 4:54 pm
Location: Northern CA

PIC Programming?

Post by JazzGuitarGimp »

Hi All,

I know some of you are wizard PIC programmers. I've been designing hardware for years, but I've never taken the time to learn how to code. I am wondering if any of you could point me in the direction of a concise tutorial on programming PIC procs. I know absolutely nothing about this, so the tutorial is going to have to start from square one. I am running Windows XP Pro, SP 3 on a MAC Mini, so if you could also point me in the direction of the necessary hardware and software (USB cabling, please), I would really appreciate it. I am wanting to write a program that reads an optical rotary encoder to control the Texas Instruments PGA2311 Stereo Volume chip. Maybe down the road, I can learn to program a logarithmic taper response.

Cheers,
Lou
Lou Rossi Designs
Printed Circuit Design & Layout,
and Schematic Capture
DonMoose
Posts: 453
Joined: Thu May 29, 2008 10:39 pm

Re: PIC Programming?

Post by DonMoose »

You'll need a copy of MPLAB:
http://www.microchip.com/pagehandler/en ... ly/mplabx/

and a programmer of some sort. Sparkfun has good prices and development boards:
https://www.sparkfun.com/categories/6
https://www.sparkfun.com/categories/9

You'll also need to learn at least one language - C and PIC assembly would be a good pair.

Hope this helps!
User avatar
Aurora
Posts: 765
Joined: Mon May 26, 2008 7:51 am
Location: Norway - north of the moral circle!

Re: PIC Programming?

Post by Aurora »

Think I've something like "PIC for Dummies"..... :-) I'm serious!
User avatar
xtian
Posts: 7263
Joined: Mon Apr 19, 2010 8:15 pm
Location: Chico, CA
Contact:

Re: PIC Programming?

Post by xtian »

See

http://en.wikipedia.org/wiki/Arduino

Super easy for beginners, large library of code already created by users.
I build and repair tube amps. http://amps.monkeymatic.com
User avatar
Aurora
Posts: 765
Joined: Mon May 26, 2008 7:51 am
Location: Norway - north of the moral circle!

Re: PIC Programming?

Post by Aurora »

Forgot - there's a lot of user groups and libraries on th enet, bot for PIC and Arduino....
User avatar
JazzGuitarGimp
Posts: 2357
Joined: Mon Jul 23, 2012 4:54 pm
Location: Northern CA

Re: PIC Programming?

Post by JazzGuitarGimp »

Thanks everyone! In keeping with "the path of least resistance" axiom, I have ordered the Arduino Mega 2560 board. I didn't know about Arduino before today. It looks like an easy portal into programming.

Thanks again,
Lou
Lou Rossi Designs
Printed Circuit Design & Layout,
and Schematic Capture
John_P_WI
Posts: 1457
Joined: Wed Aug 15, 2007 4:29 pm
Location: Wisconsin

Re: PIC Programming?

Post by John_P_WI »

The arduinos are great for playing around with, there are a gazillion tutorials on the web. Although I have not played around with them for the last two years, IIRC the hardest part I had was configuring the communication port on my old XP laptop and getting the usb driver to load...

I always wanted to use the PWM for a univibe type effect.

Ping LeftyStrat, I think he knows boatloads about the arduino.
User avatar
JazzGuitarGimp
Posts: 2357
Joined: Mon Jul 23, 2012 4:54 pm
Location: Northern CA

Re: PIC Programming?

Post by JazzGuitarGimp »

Thank you, John!

Cheers,
Lou
Lou Rossi Designs
Printed Circuit Design & Layout,
and Schematic Capture
Cliff Schecht
Posts: 2629
Joined: Wed Dec 30, 2009 7:32 am
Location: Austin
Contact:

Re: PIC Programming?

Post by Cliff Schecht »

I'm relearning C++ for the umpteenth time but this time I plan on making it stick. I've been able to read C/C++ code for years but when it comes time to write it, it's been like pulling teeth in the past because I put up this front of "oh I can't program and will never be able to". I've had to ditch that attitude and started forcing myself to watch some of the awesome tutorials available online. I'm about halfway through a series that breaks each topic down into one or many 6-8 minute tutorials and just got to a point where I'm really learning stuff again (currently on using pointers). The next step for me later this week is meeting up with one of my buddies that codes and having him give me some homework type questions to work through.

Lefty is an insanely great programmer and has been a fantastic resource as well. I try not to weigh him down with low level questions but if I have something more advanced that I'm stuck on or need direction on what to study, he's the guy I talk to.
Cliff Schecht - Circuit P.I.
vibratoking
Posts: 2640
Joined: Tue Nov 10, 2009 9:55 pm
Location: Colorado Springs, CO

Re: PIC Programming?

Post by vibratoking »

Cliff, your situation sound familiar. What tutorials are you working through? I think I'd like to do the same.
Cliff Schecht
Posts: 2629
Joined: Wed Dec 30, 2009 7:32 am
Location: Austin
Contact:

Re: PIC Programming?

Post by Cliff Schecht »

So far I've been using this one on Youtube: https://www.youtube.com/playlist?list=P ... 8440AA6B83

Each video is 6-8 minutes and he covers every topic pretty quickly with some form of humor. I probably wouldn't recommend these vids for someone first learning a language but if you want a refresher that you can get through in a few days or so they're worth a watch. I'll watch 10 or so in a sitting and pontificate over what I learned for a while. Then I have my buddy sending me C++ problems to work through. It really helps to put what you learned to use - even if you're writing simple code it gets you thinking like a programmer (even if I am writing pretty inefficient software currently).

Once I get C++ down a bit better I'll move on to Verilog and start coding stuff that is synthesizable with standard logic gates. I can work with either Icarus (Verilog simulator) or through Altium which can synthesize logic and load it to an FPGA all in one software package. The latter is probably more meaningful because I can actually buy an FPGA development board and start developing different functional blocks to eventually string together into a larger system. The initial goal here is to understand the design flow from blank sheet to fully functioning and realizable logic that can be implemented via hardware. I don't think I'll have access to Synopsys quite yet but my ultimate goal is to understand the Synopsys design flow from start to finish which will make me much more versatile as an IC designer. Regardless just learning Verilog will open a whole lot of doors for me that would otherwise be closed. Might take a while to learn everything but I'll be damned if I fall into the same rut I was in before I went to work in Seattle.
Cliff Schecht - Circuit P.I.
User avatar
xtian
Posts: 7263
Joined: Mon Apr 19, 2010 8:15 pm
Location: Chico, CA
Contact:

Re: PIC Programming?

Post by xtian »

Man on a mission!
I build and repair tube amps. http://amps.monkeymatic.com
User avatar
jaysg
Posts: 1211
Joined: Tue Feb 07, 2006 11:16 pm
Location: San Diego

Re: PIC Programming?

Post by jaysg »

I use the CCS compiler which is ANSI C. I don't think they do a good job of explaining all their idiosyncratic crap needed to actually compile and make the thing work.

// Generic include files.
#include <18F6722.h> // Target device header file.

#device adc=10 // Specifies that PIC A/D converter will have 10 bits accuracy.
#fuses H4,PUT,NOWDT,NOBROWNOUT,NOPROTECT,MCLR,NOLVP
#use delay(clock=39321600)

// FAST_IO(n) forces port n to determine its direction only from set_tris_n() instructions.
#use FAST_IO(A)
#use FAST_IO(B)
#use FAST_IO(C)
#use FAST_IO(D)
#use FAST_IO(E)
#use FAST_IO(F)
#use FAST_IO(G)
Cliff Schecht
Posts: 2629
Joined: Wed Dec 30, 2009 7:32 am
Location: Austin
Contact:

Re: PIC Programming?

Post by Cliff Schecht »

The gist of my programming knowledge is with embedded systems/microcontrollers. The Arduino setup is probably the simplest I've used. Most real compiler suites have a decently steep learning curve though. Code composer and IAR workbench (which TI uses for MSP430) have idiosyncrasies that you have to learn to work with/around (setup and choosing the right options mostly) before you are cranking out programs. Same with the PIC stuff (that uses C), I tried learning the PIC software in a day at work once and realized that I completely wasted the day trying to get a port to blink an LED. That's why once I pick a platform, I tend to stick with it for a while. Learning new software can be full of unnecessary and unforeseen headaches when you just want to start writing code.

Even Codeblocks gave me a bit of trouble the first time I installed it. Took a few tries to figure out how to tell it where the actual compiler was located..
Cliff Schecht - Circuit P.I.
Post Reply