Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I have following wire as shown below, one end has male USB connector and other end has four wires. I know, when connected to laptop, the RED one acts as voltage source and BLACK as ground. If I give 2 bits data input to GREEN and YELLOW one, is there any software or API for (Python, C or any other language) to know about state of those two wires ? I mean to check if GREEN or YELLOW one have a voltage or not.

enter image description here

Please guide me if I am asking the wrong question.

share|improve this question

2 Answers

up vote 12 down vote accepted

No, you cannot sense the USB wire state directly. USB is a much more complex interface than that, it is no comparison to the old style serial and parallel ports that could be used for direct I/O with a simple driver program. A complex handshake is exchanged with the PC even before the first byte of 'real' data/payload can sent.

Maybe your PC has a parallel port that can be used? Or you should use a USB to GPIO converter which are broadly available for varying prices (both extremely high and extremely low).

share|improve this answer
1  
Example: sparkfun.com/products/718 I don't have any experience with this module, but it looks like up to the job. There are many similar alternatives available if you look around a bit. – jippie Jun 10 at 6:46
1  
Just a small addition: you cannot abuse a USB port like this because the handshake happens at a much lower level than what you can access with normal programming languages. Parts of the handshake happen in the hardware. – Alexander Jun 10 at 15:20

What is your ultimate goal? If it is to observe the USB protocol, you can use a relatively inexpensive or relatively expensive logic analyzer.

If your goal is to capture bytes on your computer, you can get a USB debugger for your operating system (e.g., OS X has a free USB Debug Kit).

If your goal is to have an easy way to determine if you put a voltage onto an input, you'd be better off using a USB-->GPIO, as jippie suggested, or you could go down the (more expensive) arduino route and have a lot of room to grow if you wanted to do more stuff with the inputs prior to analysis on the computer.

If you really want a super-simple way to get a voltage value into your computer without buying new hardware, jippie's suggestion to use the parallel port is a good one, and you could also investigate using your microphone input as a jerry-built solution.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.