12 Replies - 40570 Views - Last Post: 30 December 2011 - 09:19 AM Rate Topic: -----

#1 gm5660   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 12-August 08

How to open a USB Port in VB6

Posted 26 December 2011 - 11:13 AM

I am not sure where or how to begin in VB to open a USB port so I can use my HID device. Can anyone tell me the code to start with just to open the USB hub so I can access the COMM4 port? Any help will be greatly appreciated.
Is This A Good Question/Topic? 0
  • +

Replies To: How to open a USB Port in VB6

#2 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6534
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: How to open a USB Port in VB6

Posted 26 December 2011 - 11:38 AM

You don't really 'open' a USB port.
They are not like serial COM ports.

You just need to talk to the driver of your device. It doesn't really matter what USB port you plugged in to.

So you need to work according the the API/SDK for the device you want to talk to.

If the USB device is really a USB to Serial converter, and thus it appears as COM4, then talk to it like any other serial port - don't complicate it by thinking of it as a USB port.

This post has been edited by tlhIn`toq: 26 December 2011 - 11:39 AM

Was This Post Helpful? 1
  • +
  • -

#3 maj3091   User is offline

  • D.I.C Lover
  • member icon

Reputation: 330
  • View blog
  • Posts: 1,998
  • Joined: 26-March 09

Re: How to open a USB Port in VB6

Posted 27 December 2011 - 02:29 AM

As tlhIn`toq has already said, if it's appearing as COM4 already in control panel, then it's presented itself as a "Standard" serial port and you can then communicate to it using normal serial communication type protocols using normal serial controls like the Microsoft MSCOMM control.

To talk to the device, you will need to know the protocol it uses.
Was This Post Helpful? 1
  • +
  • -

#4 gm5660   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 12-August 08

Re: How to open a USB Port in VB6

Posted 28 December 2011 - 11:05 PM

It shows that it is a USB converter and indicates COMM4. So all I have to do is write in VB6 the protocols to communicate with COMM4. Is this right?
Was This Post Helpful? 0
  • +
  • -

#5 maj3091   User is offline

  • D.I.C Lover
  • member icon

Reputation: 330
  • View blog
  • Posts: 1,998
  • Joined: 26-March 09

Re: How to open a USB Port in VB6

Posted 29 December 2011 - 02:59 AM

That should be right, if it's already there as COM4.
Was This Post Helpful? 0
  • +
  • -

#6 gm5660   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 12-August 08

Re: How to open a USB Port in VB6

Posted 29 December 2011 - 08:24 AM

I understand that this is right. However, it is with a USB device that I have found. The USB device I want to use has no device attached on the end. It is just bare wires streight from the USB hub. In the Device manager, it show it to be a USB device and nothing else, no drivers, no nothing. I have tied the D- (slow rate) to 3.3VDC and the system will no load a driver. I was thinking I can make VB6 tell the computer what the HID device is and how to communicate with it. Am I on the right track?

I have build a HID device from scratch and need the USB hub to recognize and communicate with it.


Thank you in advance for all the help you have given and I am greatly appreciated.
Was This Post Helpful? 0
  • +
  • -

#7 maj3091   User is offline

  • D.I.C Lover
  • member icon

Reputation: 330
  • View blog
  • Posts: 1,998
  • Joined: 26-March 09

Re: How to open a USB Port in VB6

Posted 29 December 2011 - 10:39 AM

Hmmm OK, a couple of questions:

1. What is the HID device (a basic description)?
2. Please can you explain this sentence "The USB device I want to use has no device attached on the end", I'm sorry, but it doesn't make sense to me.....maybe you could post a picture to try and explain?

Now a couple of comments.

1. As you have said that this is a self-made device, are you happy the device itself is functioning correctly (forget the comms part for now)? It's no good trying to interface to something that isn't functioning. :)

2. Did you develop the USB interface part of the device yourself? The reason I ask, is that there might be generic drivers that are available for it if not.

3. You might need to have a look at the MS DDK for the OS you're using. This link is to the home page for Windows Hardware Development.

Sorry I can't offer more at this stage...
Was This Post Helpful? 1
  • +
  • -

#8 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6534
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: How to open a USB Port in VB6

Posted 29 December 2011 - 03:29 PM

Do you think you could write this up with any more confusion or maybe a stronger attempt to hide what you are doing so as to make it even harder for us to help you?


Look: You are either building a USB device or a Serial device. Which is it? First you say it is COM port device showing as COM 4 then you say it is bare wires sticking out of a USB hub.


Show us some fraking pictures of what you are trying to do, and disclose in detail the full extent of what you are trying to accomplish because at this point it is seeming like you are either REALLY confused about it - or you are trying your best to hide what you are doing which makes me really suspicious.
Was This Post Helpful? -1
  • +
  • -

