News:

SMF for DIYStompboxes.com!

Main Menu

How to get started with PIC?

Started by frequencycentral, January 22, 2012, 03:02:33 PM

Previous topic - Next topic

frequencycentral

Ok, please assume you are talking to a complete idiot. I've built Electric Druid's TAPLFO2 for integration into my modular synth. I was going to buy a tube of 30 x programmed 16F684 to build some more, and am also thinking about doing ED's VCADSR. Then I thought it would probably be better for me to actually learn something (!). So, please, digital savants, I wanna program some 16F684 to be TAPLFO2 and VCADSR.

1. Please tell me everything I need to do this. PIC programmer? Software? Beer? Again, assume you're talking to an idiot. Links would be really useful, as far as purchasing stuff goes, I'm in the UK.

2. I've found 16F684 at Farnell, but they have different types. This confuses idiots such as I. I know I want DIP, but which ones (the tube of 30 for £30.60 looks sexy): http://uk.farnell.com/jsp/search/browse.jsp?N=2031+203063&Ntk=gensearch&Ntt=16F684&Ntx=mode+matchallpartial

So, in summary, recommend me a programmer that an idiot can use and understand. Tell me which 16F684 to buy. Handholding is optional.

I've got dreams of actually understanding coding at some point, but at this point I just wanna copy and paste it and then burn it onto a chip.
http://www.frequencycentral.co.uk/

Questo è il fiore del partigiano morto per la libertà!

slacker

#1
For programming I use this http://uk.farnell.com/microchip/dv164120/starter-kit-pickit-2/dp/9847162 you might be able to find it a bit cheaper. Assuming you use Windows, this comes with all the software you need to write programs and program PICs, the board it comes with can be used to program PICS with up to 20 pins. If you use a Mac or Linux, then there's free software available that works with it.

If you've got the HEX files for ED's stuff then the programmer comes with a simple tool to write these to the PIC, it's as simple as stick the PIC in the socket on the board, connect it to your PC, select the HEX file you want to burn and press go.

Don't know which PICs you want, which ever DIP ones work out the cheapest I guess.

Galego

I can only tell you how I did it.

I knew nothing about PICs and it was Electric Druid's TAPLFO that got me interested.

