PDA

View Full Version : Newbie at PIC/microcontroller programming




not batman
Jun 27, 2006, 12:35 AM
Sorry since there is already a thread about programming microcontrollers, but I thought it better to make a whole new thread rather than hijack that one.

Basically the most experience I have with programming is a bit of very simple Basic Stamp work. I'm an art student and programming isn't really my forte, but after taking an electronics class at my Uni I have become very interested in integrating electronics into my work.

I am getting pretty comfortable with programming my Basic Stamp (through the program MacBS2 http://www.muratnkonar.com/otherstuff/macbs2/) but I like the idea of how cheap PIC chips are. I don't really like the idea of having to shell our ~ $50 every time I manage to make and sell another electronic piece of art.

SO! Getting to my point (finally :P) I want to learn to program PIC chips, and I want to do it on my Mac. I don't know if there is some way of programming them in some sort of Basic language, since I have no clue at all about programming in C, but I am sure I can learn pretty quickly and pick things up as I need to know them.
If anyone could point me to some resources, tutorials, anything at all. Heck, even just tell me to give up now and stick with the Basic Stamp if you think that would be most appropriate. Really, anything to get me started on the way of programming PIC chips/microcontrollers would be greatly appreciated.

Thanks a lot in advance!
And if there is any more information as to what experience/equipment I have available I would be happy to divulge such details.



balamw
Jun 27, 2006, 01:17 AM
Sounds like you would really benefit from biting the bullet and learning C or Assembly and working with PICs. My limited PIC experience has been using Windows based tools so I can't be of much direct assistance, except to say look to the linux community for lots of help that could be portable to OS X...

What kind of stuff do you want the PIC to be able to do in your art.

B

not batman
Jun 27, 2006, 10:01 AM
Yeah, I have been thinking that I will just have to just buckle down and learn C, but kind of hoping there would be some easy way out. :p

Do you have any recommendations for getting started? It would be awesome if you did.

As to what I want to do with the PIC in my art, I mostly want to be able to make mass produceable, interactive art. I'd like to be able to have installations that can respond to user input or work "autonomously." I'm not exactly sure what I want to do quite yet because I don't really know exactly what I can do with PICs.

balamw
Jun 27, 2006, 12:10 PM
I'd buy the MPLAB ICD 2 and a PICDEM 2 Plus demo board from MicroChip. Then download the demo/student edition of the C-compiler and enjoy.

The combination will set you back ~US$250 and requires Windows :( , but once you have it you have a full featured in-circuit debugger which'll help you figure out what is wrong. Custom boards for specific application can be built and populated extremely cheaply, you can even design online at places like http://www.pad2pad.com/

B

csubear
Jun 27, 2006, 12:29 PM
I'd buy the MPLAB ICD 2 and a PICDEM 2 Plus demo board from MicroChip. Then download the demo/student edition of the C-compiler and enjoy.

The combination will set you back ~US$250 and requires Windows :( , but once you have it you have a full featured in-circuit debugger which'll help you figure out what is wrong. Custom boards for specific application can be built and populated extremely cheaply, you can even design online at places like http://www.pad2pad.com/

B


If you are going to do pic development then the icd 2 is the way to go. You can get a cheap knock-off here: http://www.olimex.com/dev/index.html

Also, buy a cheap pc. Its way better than try to get virtual pc and the like to work.

I've done a little PIC development, and they are fun little devices. A friend of mine suggested the AVR mircocontrollers. I guess you can cross compile binaries for them using gcc.

not batman
Jun 27, 2006, 07:52 PM
Thanks for those suggestions, I'll try to determine what will work best for me.

I guess there are no real options for using my Mac? Hmm... I guess I'll have to work harder on getting my girlfriend to give me her IBM Thinkpad and replacing it with a Macbook...

Thanks again!

balamw
Jun 27, 2006, 07:54 PM
I guess there are no real options for using my Mac? Hmm... I guess I'll have to work harder on getting my girlfriend to give me her IBM Thinkpad and replacing it with a Macbook...
I think that once you have it all working using the Windows tools you can make one of the Mac/unix tools work too, but learning on one of the slightly rougher tools might be a stretch.

B

Oscar_Wilde
Jul 5, 2006, 12:38 AM
I guess there are no real options for using my Mac?

Don't despair! There are always options.

If you want to use your Mac to do the programming then it's worth considering a PICkit 2 (http://microchip.com/PICkit2). It uses USB so you'll definitely be able to connect it to any Mac. You'll have to use command line tools to operate it but the latest version of PK2 (http://home.pacbell.net/theposts/picmicro/) works very well on MacOS and has a native driver.

As far as languages go you might have trouble finding a PIC C compiler for MacOS but you can get a good quality assembler, GPASM (http://gputils.sourceforge.net/), for free.

All of these tools will require a certain amount of effort to setup. Nothing major but if you've never compiled anything before it may frustrate you. If you have any savvy friends they may be able to help.

ChrisA
Jul 5, 2006, 12:54 AM
Yeah, I have been thinking that I will just have to just buckle down and learn C, but kind of hoping there would be some easy way out. :p

Do you have any recommendations for getting started? It would be awesome if you did.

As to what I want to do with the PIC in my art, I mostly want to be able to make mass produceable, interactive art. I'd like to be able to have installations that can respond to user input or work "autonomously." I'm not exactly sure what I want to do quite yet because I don't really know exactly what I can do with PICs.

Why PIC? If you are talking about "installations" these are large pieces arn't they? You don't need the PIC for it's small size. Why can't you se a PC. Yes a full up PC. Find one that run with no fan, no monitor or keyboard. Run Linux on the PC. If you value your time ease of programming maers. PCs are close to free. Maybe old Pentium II notebooks? Linux PCs are very much like Macs and ship with much of the same software and you can program them in BASIC, C, Perl or whatever you want.

not batman
Jul 6, 2006, 01:14 AM
Don't despair! There are always options.

If you want to use your Mac to do the programming then it's worth considering a PICkit 2 (http://microchip.com/PICkit2). It uses USB so you'll definitely be able to connect it to any Mac. You'll have to use command line tools to operate it but the latest version of PK2 (http://home.pacbell.net/theposts/picmicro/) works very well on MacOS and has a native driver.

As far as languages go you might have trouble finding a PIC C compiler for MacOS but you can get a good quality assembler, GPASM (http://gputils.sourceforge.net/), for free.

All of these tools will require a certain amount of effort to setup. Nothing major but if you've never compiled anything before it may frustrate you. If you have any savvy friends they may be able to help.

Those sound like great options, thanks for suggesting them!

Why PIC? If you are talking about "installations" these are large pieces arn't they? You don't need the PIC for it's small size. Why can't you se a PC. Yes a full up PC. Find one that run with no fan, no monitor or keyboard. Run Linux on the PC. If you value your time ease of programming maers. PCs are close to free. Maybe old Pentium II notebooks? Linux PCs are very much like Macs and ship with much of the same software and you can program them in BASIC, C, Perl or whatever you want.

I have considered a PC, and while it would be a fine option for larger scale installations I have been working lately on smaller pieces that can be deployed into public places and so I need small and cheap. I wouldn't mind if someone made off with ~ $30 worth of electronics and hardware, but a whole PC is is too much for me to risk putting out in the world.

rahji
Jul 30, 2006, 08:39 AM
>I wouldn't mind if someone made off with ~ $30 worth of electronics and
>hardware, but a whole PC is is too much for me to risk putting out
>in the world.

don't rule it out. you can get a decent computer for free very easily. i've gotten several right off the sidewalk on trash day, at the recycling center, etc. craigslist is good for free and dirt cheap stuff like that too. i'm also an artist and honestly, i think of a whole PC before a microcontroller anytime possible - the programming is already something i know more about and it makes other things simpler .. troubleshooting on site by bringing a monitor/keyboard along maybe, ease of replacement of something breaks (new free PC with a copy of the boot disk in it), no power issues - you just plug it into a regular outlet.

good luck,
rahji

Cephus
Jun 22, 2008, 10:50 PM
Also, buy a cheap pc. Its way better than try to get virtual pc and the like to work.



MPLAB 8 and an ICD2 or PicKit 2 works fine under Parallels with my MacBook. I'm just beginning to learn C and using the free educational C compilers offered by Microchip or Hi-Tech.

It took no special configuration to get the USB PIC devices to work other than to tell Parallels to port them to the virtual machine.

I'm still holding my breath that Microchip will eventually port MPLAB to OS-X.

lee1210
Jun 22, 2008, 11:41 PM
I think this should be nominated for one of the oldest resuscitated threads. When this thread was started there were only iMacs and MacBook Pros on intel, and parallels wasn't yet available.

I'm not trying to indicate that the information provided was not useful, only that I suspect the OP has come up with some solution by now.

-Lee

Cephus
Jun 23, 2008, 10:01 AM
I'm not trying to indicate that the information provided was not useful, only that I suspect the OP has come up with some solution by now.

-Lee

Entirely my fault! I was searching for programming the PIC with OS-X rather than Windows and failed to notice the date of the post I replied to.

Sorry about that! :)

Spinnaay
May 4, 2010, 12:02 PM
Hi there,

Just wanted to drop in and see if there had been any updates on this over the last few years?
I would really love a way to program my PIC's from Xcode on my macbook.

Thanks

Thom

balamw
May 4, 2010, 12:14 PM
Holy thread re-resurrection Batman! It just won't die. ;)

Paralles/VMware still seems like the best bet. You can still use Xcode as your editor though...

B

notjustjay
May 4, 2010, 12:27 PM
Cheap netbooks might work out well too. The concept of a $200 Windows laptop was unheard of a few years ago.

timbos
May 4, 2010, 12:53 PM
I've done a little PIC programming with Hitech C and a PicKit programmer. It's a commandline compiler, but I wrote a little cocoa wrapper for it so's I can click buttons rather than type commands to compile and load the hex files.

balamw
May 4, 2010, 01:01 PM
I've done a little PIC programming with Hitech C and a PicKit programmer. It's a commandline compiler, but I wrote a little cocoa wrapper for it so's I can click buttons rather than type commands to compile and load the hex files.

Shows it's been a while since I looked at it, but there was no Hitech C for Mac OS (only Windows and Linux) the last time I checked. (Which doesn't seem that long ago...)

B

Spinnaay
May 4, 2010, 03:09 PM
There is no such thing as a dead thread with google these days!

Have you guys seen this? Look for the PK2CMD install on the download list.

http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en023805&redirects=pickit2

T

marktyers
Oct 7, 2010, 12:50 PM
I am running a Microcontroller class for students on an HND course where they are designing and producing an electronic sculpture for the local art gallery. All the work is being done on Macs.

Our platform is Arduino (http://www.arduino.cc) which is available on Windows, Mac and Linux. Boards (complete with USB) can be purchase for around 20 and the components to build a custom board for under 10.

Custom PCBs are being designed using Fritzing (http://fritzing.org).

The development cost is a fraction of using PICs plus programming is done in C using the dedicated IDE.

jared_kipe
Oct 7, 2010, 02:39 PM
I am running a Microcontroller class for students on an HND course where they are designing and producing an electronic sculpture for the local art gallery. All the work is being done on Macs.

Our platform is Arduino (http://www.arduino.cc) which is available on Windows, Mac and Linux. Boards (complete with USB) can be purchase for around 20 and the components to build a custom board for under 10.

Custom PCBs are being designed using Fritzing (http://fritzing.org).

The development cost is a fraction of using PICs plus programming is done in C using the dedicated IDE.

I do like Arduino quite a lot, but I would argue that PICs are cheaper if you want to do more than just a couple of custom installations.

marktyers
Nov 7, 2010, 01:31 PM
I do like Arduino quite a lot, but I would argue that PICs are cheaper if you want to do more than just a couple of custom installations.

The benefit of Arduino is the massive online support plus complete cross-platform support. I looked a PIC a while back. If anyone can suggest a PIC solution as easy to work with as Arduino I will certainly be taking another look...;)

chown33
Nov 7, 2010, 03:08 PM
The benefit of Arduino is the massive online support plus complete cross-platform support. I looked a PIC a while back. If anyone can suggest a PIC solution as easy to work with as Arduino I will certainly be taking another look...;)

Welcome to the world of recurring vs. non-recurring costs.

Muncher
Nov 7, 2010, 06:08 PM
Arduinos can be quite cheap too, if all you need is the chip itself. Technically all an "Arduino" is composed of is an Atmel microcontroller with a bootloader.

Look at Sparkfun's website. They sell all manner of arduinos in various stages of completion and size.

jared_kipe
Nov 7, 2010, 08:57 PM
I'm not saying they are "expensive", they are just not the cheapest.

MasConejos
Nov 8, 2010, 11:23 AM
Microchip is going cross platform. MPLAB X is coming out early 2011 and supports both Mac and Linux. Microchip's compilers are also going cross platform; not sure about Hi-Tech. The new IDE is based on Net Beans and is a significant improvement over MPLAB 8.x

LakritZtrollet
Nov 23, 2010, 09:24 AM
I'm searching for a PIC controller with, at least, 14 analog outputs...
Does anyone know wich one to select?

MasConejos
Nov 23, 2010, 01:12 PM
I'm searching for a PIC controller with, at least, 14 analog outputs...
Does anyone know wich one to select?

Analog outputs? Do you mean ADC (Analog Digital Converter) inputs? If not, exactly what are you trying to accomplish?

chown33
Nov 23, 2010, 02:53 PM
I'm searching for a PIC controller with, at least, 14 analog outputs...
Does anyone know wich one to select?

Easy answer: None. No PICs have analog outputs.

If you mean analog inputs, then the simplest answer is to visit the Microchip website and search. If you don't find a suitable PIC, then consider using an analog multiplexer chip to increase the number of discrete analog inputs feeding a single ADC input pin. You can get simple analog multiplexer chips almost anywhere for well under $1, and there are lots of options (number of inputs, voltage ranges, package type, etc.). Google it.

If you really mean analog outputs, and you really need 14 of them, then you'll need external DAC chips, which you'd interface to the PIC using SPI or I2C. Then any PIC can drive the external chip (or multiple DAC chips, since I don't know of any single-chip 14-output DACs).

You should also describe what analog range you need (full-scale voltage or current range), and what precision (sample size) and bandwidth you need (sample rate). These will determine what kind of analog multiplexer to use, or what kind of DAC chips. If you need anything special, such as high-voltage isolation or microvolt ranges, you can expect to pay big money.

balamw
Nov 23, 2010, 06:27 PM
What about the old "use a PWM as a poor-mans DAC"?

Many PICs have PWM outputs.

Edit: link http://www.k9spud.com/traxmod/pwmdac.php

B

chown33
Nov 23, 2010, 08:00 PM
What about the old "use a PWM as a poor-mans DAC"?

Many PICs have PWM outputs.


I agree, in principle. But the poster asked for analog, not PWM.

Frankly, I think the poster is probably lost, and this page came up in google, so he/she posted a desperate question. None of the prior posts were about selecting a PIC chip.

Yvan256
Nov 24, 2010, 01:49 PM
I vote for using Atmel too.

jared_kipe
Nov 24, 2010, 05:07 PM
Usually when someone is talking about "analog out" and PICs they are talking about PWM outputs.

Arduino even uses the function named analogWrite() to use PWM on a pin.

If this is what you're after, the Arudino Mega has 14 PWM capable pins.

chown33
Nov 25, 2010, 12:27 PM
Arduino even uses the function named analogWrite() to use PWM on a pin.

Maybe that's why the poster couldn't find a suitable chip: he/she didn't know that analogWrite() doesn't write to an analog output, but a PWM one.

MacModMachine
Nov 25, 2010, 07:53 PM
Sorry since there is already a thread about programming microcontrollers, but I thought it better to make a whole new thread rather than hijack that one.

Basically the most experience I have with programming is a bit of very simple Basic Stamp work. I'm an art student and programming isn't really my forte, but after taking an electronics class at my Uni I have become very interested in integrating electronics into my work.

I am getting pretty comfortable with programming my Basic Stamp (through the program MacBS2 http://www.muratnkonar.com/otherstuff/macbs2/) but I like the idea of how cheap PIC chips are. I don't really like the idea of having to shell our ~ $50 every time I manage to make and sell another electronic piece of art.

SO! Getting to my point (finally :P) I want to learn to program PIC chips, and I want to do it on my Mac. I don't know if there is some way of programming them in some sort of Basic language, since I have no clue at all about programming in C, but I am sure I can learn pretty quickly and pick things up as I need to know them.
If anyone could point me to some resources, tutorials, anything at all. Heck, even just tell me to give up now and stick with the Basic Stamp if you think that would be most appropriate. Really, anything to get me started on the way of programming PIC chips/microcontrollers would be greatly appreciated.

Thanks a lot in advance!
And if there is any more information as to what experience/equipment I have available I would be happy to divulge such details.

you can build your own basic stamp for around $12.5 canadian

i use these for automation controls,

PM for parts list and dealers who sell them.
--------
i can make some for you for free, only small quantity's though i don't have much oven room.

i can tin the boards any way you need them, good for protoyping

lee1210
Nov 25, 2010, 08:48 PM
you can build your own basic stamp for around $12.5 canadian

i use these for automation controls,

PM for parts list and dealers who sell them.
--------
i can make some for you for free, only small quantity's though i don't have much oven room.

i can tin the boards any way you need them, good for protoyping

The post you're replying to is 4.5 years old. This thread was recently resurrected.

-Lee

balamw
Nov 25, 2010, 09:04 PM
Maybe that's why the poster couldn't find a suitable chip: he/she didn't know that analogWrite() doesn't write to an analog output, but a PWM one.

We'll probably never know for sure since the OP hasn't logged on since making their first and only post.

B