USB Hid communication in VB6 (Visual Basic 6)
USB Hid communication in VB6 (Visual Basic 6)
Hello,
I have the PIC18F4550 USB HID demo program (which comes with MikroC Pro) up and running successfully - in the sense that I can send and receive data with the USB HID terminal that is part of the MikroC GUI. However I am having trouble achieving the same within a VB6 program. I already downloaded and tried the USB projects from
http://www.programmersheaven.com/downlo ... nload.aspx
http://www.lvr.com/hidpage.htm
http://www.semifluid.com/?p=23
of course with suitable modifications for device ID etc. But none of them seems to be able to even "see" the PIC (they do see my USB mouse only, while the MikroC HID terminal sees both my mouse and the PIC). I ran the programs in the VB6 debugger to make sure it's not just me comparing to a wrong ID or something similarly stupid - when the programs enumerate all attached devices they simply don't find anything else but the USB mouse...
Does anybody have a VB6(!) program that works with the MikroC USB HID demo and would be willing to share it? Would be highly appreciated!
Just for completeness, I am using the EasyPIC5 development board, and my PC rund Windows XP SP3.
Wolfgang
I have the PIC18F4550 USB HID demo program (which comes with MikroC Pro) up and running successfully - in the sense that I can send and receive data with the USB HID terminal that is part of the MikroC GUI. However I am having trouble achieving the same within a VB6 program. I already downloaded and tried the USB projects from
http://www.programmersheaven.com/downlo ... nload.aspx
http://www.lvr.com/hidpage.htm
http://www.semifluid.com/?p=23
of course with suitable modifications for device ID etc. But none of them seems to be able to even "see" the PIC (they do see my USB mouse only, while the MikroC HID terminal sees both my mouse and the PIC). I ran the programs in the VB6 debugger to make sure it's not just me comparing to a wrong ID or something similarly stupid - when the programs enumerate all attached devices they simply don't find anything else but the USB mouse...
Does anybody have a VB6(!) program that works with the MikroC USB HID demo and would be willing to share it? Would be highly appreciated!
Just for completeness, I am using the EasyPIC5 development board, and my PC rund Windows XP SP3.
Wolfgang
Re: USB Hid communication in VB6 (Visual Basic 6)
Why dont you use Visual Studio express (VB.Net)
it is easier to use with HID and secondly there
are a microchip driver available for HID
in VB.Net
the days of VB6 is past
you can download express from here
http://www.microsoft.com/germany/expres ... fault.aspx
it is easier to use with HID and secondly there
are a microchip driver available for HID
in VB.Net
the days of VB6 is past
you can download express from here
http://www.microsoft.com/germany/expres ... fault.aspx
P.Erasmus
Saratov,Russia
--------------------------------------------------------------
Saratov,Russia
--------------------------------------------------------------
Re: USB Hid communication in VB6 (Visual Basic 6)
just take a look at this tread it is done with
vb.net and the MC HID Driver
http://www.mikroe.com/forum/viewtopic.p ... us#p121552
vb.net and the MC HID Driver
http://www.mikroe.com/forum/viewtopic.p ... us#p121552
P.Erasmus
Saratov,Russia
--------------------------------------------------------------
Saratov,Russia
--------------------------------------------------------------
Re: USB Hid communication in VB6 (Visual Basic 6)
First, thanks for the answer! - I'll give that program a try.
The reason I want to stick with VB6 is that I have a very large code base in VB6, so it would be a huge effort to convert everything to .NET. On the other hand, if I can get HID communication working in VB6 then the amount of changes to my existing software would be minimal. Plus, I have never worked with .NET but am quite familiar with VB6.
Wolfgang
The reason I want to stick with VB6 is that I have a very large code base in VB6, so it would be a huge effort to convert everything to .NET. On the other hand, if I can get HID communication working in VB6 then the amount of changes to my existing software would be minimal. Plus, I have never worked with .NET but am quite familiar with VB6.
Wolfgang
Re: USB Hid communication in VB6 (Visual Basic 6)
Short update: The MikroC program you link to seems to be outdated - does not even compile in MikroC without a few changes (e.g. some library function names are different).
In any case, I finally got Ian Axelson's HID demo working (which is written in VB6 - hurrah!). My troubles were actually due to a stupid mistake - I assumed the product ID (1234) was decimal, but it's in hex - no wonder the PC program never found my USB PIC... but now it's up and running and working perfectly fine.
Nevertheless, thanks for your taking the time to answer!
Wolfgang
In any case, I finally got Ian Axelson's HID demo working (which is written in VB6 - hurrah!). My troubles were actually due to a stupid mistake - I assumed the product ID (1234) was decimal, but it's in hex - no wonder the PC program never found my USB PIC... but now it's up and running and working perfectly fine.
Nevertheless, thanks for your taking the time to answer!
Wolfgang
- slavisa.zlatanovic
- mikroElektronika team
- Posts: 1321
- Joined: 07 Apr 2009 09:39
Re: USB Hid communication in VB6 (Visual Basic 6)
Hi womai!
That's why USB code written in older compiler versions couldn't compile.
See Help for more details and consult HID examples distributed with the compiler.
There were some changes (improvements) of the USB Library (starting from v3.8).Short update: The MikroC program you link to seems to be outdated - does not even compile in MikroC without a few changes (e.g. some library function names are different).
That's why USB code written in older compiler versions couldn't compile.
See Help for more details and consult HID examples distributed with the compiler.
Best regards
Slavisa
Slavisa
Re: USB Hid communication in VB6 (Visual Basic 6)
Hi, can you put your VB code here, or send it to me? h.oliveira@megamail.ptwomai wrote:
In any case, I finally got Ian Axelson's HID demo working (which is written in VB6 - hurrah!). My troubles were actually due to a stupid mistake - I assumed the product ID (1234) was decimal, but it's in hex - no wonder the PC program never found my USB PIC... but now it's up and running and working perfectly fine.
Wolfgang
Thank you
Regards
Thanks and Regards
Gadelhas
Gadelhas
Re: USB Hid communication in VB6 (Visual Basic 6)
Time to return some favours. See attached zip file. It contains the VB6 project sources as well as the compiled program. Should work out of the box with the MikroC Pro HID examples (both polled and interrupt version). It will send a block of 64 bytes, but prints only the first 8. Simply start the program, press "Once" and it should automatically detect the device, open the connections, send a block of data and then wait for the echo from the device. It will time out after ~6secs if the device does not answer. Make sure you set the USB jumpers on the development board.gadelhas wrote:womai wrote: Hi, can you put your VB code here, or send it to me? h.oliveira@megamail.pt
I sure wish MikroE would put out a set of standard PC example apps (with source code!) for USB for the most common development environments - VB6, VB.NET, VCC, Delphi should cover most requirements. The HID terminal is great to prove the microcontroller side is working, but doesn't really get you anywhere for your own application. At least their MikroC USB examples are there, that was already a big help, given than the help file for the USB library commands isn't really explaining much. And having extensive support for USB applications (based on PIC18F2550/4550) in MikroC and MikroBasic would be a very attractive marketing tool for them as well, given that all the world is moving to USB now.
Wolfgang
- Attachments
-
- USBHIDIO.zip
- (18.09 KiB) Downloaded 3185 times
- slavisa.zlatanovic
- mikroElektronika team
- Posts: 1321
- Joined: 07 Apr 2009 09:39
Re: USB Hid communication in VB6 (Visual Basic 6)
Hi!
Thank for suggesting it!
I will pass this to our developers.I sure wish MikroE would put out a set of standard PC example apps (with source code!) for USB for the most common development environments - VB6, VB.NET, VCC, Delphi should cover most requirements. The HID terminal is great to prove the microcontroller side is working, but doesn't really get you anywhere for your own application. At least their MikroC USB examples are there, that was already a big help, given than the help file for the USB library commands isn't really explaining much. And having extensive support for USB applications (based on PIC18F2550/4550) in MikroC and MikroBasic would be a very attractive marketing tool for them as well, given that all the world is moving to USB now.
Thank for suggesting it!
Best regards
Slavisa
Slavisa
-
- Posts: 619
- Joined: 05 Jul 2008 06:05
- Location: Thailand
Re: USB Hid communication in VB6 (Visual Basic 6)
What a great thread, thanks to Womai and everyone else for their input.
I know that I'm going to face this problem eventually, now it's going to be much easier! Thanks again.
I know that I'm going to face this problem eventually, now it's going to be much easier! Thanks again.
Re: USB Hid communication in VB6 (Visual Basic 6)
Wow amazing!!! Thanks for USBHIDIO.zip!
It is what I was looking for!
It is what I was looking for!
Re: USB Hid communication in VB6 (Visual Basic 6)
Here is an improved version of the HID demo program. It still works with the MikroC Pro HID demos. I cleaned up and stripped down the code. I also made it much more modular - moved all the USB code in a separate code module, and encapsulated the base operations (open and close the connection, write data, read data) in streamlined functions. Basically all you need to do is call the read and write functions to transfer data.
There are 3 buttons - to write some test data and receive back the response (either once, or automatically every second); and a speed test that sends 1000 packets (reports) at once, reads back the echo from the microcontroller, and compares them to see if there were any transmission errors. It prints a report showing the errors as well as the achieved data rate (the theoretical maximum for HID is ~64 KByte/sec and on my machine it gets very close to that).
See attached zip file and screenshots.
Wolfgang
There are 3 buttons - to write some test data and receive back the response (either once, or automatically every second); and a speed test that sends 1000 packets (reports) at once, reads back the echo from the microcontroller, and compares them to see if there were any transmission errors. It prints a report showing the errors as well as the achieved data rate (the theoretical maximum for HID is ~64 KByte/sec and on my machine it gets very close to that).
See attached zip file and screenshots.
Wolfgang
- Attachments
-
- USB HID Test.zip
- VB6 project & compiled executable
- (47.67 KiB) Downloaded 3595 times
Last edited by womai on 29 Sep 2010 04:53, edited 1 time in total.