I bought a few 16F684 directly from microchip, bought a PicKit2 compatible programmer from some company in Hong Kong on eBay (it works great, but now I'd order a PicKit3 from microchip, I still might), bought a 16F84A and a 16F877 locally because most tutorials use those.
With all that I downloaded MPLAB (free) from microchip and started doing as many ASM tutorials as I could find on google. But after a while I realized I just didn't have the time to get proficient in ASM, and decided to check out other languages. I found PicBasic Pro (not free), and that has worked quite well for me so far. People might say that you can't do some things with anything other than ASM, but so far so good, you do have to know what you're doing, figure out the dos and don'ts, but I've been able to do my own tap tempo controllers for delays and some more complicated stuff that I posted on this forum. 

Ice-9

#3
Hi Rick, There is a great place for a huge amount of PIC info here http://www.piclist.com

Its a huge resource of everything you might have questions for , the site is a bit strange to navigate but once your there you will work it out pretty quickly.
You can also build your own pic programmer super cheap or buy one of the already made programmers, I forgot the name of the programmer and software I used to use but i will find out and post that info later on.


The software was called Ic-prog and can be downloaded here.
http://www.ic-prog.com/index1.htm

And here is a link to a site for making your own pic programmer
http://www.semis.demon.co.uk/uJDM/uJDMmain.htm
www.stanleyfx.co.uk

Sanity: doing the same thing over and over again and expecting the same result. Mick Taylor

Please at least have 1 forum post before sending me a PM demanding something.

G. Hoffman

+1 for the PICkit 2.  I started with a PICkit 3, and ended up having to buy a 2 for the logic analyzer and the UART tool - much better unit, at least to start with.  If you ever what to get into the newer PICs, you'll need something else, but that is down the road a way.  Don't bother with the starter kits, imho.  If you've got a breadboard, you don't really need it, and you can do just as well with that, or by making a simple experiment PC for your PICs.  The plain PICkit 2 with nothing else is $35, which is as good a deal as you are going to find for µC programing.

Then, you need a way to hook up your PICkit 2 to the PIC.  You can probably get away with doing it on your breadboard (though Microchip doesn't recommend it), but I make little adapter boards for each PIC that I use, with a DIP socket for the chip (if it's a DIP - you need to do things a bit differently if you are using surface mount parts!).  You can also build the programer into your final board, if you'd like to be able to update the program in the future.  For a 16F684 (and you should probably double check this) the connections are:

PICkit pin 1 - 16F684 pin 4 (MCLR)
PICkit pin 2 - 16F684 pin 1 (V+)
PICkit pin 3 - 16F684 pin 14 (0V)
PICkit pin 4 - 16F684 pin 13 (Program data)
PICkit pin 5 - 16F684 pin 12 (Program clock)
PICkit pin 6 - N/C (can be used for low voltage programing, if that is enabled on the chip, but you don't need it)


Gabriel

ORK


egasimus


G. Hoffman

Quote from: egasimus on January 23, 2012, 05:00:57 AM
do NOT use PICs. they're horrible.
http://www.ladyada.net/library/picvsavr.html


Do NOT listen to people who tell you an entire - very large - range of resources is horrible.  Well, unless it was R.G., I suppose.


PICs are fine.  They have their limitations, but they are also cheap.  And unlike, for instance, ATMEL (who has never turned a profit in, what, ten years in business?  And Arduino's aren't going to keep them in business), I'm reasonable confident that their business model will still have them available in 5 years.  Best bet, though, is to find the product that best suits your purpose, and use that - if it's a PIC, use a PIC, if it's something else, use that.  Since one of the things you are interested in is an existing PIC design, it seems a good place to start.


Gabriel

egasimus

#8
^ that's true.
I've had my (small) sample of programming both PICs and AVRs, and I just, well.. strongly dislike.. the PIC architecture. :icon_evil:
both can be used successfully (and programmed in something other than BASIC), but I think that mass adoption of PICs is really their greatest competitive edge, at least when we're talking about DIY. There's been a lot written about PICs over the years, however the Arduino's popularity is making an alternative choice viable, which is always good in my book. Not that I'm an Arduino kind of guy, I'm more like an ATtiny guy :D There's a lot you can do with these buggers.

I found an ATtiny15-based VCLFO on the forums a week ago. Didn't have tap tempo, and didn't have nearly enough pins to output all waveforms simultaneously, but I'm gonna build it and maybe tinker with the source some; see how much goodies I can fit in the compatible ATtiny25.

jasperoosthoek

I can recommend this programmer: http://www.voti.nl/wisp648/index.html

But then the real Microchip programmer is not expensive. I did a university project six years ago where I decided to program a PIC. I built the Wisp programmer but my supervisor insisted that I used a genuine 150 euro ex-circuit programmer with an in-circuit kit. I blew the up the damn thing the first day :icon_evil: and finished the project with the Wisp... ;D

My supervisor just sent it back and said that it was broken. He got a new one from Farnell which I wasn't allowed to use.  :icon_mrgreen:
[DIYStompbox user name]@hotmail.com

alparent

Quote from: frequencycentral on January 22, 2012, 03:02:33 PM
Ok, please assume you are talking to a complete idiot.

Are we free to refer to this quote at will or is it reserve for your use only?  :icon_wink:

frequencycentral

Quote from: alparent on January 23, 2012, 02:38:07 PM
Quote from: frequencycentral on January 22, 2012, 03:02:33 PM
Ok, please assume you are talking to a complete idiot.

Are we free to refer to this quote at will or is it reserve for your use only?  :icon_wink:

Feel free to quote at will and to make your sig if you wish. I'm not proud, I know what I know, I know what I don't.  :icon_biggrin:

Thanks for all the great advice in this thread. I think I'm gonna go with slacker's suggestions, cos he da man. So I figure that for less than a tube of 30 x programmed PICs I can get 30 x blanks plus a programmer and software. Seems like a win to me. I might actually learn something new - coooooool!

So.......one of my motivations to go this route is this:

The TAPLFO2 works superbly well as a VCLFO in a modular synth. The equivalent in the analogue domain would be one huge circuit. So (idiot thinks to himself) surely it shouldn't be too difficult to tweak the coding a little and make it run at audio frequencies......then if it could be coaxed to operate at 1v/oct it would be a superb digital VCO. It already has a host of desirable VCO features: multiple waveforms, VC PWM, osc sync input........I know a lot of folks are averse to DCOs in analogue synths, but it sure would have some nice features and would be simple to build too, compared to a similar VCO in th analogue domain. Anyone wanna shoot me down?
http://www.frequencycentral.co.uk/

Questo è il fiore del partigiano morto per la libertà!

Taylor

I would recommend talking to Tom re audio oscillators with PICs if you haven't. I spoke to him about this a while back and I believe that it wasn't possible using anything like the PIC he's using and that code. I was really into the idea of a fully digital modular, especially for FM purposes, but the reality was a little disappointing. I'm positive that it can be done, but I suspect it would involve an entirely different PIC and all new code. But obviously he'll know better than I.

frequencycentral

I'm sure Tom won't mind me quoting from an email exchange we had recently:

QuoteFC: So......today I played around with using it as a VCO. Obviously the LFO output is pretty heavily filtered (easy enough to change that), and the maximum frequency is quite limited in the audio range. But the results were encouraging! The clock out being an unfiltered square worked best, I fed it through an Oberheim SEM filter, I used the LFO out itself as a control voltage, set to square wave and with an envelope generator modulating the Wave Distortion (ie PWM). Sounded really good actually!

TW: It ought to be alright in the bass end. You'd probably get away with it up to middle C or even concert A without changing anything much.

FC:  Which brings me to....what part of the code needs to be changed to make it an audio oscillator?

TW: The bare minimum would be to alter the Frequency Increment table at the foot of the code. you'd be better starting off with the VCLFO version rather than the tap tempo version for this, since there's less other stuff in the code and the frequency increment is used directly, rather than being subject to the tempo multiplier as it is in the tap tempo version. The multiplier code only has a certain accuracy, and it was set up for the current range and would probably break outside that range.

FC: Would the frequency be divided into semitone steps? And limited to a 5 octave range?

TW: The frequency is divided into 256 steps over whatever range you choose. That's because (currently) the knob positions are interpreted as 8-bit numbers, so it can generate one of 256 different frequencies.

It'd be possible to change this of course, but it's a bit more involved.

FC: How would it track 1v/oct? I'm not really bothered about it being a hifi VCO, just as long as it tracks well.

TW: Given the resolution limitations of the AD convertor (10-bit at best, currently 8-bits used) it'll track fine. I'd probably be inclined to use two or more frequency inputs. One would be scaled to 0.5V/Oct or something similarly easy to get from standard 1V/Oct. That'd give you 10 octaves in 5V, which is full audio range. That'd have to be semitones or quarter tones (10x12=120 semintones, so 256 is quartertones).
Then I'd use another input to provide modulation over a smaller range within an octave or something. That'd give me more resolution for the modulation.

FC: Is the change in coding to make it work as a VCO something a digital noob such as I could do myself with a bit of research?

TW: It's not what I'd recommend for your first-ever programming project, let's put it like that. That said, it isn't incredibly hard either.

FC: Or, is this something that would take the Elecric Driud only a few minutes? Sorry for all the questions!

TW: No, it's a pretty decent job to do it properly, not the work of a few minutes.

I'd really love to play about with a 'Frequency Increment table' altered version of the VCLFO, I just don't have the coding chops myself. I just don't have the time to invest in the learning curve at the moment. Anyways, I just ordered 30 x TAPLFO2 from Tom for a modular DIY project I'm offering to the EM/MW community. Got a couple of VCADSR PICs on the way too......
http://www.frequencycentral.co.uk/

Questo è il fiore del partigiano morto per la libertà!

Taylor

Interesting, well, I'll be watching. If you or anybody else does PCBs for a series of digital synth modules, put me down for a whole rack's worth.  :) About a year ago I had this plan, and even got pretty close with a Eurorack-style VCADSR design, but my old nemesis time got in the way. I'm not an analog fetishist, and the idea of an entire digital modular interests me greatly, particularly for FM sounds.

frequencycentral

http://www.frequencycentral.co.uk/

Questo è il fiore del partigiano morto per la libertà!

Hal

Do NOT use the pic16f84!  ;) ;)

