47 Comments
- afex, on 10/12/2007, -0/+10i always thought the beauty of PICs was in the unique instruction set, which you really don't see if you do it in basic...plus isn't ASM more useful than basic anyhow? i know a lot of low level hardware stuff still gets done in ASM at my firm, i'm sure there's others...
- NalosLayor, on 10/12/2007, -5/+11Why program in BASIC? PIC controllers can already be programmed in C, which is nearly as easy and quite probably faster.
- leobaby, on 10/12/2007, -0/+4check out the ez430 - inexpensive, easy to program, and low power. $20 gets you everything you need.
http://www.ti-estore.com/ - quarsaw, on 10/12/2007, -2/+6agreed,
Hi-tech makes a great free C compiler for the PIC
here: http://www.htsoft.com/products/PICClite.php
no point in toying around in BASIC, go right for the real thing. - s-m-a-c-k, on 10/12/2007, -1/+4though C is most probably the best method to program for PICs, BASIC is a really simple way to develop code fast, I know PICBasic has a large list of routines like debounce, simple A/D Conversion, stepper motor control, etc.
- jmccorm, on 10/12/2007, -2/+5FWIW, Parallax sells some good PICs that do BASIC.http://www.parallax.com
BASIC allows you to concentrate less on the software side. When you're trying to get something to work (especially if it is complex), I'd rather do it in BASIC any day, then go back and put it in Assembler (only if needed for speed) once it all works. - cypher543, on 10/12/2007, -1/+4@illicium:
Good for you. o.O - SupaFupa, on 10/12/2007, -0/+3To those that say ASM or C would be more powerful, I agree. But I think the whole point is that its aimed at the introductory level, not the 1337. Sure you can do more with C and assembly, but BASIC is much easier to learn, and a good place to start.
- ezrider0, on 10/12/2007, -0/+3ASM is way more powerful, but this is a great guide for beginners or kids in highschool / middle school who want to program PICs and don't have the formal education yet. I remember hacking away with PICs when I was 12-14 and this would have helped a ton back then. Obvi not geared towards the advanced user.
- Phocion55, on 10/12/2007, -0/+2Very cool! Thanks for the tutorial. I'm definately interested in a change of pace from my usual web programming and try something else fun. Digg++.
- gmillerd, on 10/12/2007, -0/+2Need a little more than 'c is better better' than pic basic. What is the harm, especially in prototyping to use pic basic? Adding more steps to 'can you hear me now' getting things sorted out sucks.
In addition a lot of the 'robots wars' like books use basic. - dcowboy, on 10/12/2007, -1/+3PIC is just a type of microcontroller (RISC). I think at one point in the past PIC actually stood for something (depending on the manufacturer), but not anymore. You can get low and high-end models which have a larger instruction set and can also come with extra peripherals like RS232 interfaces.
- leobaby, on 10/12/2007, -0/+2Actually, you can get this for $20 after shipping.
There's also a contest that ends Oct 2, 2006.
Here's the link for both.
http://www.designmsp430.com/?DCMP=AEC_msp430_general&HQS=Contest+OT+designmsp430 - leobaby, on 10/12/2007, -0/+2here's a link.
http://electronics.howstuffworks.com/microcontroller.htm
In essense, a microcontroller is an all in one package. It is a small piece of hardware that has a cpu, ram, and permenant storage all in one chip. They can control almost anything from led's to usb ports; and they can take almost anything as input such as buttons or music.
They allow hobbyists to make more complicated projects.
Here's just one of many projects that can be done with a microcontroller.
http://drewish.com/blogger/archives/2005/03/17/2sided_pov_toy.html - cypher543, on 10/12/2007, -0/+1I've always wanted to mess with PIC microcontrollers. I keep seeing them in robotics tutorials and things, I just never knew they were so cheap. Dug.
- magnetix, on 10/12/2007, -0/+1I suggest starting with the PIC16F84A from Microchip.
This PIC has enough I/O pins to make some sweet LED chases to start you off. If you want go for more elaborate projects you can connect some buttons, a seven segment LED display or even a LCD with no need to go for a PIC with more I/O pins.
Microchip's free MPlab IDE makes it easy to code in Assembler and with Hi-tech's picc lite c compiler you'll be writing cool stuff in no-time. PICC lite comes with some very helpful c examples and libraries for delay functions and LCD control.
To get the code onto the PIC you need a programmer and control software.
You can buy a programmer on line or build your own. I suggest the "TAIT classic" programmer. I use it and never had any problems. There is loads of software that supports this programmer. I use PICprog2.
Microchip: http://www.microchip.com
High-Tech: http://www.htsoft.com/downloads/demos.php
Tait classic programmer: http://www.bobblick.com/techref/projects/picprog/picprog.html
Propic2: http://www.bobblick.com/techref/projects/picprog/propic2.zip
- PAJK, on 10/12/2007, -2/+3Please can someone educate those of us who don't know what PIC Microcontrollers are? I've figured it's some form of hardware...programming hardware seems very intriguing to me, so pray tell. :)
- inactive, on 10/12/2007, -0/+1So the above links that has a device that looks like a jump drive, what does it do? its a microcontroller? what does it control?
- PAJK, on 10/12/2007, -0/+1Thank you for the links, but I am a bit disappointed by the howstuffworks article. The practical involves spending $200. Not wonderful for the beginner.
I am still left not fully understanding PIC, it's fundamentals, and where to start. I am now incredibly intrigued, and just getting a device to flash an LED as a result of a program I've written seems very cool to me.
Anyone have any advice for a beginner? I just really wanna pic one of these things up (pun intended) and get to writing something for it. But there are so many different models, and I just feel bombarded. - leobaby, on 10/12/2007, -1/+2exactly, perfect for the digg audience.
- NSMike, on 10/12/2007, -1/+2Fun stuff, here. I did stuff like this for my Machine Architecture class in college. I built a robot with a PIC on it, good times.
- tjlsmith, on 10/12/2007, -3/+4It would nice if this was in a printable pdf....
- PAJK, on 10/12/2007, -0/+1@magnetix:
Thanks. I've found this chip on eBay: http://cgi.ebay.co.uk/PIC16F84-8-Bit-Microcontroller-FLASH-EEPROM_W0QQitemZ180017875641QQihZ008QQcategoryZ36332QQssPageNameZWDVWQQrdZ1QQcmdZViewItem
But I don't see any kind of PC connectivity, nor does it list an LED. - AICkieran, on 10/12/2007, -0/+1@PAJK:
You connect it to the pc via a programmer [normally connects to the serial port] and 'program it'.
And you need to buy the LED's and anything else you want to use with it, You dont just write a program for it and it does everything you need to connect it into a circuit, Look into breadboarding. - billmccartney, on 10/12/2007, -0/+1I disagree... a simple C application (especially for embedded apps) is usually much simpler for beginners (since they don't use pointers or any datastructures)...
that and the fact that other chips (not from microchip) have widely available unlimited FREE c compilers - such as GCC for the ATMEGA and for the MSP430's - vimau, on 10/12/2007, -0/+1www.picaxe.co.uk
- fmaxwell, on 10/12/2007, -0/+1Some people prefer to program in a high-level language like BASIC rather than a low-level language like C or assembly (for low-level languages, I strongly prefer assembly to C). Programming in C is like walking a minefield.
* There is nothing in C that prevents a program from writing to random places in memory. Preventing this is a task left to the OS, which must sandbox processes to maintain memory integrity. This works, however it makes interprocess communication much more difficult than necessary. When the OS does step-in to prevent a write to an out-of-bounds area, you get precious little debugging information. With BASIC, the program will typically halt, showing the exact line that caused the problem, making debugging easy.
* Since integers can arbitrarily be casted to pointers and pointer arithmetic is possible, it is impossible to determine what areas of memory are in use by a C program. This leads to an entire class of memory bugs impossible in high-level languages. And it make garbage collection nigh on impossible.
* C is weakly typed. In fact, typing is barely enforced in C, encouraging poor design.
P.S. Don't even think of taking the 'you must be a newbie' attitude, because I've been a professional software engineer since 1980. - smellinator, on 10/12/2007, -0/+1Agreed, BASIC Stamp's aren't as cheap as a stand alone PIC chip, primarily because they have a PIC Chip on them (sometimes a competitive chip to PIC, depending on the BASIC Stamp model). BASIC Stamp BS-2 includes the PIC chip, plus ancillary hardware that helps you with many projects (a P-Basic interpreter chip, and various hardware to protect the novice from frying his pic chip).
So BASIC Stamp is a good place to start. It's a PIC chip on a bigger chip.
And there's really nothing to the coding - Basic or C. This is not an operating system that you're writing for these things.... you're typically responding to signals, doing some basic calculations and storing some values, and maybe taking some lines high or low as outputs. Basic is completely suitable for this, although C is fine as well. PBasic is such a scaled down variation of BASIC that you shouldn't kid yourself on this. Use the right tool for the job - and PBasic is certainly the right tool in many cases.
Amazingly, things that you take for granted in C or most dialects of BASIC just aren't true in PBASIC. Like 1+2*3 does not equal 7. It equals 9 (no precedence of operators in PBASIC). - smellinator, on 10/12/2007, -0/+1I'm not sure where you see "something that looks like a jump drive", but I'll try to explain. Microcontrollers are small computers with a very little bit of memory and a few I/O lines (maybe 8, 16, or 32).
They can run very small programs which control things. Inputs may come in on the control lines (like a temperature, or the sensing of a closure of a switch, or a water level getting to be a certain height) and outputs are sent down i/o lines (like turn on/off a motor, change an LCD display, turn on some lights, or even speak in a voice).
The idea is that you get a microcontroller, and you build something to control whatever you want! You can turn on / off your house lights. You can detect that the refrigerator door has been left open (either by switch or by temperature). You can control a Roomba to vacuum your floor (sensing where the walls are, etc). In fact, Hobbyist Robotics are a lot of fun, and very popular.
I've seen devices using the PIC microcontroller that monitor temperature in industrial settings (think large hotels and restaurants that have to keep their massive quantities of food cold). In order to maintain proper food safety AND to be able to prove that your food was all the right temperature for long periods, you monitor the temperature, report it back to a central point, and alert/alarm people if there's an issue. Great way to avoid spoiling a walk-in fridge full of meat because of an outage. And great way to save a lot of money and defend yourself in a lawsuit. Imagine having a log of your temperatures, taken every 30 seconds, and compiled every month. Very powerful stuff.
Or you could create a robotic car that can be remotely controlled by a website... - aesir_loki, on 10/12/2007, -0/+1Mythos,
Sometimes C isn't the best way, yeah it can be easier but its less efficient as for memory. - nronhubbard, on 10/12/2007, -0/+1Agreed that pic basic is a great way to start, and in fact, is quite a strong and effective language for advanced work as well, though of course probably not as fast as c.
If we are to talk the best, newest, I would put my vote in for Arduino.
Really robust, and easily programmed: great online video tutorials as well...
http://www.arduino.cc/
built in usb and ready to rock...
will be featured at ars electronica workshops in sept. as well.
Definitely the best I know for fast, effective rapid physical computing prototyping...
nron - Daiken, on 10/12/2007, -1/+1pff...C and Basic. I program nothing unless its in Assembly.
- Guysmiley777, on 10/12/2007, -0/+0Ummm, from the preface: "If something starts functioning without you knowing exactly how, it shouldn’t bother you too much. Anyway, it is better that your program works than that it doesn’t. Always stick to the practical side of life. Better to finish the application on time, make it reliable and, of course, get paid for it as well as possible."
What kind of attitude is that? Shotgun programming theory 101: Just keep hitting "Compile", eventually it'll work. - sanjeewamad, on 11/14/2008, -0/+0Writing assembly program for PIC/Microcontrollers....
read this article here..
http://www.promeganet.com/?p=897 - magnetix, on 10/12/2007, -0/+0Here is another easy to understand Tutorial : http://www.mstracey.btinternet.co.uk/pictutorial/picmain.htm
- bikeham, on 10/12/2007, -0/+0I'm surprised nobody mentioned the Picaxe? Built in basic compiler.
http://www.picaxe.orcon.net.nz/ - noel1, on 10/12/2007, -0/+0glad i found this free PIC ebook.
- skinwill, on 10/12/2007, -0/+0I fell in love with PIC controllers from http://www.parallax.com the basic stamp was my introduction to micro controllers. You can program it in basic. And they are cheap.
- bluehash, on 10/12/2007, -0/+0That was on of the first websites I used for reference.They explain concepts well.
Used the PIC to build a few.
http://www.machinegrid.com/content/view/23/54/ - kurotenshi, on 10/12/2007, -1/+1Basic is just a really easy way to start programming, Im sure this was aimed at the novice crowd. I remember starting off with basic way back when and it created a really good foundation that Ive been building on to since.
- quietamerican, on 10/12/2007, -0/+0ASM on the PIC is also a great introduction embedded systems programming issues -- handling logic levels, working with hardware, working with simple buses to talk to external components, asynchronous programming issues, resource contention, and IRQs...
Fwiw Microchip makes their IDE including a basic simulator available for free, it's called MPLAB.
Also the "flash" series of PICs (xxFxxxx part numbers, vs. xxCxxxx) can be live debugged using a very easy to use in-circuit debugger/programmer called the ICD2. USB2 and US$150.
Only downside in all of this is rolling your own PCBs... and soldering surface mount components! :) - boaman, on 10/12/2007, -5/+4thanks for the link. Sorry I wanted to 'digg' your link but clicked the wrong hand. (very new to digg)
- illicium, on 10/12/2007, -6/+5I'm going into highschool and I know ASM. :|
- dcowboy, on 10/12/2007, -2/+0Also, ASM is always free where as your C or BASIC third party tools can cost money. This is a moot point though because I'm pretty sure there is an open-source suite of tools that will let you compile for PICs in C.


What is Digg?
The Digg Toolbar for Firefox lets you Digg, submit content, and keep track of Digg even when you're not on the Digg site. Download the official