Regarding interfacing with USB via VB6

Discuss PIC and electronic related things

Moderators: David Barker, Jerry Messina

Post Reply
liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Regarding interfacing with USB via VB6

Post by liak » Tue Apr 07, 2009 11:47 am

Dear all,

I am used to Visual Basic 6.

I am having problem in making it to use USB ports. I have searched the net and to my disappointment. It seems that VB6 cannot use USB ports as readily as the serial comm ports.

Does any one use VB6 and interface it with USB? How to do this? I am thinking of moving my data transfer from PC to PIC by programs in VB6 via USB. Some say I should move to VB.NET. But it's a heavy investment.

Regards,
Liak

CharlieM
Registered User
Registered User
Posts: 211
Joined: Wed Oct 10, 2007 12:05 am

Post by CharlieM » Tue Apr 07, 2009 12:34 pm

Hi liak,

Have you looked into Easy HID.Its made by Mecanique?It does most of the work for you.Works with VB6.
Running version 2.2.4.0 ICC 1.2.1.0
Regards CharlieM

User avatar
RangerBob
Posts: 152
Joined: Thu May 31, 2007 8:52 am
Location: Beds, UK

Post by RangerBob » Tue Apr 07, 2009 2:08 pm

Liak,

I heavily use VB6 and the EasyHID stuff for some serious projects. I find it's almost easier to use the HIDUSB interface than interfacing the serial ports in VB6!

I suggest playing around with the EasyHID code generator in the IDE. I use it pretty much as the basis for each USB project I've done. The mchid.dll provided takes all the heavy lifting off you at the PC end, the generated examples show exactly how to use it.

Have a play, and if there's any questions post it back and someone should be able to answer.

Nathan

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Where to get EasyHID?

Post by liak » Wed Apr 08, 2009 2:23 pm

Dear all,

Thanks for showing me the way. Nice to hear that there is such useful tool around!

Regarding EasyHID. Is it a VB module or component made by Mecanique? I have not seen it before. I searched the net following your advises.

There are links to the mecanique website, saying the module comes free. But unfortunately, it is there NO MORE, neither free nor with purchase. Anyone has any copy of it where I can download? Nathan or Charlie, it would be a great help if you guys can help me to get one.

Another thing is, David also has put on an anouncement regarding EasyHid as well. The thread also refers to the link which is missing now.

So now, I need to get a copy first. Then I can start playing around with it.


Regards,
Liak

RKP
Registered User
Registered User
Posts: 82
Joined: Mon Oct 22, 2007 3:14 pm
Location: Maryland

Post by RKP » Wed Apr 08, 2009 4:23 pm

Liak,

I found it on the Wiki site here is the link http://www.sfcompiler.co.uk/wiki/pmwiki ... er.Plugins

Have fun,

RKP

liak
Registered User
Registered User
Posts: 195
Joined: Fri Oct 05, 2007 12:26 am

Post by liak » Thu Apr 09, 2009 12:58 pm

Dear all,

Thanks RKP. I didn't see it in the Wiki earlier.

I am entirely new to the USB area. Some of the question I will ask may make me look stupid. One of it is this:

What is the difference between CDC and HID? I have read the introduction to each module in the Wiki but not very sure if I understood correctly.

But what is important to me is this. If I am to transfer data from VB6 to PIC and vice versa. Do I use CDC or HID?

Regards,
Liak

User avatar
RangerBob
Posts: 152
Joined: Thu May 31, 2007 8:52 am
Location: Beds, UK

Post by RangerBob » Mon Apr 20, 2009 10:53 am

Hello Liak,

No such thing as a stupid question, only stupid answers!

Sorry I wasn't able to get back to you sooner, been away on my honeymoon, and the new wife wasn't keen on me taking my laptop with me! ;)

I thought EasyHID was built into the IDE, i'm pretty sure I didn't add it! (check "Plugin - Swordfish - EasyHID")

Re: differences between CDC and HID

CDC allows the USB device to present itself as a serial port device. Ie. when it connects, it shows up as a COM port on the PC. You can then send data to/from it as if it was a real serial device using tools such as hyperterminal or the VB mscomm routines. Your users needs to tell the PC which com port it has presented itself as though, and tell it if it has connected etc.

HID allows the usb device to present itself as a "proper" usb device, in that the user does not need to track ports or anything else. The term Human Interface Device is a little confusing as the device does not have to present itself as a keyboard, mouse, joystick etc (but can if you want!).
Your program knows which device to talk to by the VID & PID (Vendor ID & Product ID). Using the Mechanique mcHID.dll makes it really simple to recognise connects and disconnects. You can then send the data however you like by creating packets or messages, similar to serial if you like.

(note: if you are selling commercially regardless of CDC or HID or whatever, you will need to get yourself a PID & VID for your product. I think a few places, including mechanique will sell you one quite cheaply. For just fooling around though, you can get away without it.)

For both methods, you do not need to worry about drivers as these are built into the operating system. The Mechanique mcHID.dll provides you with easy handlers, similar to the mscomm dll's.

The easyHID wizard should get you going really quickly. If unsure, leave it as the default, you can always fix it later.

I personally feel that the little bit of extra effort needed to create a HID device under easyHID is well worth it for a new project. It presents a much better USB experience than having to ask your users to check which virtual COM port your device is under and having to put it in manually. CDC really excels in updating legacy serial projects though.

With HID, to the user, it "Just Works *". No drivers, no restarts, no COM ports.


Hope this helps, any further questions, I'll try and answer!



* May or may not actually work, depending on your code ;)

Post Reply