I guess reasons to use it are that there is a lot already written for it, and there aren't many features which makes it a bit easier to use. But the 16f628a and 16f88 are better in every way, and cheaper too! But still, the code is very similar, so if you want to learn something, you can port something written on the f84 to f88 fairly easily.

http://www.finitesite.com/d3jsys/16F88.html

Good luck! The rest of the advice here seems pretty sound. I'd also recommend a pickit2 and mplab. After trying mplab X for a while, I still prefer 8.

DavenPaget

Guys , i just got my MPLAB USB Starter Kit for the PIC24E series from Element14's RoadTest program for free ...  :icon_redface:
Time for some 16bit PIC fun !

Some good , cheap , epic chips i found on E14
PIC16F724 - 40DIP Good , 36 I/O's but only 2 PWM channels and 20MHz
PIC16F1933 - 28SDIP/SOIC 25 I/O's but 5 PWM channels and 32MHz
Both have 7 KB of Flash and 4kBytes of Program Memory but 724 has only 192Bytes of RAM and 1933 has 256Bytes of RAM+EEPROM
Not a problem in any case , they are ok .
Since the 724 only costs $SGD0.61/pc at 1+ quantities , it's basically a STEAL .
Hiatus

DavenPaget

Quote from: Hal on February 04, 2012, 05:09:19 PM
Do NOT use the pic16f84!  ;) ;)

I guess reasons to use it are that there is a lot already written for it, and there aren't many features which makes it a bit easier to use. But the 16f628a and 16f88 are better in every way, and cheaper too! But still, the code is very similar, so if you want to learn something, you can port something written on the f84 to f88 fairly easily.

http://www.finitesite.com/d3jsys/16F88.html

Good luck! The rest of the advice here seems pretty sound. I'd also recommend a pickit2 and mplab. After trying mplab X for a while, I still prefer 8.
Yep , even now the F88 is obsolete .
I just wrote up some chips which are cheaper and better , but i'm not sure if they will run the same code
MPLAB is better honestly , MPLAB X is SLOW but i can tell it's Eclipse-based like Netbeans ( that's a java compiler ! ) and Atollic Truestudio .
Hiatus

Gurner

There's a lot to be said with startiung on a low end basic PIC...else you'll be swamped with the huge amount of new info to take in setting up all the peripherals.

My preferred PIC of choice nowadays is a 16F1828 (it's chocka with stuff for just a quid), but I wouldn't recommend it to a beginner ....when I started learning this stuff a couple of years ago the starter kit came bundled with a PIC16f690 which was peripheral rich, but an absolute bar steward as a starter PIC! (and hampered me no end), So perhaps start with a lowly PIC...wrap your head around what they're doing with all the registers & then gear up & start getting into some funky more powerful PICs.