#9 gm5660   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 12-August 08

Re: How to open a USB Port in VB6

Posted 29 December 2011 - 05:55 PM

OK. The device is a 'Home-made Christmas display that runs animation, that is I want the computer to send data to the D+ line of the USb to a Shift register. I use TTL because I know a lot about TTL. I am using a 74LS164 chip. I amclocking at 9600 Baud, so I can make the shift register function properly.

From the shift register, I have 8 data lines operating 8 trannsistors, which in turn turn on/off 8 SSR's that supply 120 VAC to the light display. This is what my wife suggested I try to do. The problem I am having is getting a single bit of data to the shift register. I can hard wire it and it works fine, but when I connect it to the system(computer), there is nothing. No lights no error message. It is as if all went well, but no display.

What I ment is that I had a device which crashed and no longer functions, so I removed it from the one end of the cable (loose wires) and I kept the USB connector (USB 2,0 connector, 4 pin) on the other end. Sorry for the confusion.

I also have a USB which the computer recognizes as a serial converter, from USB to a DB-9 connection. Again, I have the DB-9 cable fromm a device which craashed asnd is now loose ends.

So I have 2 way of connecting the HID, one with a USB cable and one with a Serial Converter. The Converter is sending out 9600 Baud rate. I only need 300 Baud to make the lights run.

I am thinking of using the Converter and telling VB6 to change the rate if possible. I hope this answers a lot. This project is beginning to get more complicated than I am use to. So, once again, any help is greatly appreciated on my end and I truly thank all who has helped.

For those of you who are suspecious, I'm sorry if I can't explain it fully, for you see, I have an exetremely limited experience with programming. You might say I am a newbie, so bear with me. I am trying to describe this problem the best way I can. If I am making it more confusing, then I'm sorry for the confusion, but I still want to thank all those who have helped.

This post has been edited by gm5660: 29 December 2011 - 06:05 PM

Was This Post Helpful? 0
  • +
  • -

#10 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6534
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: How to open a USB Port in VB6

Posted 29 December 2011 - 06:41 PM

Sounds both interesting... and like a cluster f*ck at the same time. But that is the nature of experimentation isn't it? I'm at least happy to see someone trying something new and not just asking for homework help.

Personally, I'd stick with one method of connectivity at a time until you get that worked out.
To me, serial is the easiest to set up communication.

But then again, there are so many existing USB experimentation boards out there I am not sure why you are trying to create it all from scratch unless its just for the challenge.

http://www.create.ucsb.edu/~dano/CUI/

http://www.pcworld.c...y_projects.html
Was This Post Helpful? 1
  • +
  • -

#11 maj3091   User is offline

  • D.I.C Lover
  • member icon

Reputation: 330
  • View blog
  • Posts: 1,998
  • Joined: 26-March 09

Re: How to open a USB Port in VB6

Posted 30 December 2011 - 01:36 AM

I agree with tlhIn`toq on this, use the USB to serial converter adapter that you have, otherwise I do feel you will need to write a device driver of some description (never personally interfaced a USB device, but I can't think of one that works without a driver).

I have a rough idea what you're trying to do, but my electronics is a little rusty nowadays (20 years since I did anything in anger. :) ).

The baud rate you mentioned will be the default of the device when it's connected and you can change that using the MSCOMM control. I've put a couple of links below, because off the top of my head, I don't know if it will do 300bps (think it has set values like in control panel).

Link 1 (Setting unusual baud rates)
Link 2 (MSDN Usage of MSCOMM Control)

Only other thing to say....ensure your voltages are matched and you have some isolation between your port and device (but I'm sure you know that already! ;) ).

Good luck.
Was This Post Helpful? 1
  • +
  • -

#12 gm5660   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 12-August 08

Re: How to open a USB Port in VB6

Posted 30 December 2011 - 06:06 AM

Thank you again for the help. It is a challange. I am retired and have, as my wife says, too much time on my hands, so I decided to try to 'out shine my neighbor' and creat something from scratch. My experience with VB6 is limited, but I did go to school when DOS was the main OS for computers. Infact, I know my way around an IBM XT system. Too old for today.

I have the figuresof angles singing and I was wantint to make the note visible and computer controlled. I also plan to have a sound system going, via computer (Vista OS) while the animation is going on.

I'll check the links and again, thank you all for the help. I'll let you know what becomes of it and I'll be asking for help in the VB6 code.
Was This Post Helpful? 0
  • +
  • -

#13 maj3091   User is offline

  • D.I.C Lover
  • member icon

Reputation: 330
  • View blog
  • Posts: 1,998
  • Joined: 26-March 09

Re: How to open a USB Port in VB6

Posted 30 December 2011 - 09:19 AM

Feel free to post back whenever you need to. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1