P18f4550 MicroC USB example problem

General discussion on mikroC.
Post Reply
Author
Message
Klemen
Posts: 4
Joined: 23 Feb 2010 18:59

P18f4550 MicroC USB example problem

#1 Post by Klemen » 23 Feb 2010 19:10

Hi

I have PIC 18f4550 and i want to use it for input device for my computer. I tried to programm my pic with sample program witch I have found in microC (under Help->USB HID library) but it seems that the sample program is not working. I have easypic4 and i'm programing pic via PicFLASH [v7.13]. What am I doing wrong?

I have 8mhz oscilator on easypic.

Thanks, Klemen

dariush_abbasi
Posts: 120
Joined: 11 May 2008 18:47

Re: P18f4550 MicroC USB example problem

#2 Post by dariush_abbasi » 26 Feb 2010 22:41

Hi,
I've checked HID-library and it works fine.
Check the manual for easypic4, maybe useful.
By the way, you must compile the program with 48M.
Be successful.

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: P18f4550 MicroC USB example problem

#3 Post by tihomir.losic » 27 Feb 2010 11:31

Klemen wrote:Hi

I have PIC 18f4550 and i want to use it for input device for my computer. I tried to programm my pic with sample program witch I have found in microC (under Help->USB HID library) but it seems that the sample program is not working. I have easypic4 and i'm programing pic via PicFLASH [v7.13]. What am I doing wrong?
Hello,

please, can you check JP9 jumpers on your board (they should be on the right hand side for this example)?

If error persists, feel free to contact me.

Best regards,

Losic Tihomir
mikroElektronika [Support team]

vikky
Posts: 19
Joined: 11 Jan 2011 10:30

Re: P18f4550 MicroC USB example problem

#4 Post by vikky » 13 Jan 2011 11:49

Sir,

I have built an USB circuit using PIC 18f4550.I used micoC and 8MHz crystal.it worked fine in the beginning.After sometime no device was detected in Windows.Can anyone help me to solve this problem.I am attaching the schematic and program

Thank you

Vikky
Attachments
FINAL USB KEYBOARD PGMv1.1.zip
(97.48 KiB) Downloaded 359 times
Schematic.zip
(13.2 KiB) Downloaded 288 times

w7ami
Posts: 111
Joined: 21 Aug 2008 00:08
Location: Idaho

Re: P18f4550 MicroC USB example problem

#5 Post by w7ami » 16 Jan 2011 17:49

Go to this site and download USBDeview.
http://www.nirsoft.net/utils/usb_devices_view.html
Unplug your PIC from the USB port and then run USBDeview. Delete any instances of your device. Now plug your PIC back into the USB port and if it is working it should detected by windows and the drivers re-installed.

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: P18f4550 MicroC USB example problem

#6 Post by Dany » 16 Jan 2011 18:57

vikky wrote:I have built an USB circuit using PIC 18f4550.I used micoC and 8MHz crystal.it worked fine in the beginning.After sometime no device was detected in Windows.Can anyone help me to solve this problem.I am attaching the schematic and program.
Hi, I see some issues in the circuit diagram:
- C8 and C9 should be both 220 nF (Vusb)
- C1 should be 100 nF
- Between Vdd and Vss there should be somewhere a capacitor (elco) of approx. 100uF
- C6 and C7 should be surely not 1 nF, but much smaller, 15pF..27 pF (crystal).
- The PIC in the schematic is a 16LC64 in stead of a 18F4550.

Most probably the above issues are not as such present in the actual test board (it has worked...), only in the schematic.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

w7ami
Posts: 111
Joined: 21 Aug 2008 00:08
Location: Idaho

Re: P18f4550 MicroC USB example problem

#7 Post by w7ami » 16 Jan 2011 20:21

Dany makes some excellent comments. I did not look at the schematic closely before and have some additional comments.

Resistors R3 and R4 should be eliminated. There are internal pull up resistors in the PIC for these lines and it is best to use them.

Resistors R8 and R9 should also not be used. Not sure why they are there? You should connect the D+ and D- lines directly to the USB connector.

You really should have a 100 nF capacitor to GND at each VDD pin. Keeps these leads as short as possible.
- Between Vdd and Vss there should be somewhere a capacitor (elco) of approx. 100uF
That is much to big if you are powering your device from the USB port. The USB specification limits the total inrush current and 100 uF would far exceed that limit. Use a value of between 5 and no more than 10 uF and you will be right.

I prefer not have an LED tied directly to the VDD line from the USB connector. I always put two LEDs on my boards both driven through a current limit resistor from pins on the PIC. I toggle one LED at about 500 mS from an interrupt to show that the PIC is running. The other is turned on when the PIC is successfully enumerated by the host PC and stays on as long as the connection remains. That way I can tell at a glance if the PIC is running and is connected to the host PC.

I also use a small USB hub that has LEDs to indicate when a device is actively connected on each port sitting next to my project to connect the device to the computer. If I do something really stupid and damage the hub it is easily replaced at low cost. The connection light is a quick and cheap indicator that the my PIC has successfully connected to the host PC.

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: P18f4550 MicroC USB example problem

#8 Post by Dany » 16 Jan 2011 20:37

w7ami wrote:
- Between Vdd and Vss there should be somewhere a capacitor (elco) of approx. 100uF
That is much to big if you are powering your device from the USB port. The USB specification limits the total inrush current and 100 uF would far exceed that limit. Use a value of between 5 and no more than 10 uF and you will be right.
I did not know that. Thanks! :oops: :oops:
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Post Reply

Return to “mikroC General”