PDA

View Full Version : Discussion Mechanical engineer crossing over to the dark side - PIC or PICAXE?


viva_peru
Dec 10, 2008, 08:35 AM
Hello,

I am a mechanical engineer who is starting to develop an interest in electronics and who would like to do a little tinkering just for fun. I have been considering buying one of the starter kits for either the PIC or PICAXE chips and would like to hear what would more knowledgeable people would recommend. In am leaning towards the PICAXE simply because I feel that learning how to program in BASIC would be easier (I already know FORTRAN quite well which uses a similar structure). Also, I was wondering if for the same number of pins, is there a significant difference in functionality between the two?

Thanks in advance,

Teo

Acetronics
Dec 10, 2008, 08:54 AM
Hi, Teo

Picaxe ... are only Preprogrammed Pics, this is captive chips ... so, you MUST buy their chips !!! ( like Parallax Basic stamps )

So, the question is : what do you want to do ...

The Way to high level programs is BASIC Compiler like PicBasic Pro from Melabs, MikroBasic from Mikroelektronika, ...

The Backdraw is relatively expensive compilers ( say > 150 US$ ) but unlimited use with every Microchip 8 bit processors ... that are not expensive.

Hearing you about FORTRAN ... I'd rather think ( from what I understood ... lol ) it's closer to "C" ...

To have a good Idea ...

I'd recommend you to download the Mikroelektronika Basic AND C free compilers : they have a HUGE 2K code limit ... allowing you to run consistent developements.
Their structured programming way will sound good to you ...

Here : http://www.mikroe.com/en/compilers/

YOU will then be able to choose between C and Basic ...


AND, after that, you can order really handy developing tools from this site ...

ALSO think to have a look to the "Special offer" section ... Worth the look.

Alain

Tomapowa
Dec 10, 2008, 09:23 AM
If you'd never used a PIC programmer before and want to code some simple (and some complicated!) programs into a PIC, I would buy the Picaxe. You can get them on Ebay for something like 3 for $10 (Picaxe 08M). PICs themselves (12F683) are a bit more than $1 each... so markup on the picaxe chips are very reasonable for hobbyists and quick prototyping. After downloading their free software and you build yourself a programming cable (rs232 conn. with two resistors) you can program (BASIC-like) some cool stuff into them using functions such as ADC, serial in/out, 4 input/outputs, etc.

If you feel like you get the hang of it and you want to program bare PICs, then I would go with the PicKit2 PIC programmer starter package (on sale now I think for something like $30-35). You can then use a few free PIC Basic compilers out there that have similar functions and program structure as the Picaxe, so your learning curve is minimal.

orraman
Dec 10, 2008, 10:09 AM
Greetings Teo,

Ease of use, speed of making corrections to programmes, no need for a programmer are all points in favour of the Picaxe and make them ideal for a beginner. They are well suited to radio control applications, driving servos and sensors for temperature, light, voltage and current etc.
However Picaxe chips are pre loaded with an interpreter which reduces the available memory space, particularly so in the smaller sizes, that said, many quite involved applications are in operation. The price for each chip includes small premium for the programming of the interpreter and for hobby use this is inconsequential. The software for the entire system is free, the Programming Editor is comparable to the best, there are 3 large manuals and many if not hundreds of examples. There are some restrictions in the availability of functions on pins, the 08M (12F683) has 1 pin unavailable for I/O and one dedicated to output and 3 normal GPIO.

Your previous programming experience and the fact that you enquire about functionality prompt me to lean towards suggesting the pic with a good Basic compiler.
Interpreters are much slower than compilers which are very close to assembler in code compression and speed.
I use Crowhill Proton Basic Compiler because it's virtues and superiority have been convincingly demonstrated by a friend. He particularly points to the short time taken to resolve issues and the speed with which newly issued pic chips are incorporated, in some cases before they are commercially available.
The Proton Development Suite has a host of user friendly features that are also in the free (50 line) download.

Both systems have very active forums and visiting them may help you decide.

Dave

BushmanLA
Dec 10, 2008, 10:57 AM
Tough call, choosing PICAXE will make getting started a bit easier, but will limit you to what you can do.

I'm a PIC junky myself but I'm also in the last semester of my EE degree (plus some years of electronics tinkering/work).

My vote is that you start with microelectronica's free PICBASIC compiler, integrate it into MPLAB and the PICKIT 2 programmer and some free samples from microchip.

I got a final in a few mins, when I'm done I'll post a few links to help you get started.

