Pic 18f Usb


Closed Thread
Results 1 to 40 of 135

Thread: Pic 18f Usb

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    154


    Did you find this post helpful? Yes | No

    Default Device Not Recognised

    Hi,

    I've built the simple piece of hardware using the 18F2550, it has been programmed as per the files generated by the EasyHID application.

    Having plugged the hardware into the USB port, it states the device is not recognised. I was expecting it to come up with the device name as i stated in the EasyHID compilation.

    I was expecting a .ini file or similar to be generated for the installation of the device.

    Can anyone help why this might be.

    Many thanks.

  2. #2
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    154


    Did you find this post helpful? Yes | No

    Default

    OK, seem to have that issue sorted now, it actually was something to do with the programming fuses.

    Although it now connects OK, when i look at the device manager, it only shows up as a 'USB Human Interface Device' and HID-Compliant Device' and not as i set in the EasyHID maker.

    Also, can anyone help with what is required at the VB and PIC end to light a simple LED. ie when i click a 'button' in the VB code, it turns an LED on one of the ports, ie PORTB.1.

    Many thanks,

    Steve

  3. #3
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    154


    Did you find this post helpful? Yes | No

    Default

    Can anybody help with the above request or point me in a direction of who / where might?

    Many thanks,

    Steve

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Steve,

    If you have the PIC being recognized as an HID device, try this. It's real simple, but will allow you to control an LED from VB6 (should also work with VB5) but I don't have that to test it with.

    Create your VB code with EasyHID. Open the project, and drop two command buttons on your form. Add this code for your buttons --

    Private Sub Command1_Click()
    BufferOut(8) = 0 ' LED on
    hidWriteEx VendorID, ProductID, BufferOut(0)
    End Sub

    Private Sub Command2_Click()
    BufferOut(8) = 1 ' LED off
    hidWriteEx VendorID, ProductID, BufferOut(0)
    End Sub

    Modify the PBP code created by EasyHID something like this --

    PORTB = 0
    TRISB = 0

    usbinit ' initialise USB...
    ProgramStart:
    gosub DoUSBIn
    PORTB = USBBuffer[7]
    goto ProgramStart

    Note this doesn't send data, it's just a sit & spin simple app reading USB input, and placing the value received in USBBuffer(7) on RB.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    154


    Did you find this post helpful? Yes | No

    Default

    Bruce, thanks ever so much for taking the time to reply and for starting me in the right direction. Indeed i now have VB talking to the PIC over USB.

    Do you have any knowledge of the EasyHID application? Having used EasyHID to set the base code etc, when i look at the device manager, it only shows up as a 'USB Human Interface Device' and 'HID-Compliant Device' and not as i set in the EasyHID maker, such as 'USB LED Controller'.

    I was expecting an .inf file or similar to be compiled. Is this something that needs to be done manually? It would be a nice touch to have that when i plug in the device, in the task bar, the name of this device is displayed like any other USB device when connected.

    Thanks again for you kind help,

    Steve Tisseyre

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Steve,

    The information you enter when creating USB framework files with EasyHID is just for the embedded side with a very handy .dll that handles host to function communications.

    EasyHID just gives you the USB framework. As far as I know, it does not create a Windows .inf file. That's up to you to create.

    If you don't have your own .inf file or HID driver, then Windows will install its own HID drivers, and your new USB gadget is just going to show up with the default Windows name in Device Manager like 'USB Human Interface Device' and 'HID-Compliant Device'.

    If you're running XP, look in the Windows input.inf file, and you'll see why. It tries to match the descriptors, VID, PID with existing "certified" manufacturers & hardware. If your new USB gadget isn't in the list, Windows uses the default HID compliant description with generic HID drivers.

    Download the Microchip USB framework and take a look at how they setup the .inf & driver files. That will help you understand what's required.

    If you plan on making a USB enabled "product", then you might also want to grab a copy of Jan Axelson's USB Complete 3rd edition. It's worth every penny, and gives you details on how to get your USB product/manufacturer name to show up in Windows Device Manager.

    EasyHID will get you started, (and really quick I might add), but there's still a lot left to the end user to figure out.

    Hats off to Dave at Mecanique for putting in the HUGE amount of time & study required just to give everyone that nifty "free" utility.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    154


    Did you find this post helpful? Yes | No

    Default

    Hi Bruce,

    I have now ordered the book as you recommended, i'm sure it will come in very handy.

    I have figured out that if you use EasyHID to set the maximum Buffer size to 32, then you can increase the amount of outputs on the PIC that you can set HIGH or LOW. ie the PIC side is odd numbers 1 - 31 and the VB side is even numbers 2 - 32.

    ie on the PIC side requires:

    PORTC.1 = USBBuffer[23]

    where as on the VB side requires:

    BufferOut(24) = 1 ' LED on

    If i want to use all of PORTA and PORTB, is there an easy way of listing these in the two codes, or do they have to be done seperately? ie:

    PIC
    PORTA.1 = USBBuffer[1]
    PORTA.2 = USBBuffer[3]
    PORTA.3 = USBBuffer[5]
    PORTA.4 = USBBuffer[7]
    PORTA.5 = USBBuffer[9]

    VB
    BufferOut(2) = 1 ' LED on
    BufferOut(4) = 1 ' LED on
    BufferOut(6) = 1 ' LED on
    BufferOut(8) = 1 ' LED on
    BufferOut(10) = 1 ' LED on

    Moving on from the switching of outputs HIGH or LOW, how would one send say text from the PIC to a text box in VB. For example, on the PIC, if a certain routine is executed, it sends a command to the VB application which is then displayed in a text window. Or is this getting too advanced for a quick explanation??

    Thanks again for you assistance,

    Steve

  8. #8
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,172


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce
    ...
    Download the Microchip USB framework and take a look at how they setup the .inf & driver files. That will help you understand what's required.
    ...
    Hi Bruce, do you have a link? I did a search on the Microchip site for <Microchip USB framework> and couldn't find a download.

    (I'm assuming this is some sort of compile utility that will help Windows XP make a link between the USB device and our EasyHID-generated VB code.)

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

Similar Threads

  1. USB CDC Communications for Dummies!
    By Squibcakes in forum USB
    Replies: 104
    Last Post: - 15th January 2014, 13:43
  2. Reading a slave USB with a pic
    By pcaccia in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 25th October 2008, 12:00
  3. Replies: 15
    Last Post: - 30th October 2007, 19:25
  4. USB communication with pic
    By Shamir in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th August 2006, 23:43
  5. USB PIC without USB Connection
    By Tissy in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 26th December 2005, 17:39

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts