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

    Thanks Sean for the explanation, but there is still something i don't understand.
    Question#1:
    On the microcontroller side: How can i send the results of a 12 bits A2d Signal from the microcontroller to visual basic.net since USBBufferout is defined as a byte.
    Question#2
    on the Visual basic.net side when your ready to send data back to the controller:
    do you just include all the 64 bufferout bufferout(1) bufferout(2)....bufferout(63)
    HidWriteEx, VendorId, ProductID, BufferOut(0), BufferOut(1)....BufferOut(63)
    Or is there a shorter way to do it.

    Thanks Sean

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

    Default One more question

    Question#2:
    On the visual studio.net side: In this code below that i got from EasyHid how do you fill in where it says: put your code here?
    I would appreciate Any examples:

    Public Sub OnPlugged(ByVal pHandle As Integer)
    If hidGetVendorID(pHandle) = VendorID And hidGetProductID(pHandle) = ProductID Then
    ' ** YOUR CODE HERE **
    End If
    End Sub

    '************************************************* ****************
    ' a HID device has been unplugged...
    '************************************************* ****************
    Public Sub OnUnplugged(ByVal pHandle As Integer)
    If hidGetVendorID(pHandle) = VendorID And hidGetProductID(pHandle) = ProductID Then
    ' ** YOUR CODE HERE **
    End If
    End Sub

    '************************************************* ****************
    ' controller changed notification - called
    ' after ALL HID devices are plugged or unplugged
    '************************************************* ****************
    Public Sub OnChanged()
    Dim DeviceHandle As Integer

    ' get the handle of the device we are interested in, then set
    ' its read notify flag to true - this ensures you get a read
    ' notification message when there is some data to read...
    DeviceHandle = hidGetHandle(VendorID, ProductID)
    hidSetReadNotify(DeviceHandle, True)
    End Sub

    '************************************************* ****************
    ' on read event...
    '************************************************* ****************
    Public Sub OnRead(ByVal pHandle As Integer)

    ' read the data (don't forget, pass the whole array)...
    If hidRead(pHandle, BufferIn(0)) Then
    ' ** YOUR CODE HERE **
    ' first byte is the report ID, e.g. BufferIn(0)
    ' the other bytes are the data from the microcontrolller...
    End If
    End Sub

    '************************************************* ****************
    ' this is how you write some data...
    '************************************************* ****************
    Public Sub WriteSomeData()
    BufferOut(0) = 0 ' first byte is always the report ID
    BufferOut(1) = 10 ' first data item, etc etc

    ' write the data (don't forget, pass the whole array)...
    hidWriteEx(VendorID, ProductID, BufferOut(0))
    End Sub
    End Class

  3. #3
    Join Date
    Aug 2005
    Posts
    42

    Default

    Hi Rocky

    I got compile errors in VB2005 so sticking with VB6, does it compile okay with ,net your end?

    The two main routines to worry about and get you going are receive and transmit Data Routines.

    Please scroll up on this post as I have given some VB examples already on what you have just asked.

    Regards

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

  4. #4
    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

  5. #5
    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?

  6. #6
    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.

  7. #7
    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

  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

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

    Default

    Quote Originally Posted by sean-h
    Hi Rocky

    I got compile errors in VB2005 so sticking with VB6, does it compile okay with ,net your end?

    The two main routines to worry about and get you going are receive and transmit Data Routines.

    Please scroll up on this post as I have given some VB examples already on what you have just asked.

    Regards

    Sean.
    Sean,
    I am just wondering if you know any good graphical widgets for Visual basic 6.0. Like meters, gauges, level indicators and so forth.

    Thanks

  11. #11
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    http://www.picbasic.co.uk/forum/show...light=softwire

    Seems to have change now.. maybe there's still some free version for VB6 somewhere

    Ask them
    Last edited by mister_e; - 16th March 2006 at 04:40.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  12. #12
    Join Date
    Mar 2006
    Location
    Gothenburgh, Sweden
    Posts
    18

    Default

    Hi.
    Im using EasyHID and a 18f4550 to communicate with VB6.
    I use MicroCode Studio Plus and PicBasic 2.46. I download my programs using Microchip USB bootloader. And this works just fine.
    Now I want to write a program that counts how long time an input pin is activated. Typical time will be in range form about 1ms - 120ms.
    Normaly I would use "Pulsin" but what I understand the USB commands must be polled every 1ms or so. Is there another way to solve it in Basic?
    Maybe to use the timers in 4550? If so, how shall that basic code be written?
    Im not skilled enough to write the code in asm so it would be great if it is possible to do it in PicBasic.

    Thanks in advance.

    /Stefan.

  13. #13
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257

    Lightbulb

    Just revisiting this topic again....

    It seems that HID is good enough to program and set up the PIC for USB use, but one really needs to generate a VB program to interface the PC to the USB device (aka PIC device)

    I don't have VB, and was considering downloading the 60MB VB express from Microsoft.

    Does anybody have experience with VB Express?

    Does it have COMM components included? Or can you get them from a 3rd party? Prefer if they were free.... hahaha

    I'm really interested in doing a bit of serial communications between the PIC(4550) and PC over the USB link, as most PC nowdays don't even come with Serial Com ports, USB interfacing is gonning to be the way of the future.

    I don't want to go down the path of using a pre built usb 2 serial converter when a USB pic should be good enough, right?

  14. #14
    Join Date
    Aug 2005
    Posts
    42

    Default

    Quote Originally Posted by rocky79
    Thanks Sean for the explanation, but there is still something i don't understand.
    Question#1:
    On the microcontroller side: How can i send the results of a 12 bits A2d Signal from the microcontroller to visual basic.net since USBBufferout is defined as a byte.
    A byte is only 8 bits so you will have to store your result in a variable defined as a Word (16bits)
    Now you will need to split the word and send the highbyte and lowbyte out as two bytes.
    In your VB program you will then need to take the 2 bytes and joing them back as a word.

    Quote Originally Posted by rocky79
    Question#2
    on the Visual basic.net side when your ready to send data back to the controller:
    do you just include all the 64 bufferout bufferout(1) bufferout(2)....bufferout(63)
    HidWriteEx, VendorId, ProductID, BufferOut(0), BufferOut(1)....BufferOut(63)
    Or is there a shorter way to do it.
    Re-read what I wrote above regards data being sent from VB. when you call HidWriteEx, VendorId, ProductID, BufferOut(0) you are telling the USB port to send all the data in the BufferOut.
    So if you have defined your BufferOut as being 64 bytes long then when you call HidWriteEx it will send all 64 bytes, if you defined your BufferOut as being 8bytes long then it will send 8 bytes.

    So simply load all the buffers up with the bytes you want and call HidWriteEx when you want to send.

    Regards

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

Similar Threads

  1. Simple USB Comms Problem
    By awmt102 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th January 2010, 21:17
  2. EasyHID max usb buffer size
    By jizyjuice in forum USB
    Replies: 4
    Last Post: - 29th November 2007, 06:12
  3. Speed of USB EasyHID and Time problem
    By sjohansson in forum USB
    Replies: 10
    Last Post: - 18th January 2007, 23:21
  4. USB and EasyHID Problems
    By Rob in forum USB
    Replies: 8
    Last Post: - 6th January 2007, 19:19
  5. USB PIC without USB Connection
    By Tissy in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 26th December 2005, 18:39

Members who have read this thread : 0

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