Tuesday, April 13, 2010

PICMAN

For a long time now I've been wanting to make my own microcontroller-based prototyping board. My original motivation was the unjustified high costs for even the simplest boards (a basic Arduino for $30 - why???) and the challenge of designing something that anyone can make at home within a few hours, with parts that can be cheaply obtained on eBay.

Eventually, I came up with the PICMAN. It is:

  • Based on Microchip's PIC18LF4553 - a 12MIPS microcontroller with 12-bit A/D, plenty of I/O, built in USB transceiver and tons of other coolness.
  • A single-layer PCB design - ideal for DIY toner-transfer etching fabrication.
  • Small form-factor that nicely fits on a solderless breadboard.
  • Can be powered by USB/external 5V/external 8V-35V using on-board 1.5A regulator.
  • Has a reset button, a user button a power LED (blue) and 3 user LEDs (red, yellow, green).
  • Needs zero external components to work.
  • Programmed with a bootloader, making it possible to download a program via USB.
  • Can implement any USB device using Microchip's USB stack.
  • Less than $7 total with easily obtainable parts (not including shipping costs, which are usually low if not free, and assuming that some of the small parts are bought in quantities).
I made two pieces so far, each took a couple of hours' work, requiring some SMD soldering experience. I did the initial programming (bootloader image) with a PICKit2 programmer, after having to struggle a little with the Microchip provided bootloader firmware code. It really works nicely - I like it much better than most Arduinos that cost 5+ times as much and it was really fun to build.
Some ideas that I used in the design:
  • Mount the PIC at the bottom of the board, between the header pins.
  • Use the copper layer for text to make it easier to locate individual pins.
  • Use a mini-B USB connector for smaller form factor (than B) and availability of cables.
Some assorted design/fabrication tips:
  • Edit the final PostScript file generated by Eagle with a text editor, replacing the last number in every line ending with "h" with 2000. This effectively resizes all holes to 0.2mm making them perfect for centering the drill bit.
  • Add a cool logo on the final PDF with Illustrator.
  • Print in 1200DPI on a transparency with a laser printer.
  • Cut board with a large paper Guillotine.
  • Use lamination machine for toner transfer. Let fully cool in air before gently removing transparency. Verify before etching, or otherwise scrape off toner and retry.
  • 1 part HCl, 2 parts 3% H2O2 for etching.
  • Final cutting of the board to shape with tin snips.
  • 0.6mm holes for PIC and ceramic capacitor, 1mm holes for L7805 and all mounting holes (switch and USB jack), 0.8mm holes for the rest.
  • 1k resistor for the green LED makes it just as bright as the other ones with 330 resistors.
  • Solder USB jack first. Have a lot of patience ready.

Here is the schematic, the layout and the final artwork (mirrored). The Eagle files, firmware images and programming software can be downloaded from here. I'll happily share eBay links, where all these components can be bought cheaply, just ask if you can't find any of them.
If anyone has any constructive comments, or has built one and wants to share it, feel free to comment below.

