Monday, August 10, 2009

PIC 18f14k50 based USB WISP programmer

Introduction
Today the description of a USB WISP programmer. A while back I had some trouble with my ICD2 clone, therefore I decided to make a WISP programmer. Since I've written the USB libraries for JAL(lib) and because I just had ordered a tube of 10 PIC18f14k50, I decided to redesign the original WISP so it uses the PIC18f instead of the the PIC16f648 (which I did not have in my junk box), and use the USB-Serial library so I can still use the various host applications but I can plug it in directly to the USB port. The additional benifits are:

  • Very cheap (just a PIC18f14k50 + resistor and capacitors, total costs ~5 Euro)
  • Have a fast serial connection
  • Can use exsisting WISP host applications (like Rob's XWISP2)
  • Can be directly powered from the USB port (no external power supply needed)
  • When adding a 3.3V regulator, board can also be used to program LF devices (if Vpp = 9v)
  • Added an additional connector for future use, like JTAG & I2C and RS-232 TTL

The schematic is very straigtforward, the blue boxed areas contain the optional section of the USB WISP programmer





I've made a few modifications to the original design, first the Target power is controlled by a PNP transistor, which acts as switch (so target power can be turned on/off), because USB 5v does not like to be short circuited for a short period, as is done in the WISP 648. In addition I've added a PNP transistor to control the Target VPP line, this is for future use.

I also made a small PCB, however, Wouter van Ooijen (the designer of the Wisp 648 programmer, see www.voti.nl) asked me not to publish the PCB layout. So don't ask me for it, if you want to build this project you have to design you own PCB, if you can't, buy a Wisp 648 kit from Wouter. The assembled PCB is depicted below:




The Source code
I just made minor modifications to the original source code (see www.voti.nl). The changes are:
  • Include usb_serial library
  • Change UART functions, so they send and receive chars from the USB library
  • Tune the timing delays (becuase effective speed is raised from 20->48 MHz)
  • Had to adapt the HEX<->ASCII function, because the original code still uses some inline assembly which did not work properly for the PIC18f
  • Call USB-Flush in the main routing

There still some work left, i.e. the port trough function is not working yet, the advantage of this design is the the UART can be used (even the polarity inversion of the UART signals can be programmed with the PIC18f14k50), so pass trough can work with speeds up to 115200 baud.
The JAL source code is uploaded in the JALLIB google code file download section, http://groups.google.com/group/jallib/files

Results
The USB Wisp is operation for a couple of weeks, so far it worked flawlessly. With a small change in the XWISP2 configuration file, I was able to program the PIC14k50 as well. But of course, there is a big discalaimer, I only have a couple of PICs, so the solution is not tested extensivly, thus if you want a good and robust PIC programmer I advice you to buy or build the original WISP 648.

Conclusion
This small exerise shows the strenght(s) of JalV2 and Jallib, it shows how easy it is to port a large application from a PIC16f devices to a PIC18f device and that only a little effort is required to move from a RS-232 (UART) communcation interface to a USB (serial) based communication interface.






21 comments:

  1. And, as a downgrade, can be used a 16F690 (identical pins?) with serial instead of USB...

    ReplyDelete
  2. If you designed your own schematic, why can't you provide a PCB from your own work (provided *you* do want this) ?

    ReplyDelete
  3. Is a nice alternative to Pickit2

    ReplyDelete
  4. looks really nice, thank you...

    ReplyDelete
  5. interesting huh!!! i will have to try this to my one and only PIC18F14k50.

    may I request if, not to much to ask, a hex file?

    I'm really new to JAL. never have tried though.

    Also I'm confused which source i should be looking on the source link given.

    Thanks.

    ReplyDelete
  6. uploaded hex file to:
    http://groups.google.com/group/jallib
    (file) usb_wisp_code_and_hex.zip

    ReplyDelete
  7. ^thank you very much.

    i will share my thoughs later when I test it... once again, thanks ;D

    ReplyDelete
  8. I recently came accross your blog and have been reading along. I thought I would leave my first comment. I dont know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.


    Susan

    http://carusbcharger.com

    ReplyDelete
  9. hello i am using a pic18f14k50 usb installed microcontroller . I have download the hex file to the microcontroller but when i connect it to the usb it shows a error message ' One of the USB Device attached to the computer is malfunctioned ' I have tried everything please tell me wat to do now.......

    thank you!

    ReplyDelete
  10. hello what is the small change in the XWISP2 configuration file? please tell me wat to do now tanks

    ReplyDelete
  11. Hi Albert,

    I would also be curious of the config file changes for 14K50. Could you share it with us?

    Thanks,
    Victor

    ReplyDelete
  12. Hi Albert,

    I'm using the schematic above as a base for a simplified version with a few modifications.
    However, I didn't understand the purpose of some of the components on the schematic.
    Could you explain where transistor Q3 is needed for and what it does?
    The other question is about Coil L1. Is this one needed if I remove both optional circuits?

    http://jallib.blogspot.com/2009/08/pic-18f14k50-based-usb-wisp-programmer.html

    Kind regards,
    Bjorn

    ReplyDelete
  13. The both optional circuits being 5Vcc and 3.3Vcc regulators? Then, the coil L1 is needed as you get power from USB.

    In schematic, the first optional block must not include the L1 coil and C8 capacitor. In other words, if you exclude 5V and 3.3V regulators, the coil L1 and C8 will remain.

    Regarding to Q3, as I understand, is described here:

    "I've made a few modifications to the original design, first the Target power is controlled by a PNP transistor, which acts as switch (so target power can be turned on/off), because USB 5v does not like to be short circuited for a short period, as is done in the WISP 648."

    In short words, you can power (5Vcc) your target board from this switch, as in Pickit2.

    Q4 is not used in actual firmware but is designed to do the same on VPP as Q3 is doing on VDD - if I understand correctly.

    ReplyDelete
  14. Hi Bjorn,

    >Could you explain where transistor Q3 is needed >for and what it does?
    Q3 is not used right now, but I made it this ways to use the WISP for other devices, so you can leave it out.

    >The other question is about Coil L1. Is this
    >one needed if I remove both optional circuits?

    Yes you can leave it out, it is just for safety to get a clean(er) power signal.

    Albert

    ReplyDelete
  15. I could not save this file from the USB firmware again could indicate the path of the firmware. grateful

    ReplyDelete
  16. Your best bet for an open source usb pic programmer would be
    http://usbpicprog.org/

    ReplyDelete
  17. Hi, where I can download the project? I can not find that page! thanks

    ReplyDelete
  18. I cannot find the usb_wisp_code_and_hex.zip. Can someone share me the file.

    ReplyDelete
  19. Great idea, except that... The files are not there!

    ReplyDelete
  20. Is there someone who has the HEX files? Thanks

    ReplyDelete
  21. I am learning about this devices and find this one cool.
    Booth There aren't ASM Files and HEX files.

    Can say one sent to me please.

    duti_e@hotmail.com

    ReplyDelete