Programmable Logic Chips and Microcontrollers: Which language and where to learn online?
June 30, 2009 12:50 PM   Subscribe

Programmable Logic Chips and Microcontrollers: Which language and where to learn online?

I have a couple electronic projects I'd like to start tinkering around with, and the more I look into it the more I realize that I'm going to need to learn how to do some programming.

So here's the question, and it's a two-parter: Assuming that I'm going to have to do some programming with embedded chips, what is the programming language best suited to the task, and what sites can you recommend for learning online?

Looking around, I'm under the impression that C is the most common language used, but since I have only the vaguest notion of what to look for, I could be way off base. Anyone care to disabuse me of that perception?

Ideally, any online learning site would have projects that progress in complexity as the depth of the lessons increases, rather than a dry laundry list of attributes and variables and what-have you.

The long-term goal here is to build audio and synthesis toys/tools/kits.

So what have you got for me, Metafilter?
posted by lekvar to Education (21 answers total) 12 users marked this as a favorite
 
Best answer: Arduino seems pretty popular for snyth "circuit bending" applications. There are plenty of examples that come with the programming application which will lead you through the basics. It uses Processing, which is a simplified version of C tailored for microcontroller applications. There's a pretty big following for Arduino, too, so a lot of common utilities (talking over ethernet, twitter commands, etc.) already have libraries that you just plug right into your code.

The thing I like about it is that it's open source and the programmers are relatively cheap. From a practical standpoint, this means a relatively low cost of entry; $30 will get you the chip and a pre-built, tested programmer. You can buy unassembled kits (good way to learn how to solder, since they tend to avoid surface-mount components), or - since it's all open source - you can get plans online and build the whole programmer yourself.

Two other options I can think of are PIC and BASIC Stamp. BASIC Stamp runs on - you guessed it - BASIC, and is another popular platform; FIRST Robotics uses it for their robot controllers (or they did when I was in it). PIC uses another C variant, I think, but the cost of entry seems to be a little higher than Arduino.
posted by backseatpilot at 1:02 PM on June 30, 2009


Best answer: I do a lot of audio work, circuit bending, and general building of shit. Processing and Arduino did what years of fucking around with PIC processors never could -- I enjoy using them.
posted by fake at 1:07 PM on June 30, 2009


Response by poster: Oops, I forgot to mention the Arduino. I'm familiar with it, and it certainly looks like a capable beast, but I'm looking for something a little more universal. Thanks for the info on PIC and BASIC Stamp.
posted by lekvar at 1:10 PM on June 30, 2009


I recommend the AVR family. Powerful, cheap, popular, widespread, lots of online resources. In that case, yes, the most commonly used and supported language is C. But the beginners tutorials and resources for learning to program microprocessors in C are rubbish, unless you already know C, in which case they're still rubbish, but you can fill in the holes yourself while being talked to as if a child.

I gave up and found it was easier to learn C from the endless good resources about learning to program computers in C, (teaching beginners to successfully program computers is a MUCH more hammered out path), and then making the necessary adjustments to the knowledge to write for microprocessors. It sucked not being able to take a direct route to learning how to program micro-controllers, but as a side benefit to the indirect route, you learn how to make your own software for computers too :-)

But over and over, when trying to take the direct route, tutorials expounded the obvious in great detail as if "beginner" meant "moron", while completely omitting all sorts of vital foundational stuff that the beginner does not know and needs to know, but which the author seemed to take so much for granted that it didn't occur to them to explain it. Hence the well-beaten path to computer C-programming being more useful - all those issues have been addressed and iterated on until introductions really actually genuinely work in the real world with real people.

posted by -harlequin- at 1:16 PM on June 30, 2009


What do you mean by "universal"? The world of microcontrollers is by its nature one of proprietary and specialized chips. Anyway, this Arduino starter kit is honestly the kind of thing that comp eng undergrads would spend four years pounding on so if you can hack on that you're as good as it gets.
posted by GuyZero at 1:17 PM on June 30, 2009


Also, learn C. It's like learning Latin - everything else is derived from it or influenced by it. Once you can handle for(;i++=j++;); you're ready for anything.
posted by GuyZero at 1:20 PM on June 30, 2009


Best answer: Arduino is to AVR what Basic Stamp is to PIC.
AVR and PIC are the microprocessors, while Arduino/Basic Stamp are a widely used generic computer platform build around that microprocessor.

In either case, it's cheaper and more powerful to learn AVR/PIC instead of Arduino/BasicStamp, but you'll likely be up and running quicker by chosing Arduino/BasicStamp.
posted by -harlequin- at 1:20 PM on June 30, 2009 [1 favorite]


Response by poster: What do you mean by "universal"?