23 comments:

  1. Very nice! I've been thinking about doing this for quite a while but haven't got around to it. Are you running unregulated power in through a pin near the 7805 when off USB?

    ReplyDelete
  2. There are 3 options:
    1. USB power (slider switch in center position)
    2. 5V power from pin labeled "5V" (slider switch away from USB jack)
    3. 8V-35V from pin labeled "8V+" (slider switch close to USB jack)

    Either way, the Vdd pins of the PICMAN (the unlabeled ones right next to "B0" and "E2" can be used as 5V supply for the circuit (up to 500mA from USB, up to 1.5A using L7805).

    ReplyDelete
  3. You wouldn't be willing to share the source code for the software and firmware would you?

    I'm a bit of a source code junkie. Also, I like to see how exactly something like this works, on the code level.

    ReplyDelete
  4. I didn't do much, really.
    You can D/L Microchip's libraries from here.
    My bootloader is just a minor modification on their HID bootloader, to account for the correct button and LED pins. I also needed to throw away the LED blinking code that originally nicely blinks the LEDs when in bootloader mode, since it seemingly caused some timing issues that prevented the device from enumerating correctly. Their USB stack is apparently rather fragile - I've encountered problems with it on PIC32 too.
    Anyway, here's the code if you want to have a look. You can diff it against the original.

    ReplyDelete
  5. How is $30 too expensive for a prototyping board? Peanuts I say! Peanuts!

    Anyway, very nice project. I'd like to see a robot powered with it!

    ReplyDelete
  6. You could do a tinner board by using "wirewrap" sockets. I think all the electronics would fit inside and you will get an access to two others row of holes. You can save even more space by replacing the 5v and the ground traces running on the edge of the board by wire. It's less "clean" but more useful. I am going to do something similar this summer to get rid of my old laptop with a serial port: he is 10 years old! The usb interface is a major plus!

    ReplyDelete
  7. @Simon I also thought about using wirewrap sockets, but they're very expensive (more than the uC). Furthermore, you'd only save ONE additional row, since in this case the pin headers are 0.05" from each side, not 0.1". The PIC is 0.6" and the PICMAN 0.7", so you are left with 2 breadboard rows on each side.

    ReplyDelete
  8. Nice looking project, good job!

    ReplyDelete
  9. It's true :P

    Great Job ;)

    got difficulties making the pcb?

    ReplyDelete
  10. @Simon
    It took me a while to optimize the PCB fabrication process, so you could say I had difficulties. But once I figured out the right process a few months ago, I'm able to make nice boards with high success rates and without ever wasting copper clad board, i.e. if something goes wrong, it can be detected before etching and undone.
    What I've written in the "tips" section pretty much summarizes my cumulative experience, which got me to a level I'm quite pleased with.
    The only thing not mentioned is having to thouroughly scrape the board before transfering the toner with scotch bright, then wash it with some water and dish soap and dry it well.
    I'm not using any other materials that other people have sometimes recommended (alcohol, acetone, etc.)
    I also found that the HCl+H2O2 solution works great, so no need to search for Ferrite Chloride and other exotic etching materials that some people have suggested.
    In fact, the main pain of fabriaction is now the drilling part, requiring precise positioning and good eyes. This board has almost a 100 holes... The 0.2mm etched holes really helps with centering the drill, and speeds up the process a little.

    Good luck!

    ReplyDelete
  11. Hi,

    After loading the bootloader, is there a program like Arduino to put the code insite the PIC?
    I not, what can I use?

    Jose

    ReplyDelete
  12. Here's a sample MPLAB project of a simple program that can be uploaded using the bootloader.
    It can serve as a basis for modifications as it contains some boilerplate code that is essential for the program in order to run correctly alongside the bootloader.

    ReplyDelete
  13. @Jose
    I'm not sure what exactly you mean.
    If you are asking about how to write a program, you need a compiler for PIC18, one option being downloading a C-compiler and the MPLAB IDE from Microchip's site (free).
    In my previous comment you can find a sample project for this environment.
    If you meant something that will make the PICMAN behave like an Arduino clone - I don't have such a program. You might want to look into a project call Pinguino, which seems to do just that (and is otherwise rather similar to the PICMAN).

    ReplyDelete
  14. ניב פינטובApril 17, 2010 at 3:49 PM

    אחלה בלוג.....אין לי שמץ על מה אתה מדבר
    אבל נראה גאוני
    :-)
    תכין 3 כאלה....לכל מקרה

    ניב פינטוב

    ReplyDelete
  15. Hi i like the project / post so much i decided to etch your design for myself, i have the pic 18's and the board readied. can you please tell me specifically all the other components on the board.

    i see you used some capacitors, 3 different types, the ceramic cap by the voltage reg, the surface mount cap and then the " Yellow " cap.

    any links you can send me or post would be appreciated.


    And great job again :)

    ReplyDelete
  16. Thank you!
    The yellow component is not a capacitor, but a 16MHz ceramic resonator.
    You'll also need:
    - Pin headers.
    - 7805 regulator.
    - 2 tantalum caps, 22uF, 3216 size. They are polar - pay attention to the direction!
    - 0805 resistors: 3x330, 1x1k, 1x10k
    - 0805 LEDs: yellow, red, green, blue.
    - 2 tactile switches (buttons).
    - 1P3T slide switch.
    - PIC18LF4553.
    - 0.22uF ceramic capacitor (through-hole).

    A lot of those components can be bought cheaply on Tayda. The rest can be found on eBay. For the LEDs, I recommend you to buy a kit with several colors, they often come in quite handy.
    Let me know how that went!

    ReplyDelete
  17. I cant easily source a 18 mhz ceramic res of ebay in the uk, but i can grab either 10 mhz 20 mhz or 32 mhz, this is for timing on chip correct ?

    so would i need to change the prescaler value if i did ? what do you reccomend ?

    ReplyDelete
  18. It is actually 16MHz, not 18MHz, and those are pretty common. Otherwise, you could definitely use 20MHz, but you'll have to change the configuration bits yourself to match that resonator. Not a big deal, I can help you do that if you need once you have everything set up.

    ReplyDelete
  19. Yes ! Finally; I built my own.

    I flashed it from my computer using my MPLAB ICD2 Device and it now powers on the green led when it comes out of reset. however i have no joy in getting it to reply to your software hid flasher tool, it is at this point that i believe it is to do with the resonator. ( timings of the usb stack on device ? ) anyway

    Its exactly the same as your device with the exception that it has a 24 mhz resonator.

    Can you advise on what i can do to get it working now;


    And also thanks again for your time

    ReplyDelete
  20. Glad to hear!
    What you should do is:
    - Take the code from here.
    - In main.c, line 177, change the PLLDIV from 4 to 6.
    - Build it in MPLAB to get a hex file, preferably in "release" mode.
    - Flash it using your programmer, making sure to flash the configuration bits as well.

    Let me know how that went. Would be happy to see some pictures too and hear about what you do with it.

    ReplyDelete
  21. I admire your projects and ability to hop from PIC to AVR w/o difficulty

    I bought a PicKit2 and have tried my hand at that plus have an Arduino with some good results

    How does your PICMAN compare to a Pickit?
    Toda (or in Danish - tak)
    Tak from an American in Danmark for 42 years.
    jeff

    ReplyDelete
  22. @Jeff
    Thank you!
    When you refer to PICKit, do you mean the evaluation board that comes in the starter kit? Normally, PICKit refers to the programmer I believe.
    The PICMAN is in fact very simple: it just wraps the PIC18F4553 with the bear minimum it needs to work (5V regulator) + a little convenience (LEDs, buttons, USB jack, male pins to fit a breadboard). What I like most about it is its simplicity in this sense. When used with a bootloader, as I normally use it, it can become a really helpful tool. You can, for example program it to act as any USB device, so you can build a working mouse out of two potentiometers within a couple of hours! Or in the case when I needed an AVR programmer - I just made my PICMAN be one.
    You're welcome to try and build one for yourself - it is really cheap and fun.

    ReplyDelete
  23. I always appreciate people who share creativity with us thanks for the post keep posting more...

    ReplyDelete