1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Electronics Microcontroller guide / FAQ

Discussion in 'Modding' started by g0th, 15 Apr 2005.

  1. g0th

    g0th What's a Dremel?

    12 Apr 2005
    Likes Received:
    I would like everyone to get in and contribute to this, and suggest things to cover and improvements.

    I think we should focus on the Microchip PIC microcontrollers, and the admittedly obsolete PIC16F84 as a specific example.

    Here's a very rough beginning.


    The PIC microcontrollers use a RISC architecture, with a set of 35 instructions, compared to 100's of instructions for CISC devices like the Motorola microcontrollers, etc.



    So there's your PIC16F84.
    Here's what the pins do:

    Pin no.1 RA2 Second pin on port A.
    Pin no.2 RA3 Third pin on port A.
    Pin no.3 RA4 Fourth pin on port A. TOCK1 which functions as a timer is also found on this pin

    Pin no.4 MCLR Reset input and Vpp programming voltage of the microcontroller.

    During normal operation, you might pull pin 4 high with a resistor, and maybe add a pushbutton switch to ground, allowing you to reset the program.

    Pin no.5 Vss Ground of power supply.
    Pin no.6 RB0 Zero pin on port B. Interrupt input is an additional function.

    Pin no.7 RB1 First pin on port B.
    Pin no.8 RB2 Second pin on port B.
    Pin no.9 RB3 Third pin on port B.
    Pin no.10 RB4 Fourth pin on port B.
    Pin no.11 RB5 Fifth pin on port B.
    Pin no.12 RB6 Sixth pin on port B. 'Clock' line in program mode.
    Pin no.13 RB7 Seventh pin on port B. 'Data' line in program mode.
    Pin no.14 Vdd Positive power supply pole.
    Pin no.15 OSC2 Pin assigned for connecting with an oscillator
    Pin no.16 OSC1 Pin assigned for connecting with an oscillator
    Pin no.17 RA2 Second pin on port A.
    Pin no.18 RA1 First pin on port A.

    To come: Maybe more details of the instruction set, memory map, blah blah blah.

    Programming the microcontroller:

    Very basically, these are the steps involved in programming a PIC:

    i) Write the code, in ASM, C, Basic or whatever language you like that you have a compiler for.

    ii) Compile the code into .hex, using a compiler such as MPASM

    iii) Load the .hex file into a programmer, such as IC-prog, connect up the programmer and the PIC, and program the device.
    MPLAB is the free software suite that includes the MPASM ASM compiler.


    You can download IC-prog here, i highly recommend this one, it supports a huge range of programming hardware and target devices.



    Now you need programming hardware.

    Basically, to program a PIC, you connect it's main power rails (5V) up, raise the MCLR pin to about 12-13V to put the chip in programming mode, and apply serial data to the appropriate pin (typically RB7), synchronised to a clock signal on RB6.

    Here's a simple programmer circuit i use, it works well. Whilst i have an 18 pin socket, i have plug in adaptors used for different devices.



    That PCB drawing is pretty crap i know, sorry about that.

    The circuit is a slightly modified version of the "JDM" serial programmer, named for the guy that originally designed it.

    Unfortunately the operation of the circuit isn't really intuitive for those without much electronics experience, but it is a clever circuit.

    It generates 13V Vpp without an external power supply, and without asking too much of the dodgy "RS-232" interfaces on most PC's which generally only produce voltage levels of about +/- 10V instead of the 12V levels the RS-232 standard specifies.


    This site explains the circuit operation very well.

    Well, that's all for now from me. I'll work on this later.

    Here are some good links:


    Last edited: 15 Apr 2005
  2. NoMercy

    NoMercy What's a Dremel?

    23 Nov 2004
    Likes Received:
    Could you shrink some of those images down (ideally re-do them after zooming out slightly, so the lines/text don't get distorted), for those of us with smaller screens it means having to scroll the page left and right so we can read the text as the page has been streched horizontally to fit the image.
  3. One~Zero

    One~Zero What's a Dremel?

    9 Sep 2004
    Likes Received:
    I think this guide would be a wonderful addition. As pointed out to me only days earlier, Hazer has a great guide to getting started in PIC's as well (http://members.cox.net/sonjarob/TUTs/uP4Idiots.html)
    It will be great to see what other members have come up with for projects, as well as the vast amount of information that can be shared with us "newbies".
  4. iamnafets

    iamnafets What's a Dremel?

    24 Feb 2005
    Likes Received:
    Link up the data sheet, particularly the page with the pin diagram and instruction set. That helped me a lot.

Share This Page