USB with PIC 18F4455
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
USB with PIC 18F4455
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
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 ).
I hope it's all you need to help me.
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
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
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 ).
I hope it's all you need to help me.
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
- Attachments
-
- USB_TEST.fcf
- Flowcode File
- (4.5 KiB) Downloaded 546 times
- Steve
- Matrix Staff
- Posts: 3424
- Joined: Tue Jan 03, 2006 3:59 pm
- Has thanked: 114 times
- Been thanked: 422 times
- Contact:
Re: USB with PIC 18F4455
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.
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.
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: USB with PIC 18F4455
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.
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.
- Attachments
-
- USB_TEST.fcf
- (5 KiB) Downloaded 543 times
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: USB with PIC 18F4455
Hi Benj,
I tried to load your flowcode file but it gives me the following error:
Thanks for your reply !
I tried to load your flowcode file but it gives me the following error:
And if I try to load it I get another one:The file you are loading was made on a newer version of Flowcode (31>20)and may not load correctly. ...
I'm currently using flowcode v3.6.11.53.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.
Thanks for your reply !
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: USB with PIC 18F4455
Hello,
Sorry about that here is a V3 file complete with the mods to the chip configuration.
Sorry about that here is a V3 file complete with the mods to the chip configuration.
- Attachments
-
- USB_TEST.fcf
- (4.5 KiB) Downloaded 487 times
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: USB with PIC 18F4455
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.
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.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: USB with PIC 18F4455
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.
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.
- Attachments
-
- SS1.JPG (67.71 KiB) Viewed 22382 times
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: USB with PIC 18F4455
Awesome
Thanks Benj, I'll definitely try that .
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
Regards,
Nicolas L.F.
Thanks Benj, I'll definitely try that .
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
Regards,
Nicolas L.F.
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: USB with PIC 18F4455
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 :
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.
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 :
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.
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: USB with PIC 18F4455
Hi Benj,
Hope you didn't forget me
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 ).
Hope you didn't forget me
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 ).
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: USB with PIC 18F4455
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: USB with PIC 18F4455
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 !!!
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.
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 !!!
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.
- goldwingers
- Posts: 118
- Joined: Wed Sep 06, 2006 1:22 pm
- Location: London
- Been thanked: 1 time
- Contact:
Re: USB with PIC 18F4455
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
I use the Matrix ECIO 40 doing serious comms to VS2008 and it works like a dream.
Ian
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: USB with PIC 18F4455
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.
You could try changing the PID value by 1 and regenerating the driver and VB code etc and see if this helps.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: USB with PIC 18F4455
Hi Benj,
I don't program in VB and I tried tons of different VID / PID combinations. ^^
Rgds,
Nicolas L. F.
I don't program in VB and I tried tons of different VID / PID combinations. ^^
Rgds,
Nicolas L. F.
- goldwingers
- Posts: 118
- Joined: Wed Sep 06, 2006 1:22 pm
- Location: London
- Been thanked: 1 time
- Contact:
Re: USB with PIC 18F4455
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
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: USB with PIC 18F4455
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: USB with PIC 18F4455
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.
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.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: USB with PIC 18F4455
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: USB with PIC 18F4455
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.
Anyway, thx for help Benj.
Regards,
Nicolas L. F.
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.
Anyway, thx for help Benj.
Regards,
Nicolas L. F.
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: USB with PIC 18F4455
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.
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.
Last edited by Spanish_dude on Sun Jul 11, 2010 6:11 am, edited 1 time in total.
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: USB with PIC 18F4455
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%.
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
Regards,
Nicolas L. F.
So like I said, I tried the test example for the E-Block USB Board EB-055 and it is working... but not 100%.
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
Regards,
Nicolas L. F.
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: USB with PIC 18F4455
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: USB with PIC 18F4455
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.
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.