Page 1 of 2

USB with PIC 18F4455

Posted: Wed Jun 16, 2010 7:10 pm
by Spanish_dude
Hi everyone,

So, a couple days ago I ordered some samples from Microchip and because I'm interested in using the USB functions of flowcode, I ordered an 18F4455.

Thanks to Bens' video "USB Made Simple", I did an easy little program that outputs some strings on the hyperterminal.

The problem is, I can't get it to work and I do not know if it's because of an hardware problem or if it's a software problem or both :shock: :cry:

I attached the flowcode file, it is made on flowcode v3, and I also attached an image of the hardware (made it quickly in paint sorry :mrgreen: ).
I hope it's all you need to help me.

Image

Thank you.

PS: Forgot to mention : the program runs on a 20MHz XT and I never used an 18F4455 before so the config is maybe wrong

Re: USB with PIC 18F4455

Posted: Thu Jun 17, 2010 6:52 am
by Steve
The "+" signal from the USB connector gives out 5V and needs to be unconnected (for self-powered devices) or used to power the PICmicro, etc (for USB-powered devices).

The "VUSB" signal on the PICmicro is a 3.3V output. See the 18F4455's datasheet for more info about this.

The schematics for our USB-enabled products or those from Microchip should help you design the hardware correctly.

Re: USB with PIC 18F4455

Posted: Thu Jun 17, 2010 10:44 am
by Spanish_dude
Ok, thx for your help steve.

I'll look at it later today.

Re: USB with PIC 18F4455

Posted: Thu Jun 17, 2010 11:06 am
by Benj
Hello,

Steve is correct the + signal from the USB should be connected to your +5V supply rail to drive the chip or you should leave it disconnected if you are using an external power supply.

The RC3/VUSB pin should be connected to a 220nF capacitor with the other side of the cap connected to ground. Nothing else should be connected to the RC3/VUSB pin. This can be a ceramic or a electrolytic. Ceramics will be much cheaper and I've never had a problem with them.

You chip configuration was also incorrect. I have updated your program with a correct set of configuration values.

Re: USB with PIC 18F4455

Posted: Thu Jun 17, 2010 1:01 pm
by Spanish_dude
Hi Benj,

I tried to load your flowcode file but it gives me the following error:
The file you are loading was made on a newer version of Flowcode (31>20)and may not load correctly. ...
And if I try to load it I get another one:
Flowcode could not load one of the components in the file because it is not registered on this machine. Install the necessary component before opening this file.
I'm currently using flowcode v3.6.11.53.

Thanks for your reply ! ;)

Re: USB with PIC 18F4455

Posted: Thu Jun 17, 2010 2:33 pm
by Benj
Hello,

Sorry about that here is a V3 file complete with the mods to the chip configuration.

Re: USB with PIC 18F4455

Posted: Thu Jun 17, 2010 5:33 pm
by Spanish_dude
Hi Ben,

Thanks for the flowcode file. It's detected by the PC and I can install the driver.

So far so good, but ...

It's installed on Port COM5.
I run the hypertrm and create a new one.
I choose the COM5, then 19200 (like in your (Ben) video),... then select none.
Ok, it's ready to go.

As you may have seen Benj (or someone else) the PIC sends a string to the PC.
It should be written on the hyperterminal, but nothing happens ??

Thanks for helping me again ^^

Regards,

Nicolas L.F.

Re: USB with PIC 18F4455

Posted: Fri Jun 18, 2010 10:36 am
by Benj
Hello,

Right I have had another quick look at your program and I have spotted something but I dont think it would stop the program from running correctly.

The clock speed in the project options should be set to 48000000 or delays etc will not run at the correct rate.

I changed the clock speed and then downloaded to an ECIO and here is my hyperterminal output.

Re: USB with PIC 18F4455

Posted: Fri Jun 18, 2010 1:21 pm
by Spanish_dude
Awesome :D

Thanks Benj, I'll definitely try that :mrgreen:.

One more question:
I would like to create my own C program that will communicate with the PIC instead of using the hyperterminal. First I would like to turn a LED on or off, I don't think it will be difficult to do.
The problem is, I don't know how to use the USB in a C program. Do you know any lib I could use ?

Thanks again for your help :D

Regards,

Nicolas L.F.

Re: USB with PIC 18F4455

Posted: Fri Jun 18, 2010 5:53 pm
by Spanish_dude
Hi Benj,

I have bad news ... It doesn't work anymore. The PC doesn't recognize the PIC :S

I tried your flowcode file like 10 times or something, with different VID and PID, but nothing happens.

I did test if the USB is initialized and that's ok. (I used the LCD)

I went to my Device Manager and I saw this :
Image

Could the "Serial" be the problem why it doesn't recognize the PIC ?

Hope you can help me solve that problem.

Regards,

Nicolas L.F.

PS: My PC is installed in French, sorry if that makes it more difficult for you.

Re: USB with PIC 18F4455

Posted: Tue Jun 22, 2010 6:11 pm
by Spanish_dude
Hi Benj,

Hope you didn't forget me :lol:

I somehow got it to work again. The PC does recognize the 18F4455, but when I open the hypertrm (just like in the video) I get an error (something like check/wrong properties :roll:).

Re: USB with PIC 18F4455

Posted: Wed Jun 23, 2010 8:45 am
by Benj
Hello,

When using Hyperterminal the serial connection cxan be a little funny. You must first insert your USB device and allow it to enumerate as a serial device. Us device manager to confirm this. Once you have the device connected open Hyperterminal and set up the connection. If you need to unplug the USB for any reason then always remember to disconnect hyperterminal first, this way when you reconnect the USB eg after reprogramming then you can simply click the connect button in hyperterminal. If you are getting an error in hyperterminal then disconnect hyperterminal, reset your USB device, wait for enumeration and then connect hyperterminal again.