balesse
Dec 10, 2008, 12:58 PM
It's a slippery slope to talk about other chips (because there are a number of good choices), but for tinkering, you might want to look at an Arduino (http://www.arduino.cc/).
- It's all open source, so that has lead to quite a bit of inovation that is then available for your use.
- It is targeted towards hobbiests, so it tends to support the sort of things that we want to do.
- Want to flash LEDs, drive stepper motors, drive servos, plug in sensors, talk to a PC, talk wirelessly to another device? Instead of spending time figuring out how to do all of these things, just use a library designed for that function and spend your time on the goals of your project rather than figuring out how to make these things work.

Anyway, I was just blown away with how simple the Arduino was to setup. Literally within 15 minutes I had it doing some basic things. (It took me a lot longer to accomplish the same things with a PIC. It does not help that I used assembly on the PIC where as the Arduino is very java like, which I already know. But still the Arduino is a nice little package.)

BushmanLA
Dec 10, 2008, 03:14 PM
I'd have to agree Arduino is probably better than PICaxe

If you want to be hard core and get setup with the PIC here are my suggestions.

1. Get a programmer
I use this one
http://www.sparkfun.com/commerce/product_info.php?products_id=8558

This is another great option from microchip. The programmer alone is only $35
If the link doesnt work just search for PICkit 2
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en023805


2. Get MPLAB and C18 compiler from Microchip.
This will let you program the 18series PICs in C, both are free.

3. Get PICBASIC
This will let you program the smaller 16 and 12 series pics in BASIC (as well as the bigger 18 series)
The demo is free and the restrictions shouldn't bother you.
http://www.melabs.com/pbpdemo.htm

Don't bother with the MicroCode studio stuff, you are better off integrating the PICBASIC compiler into MPLAB so you can write/compile/program all with the same program (MPLAB). The procedure to get PICBASIC integrated into MPLAB is a bit of a hassle, but trust me it is worth it. Otherwise you have to write/compile in MicroCode studio, import the hex into MPLAB and program with MPLAB.

4. Get some PICs!
You can get free samples from microchip.com, sparkfun carries all the popular PICs if you run out of samples

Some Suggestions:
12F683 for small jobs. I use this one for my RC rocket launcher and my RC camera trigger.

16F628A or 16F688 for medium jobs

Fob big jobs that needs lots of I/O pins and stuff
18F4550 - USB stuff
18F4525 - no USB crap


Useful components.
Breadboard
http://www.sparkfun.com/commerce/product_info.php?products_id=112

A power supply
http://www.sparkfun.com/commerce/product_info.php?products_id=114
http://www.pasqualy.com/PowerSupply/

A few voltage regulators
http://www.sparkfun.com/commerce/product_info.php?products_id=107

Some oscillators
http://www.sparkfun.com/commerce/product_info.php?products_id=542

Some filter caps
http://www.sparkfun.com/commerce/product_info.php?products_id=8375
http://www.sparkfun.com/commerce/product_info.php?products_id=96

Other stuff:
Hookup Wire
Resistors - for 10 bucks you can get a bundle of assorted resistors from radioshack or whereever
LEDs - buy these in bulk or from grab bag bundles from jameco etc Don't pay out the nose from radioshack for single LEDs


Also, a word of advice.
Pin A4 is open collector on most PICs. This means it can sink current when set to 0V, but it cannot source current when set to 5V.


I need to write a web tutorial about this...

Malc C
Dec 10, 2008, 03:50 PM
Or get an all in one development board like

http://micro-heli.co.uk/easypic5_550_3.jpg

I started off with a cheap programmer (eventually ended up with around 4 ) before I invested in an easypic board... this makes programming and testing easy and would really recommend it.

spinup
Dec 10, 2008, 04:41 PM
I am a mechanical engineer who is starting to develop an interest in electronics and who would like to do a little tinkering just for fun.I'll cast another vote for the Arduino. I just got back into micros after a long hiatus. The last time I'd used them was before EEPROMS...we had to erase the code with a strong UV light. :)

IMO, it is rare to find a system that is dead-simple to start playing with, but does not limit you as you learn. With most systems, you trade beginner simplicity against long-term capability. Not so with the Arduino.

This is the basic Arduino language: http://arduino.cc/en/Reference/HomePage
and they have a growing set of high-level libraries for stuff like servo control, LCD display, networking, etc. BUT it is all just a friendly face on top of C! You have full access to the standard C libraries, and you can dip down to inline assembly code if you want. And it is all open source, so you can change or replace or just read & learn from the existing code.

For example, here is the Arduino code to read a PPM signal from an RC transmitter and show the channel values on your computer:

#define numChannels 6
int channelValue[numChannels];

void setup()
{
Serial.begin(57600); // 57.6 kbps
pinMode(3, INPUT);
}

