Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

First Microcontroller

  1. Aug 16, 2009 #1
    Hey Guys

    I have been experimenting with electrical engineering for the past few months and I now am interested in buying my 2nd micro-controller. My first was Basic Stamp II but that got friend and was not really suitable. I have read several articles on microcontrollers but am confused where to buy my first one. I am interested in only buying a controller itself and a programmer for it. I want to test it on the protoboard I already have. If possible could you guys suggest a controller and the company where to get it. The programming language and whether serial or usb is not an issue. Thanks
  2. jcsd
  3. Aug 16, 2009 #2
    Welcome to PF JCoder. My first controller was the PIC16C84 which has been replaced by the PIC16F84. It's still a good part to start out with because there's been a lot of books and tutorials written for it. I usually order my parts from DigiKey.com. As for the programmer, I've always used the Pic Start Plus. But you can get less expensive programmers. I think Digikey sells programmers also.
  4. Aug 16, 2009 #3
    Thanks TurtleMeister. One thing I did forget to mention is I have read that certain microcontrollers have GCC assemblers/compilers associated with them. I am using the Linux Kernel so for ease of programming which controllers are under this category?
    Last edited: Aug 16, 2009
  5. Aug 17, 2009 #4
    I only have experience with the Microchip PICs. I use MPLAB IDE which runs under Windows. I don't know if it will run on Linux. I did a quick qoogle search and it appears some people are using it on Linux but I don't know what's involved. You can use the C programming language or Microchips assembly language with MPLAB. You can download MPLAB from the Microchip web site. It's free, and so is the data sheets for any chip they make.
  6. Aug 17, 2009 #5


    User Avatar
    Science Advisor

    There's a freeware GCC-based C compiler suite for the ATMEGA suite:

    There is apparently a Linux-based tool chain for ATMEGA compilation, but I have yet to use it.

    I, too, started out with PICs (the fact that they give away free samples, and that my school used them as the default microcontroller for the project course led me there). However, they are processors which are very much designed to be programmed in Assembly. Though C compilers do exist, and you can even get Microchip's variant, with minimal crippleage after the trial period is over (it's intended for student / hobbyist use, so as long as you don't turn a profit, you're okay). I believe this philosophy (of assembly-oriented design) may be changing with their new line of PIC32s.

    In contrast, ATMEGAs were designed to be programmed in higher-level programming languages. As well, the cheapest (and most reliable) ATMEL programmer out there is the official ATMEL AVR ISP mkII (note that it does not have in-system emulation / stepping abilities):

    In contrast, the PICStart (basic programmer) is quite a bit pricier, though the ICD (debugger + programmer) is around the same price as the ATMEL one. Some of the other (cheaper) programmers out there don't work as reliably with the newer chips (in my admittedly-limited experience with a sample of 3 PIC programmers). Just Google PIC programmer for some of them. There's a very basic JDM-style one that someone made long ago, and which has since been copied / emulated / improved upon:
  7. Aug 19, 2009 #6
    So my understanding is any PIC programmer will work with any PIC microcontroller? Also, these programmers, what exactly is the definition of them. I have seen some where they plug right into a protoboard and other others that require the microcontroller to be plugged into it. Also, what is the best price I can expect to get a basic programmer for the PIC.
  8. Aug 19, 2009 #7


    User Avatar
    Science Advisor

    If you don't need great speed and can program in Basic, have a look at Picaxe chips.
    The language is very much like the Stamp but the chips are nowhere near as costly.

    The chips cost about $5 to $20 (depending on type) and the programming editor is free. The cable from your computer costs about $10 to make or you can use an old serial mouse cable.

    The chips have an impressive range of tools built in and they are very simple to get going. Lots of fun too.

    Have a look at :
    if you are in the USA

    Get the free software and chips from :

    These chips just go in normal IC sockets so you don't need the expensive "development kits". Just wire them up yourself.
  9. Aug 19, 2009 #8


    User Avatar
    Science Advisor

    I'm guessing this is just a PIC with a serial bootloader installed. In which case, somebody's probably figured out a way to modify it to accept any arbitrary compiled code. If someone else you know has a 'real' PIC programmer, they can install a bootloader for you, and let you program via a serial port.
  10. Aug 19, 2009 #9


    User Avatar
    Science Advisor

    Yes, that is right. The chips still have the original PIC numbers on them, but the bootlooader lets you do easy programming without the bit bashing of assembler. They cost about the same as the original chips because of bulk buying.
    The serial bootloader is not available though. That is Rev-Ed's property.
    Easy programming reduces development times so serious programs can be produced very quickly.

    Here is a typical fragment of code from a NiMH battery charger program. The comments at the right are ones I just added.:

    Start: '................label

    Readadc10 0,w1 '...............read the 10 bit ADC port

    pause 1000 '.................wait one second
    high portc 5 '..................put 5 volts on one pin
    pause 1000 ' ..............wait one second
    low portc 5 ' .................put 0 volts on the same pin

    if w1>1000 then start '.........check for overvoltage

    w3 = w1*49/100 '........integer arithmetic
  11. Aug 19, 2009 #10
    I've had some experience with the PICAXE chips and I really like them. They are very easy to use and being able to program directly from USB port to chip is pretty spiffy too. If I'm working on a project that doesn't require any super fast computation or anything fancy I always use the PICAXE chips since it usually cuts the build time in half.
  12. Aug 19, 2009 #11
    Okay I decided I want to get the PIC16F84. I am confused though on where to buy a programmer for this chip. I dont feel comfortable making one myself at this time. Can anyone provide a link to a site they trust to buy one?
    Last edited: Aug 19, 2009
  13. Aug 19, 2009 #12


    User Avatar
    Science Advisor

    Here is a link to give you an idea of how simple these programmers are.


    Note that this chip requires a high voltage to program it.

    The first reply above gave some sources for programmers.
    Welcome to PF JCoder. My first controller was the PIC16C84 which has been replaced by the PIC16F84. It's still a good part to start out with because there's been a lot of books and tutorials written for it. I usually order my parts from DigiKey.com. As for the programmer, I've always used the Pic Start Plus. But you can get less expensive programmers. I think Digikey sells programmers also.

    I used these chips for a while, but I was forever unplugging them from the programmer to try the program in a test circuit.

    If I dare mention it, the Picaxe allows you to use the "debug" command which puts a dump of variables on your computer screen as the program runs. So, you can put this command somewhere in the program where you are getting odd behaviour and see what is happening.
    You can put the chip in-circuit and program it there with just two resistors left in circuit for programming.

    Here are some other chips you could consider:

    The 8-pin, 12-bit 12C508 device is arguably the best-selling microcontroller of all-time, but has now been superceded by the 14-bit 12Fxxx range.
    The 8-pin, 14-bit 12F675 is one of the new breed of PICmicros® that incorporates advantages such as ADC, comparators, on-chip EEPROM and of course Flash re-programmability.
    The 18-pin, 14-bit 16F628A is the sucessor to the ever popular, but now very outdated, 16F84 device. The 16F628A offers 2KBytes of code space, 128Bytes of RAM, on-chip EEPROM, comparators, USART and hardware PWM.
    The 40-pin, 14-bit 16F877 is the Rolls-Royce of the 14-bit core devices and contains 8KBytes of code space, 368Bytes of RAM, 256Bytes of on-chip EEPROM and more on-chip features than you can shake a stick at - such a USART, HPWM, etc, and is the obvious choice for any new design.

    There is a company in England that makes a free Basic programmer for some of these chips:

    However, the Picaxe is a far better choice. :)
    Last edited by a moderator: Apr 24, 2017
  14. Aug 19, 2009 #13
    Okay I will go with the PICAXE for now due to its simplicity for me to get started. I live in the US and see it is a European based company. Has anyone had problems with shipping before through them? And geez Fed EX is mad expensive over there for a shipment to the US.
  15. Aug 19, 2009 #14


    User Avatar
    Science Advisor

    Have a look at :
    if you are in the USA

    But download the software from the British site.

    You will find there are about 10 different Picaxe chips. They are named according to the number of pins on the chips. So a Picaxe 14 is in a 14 pin 0.1 inch spacing DIP case.

    I would download the free software first as this has a lot of documentation built into it. You can find comparison data there and also the pin connections of the various chips.

    The Picaxe 14M is probably a good starter chip. It has 5 inputs and 6 output pins. 2 of the inputs are also A to D converters.
    The chip can be reconfigured so that 3 of the outputs are also A to D input converters.

    Here is a summary of the commands for the 14M: (these are described in detail, with examples, in the documentation)

    Output ..........high, low, toggle, pulsout, let pins =
    ADC ..........readadc
    I/O ..........Config. input, output, reverse, let dirs =
    PWM ............pwm
    Sound ............sound
    Input .............if...then, readadc, pulsin, button
    Serial ...........serin, serout
    Program Flow .........goto, gosub, return, branch
    Loops ................for...next
    Mathematics .............let (+, -, *, **, /, //, max, min, &, |, ^, &/, |/, ^/ )
    Variables ...............if...then, random, lookdown, lookup
    Data ................memory eeprom, write, read
    Delays ..............pause, wait, nap, sleep, end
    Miscellaneous ..........symbol, debug

    PICAXE-08M/14M/18M Additional Commands:
    Input .............count
    ADC ............readadc10
    Interrupt ...........setint
    PWM .................pwmout
    Music .................play, tune
    RAM .................peek, poke
    Servo ................Control servo
    Infrared ............infrain2, infraout
    Temperature ...........readtemp, readtemp12
    1-wire Serial No ............readowsn
    Clock Frequency ...........setfreq
    Last edited: Aug 20, 2009
  16. Aug 20, 2009 #15
    Last edited: Aug 20, 2009
  17. Aug 21, 2009 #16
    I placed my order for the PICAXE-18X through Solarbotics. This is truly a noobish question but why are there so many programmers out there for only one chip? Also, I believe a low voltage programmer means power must be supplied externally. Is this correct?
  18. Aug 21, 2009 #17


    User Avatar
    Science Advisor

    The Picaxe 18X is a great chip. It has heaps of memory and plenty of useful commands.

    The different Picaxe chips use different programming boards because they have different numbers of pins and different pin arrangements. The Picaxe 18X, for instance, has a reset pin which the smaller chips don't have. So, even if you don't use a reset switch, this pin must be held high with a 4.7K resistor or similar.
    Different makers produce programming boards, but they are fairly standard for a particular chip.

    Yes, you do need a 5 volt power source. Most will run on lower voltages, but do not exceed 5 volts. Currents are small. Probably about 20 mA, so a modest power supply is OK provided you can control it to not go above 5 volts. I mount a 5 volt regulator on the board and all power goes through that, so I can't make a mistake and feed a higher voltage in to the chip.

    4.5 volts from 3 AA cells is OK too, but if you are using the A to D converters note that the reference voltage for this is the power supply, so it needs to be steady and whatever it is will be divided down to 1024 increments to give the final result.

    Hope you downloaded the Programming Editor OK. It is about 20 MB I think but a lot of this is documentation and program examples. They put out updates regularly but these are smaller than the main download.
    The documentation of commands etc is as good as it gets with a clear explanation and then some examples.

    You need to know about variables. These are restricted to the following:
    B0 to B13 for byte sized variables. These can have values of 0 to 255.
    W0 to W6 for word sized variables. These can have values of 0 to 65535.
    You can have symbols if you want to deal with something easier to remember.
    W0 is actually B0 and B1 combined and so on for the other word variables. So if you use W1 you can't use B2 or B3.

    All calculations are in Integer form. So 9 divided by 4 is 2. However, 900 divided by 4 is 225 so you can get around this if you want to. Just imagine the decimal point.

    Input / output pins numbers do not correspond with normal pin numbers. For example, input pin 1 is actually on physical pin 18 on your chip. These pinouts are on about page 8 of Picaxe_manual 1.
  19. Aug 21, 2009 #18
    My first micro was a Zilog 2650 CPU, circa 1978 I think it was expandable to 2k x 8 2114 static RAM's, and sported a 1Mhz clock (or less). A 20Ma current loop and baudot code allowed it to communicate with a Model 28 Teletype, it also ment you were able to store code with punched paper tape ! :).

    Second was a DREAM 6800 that had GRAPHICS on a TV and a keyboard (alpha-numeric).

    I really like the ATMEGA range and the other offerings that ATMEL produce, there are alot of free development tools, dedicated web sites for support.

    The ATMEGA range have good speed, a high number of internal counter/times, Compare and Captures, and interrupts. All in all they are very good for science and physics work, or any controlling type applications.

    The new SPIN PROPELLER 8 core, 32bit CPU's with common memory are very interesting as well, but ive not used them yet.

    And HIHI VK6KRO, I used to be VK2N(something), VK2K(something), VK1DRL.
    73 OM
  20. Aug 21, 2009 #19
    My order did come today. Haha I meant to ask why for example a specific PIC micro controller has 5 different ways the programmer can be designed. What is the difference between these programmers? Oh and on the topic of programming. Thank you for the advice. I am not as concerned with programming though as I have done projects in Operating System Development and several other areas. This would just be my first real time choosing which individual hardware to buy.
  21. Aug 21, 2009 #20


    User Avatar
    Science Advisor

    The actual programming circuit only involves two pins on the chip and two resistors.

    However, the kit might give you a power supply, thermistors, LDRs, sound output device, a breadboard vs a printed circuit board, a switch to switch outputs to the computer serial port etc. See what is being offered if you want to go that way.
    Some will sell you the software on a CD when it is free for download.

    I can get a type of board with a grid of holes and each hole has a ring of copper track around it. I get computer header pins and put columns of these alongside the chip and connect the pins with soldered wires.
    I can then see where any connections go.
    I prefer this to using breadboards, but breadboards are necessary for computer classes, of course.
    Mostly, I just program the chip on the board it is going to be used on permanently.

    Some of my chips have been reprogrammed dozens of times while playing with them.

    There are very good support groups for Picaxe at Rev-Ed in England and also Yahoo Groups.

    If you have done any programming before, you should find these very easy, but it still takes some experience to get used to the syntax. Fortunately, there is a syntax reference built into the Programmer so you can see where the commas go.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook