Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I am a computer sciences student looking to do some PIC microcontroller programming for some small home projects . I am fluent in C/C++/C#/Java and i also have an understanding of programming microprocessors(ALP - the 8086 ) . I plan on building a USB interface to control some lighting and a motor in one of my projects . I have the circuit components and the layout planned out . I have the PIC 18f4550 in mind and I have already downloaded the libraries from the microchip website . The only problem is I don't know what code to write for this . The libraries are huge and I don't really need to go into all the details(that's what I think) . I tried finding other resources but it appears that the PIC is old and most of the links off of Google have only been dead ends . Does anyone know of a blog , a video , or anything that could help me get started ? I'm hoping it's possible to do this using one of the languages I mentioned above .

share|improve this question
5  
Did you take a look at the examples provided with the Microchip usb library? When you google, try not to search for only PIC18f4550, but for PIC18f USB examples in general. The PIC18 devices are similar enough to transfer (most of the) USB code from one to another. –  PetPaulsen Jul 6 '12 at 15:44
1  
If you don't mind not coming up the USB learning curve, using a FTDI USB chip/connector/cable may be the easiest way to get a PIC up on USB. ftdichip.com/FTProducts.htm and digikey.com/PTM/… –  kenny Jul 6 '12 at 20:07

2 Answers 2

You should first take a look at the examples provides with the Microchip USB Framework (part of the Microchip Application Libraries). The docs give some descriptions on the individual demos. The helpfile itself is in my opinion a little bit hidden, but you can find it at <YourInstallLocation>\Microchip\Help\MCHPFSUSB Library Help.pdf

To get started and depending how you want your device to appear on the host pc, I would go through the code of the following demos:

  • Device - CDC Basic Demo
  • Device - HID - Custom Demo

Both state in the description that they are able to run on the 'Low Pin Count USB Development Board', which is using a PIC18F14K50. The PIC18F4550 should be similar enough to allow you to transfer most, maybe even all, of the code.

Another approach, as kenny recommended, is to use a IC that handles most of the USB stuff for you. A popular choice are the ones from FTDI. When you take the FT232R, you hook the UART of your microcontroller to the IC. Writing code to transmit / receive data is now much simpler.

Similar to the FT232R is the IC MCP2200 manufactured by Microchip. Which one you choose is a matter of taste (and maybe driver support).

share|improve this answer

Building a PIC18F USB Device

I've used his C# library and it works very well and it's easy to use. It can be easily expanded or modified to meet whatever needs you have. His tutorials are also very thorough and easy to understand and he usually replies quickly on the forums if you have questions.

As PetPaulsen already mentioned, look through all the code and sample projects provided by Microchip. You do not need to understand how the USB protocol works. You really only need to modify the main file and usb_descriptors file to get things working.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.