If hyperterminal is refusing to work for you then RealTerm is a good alternative.

Re: USB with PIC 18F4455

Posted: Sun Jul 04, 2010 1:40 am
by Spanish_dude
Hi everyone,

I did try this with a 18F4550, but it couldn't program the µC and if it did program it, a window tells me program fail <1><2><3><5>... or something similar.

I went back to my 18F4455, did a couple of programs, tried many different configs, but it never worked.
A simple LCD program didn't work either, I got corrupted chars on it (wrong sync, but config seemed ok ...)

So... I'm at the point of throwing everything out of the window :evil: !!!

May I ask a working flowcode file, the exact XT and maybe a schema if there's something special to do with the PIC.

Thx for your help,

Hope it will work this time (with your flowcode file).

Regards,

Nicolas L. F.

Re: USB with PIC 18F4455

Posted: Sun Jul 04, 2010 10:52 am
by goldwingers
If your PC is not seeingthe virtual com port, try installing the device driver again, My laptop sometimes crashes and need to re install the driver, this takes no more than a couple of Mins.

I use the Matrix ECIO 40 doing serious comms to VS2008 and it works like a dream.

Ian

Re: USB with PIC 18F4455

Posted: Mon Jul 05, 2010 3:45 pm
by Benj
I have had problems using a USB device with the same VID PID combination but with a different device name.

You could try changing the PID value by 1 and regenerating the driver and VB code etc and see if this helps.

Re: USB with PIC 18F4455

Posted: Tue Jul 06, 2010 4:39 pm
by Spanish_dude
Hi Benj,

I don't program in VB and I tried tons of different VID / PID combinations. ^^

Rgds,

Nicolas L. F.

Re: USB with PIC 18F4455

Posted: Tue Jul 06, 2010 5:00 pm
by goldwingers
By the look of your serial ports on the PC it has lost the matrix multimedia driver for the com port - Nothing to do with VB2008

Re: USB with PIC 18F4455

Posted: Tue Jul 06, 2010 11:46 pm
by Benj
Which version of windows are you running and which section of the device manager is that serial component in. It looks like a part of the windows serial driver has failed maybe. I will shortly be doing another demo that includes the serial and slave devices. Maybe you will have more success with the slave device. This is nice and easy and the example comes with VB example code.

Re: USB with PIC 18F4455

Posted: Wed Jul 07, 2010 12:25 am
by Spanish_dude
Hi Benj,

I'm running Windows XP and I'm doing exactly the same thing as the video.
When I did get it to work, but nothing on the hyperterm, the PIC was in the COM/LPT section (COM 5 or 6).

Have you ever tried libusb ?
I'd like to use that to communicate with my PIC (didn't find another C usb library).

I'll wait for your videos, hope it will work after seeing them ^^.

Thx,

Nicoals L. F.

Re: USB with PIC 18F4455

Posted: Wed Jul 07, 2010 1:59 pm
by Benj
Hello,

I did try Libusb on my Windows Vista PC back when I was using Vista anyway and the Libusb stopped Vista from booting. In the end I had to re-install. Thought it was maybe something I had done so I repeated the process and again had to re-install, maybe they have fixed this in the mean time.

The VB method for talking to the slave component as shown in the examples is very useful and allows for a high throughput of data. I have written several articles on this which are available from the articles section of the forum if your interested.

Re: USB with PIC 18F4455

Posted: Thu Jul 08, 2010 12:00 am
by Spanish_dude
Hi Benj,

Ok, I'll take a look at your articles when I have some spare time, I'm trying to use QT.

I'd like to use it with libusb and the PIC to make a "cool-looking" PC program to control some servo's or some LED dot matrix or ...

I hope, that one day, I'll be able to connect my PIC (or other microcontroller) to my PC trough USB connection. :lol: :mrgreen:

Anyway, thx for help Benj.

Regards,

Nicolas L. F.

Re: USB with PIC 18F4455

Posted: Sat Jul 10, 2010 5:14 pm
by Spanish_dude
Hi,

I found the test example for the E-Block USB Board (EB-055 I think). I'm going to try that.

Regards,

Nicolas L. F.

Re: USB with PIC 18F4455

Posted: Sun Jul 11, 2010 6:10 am
by Spanish_dude
Hi ,

So like I said, I tried the test example for the E-Block USB Board EB-055 and it is working... but not 100%.

Image

This is the error I get when I instal the driver.
I tried different VID/PID combinations but still same error and I can't select the microcontroller (COM 7) in the hypertrm.

Any ideas on how to solve this :s ?

Sorry, it's in french :mrgreen:

Regards,

Nicolas L. F.

Re: USB with PIC 18F4455

Posted: Mon Jul 12, 2010 8:42 am
by Benj
Hello Nicolas,

I have received the error code 10 on a Vista / Win 7 PC when I changed the size of the USB data buffers. Have you done any code customization or are you using the component as standard? Which version of Flowcode are you running? Could you post up your Flowcode project file and the output C file.

Re: USB with PIC 18F4455

Posted: Mon Jul 12, 2010 8:41 pm
by Spanish_dude
Hi Benj,

I didn't change the code. I compiled the test example directly. I followed the different steps in the word document.
I did change the VID/PID.

I'll attach the files when I'm on my other PC (I don't use this one with flowcode).

Btw, I'm using the latest (pro version) flowcode v3 update.

Regards,

Nicolas L. F.