void loop()
{
while (pulseIn(3, LOW) < 4000) {} // wait for PPM frame sync pulse > 4000us
for (int i=0; i<numChannels; i++) {
channelValue[i]=pulseIn(3, LOW); // read next PWM channel signal
}
for (int i=0; i<numChannels; i++) { // send channel values to computer
Serial.print(channelValue[i]);
Serial.print(" ");
channelValue[i]=0;
}
Serial.println("");
}

All you need is a $35 Arduino USB board, and a computer with a USB port. The latest rev of this board is the Duemilanove (2009):
http://www.sparkfun.com/commerce/images/products/00666-03-L.jpg

The software is totally free, and runs on Windows, Mac, and Linux. You write your code, click one button, and the code is compiled, linked, and uploaded to the Arduino board. Super easy. You can use that board for your final project, or you can use it as a chip programmer. Pop out the AVR chip when you're happy with the code, and stick it in your final device. A bunch of companies make boards with different size/voltages/supporting components if you want a pre-packaged solution for deployment.

This is a great way to get started. When you dig deeper, you'll find that all micros provide more-or-less the same universe of functionality, and you select your PIC, AVR, LPC, PSoC, or whatever based on specific application requirements. I'd love to see the Arduino platform extended to other chips.

BTW, if you want to expand into electronics beyond micro programming, I highly recommend "Practical Electronics for Inventors" by Paul Scherz. This is the best book I've found for anyone with an engineering background/mindset who wants to dive into electronics. It covers the important theoretical stuff if you want it, but it mostly covers real components and applications. It does not focus on microcontrollers, though they get a good appendix. :)

Have fun-
Jeff

JohnMuchow
Dec 10, 2008, 04:53 PM
BTW, if you want to expand into electronics beyond micro programming, I highly recommend "Practical Electronics for Inventors" by Paul Scherz. This is the best book I've found for anyone with an engineering background/mindset who wants to dive into electronics. It covers the important theoretical stuff if you want it, but it mostly covers real components and applications. It does not focus on microcontrollers, though they get a good appendix. :)

Have fun-
JeffI also highly recommend this book. It is leaps and bounds ahead of any other book I've seen recommended, especially The Art of Electronics which is touted as the bible but is an incredibly hard read when you just want some practical info so you can start playing around.

But, I'm a PIC guy and highly recommend the PICKit 2 Start Kit and the free PICBasic Pro Compiler. :)
I prefer the MicroCode Studio development environment over MPLAB though.

John

viva_peru
Dec 11, 2008, 09:05 AM
Hello guys,

Thank you so much for all of the input. I did not expect to get so much help. I did not even know that the Arduino chip existed, so I think I have a little more reading ahead of me. It might simply come down to either the PICAXE or the ARDUINO. It seems that the development boards are not terribly expensive, so I am not too concerned about getting it just right from the begining. I am more curious to try a few simple things out to see how much I like tinkering with electronics.

BushmanLA - I hope that you final went well. Although the job market is not the greatest rigth now, I feel that the country needs as many engineers as it can produce if we want to remain a source of innovation.

I will put the books on my Christmas list; my girlfriend will probably just shake her head when she sees the list wondering what she is getting herself into....

Once again, thanks for all of the advice,

Teo

balesse
Dec 11, 2008, 11:43 AM
I will put the books on my Christmas list; my girlfriend will probably just shake her head when she sees the list wondering what she is getting herself into....
Last night my wife asked if there was anything on my list that she would actually know what it was or that didn't have micro in the name. :)

http://adafruit.com/ is a good source for the Arduino stuff.

orraman
Dec 11, 2008, 01:42 PM
Teo,

If you decide on the Picaxe you may care to look at this post. I still have a couple of these bare boards going spare and would be happy to send you one.

http://www.rcgroups.com/forums/showthread.php?t=727280

Dave

spinup
Dec 11, 2008, 02:29 PM
I did not even know that the Arduino chip existed, so I think I have a little more reading ahead of me.Arduino is actually a prototyping platform, not a chip. It basically consists of some high-level code libraries, an IDE that runs on your computer, a bootloader that lets you "program" the chip without a hardware programmer, and reference designs for various boards that provide the supporting components (power supplies, oscillator, USB, status LEDs, reset switch, headers).

The chip in most Arduinos is currently an ATMega168. Here's the datasheet: http://www.atmel.com/dyn/resources/prod_documents/doc2545.pdf. But you can start programming without knowing anything about the chip. :)

-Jeff

HFG
Dec 11, 2008, 07:09 PM
Go with ATMEL instead.