USB with PIC 18F4455

Any general or miscellaneous queries that do not fit into the other forum catagories

Moderators: Benj, Mods

User avatar
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

Post by Benj »

Great ok thanks looking forward to the files.

Spanish_dude
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

Post by Spanish_dude »

Hi Benj,

First of all, sorry for the late reply.
As you asked, I attached the .fcf and .C file.

Regards,

Nicolas L. F.
Attachments
USB.c
(13.08 KiB) Downloaded 425 times
USB.fcf
Flowcode File
(6 KiB) Downloaded 465 times

User avatar
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

Post by Benj »

Hello Nicolas,

I've had a good look through the C code that your Flowcode is producing and it appears to all be correct. I have also compiled your program here and it is producing identical code and that code is running on the test machines here. Have you tried the device on another PC to see if it is just the one PC that seems to have this problem?

Spanish_dude
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

Post by Spanish_dude »

Hi Benj,

I did not try it on another PC. The one I'm using with flowcode has windows XP.
The other PC have windows vista.

I'll try on windows vista later today.

Regards,

Nicolas L. F.

Spanish_dude
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

Post by Spanish_dude »

Hi Benj,

Great news, it's working on my windows XP PC.
I think that you need to restart the PC after installing the driver else you'll get an error, like I had.
I did not change the code, I just connected the PIC to the PC and saw that the PC didn't show me any error.
I opened hyperterminal, but changing the bits per second to 9600 gave me an error.
So I went to the device manager and looked at the parameters of the COM7 (pic serial usb) and changed the bits per second from 19200 to 9600, then reseted the pic.
I opened hyperterminal again, changed bits per second to 9600, flow control to none, then I wrote my name an saw it on the LCD screen.

Everything I'm writing in the hyperterminal is written on the LCD screen :mrgreen: .

I'm going to uninstal the driver, instal it again, if I see that there's an error (code 10) I'll reset the PIC and/or restart the PC.
If it works then I'll try to send chars from the PIC to the PC instead of sending chars from the PC to the PIC.
________
EDIT 1:
Like I thought it doesn't work anymore. I did get an error code 10, I reseted the PIC and the error was gone.
I changed the bits per second in the COM7 parameters to 9600.
Then I tried hyperterminal but it gave me an error "Can not connect to COM7, check properties" or something like that.
And right know it doesn't detect it at all !

Right know I'm trying to reflash the PIC with the same program and different VID/PID, but it takes forever to build the ASM.
I'll restart the PC to see if something happens...
__________
EDIT 2:
Okay I'm back :mrgreen: .
I needed to hard reboot the PC, because it wouldn't restart. Even with shutdown -a command.

It worked, but I just reseted the PIC and it doesn't work anymore.
__________
EDIT 3:
Still no luck with the PIC. It just won't work anymore... :roll:
I did try on another PC (windows vista), installation is ok, but same error in hyperterminal (needed to download it because windows vista doesn't have hyperterminal).

This is the error I get from the hyperterminal.
Image

I'm very disappointed that it doesn't work anymore.
I don't have the courage to continue right now.
I will try, perhaps, another day.

Thank you Benj for helping me.

Regards,

Nicolas L. F.

User avatar
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

Post by Benj »

Hello Nicolas,

If you uninstall the device and reinstall then it may be assigned a different COM port number. Are you sure that the COM port number in Hyperterminal matches the device in the device manager.

You may want to close Hyperterminal or at least make sure that it is in disconnected mode before you remove the device otherwise Hyperterminal will lock up and you will have to restart it to get it to work again.

As I say the Slave and HID devices are a bit more reliable. I created my CNC machine using the serial method and I know of all the annoying problems you are talking about. In the end I managed to make my Labview interface (Hyperterminal Replacement) work correctly so it could recover itself if a problem happened but it was a lot of hard work to get right.

Spanish_dude
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

Post by Spanish_dude »

Hi Benj,

I always quited hyperterminal before unplugging the device.
Also, the com port was ok, I did check it in the device manager.

Never mind, I'll try with USB Slave. I'll wait until you do the video/tutorial you talked about. (hope it won't take too long to make :))

Btw, I installed VB 2008. (I saw a VB 2010, isn't this one better ?)

Regards,

Nicolas L. F.

PS: I'd love to make a CNC machine :D

PPS: I made a little program to drive an LED Dot matrix. Right know its only a "virtual LED Dot matrix". I still need to figure out how I could send the different bytes to the microcontroller.
Here's a link to the program with source code : http://www.mediafire.com/?i1gmz9czr2ql6fu
This is the first video I made (wasn't 100% done) : http://img828.imageshack.us/i/simulationledmatrix.mp4/

I suggest you to read the readme file first :D

Spanish_dude
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

Post by Spanish_dude »

Hi everyone,

After having a couple of issues with my USB to RS232 cable I decided to try the USB Serial again.
So, I downloaded some PDF file about USB I found in the Learning Center and some USB example Flowcode Files.

After reading through the PDF file and the USB Serial example I made myself a program.
It uses the keypad e-block, the USB interface e-block and a 18F4455 (not ECIO) with a 4MHz osc.

When I press a key on the keypad it is shown on the LCD screen and in hyperterminal.

I'm still not sure what the problem was but I'm thinking about a wrong clock and/or wrong config in PPP.

Thanks for everyones help.

PS: I attached the program if someone needs it or just wants to see how I did it.
Attachments
usb_test_flowcode.fcf
(8.5 KiB) Downloaded 422 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: USB with PIC 18F4455

Post by medelec35 »

Hi Nicolas,
The configuration was slightly wrong.
If using 19.6 MHz xtal, then you need to change OSC select to Divide by 5 (20MHz input)
Not able to test as a bit late for work, so can't guarantee hardware will work.
Attachments
usb_test_flowcode_modified.fcf
(10 KiB) Downloaded 445 times
Martin

Spanish_dude
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

Post by Spanish_dude »

Hi medelec35,

I'm using a 4MHz xtal and hardware worked fine with the config I had, but thanks anyway :mrgreen: .

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: USB with PIC 18F4455

Post by medelec35 »

Spanish_dude wrote:Hi medelec35,

I'm using a 4MHz xtal and hardware worked fine with the config I had, but thanks anyway :mrgreen: .
Ahh sorry My bad.
Missread. Though you was using EB006.
Now re-read I can see the 4MHZ.
I sould not quickly read before going to work in future.
Martin

Post Reply