• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1815
  • Last Modified:

VB 6 Receive Data from USB Port

Hi everyone..

Can anyone help me..i'm going to make an improvise optical sensor by using the sensor of an optical mouse..
i want it to act like a counter
can anyone teach me on how to do this..if it is possible

btw im using visual basic 6

Thanks in advance..
0
pentacost
Asked:
pentacost
  • 5
  • 3
  • 2
  • +2
1 Solution
 
JigglyDCommented:
Pentacost, are you looking at making some sort of motion detector?
0
 
pentacostAuthor Commented:
yes i do..actually im looking for a device that could act as a counter..
0
 
JigglyDCommented:
Well, here's a strange possibility for you...

By leaving the optical mouse connected via USB, you could simply respond to a MouseMove event (which would automatically be fired whenever the optical sensor is tripped).  I would also put in some sort of minor delay timer so you didn't record the same person more than once.

Of course, this means that you would have to create an application that was complete keyboard (or touch screen) driven.

Jiggle On ! ! !
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
pentacostAuthor Commented:
hmm..may i ask for some sample codes on how to do this..

coz i this is my first time to USB port..can u give me some tips?

thank you very much i appreciate your help..
this'll help me alot in my thesis..coz im doing a prototype project of a filler machine downtime
0
 
JigglyDCommented:
I have to take off now, but I will post some code later tonight.

Jiggle On ! ! !
0
 
rettiseertCommented:
Will this mouse count people?, tickets? other objects?

I dont think a mouse can detect motion if is not close enough to the object.

btw, if you use a mouse following pentacost's advice, you don't need to interact with usb ports, vb can handle the device as a standard mouse
0
 
pentacostAuthor Commented:
the mouse will count canned goods..
i think retitiseert is right..it should be close enough, but i'll think of some better way later on..my only concern by now is how to take control it's events.. btw rettiseert im going to use an optical mouse and i'm going to remove it's optical sensor and make an improvised motion sensor that's why i want it to interact with the usb port..

is controlling a standard mouse in vb the same when controlling an optical mouse.. because i want it to trigger when a canned good pass through it and make a count in vb..

thanks for advices guys..
god bless
0
 
pentacostAuthor Commented:
oooops.. i think im going to have another problem..because by setting the mouse Event it will restrict the movement of the cursor..

is there any other way to do this? coz i still want to control the cursor of the mouse..
0
 
fulscherCommented:
pentacost - Using an optical mouse for this purpose is an excellent idea. Cheap and reliable.

Setting the MouseMove event should not restrict the mouse movement at all. However, the event fires only in the active form or control - so basically, if you move the good over the mouse sensor, this is interpreted as a mouse movement. Therefore, the cursor moves in one direction until it's at the border of the form or screen. You could prevent this by setting your application to full screen.

Another option would be to write a filter for windows events ("hook"). Check out this article: http://www.vbaccelerator.com/home/VB/Code/Libraries/Hooks/Mouse_Gestures/article.asp - it explains how to create a filter which will trigger any movement of the mouse irrespective of the active window. You wan't need most of the code (it's for detecting gestures), but it shows the idea.

The third option would be to actually catching the mouse movements at the USB port. A mouse is generally a serial device, so mouse movements translate into a stream of data into the serial port. Unfortunately, Windows seems to know that a mouse is a mouse and not another serial device...

Jan
0
 
pentacostAuthor Commented:
fulscher:
is there any way i can catch the binary data sent by the movement of the mouse?
0
 
fulscherCommented:
I'm not sure - look to me that you would have to write your own mouse driver to catch that data. In addition, you'd have to interprete the data coming from the mouse. I think it might be easier to go the hook way (at least for me, it would be easier).

Or you try to find an optical mouse which connects to the serial port. You could then catch the data coming from the serial port (after telling Windows that it's not supposed to treat that device as a mouse). This probably would be easier than trying to fetch data from the USB port (to be honest, I've no idea how to do this).

Jan
0
 
moduloCommented:
PAQed with no points refunded (of 50)

modulo
Community Support Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 5
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now