EasyHID and USB for Newbies??


Closed Thread
Results 1 to 40 of 69

Hybrid View

  1. #1
    Join Date
    Aug 2005
    Location
    Los angeles
    Posts
    39

    Default

    sean,
    Sorry for the late reply, my computer crashed so i was crippled for the past week. I will try your code as soon as i get things back in place.
    thank you much

  2. #2
    scorpion's Avatar
    scorpion Guest

    Default got it working.... kindof

    Hi
    I was wondering what I might be doing wrong...
    I used HIDMaker to make an input device. Im using the standard HID descriptors, so I am not writting any PC side software.
    Everything is working well, but I have two analog inputs. They are both set to words so i can use the 10bit a/d. but when I look at the input on the computer its only 8 bit. and if i right justify the results i am only getting a change of 3.... which is what i would expect if it was only sending 8 bits.

    hrm........
    if i do some math (invert one input) i can offset the output to 10 bits, so is my a/d conversion 8 bits?

    I have used 10 bit inputs on other projects with other pics and I have never ran into this problem before.

    I have everything set up.

    DEFINE adc_bits 10
    TRISA = 255
    TRISB = 255
    ADCON0 = 0
    ADCON1 = %00001101

    does anyone have any idea what im doing wrong?

  3. #3
    Join Date
    Jan 2006
    Location
    Toronto
    Posts
    109

    Default

    USB can only send bytes not words so divide your word into 2 bytes to send to the pc (Byte.HiByte & Byte.LowByte), on the PC side simply convert these 2 bytes back to a Long variable and everything should be fine.

    I hope this helps.

  4. #4
    scorpion's Avatar
    scorpion Guest

    Default

    I wish I could say it did help
    thank you though.

    I set the test data to 1000 and 580 and sent it to the pc and i received 1000 and 580.
    I think its the number from the ADC that is 8 bit.

    thanks for any help

  5. #5
    scorpion's Avatar
    scorpion Guest

    Default

    its working, but im still not sure why it wasnt working
    what I did was:
    variable.highbyte = adresh
    variable.lowbyte = adresl

    again. I dont know why, but I was only an 8 bit result from the adc.

    Im glad its working and Ill move along, but does anyone know why my
    adcin 0, variable
    didnt work?

    Other than that snag. my project went well.
    I liked hidmaker. It took me alot longer than the hour or whatever Dr. Bob says it should take, but most of my time was deciding which descriptors to use.

  6. #6
    Join Date
    Aug 2005
    Posts
    42

    Default

    Glad you got it working Scorpion, it is not too bad when you have all the elements in place.

    Regards

    Sean.
    *********************
    http://www.cncdudez.co.uk
    *********************

  7. #7
    Join Date
    Aug 2005
    Location
    Los angeles
    Posts
    39

    Unhappy Vb6 to Vb.net

    I am using easyHID sofware to generate a Visual basic code 6.0. I have the visual basic .net installed. So when i copy the file from vb.6 to vb.net , Vb.net upgrades the file to the .net configuration.Except for one thing that gave me an error:it's the upgrade warning about adding a delegate.

    Public Function ConnectToHID(ByVal pHostWin As Integer) As Boolean
    FWinHandle = pHostWin
    ConnectToHID = hidConnect(FWinHandle)
    'UPGRADE_WARNING: Add a delegate for AddressOf WinProc Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1048"'
    FPrevWinProc = SetWindowLong(FWinHandle, GWL_WNDPROC, AddressOf WinProc)
    End Function

    I couldn't figure out how to fix it, Any idea?? here is what the help menu suggested :

    In Visual Basic 6.0, the AddressOf operator was used to pass the address in memory of a function to an API procedure that takes a function pointer as an argument.
    In Visual Basic .NET, the AddressOf operator must be used with a Delegate type. Delegates allow Visual Basic .NET to maintain a pointer to a function even if the function itself has already been garbage-collected.
    The following example illustrates how a callback function that uses AddressOf is upgraded:

    ' Visual Basic 6.0
    Declare Function SetWindowLong Lib "USER32.DLL" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal attr As Long, ByVal lVal As Long) As Long
    Sub SubClassWindow(ByVal hwnd As Long)
    If PrevProcPtr = 0 Then
    PrevProcPtr = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf SubClassProc)
    End If
    End Sub

    ' After upgrade to Visual Basic .NET
    Declare Function SetWindowLong Lib "USER32.DLL" Alias "SetWindowLongA"(ByVal hwnd As Integer, ByVal attr As Integer, ByVal lVal As Integer) As Integer
    Sub SubClassWindow(ByVal hwnd As Integer)
    If PrevProcPtr = 0 Then
    ' UPGRADE_WARNING: Add a delegate for AddressOf SubClassProc.
    PrevProcPtr = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf SubClassProc)
    End If
    End Sub
    What to do next

    Add a delegate for the AddressOf operator, and change the parameter of the function declaration to the Delegate type:
    Delegate Function SubClassProcDelegate(ByVal hwnd As Integer, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    Declare Function SetWindowLong Lib "USER32.DLL" Alias "SetWindowLongA" (ByVal hwnd As Integer, ByVal attr As Integer, ByVal lVal As SubClassProcDelegate) As Integer
    Sub SubClassWindow(ByVal hwnd As Integer)
    If PrevProcPtr = 0 Then
    PrevProcPtr = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf SubClassProc)
    End If
    End Sub


    Thank you in advance
    Last edited by rocky79; - 3rd March 2006 at 07:24.

  8. #8
    Join Date
    Nov 2015
    Posts
    13

    Default Re: EasyHID and USB for Newbies??

    Hello. I'm making a program who include easyhid for the 18f4550 but I have some questions:
    I want to pass 10 decimal 2 digit variables and 11 bit variables from the PIC to the PC, then something simmilar in return. Do the usb buffers support this just declaring de proper variables?
    Or I need some kind of conversion or trick?
    Thank you for your help.
    Luis

  9. #9

    Default Re: EasyHID and USB for Newbies??

    USB doesn't really work like that. The buffer is just a string of bytes, the significance is determined by your application. For instance the first byte could be the status of a LED or the first digit of a number.

    George

Similar Threads

  1. Simple USB Comms Problem
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th January 2010, 20:17
  2. EasyHID max usb buffer size
    By jizyjuice in forum USB
    Replies: 4
    Last Post: - 29th November 2007, 05:12
  3. Speed of USB EasyHID and Time problem
    By sjohansson in forum USB
    Replies: 10
    Last Post: - 18th January 2007, 22:21
  4. USB and EasyHID Problems
    By Rob in forum USB
    Replies: 8
    Last Post: - 6th January 2007, 18:19
  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