Author Topic: PIC or AVR to get started?  (Read 11969 times)

Earthscum

PIC or AVR to get started?
« on: April 26, 2012, 08:54:18 PM »
I've been eyeballing Arduino stuff for quite some time, and recently have been getting the bug to try it out. My senses are leaning towards PIC, but it's all kinda overwhelming with choices.

So, my main goals to start out will probably be switching and note tracking. Everything else I can cover easily enough (I don't need much in the way of time-delay effects, at the moment... that is later, you know... the "I'm hooked... time to upgrade" moment).

I got 3 PCD3311P DTMF/MoDem/Tone Generator chips, and figured I'd just go F -> V, and figure out a logical way to convert V -> HEX Code. I ordered a crystal for each one. Well, throw in note tracking (probably PLL) and I'm looking at a very large and troublesome board. Ok, I'll go with the uC solution.

So, which would you guys recommend to get started? Note tracking and controlling the PCD3311 is what I'm going to focus on first, unless I start banging my head against the wall, then I'll play with some switching. I'd love to go ahead and DIY as much as I can... I'd prefer to run from scratch. I am pretty familiar with good old BASIC (I assume the BASIC Stamp would be fun, but if it's going the way of the Dodo, or too costly for some reason, then..). I've also done some fairly extensive work with XML building widgets and themes for EverQuest back in the day. Other than those two, I've really only done any other type of "coding" as HTML, and not Frontpage... I could never get it to work cross-platform with Netscape, so I always wrote my sites' codes in Notepad.

Second question... WHICH one? lol... I guess that may weigh in on "PIC or AVR". I notice there are a ton of different PICs. AVR seems pretty straight forward. It would be neat to be able to program a chip and drop it in a circuit (like Molten Voltage stuff, or the Taptation, etc.). From what I've been able to tell, if I want to be able to make an 8-pin chip controller of some sort, I would rather go with PIC... and that leaves open about 50 options. AVR, I guess, I could go with the micros and plug them into the board, but at $20 a pop... ugh. All the ATMEGA chips are huge, as well... and I can't find much on the ATiny chips. I like small chips.  :icon_biggrin:

So, I'll just start there. If ya need more info about future intentions or something, don't hesitate to ask. I'm totally a noob to uC's. I'm kinda digging on PIC just because of the geekiness (I run Ubuntu... I used to run LiteStep on my Windows98 machine, I'll buy a car based on what I can do to it rather than how good of shape it's in).  Saw some ways you can just hack a serial cable and make a breakout board for them, etc. Saw the same for AVR, but didn't seem as "hackish".
« Last Edit: April 26, 2012, 08:55:49 PM by Earthscum »
Give a man Fuzz, and he'll jam for a day... teach a man how to make a Fuzz and he'll never jam again!

http://www.facebook.com/Earthscum

Hal

Re: PIC or AVR to get started?
« Reply #1 on: April 27, 2012, 02:36:30 AM »
The bad news is that there is no easy answer to your question...they are both pretty much the same. I think AVR in general has a little bit more support, and I like the free toolchain a bit better then PIC, but I think that PICs have a bit of an edge when it comes to audio stuff. Not sure if this is even really true though, since I haven't used any of the 16 or 32 bit AVR chips. The good news is that once you learn fundamentals of microcontroller programming, it won't take you long to migrate to different platforms. So that's my advice - whichever you choose, learn C. Then if you ever want to switch for some reason, it'll really take only a couple of hours to learn the ins and outs of the new platform.

Earthscum

Re: PIC or AVR to get started?
« Reply #2 on: April 27, 2012, 09:53:10 AM »
That's exactly the issue I'm coming across. I'm leaning towards PIC, but there's so many of the chips, where AVR seems to have a limit on the chips used. Tayda carries some PICs, but I don't see anyone using them as much as other numbers... then I realized it seems that everyone has their "favorite" and that makes it more frustrating.

This is kind of a question of "I want to race cars, but I don't want you to strap me into an F-1 Indy on my first few lessons... have a C.A.R.T.?"  :icon_biggrin:
Give a man Fuzz, and he'll jam for a day... teach a man how to make a Fuzz and he'll never jam again!

http://www.facebook.com/Earthscum

Hal

Re: PIC or AVR to get started?
« Reply #3 on: April 27, 2012, 06:06:04 PM »
true, but each different chip for both AVR and PIC, are really just slightly different variations on the same family. In fact, when you download a datasheet, it's sometimes good for something like 20 different chips, some of which simply have more or less memory or other peripherals. PIC has more because it has more volume, and if someone can save 3 pennies per chip in volume by cutting down to 256b of EEPROM rather than 512, there will be demand for that chip....

If you want a couple of devices to start with, I'd point you to 16f88 (very similar to c84/f84 and f628a) as a first chip to learn with (and for small projects), 18f2550 for something a little bigger, and dspic33fj128gp802 as an audio processor. I'd highly recommend the pickit as a programmer.

If you choose to start with AVR, I'd say to just stick with atmega328 until you need something bigger/different. It is a bit more feature rich than what would normally be good for beginners, but has so much support that it shouldn't be a problem.


ElectricDruid

Re: PIC or AVR to get started?
« Reply #4 on: April 28, 2012, 03:55:00 PM »
I can't speak for the AVRs, which I don't use, but I can explain the PICs a bit. There are various families.

The 10F and 12F chips.
These are tiny 6 and 8 pin chips used for the most basic tasks. I did a digital noise gen based on a 12F508. Even with such small chips, the 12F675 has an ADC and some analog inputs, so they're not completely limited to copying basic logic functions in less chips and less space, but that is probably their most useful function.

16F chips
These are basic 8-bit processors. They come in so many varieties to give you some choice over memory size and which peripherals you want/need. Obviously this makes a lot of difference if you're a manufacturer making 1,000,000 units, but isn't so important for us if you're talking about the difference between a chip that costs $1.20 and one that costs $1.27.
The available peripherals include multi-channel ADCs (8 or 10-bit, usually), SPI, I2C, serial UART, and more specific stuff. My personal favourite is the PWM module which can be used as a cheap DAC to produce up to 10-bit output. This will generate audio, but it's not CD quality. It's good for modulation sources - envelopes and LFOs and such like.
Max clock speed is 20MHz.

16F18xx chips
These are a recent improvement on the above 16F chips. They've added some extra instructions which help speed things up, and increased the maximum clock to 32MHz, as well as offering a low voltage version for 3.3V supplies. They're an evolution, but they have a fair bit more power.

18F chips
These are improved 8-bit chips. They include a multiply, which is a notable plus. I've never used them, so I can't comment in detail.

24F/24H/dsPIC
These are 16-bit chips. The 24F are aimed at low power applications, whereas the 24H aim at performance. The dsPICs include some DSP instructions. These are powerful if you can make best use of them, which isn't easy and takes a bit of rearranging. Some of the instructions do five or six things at once though, so it's worth taking the time to learn to use them to their potential, even if it is a bit around-the-houses to get there.
The 30F chips are +5V and tend to be what you need f you want larger DIP format. The 33F chips are 3.3V and use much less power. There are some great 28-pin DIPs available here. My favourite is the 33FJ128GP802, which has a 16-bit stereo DAC on the chip. Ace for all kinds of oscillator projects and audio generation stuff. There are others. For audio *processing* you want to be looking for chips with the codec interface peripheral. This gives you an easy way to get audio ADC/DAC on and off the chip. Seb Francis has some good projects online at http://burnit.co.uk/sdiy/ demonstrating this.

32-bit chips
Dunno. Haven't played with 'em, so I can't really comment.

For all this, there's probably an AVR roughly-equivalent chip. There'll be some benefits to one and some to other. Ultimately I don't think it matters too much which you use, as long as you're able to make it do what you wanted it for in the first place. I do a lot of synth stuff on PIC and dsPIC, but Olivier Gillet over at MutableInstruments has done many synth things on AVR. Either does the job.

2cents,
Tom



Earthscum

Re: PIC or AVR to get started?
« Reply #5 on: June 03, 2012, 10:56:36 PM »
So, I got myself an UNO (figure I can burn my own bootloaders afterwards... maybe...). "Maybe" doesn't mean it isn't possible, it means besides acting like some kind of script kiddy about this thing (copy->paste), I am sooo lost. I feel like someone threw me back on a Mac (no offense to Mac users... as long as you know WTF a double-click is    :icon_neutral: ). Seriously, I dealt with Mac-erters that would push both buttons at the same time "No, push the left button twice" That would instigate two fingers on the left button and confusion about why everyone was so strict about proper clicking "form". This was usually followed by a large, sore lump forming on my forehead, and other techs finishing up calls because I was about to tell a good one. Anyhoo...

My question... Should I be looking at the programming from an XML (definition language) standpoint? The analogy that comes to mind is:

What happens: I throw a stick, the dog gets in a cab, goes to the store to buy a tape measure, consults with a nutritionist, comes back, measures it, figures caloric burn vs. intake, and tells me "No". Sometimes I don't throw the stick too far (meaning I copied and pasted the whole thing, probably), and the dog fetches.

What I want to happen: I throw a stick, grab a longer stick, shove it up the dog's butt, and reach out and fetch the small stick.

Are there other programming languages I can use with this UNO that let me have a bit more control? Something that makes sense to me, I think is what I'm looking for. If a machine isn't running right, I open it up and see how it works, and what is affecting the operation of said machine. I would like to kind of be able to take that approach. I don't like "button mashing" games, lol.

Enough analogies here? Have I exposed my digi-noob-ish side well enough?  :icon_lol: (honestly, though... logic is just like gears... a metric sh** ton of 2-toothed gears... oh yeah, those are called Levers!  :icon_biggrin: )
Give a man Fuzz, and he'll jam for a day... teach a man how to make a Fuzz and he'll never jam again!

http://www.facebook.com/Earthscum

g_u_e_s_t

Re: PIC or AVR to get started?
« Reply #6 on: June 04, 2012, 12:47:00 AM »
i would suggest just starting with the arduino language
which you can quickly program up a few examples
to get a hang of using the IDE
and then jump to using C to do more complicated things as need be
the transition shouldnt be too bad
as the arduino language is basically C

the only thing the arduino language does for you
is makes it so you dont have to deal with setting registers
and looking under the hood of the chip

Earthscum

Re: PIC or AVR to get started?
« Reply #7 on: June 04, 2012, 01:42:33 AM »
All it is to me is an intricate high speed switching scheme. I've had it for a couple weeks, and it's boring and monotonous. So, I guess it's going back in the box instead of getting moved around my work area. Suck... I shouldn't have wasted the money.
Give a man Fuzz, and he'll jam for a day... teach a man how to make a Fuzz and he'll never jam again!

http://www.facebook.com/Earthscum

Gurner

Re: PIC or AVR to get started?
« Reply #8 on: June 29, 2012, 02:36:36 PM »
I went the PIC route (mainly because I'm unfeasibly tight & they're cheap as ...erhm chips)....the appeal of getting deep down with registers was not that high, but as time has progressed it has become second nature.

I'd say after 6-8 weeks you can make it do most of things you want (from a standing "I know zilch" start) ....after 6 months you start getting to know them well enough to really make those puppies work for their $1.20c!

I guess a reasonable analogy would be....if you're a stompbox vero/layout kinda guy, then probably the arduino is the path to take (let everyone else do the work!) but if you're a 'create your own circuit & schems type of fella ....then I reckon a PIC is the way to go.
« Last Edit: June 29, 2012, 02:43:04 PM by Gurner »

defaced

Re: PIC or AVR to get started?
« Reply #9 on: July 01, 2012, 10:19:50 AM »
What PIC resources are you using Gurner?  I have used PICs, made projects with them and the like, but I don't feel like I really understand them.  The learning curve for me with PICs has made my times learning Eagle seem like a cake walk.  I'd like to find something that skips the "how to make a project" and goes back one more step and explains "here's how this thing works and why you do things a certain way".  I won't be surprised if I need something that is taught in college, and is assumed knowledge in PIC specific docs.  I just have no clue where to look for it and was wondering if perhaps you've stumbled across something like this. 
« Last Edit: July 01, 2012, 10:21:34 AM by defaced »
-Mike

slacker

Re: Re: PIC or AVR to get started?
« Reply #10 on: July 01, 2012, 12:32:43 PM »
The gooligum.com tutorials are really good. They've got assembly and C tutorials that take you through all the basics, using digital and analogue inputs and outputs, manipulating registers, using timers and interupts, etc. Basically all the building blocks you need to use PICs. If you go through all the tutorials in order they introduce things as they go along and later tutorials build on things from earlier ones.
As a bonus, even though they specifically say the C ones aren't supposed to teach you C, starting from knowing nothing, I rewrote an assembly program I'd written in C after reading them all.

Gurner

Re: PIC or AVR to get started?
« Reply #11 on: July 01, 2012, 05:44:31 PM »
What PIC resources are you using Gurner?  I have used PICs, made projects with them and the like, but I don't feel like I really understand them.  The learning curve for me with PICs has made my times learning Eagle seem like a cake walk.  I'd like to find something that skips the "how to make a project" and goes back one more step and explains "here's how this thing works and why you do things a certain way".  I won't be surprised if I need something that is taught in college, and is assumed knowledge in PIC specific docs.  I just have no clue where to look for it and was wondering if perhaps you've stumbled across something like this.  

I guess this depends on what programming background you have. I came into PICs with none (I can't count programming in DCL on VAXs 20 years ago!), so couldn't leverage on say former C experience. Assembly is just way too verbose & eggheadish for my palette....so I went the way of PICbasic...it's friendly-ish & there's a great forum (http://www.picbasic.co.uk/forum/forum.php)

I didn't use any training resources per se ...I just set myself small 'bite size' targets...light an LED, take an AtoD reading...drive an LED with PWM ....then join them all up .....AtoD a pot, then drive an LED with PWM relating to the pot postition. I asked a lot of questions on the forum & got a lot of help (the search function on that forum is excellent too). The one *big* thing picbasic has got going for it, is the way everyones uses interrupts.....a chap called Darrel Taylor did the heavy lifting in this area & provided routines that make using interrupts a breeze.  It really drives you on if you have a specific goal in mind (I did)...else I can see how many would fall by the wayside after getting the basics squared away (vs. having to trek on into the heavier stuff)

Even just to get an LED to flash takes eons when you start out ...so many new concepts, registers to set blah...but like eveything else in life, the more time you put in the easier it becomes....I'm lightning fast at sussing stuff set wrong within the PIC nowadays (& that would have took me many days when I first started!)

It also helps to have a good solid electronics footing (but I guess most on here have that)...to get your head around what needs to happen to interface the PIC with the outside world etc ....but it's not hard (fun actually). The microchip application notes are great too (albeit have an assembly/C slant), for example...

http://ww1.microchip.com/downloads/en/devicedoc/40040b.pdf

http://ww1.microchip.com/downloads/en/devicedoc/40040b.pdf

I'd like to learn assembly now...cos I'm pushing the boundaries what can be done with a higher level language & often need the speed that assembly allows.
« Last Edit: July 01, 2012, 05:58:43 PM by Gurner »

ElectricDruid

Re: PIC or AVR to get started?
« Reply #12 on: July 02, 2012, 05:01:04 AM »
I'd like to learn assembly now...cos I'm pushing the boundaries what can be done with a higher level language & often need the speed that assembly allows.

Another +1 for assembly. If you want to really understand what's going on, there's nothing like it. There's nothing there unless you put it there - no stupid APIs or OS interfaces or any of that other stuff that clutters computers up. (Can you tell I'm a purist?!)
But that doesn't half make the debugging easier. I used to do web programming, and it was never clear whether the bugs were you or the browser. At least with a PIC, you know it's your code. There simply isn't anything else to consider.

One thing I would note about assembly though; You don't so much learn the language as the techniques. The instruction set is so limited (3 or 4 dozen instructions on the PIC) that you learn those in a pretty short time. But they do so little on their own that you need to learn how you use them to build structures that high level languages give you already built, like loops, branches, and arrays and other lookups.

Tom

Earthscum

Re: PIC or AVR to get started?
« Reply #13 on: July 03, 2012, 07:46:35 PM »
I used to do web programming, and it was never clear whether the bugs were you or the browser.

Or the host... I had one that I dumped within a week because some crap they had going made it so simple HTML wouldn't work unless you inserted ALL the parameter tags, values or not. I hated FrontPage the first time I tried it because it would write the code exactly like that and make a freakin cluster of crap to go through for no reason at all.

Quote
One thing I would note about assembly though; You don't so much learn the language as the techniques. The instruction set is so limited (3 or 4 dozen instructions on the PIC) that you learn those in a pretty short time. But they do so little on their own that you need to learn how you use them to build structures that high level languages give you already built, like loops, branches, and arrays and other lookups.

Tom


Thanks, all you guys... I'm gonna check into this once I can scrape a bit of my sanity back together (wedding). I read somewhere about doing assembly on AVR, might look into that a bit until I can scrape together a buck or two for some PIC stuff (wedding).

I didn't learn about an engine by staring at it and putting headers on it, I learned about it because I rebuilt it. It seems like a similar thing... you can't just slap a cam in and expect things to work. Tolerances need to be observed, proper parts matching is key. You have choices of HOW your cam works with the system, by replacement of the cam with different grinds of cams, but you can't use a roller cam with flat tappet lifters. After a cam swap, you get to make sure the rest of the parts will play nicely. Fun balance game... tuning a carb is just as fun to me. I'm a Quadrajet junkie, and most people think they suck... you just have to understand how the system works, and you have unlimited potentials without having to even swap out a jet.

Inspiration... I'll just think of it as my little electronic engine.
Give a man Fuzz, and he'll jam for a day... teach a man how to make a Fuzz and he'll never jam again!

http://www.facebook.com/Earthscum

aron

Re: PIC or AVR to get started?
« Reply #14 on: July 04, 2012, 03:45:41 PM »
I've been looking at this a bit and I think I'm going to start with an UNO. I want to experiment with controlling my analog pedals. It looks like fun and not only that, I can't believe how easy it is to get MIDI going!!!!

mhelin

Re: PIC or AVR to get started?
« Reply #15 on: July 15, 2012, 01:18:22 PM »

artifus

Re: PIC or AVR to get started?
« Reply #16 on: July 15, 2012, 05:10:27 PM »
^ less than five dollars/pounds. that's a quarter the price of the cheapest arduino i've seen going.

Earthscum

Re: PIC or AVR to get started?
« Reply #17 on: July 15, 2012, 09:12:36 PM »
Damn... that looks intriguing. So, I can't really tell right off hand, you should be able to program a chip and pop it into your own layout like PIC and AVR, correct? That thing is cheap enough a person would be silly to not give it a shot.
Give a man Fuzz, and he'll jam for a day... teach a man how to make a Fuzz and he'll never jam again!

http://www.facebook.com/Earthscum

artifus

Re: PIC or AVR to get started?
« Reply #18 on: July 15, 2012, 09:33:11 PM »
yes, yes and yes. had to double take too, but $4.30 for the launchpad board, chip and usb cable with opensource software available. ti note 'we're making them as fast as we can' and are out of stock. spotted over here for between 3 - 7 from a few suppliers.

aron

Re: PIC or AVR to get started?
« Reply #19 on: July 17, 2012, 02:05:40 AM »
Awesome. Macintosh support is dodgy so I will hold off for now, but it looks great!