Well, long-term, I'd like to be able to build and sell these toys I'd be making. The Arduino looks great for rapid prototyping and for one-off projects, but I'm hoping to get into small-scale production. Now, I may be entirely wrong-headed about this, but from what I've seen, the Arduino would be impractical for this, as opposed to simply going straight to the ATMega chip. My understanding is that the Arduino is the I/O board, Processing, and the ATMega chip. Ideally, I'd like to cut out the middle-man and just program the chip directly without having to rely on having the Arduino I/O board. I'm also under the impression that the ATMega chip has to stay attached to the Arduino board once it's been programmed.

Like I said earlier, I'm probably wrong on a number of points, and I'd be happy to be told why and how.
posted by lekvar at 1:39 PM on June 30, 2009


Best answer: Scratching up an OS by hand is possible and it's quasi-fun in that way that staying up for 72 hours to do one lab project out of 5 was fun back in undergrad, but basically taking someone else's OS is a lot less work. Going without the Arduino s/w turns this into an embedded OS project which can be fun and doesn't have to be a lot of work,. but if what you want to build is an application then it's not necessarily the best use of time.

Building Arduino boards isn't that bad and the site seems to have some instructions on how to do your own board. The s/w is open-source (LGPL for the C/C++ libs) so you could redistribute it without any issues. You wouldn't be compelled to buy or pay licensing for something that you make built on the platform.

You can also use the boards without the s/w environment, so if you want to hand-assemble Amtel opcodes you can always do that too.

Having been forced to do this sort of thing soup-to-nuts in school years ago it's a lot of work for not much payoff. Using a pre-built environment is a huge step up.
posted by GuyZero at 1:50 PM on June 30, 2009


Also, every chip needs a support board. There's no way to program a chip "directly". It's got to be connected to some I/O components one way or another.
posted by GuyZero at 1:51 PM on June 30, 2009


Best answer: You're mistaken about Arduino---the I/O board makes it easy to program the chip, sure, but once it's programmed you don't need the board anymore. I've made several projects that used Arduino-programmed chips on custom boards.

The Arduino board itself is little more than a few support resistors + female headers + power regulator + USB interface. It's not a big deal to make your own Arduino-compatible board.

Arduino is awesome and I highly recommend it for your purposes. I would only recommend moving to something lower-level (C or asm) if you want to do something time-sensitive, like video or sound generation.
posted by aparrish at 2:07 PM on June 30, 2009 [1 favorite]


Response by poster: Sound generation is exactly what I'm looking to do, but it looks like I'm going to have to take a much closer look at the Arduino now.
posted by lekvar at 2:30 PM on June 30, 2009


Best answer: You definitely want the Arduino.
posted by FusiveResonance at 2:32 PM on June 30, 2009


Response by poster: METFILTER HAS SPOKEN!

Ok, ok, I'll go get an Arduino.
posted by lekvar at 2:40 PM on June 30, 2009


Nthing Atmel AVR/Arduino. One big advantage almost any of those processors have is that they support in-circuit programming; this means you can reprogram them without removing them from their place in an already finished project. Just connect the ISP pins to a port leading outside and you'll never have to worry about re-building stuff just to change the software again.

Plus, they produce a wide range of microprocessors that basically speak the same language, ranging from the 6-pin, 1kb memory Tiny series to the brawny ATMegas...
posted by PontifexPrimus at 2:52 PM on June 30, 2009


You will eventually need to do a bit of assembly-language tweaking, and when you get to that stage, you will be glad you picked AVR over the PIC. Atmel actually put quite a nice architecture in the AVR; the PIC is completely squirrelly by comparison. On the other hand, if your intent is to churn out tens of thousands of some kind of gadget at the lowest possible price and performance is not really an issue, low end PICs are rather cheaper than low end AVRs.
posted by flabdablet at 4:06 PM on June 30, 2009


If you want to avoid the simplified Arduino language/hardware, but work with AVRs, you could get an STK-500 development board and develop using the AVR-GCC (C-based) or AVR Studio (Assembly) development environment. The cost of the dev board is higher, and it's not quite as prototype-friendly, but there it is. The STK-500 can also in-system program chips that're soldered to a board, which is handy (and will let you flash programs to a blank AVR (w/o the Arduino bootloader) installed in, for instance, an Arduino board. AVRFreaks is a good place to start down this path.
posted by Alterscape at 8:37 PM on June 30, 2009


Response by poster: So, are there any good resources for learning C online? I'm having a hard time sorting through the Google deluge.
posted by lekvar at 2:01 PM on July 1, 2009


Programming in C by Kochan. Same book I learned from in, uh, '86? Get the latest edition though.
posted by GuyZero at 2:14 PM on July 1, 2009


oh, online... C Programming Tutorial seems decent. But buy a copy of Kochan.
posted by GuyZero at 2:16 PM on July 1, 2009


Also, everybody who does any amount of C programming will eventually wish they owned Harbison and Steele.
posted by flabdablet at 7:19 PM on July 1, 2009


« Older Can you save remote desktop connections to log in...   |   Cash now, please! Newer »
This thread is closed to new comments.