Raw USB port

Go To Last Post
17 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To me, USB is rather a black box because I can’t access all technical resources and services that are available to most engineers in the world.

So it is impossible for me to design a project that uses USB port.

 

But may I ask one question?

Do you think it is possible for a USB PC driver to have a simple (raw) command that sets the level (high/low) of the USB data pin D+ and of D-?

If it is, is there a USB PC driver, you know, that has such command?

 

Thank you.

This topic has a solution.

Last Edited: Thu. Jan 14, 2016 - 04:43 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There's usb reset, but that would be buried down low i think.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:

There's usb reset, but that would be buried down low i think.

 

Thank you for your reply.

 

As you know, most pins of the printer and COM ports could be set/reset each. So I was able defining special protocols using these ports in order to control external devices (relatively slow) and MCUs.

Now, it seems there is not even 'one' digital pin, on the new laps and PCs, that could be set/reset by a program via a driver.

  

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I assume you can not get/use e.g. an external FTDI device/dongle? Some of those have several pins that can be individually controlled. Last time I looked the FTDI drivers had support for wiggling the FTDI-chips GPIO pins.

 

Example: https://www.adafruit.com/product...

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

Last Edited: Wed. Jan 13, 2016 - 08:00 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

KerimF wrote:

To me, USB is rather a black box because I can’t access all technical resources and services that are available to most engineers in the world.

So it is impossible for me to design a project that uses USB port.

Why it is impossible for you ?

The most common way to use USB is via Virtual COM port drivers, and they work in most any language.

I can write this, in FreeBASIC

If Open Com ("com2:57600,n,8,1,cs,ds,bin" For Binary As #1) <> 0 Then 

and then control the TXD and Handshake lines, the same as old PC's (but with a little more latency)

Devices that use VCP interface are available from FTDI, SiLabs, Microchip, Cypress, NXP, EXAR....

 

KerimF wrote:

Do you think it is possible for a USB PC driver to have a simple (raw) command that sets the level (high/low) of the USB data pin D+ and of D-?

If it is, is there a USB PC driver, you know, that has such command?

That is unlikely, as the Operating system polls (at 1ms intervals, IIRC) every USB port, checking if you plugged something in.

Last Edited: Wed. Jan 13, 2016 - 08:44 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Salaam Kerim.

 

Have you investigated or considered V-USB? https://www.obdev.at/products/vu...

 

I have used it for several little projects with success.

 

Cheers,

 

Ross

 

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why it is impossible for you ?

Does your country really block access to:

 

http://www.usb.org/developers/docs/

 

Everyone who has ever used USB has surely learned (or is that learnt?) most of what they know about USB from usb.org.

 

The other resource that almost everyone using USB will have used are the books/documents by Jan Axelson:

 

http://janaxelson.com/usb.htm

 

I suppose it's true that some of the info is in commercially available books so there might be issues making international purchases?

 

Of course a lot of what the world knows is written down at:

 

https://en.wikipedia.org/wiki/Ma...

 

and that has reams about USB.

Do you think it is possible for a USB PC driver to have a simple (raw) command that sets the level (high/low) of the USB data pin D+ and of D-?

If it is, is there a USB PC driver, you know, that has such command?

That sounds like you just want a couple of IO on the PC - where does the "USB" actually come into this if you are just going to treat D+/D- as two IO pins? I think you may be looking at USB at the wrong level if you are actually concerned about the signalling on the D+/D- wires. In fact the whole point of USB is to put higher layers on top of the low level transport protocol so you never need to worry about the implementation. I suppose it's a bit like Ethernet and TCP/IP. Most users of those things only concern themselves with high level concepts like FTP and HTTP and are not concerned about how the information is actually carried from one place to the other. USB is just like that.

 

(I suppose this all goes back to OSI Seven Layer models in fact - you have to pick which level you want to get your hands dirty with - the low level transport and signalling is not usually the level at which you use such things).

 

For USB your concerns are more like "what kind of device do I want to make today?". Will it be "virtual serial" (aka "CDC-ACM" = Communications Device Class - Abstract Control Model) or a "memory stick" (MSD = Mass Storage Device) or a Printer (Printer) or a keyboard/mouse/joystick (HID = Human Interface Device). Don't worry about how these things "appear" on the D+/D- signalling.

 

Having said all that when you design/implement USB devices there is a limit imposed by the implementation you probably do need to be aware of and that is that the "clock" for USB is effectively 1ms. You cannot make things happen faster than an "information exchange" every 1 millisecond. Now as it happens you use memory buffers which in USB are called "endpoints" and these are typically 64 or 128 bytes in so you can often arrange to send or receive a complete 64 or 128 bytes every 1ms but what you cannot do is send/receive individual bytes every 4 microseconds or something like that (as you might with SPI or a UART or something). So you have to think about your information transfer and how you might want to block things up into lots of 64 or 128 bytes to get the best throughput on the data channel available.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If it is, is there a USB PC driver, you know, that has such command?

Doubtful, and even if you found one, doubtful it would work universally, as much of the low level USB is done in hardware. 

It is not like an old RS-232 or Centronics parallel port where the BIOS had control of the low level hardware.

 

Ross mentioned V-USB, which lets a uC talk to a USB driver on a PC.

The FTDI chips are expensive, but work great.  PC to FTDI chip, which then connects to the USART on the uC, for two way comm's between the PC and the uC.

The uC then decodes commands, e.g. Set Portc.2 high, etc.

 

Some of the uC's have a USB hardware module to handle much of the interface.

Dean's LUFA software and examples demonstrate their use.

 

JC 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Johan wrote:

I assume you can not get/use e.g. an external FTDI device/dongle? Some of those have several pins that can be individually controlled. Last time I looked the FTDI drivers had support for wiggling the FTDI-chips GPIO pins.

 

Example: https://www.adafruit.com/product...

 

Thank you for the link. But as you already guessed I can't get an external board. At best, I may be able to find an MCU that has a USB interface though the package of such MCU is likely not PDIP.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Who-me wrote:

The most common way to use USB is via Virtual COM port drivers, and they work in most any language.

 

This could be great if I can get/order a device that uses VCP interface.
But thank you for the hint.

Who-me wrote:

That is unlikely, as the Operating system polls (at 1ms intervals, IIRC) every USB port, checking if you plugged something in.

 

You are right, I forgot the OS checking routine.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Do you think it is possible for a USB PC driver to have a simple (raw) command that sets the level (high/low) of the USB data pin D+ and of D-?

 No, this isn't possible.  What you are asking for is roughly equivalent to "can I set the antenna of my radio to a particular voltage?"  (Or perhaps "can I use the RJ45 Ethernet port as 8 bits of General Purpose IO?")

 

Now, it seems there is not even 'one' digital pin, on the new laps and PCs, that could be set/reset by a program via a driver.

  That is the way things seem to be.  What kind of USB peripherals or chips CAN you get?  For example, many USB keyboards have an LED or two than can be program-controlled.  And people have made audio outputs do more than just audio...

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ross wrote:

Salaam Kerim.

 

Have you investigated or considered V-USB? https://www.obdev.at/products/vu...
I have used it for several little projects with success.

 

Cheers,
Ross

Good morning Ross.

 

I downloaded vusb-20121206.
From the first sight and as you said, it seems good and detailed.

 

Thank you for introducing this interface.

 

Kerim 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you, clawson, for the hints and references.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"USB" defines both hardware and protocol. You cannot "just send single bits" like you could with RS232. That is exactly how USB is NOT supposed to work. It needs to support memory devices AND human interface devices (mouse, keyboard) communication devices (virtual COM ports) AND audio and more. And, it must do that simultaneously over a shared USB channel (a physical port and cable). Individual bit access would cause that shared operation to fail. Further, everything is handled by predefined packet at specific bit rates. Everything MUST go through an "enumeration" process by which USB devices identify themselves and agree (with the host) about how they are to operate.

 

So, NO, there is no bit-level access to USB. That is on purpose. 

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

westfw wrote:

And people have made audio outputs do more than just audio...

 

You are right, I forgot this output. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

KerimF wrote:
But as you already guessed I can't get an external board.
An alternative to an FTDI is the CH340 series; these are ubiquitous from China in IC and on a board.

CH340G is in SOIC (1.27mm pitch); easy to solder.

CH340R and CH340T are SSOP (0.65mm pitch); do-able to solder.

Located some CH340 on Mac OS X; did not search for Linux or Windows though both do exist.

 

Laptops - most likely Windows, next most likely is Mac OS X, though there are some off-the-shelf with Linux (for US usually Dell for notebook and maybe HP for desktop; a number of local or regional Linux shops sell laptops).

 

Prolific PL2303SA (maybe only TXD and RXD) is in SOP8; that might be 1.27mm pitch.

Remainder of the PL2303 series (TXD, RXD, GPIO) is in SSOP; most are no crystal!

Some B&M about Prolific drivers though some do like Prolific USB bridges.

KerimF wrote:
At best, I may be able to find an MCU that has a USB interface though the package of such MCU is likely not PDIP.
Please consider moving to SMT.

There are some 1.27mm pitch SMT prototyping boards; easy to solder.

There's a plethora of SMT pitch adaptors; not easy for QFP or QFN but once the pitch is 1.27mm or 2.54mm you're good to go onto your preferred prototyping board.

Breakout boards with a USB AVR already soldered are available; in mind are PJRC Teensy 2.0 and Teensy++ 2.0

Likewise there are breakout boards for op amps and etc.

There are a relative few AVR and SAM D in SOIC (1.27mm pitch).


mac-usb-serial.com logo

Mac OS X Drivers for CH340 / CH341 / PL2303 USB to RS-232 Devices

Specifications Winchiphead CH340 / CH341 / HL340 driver

https://www.mac-usb-serial.com/wordpress/support/specifications-winchiphead-ch340-ch341-hl340-driver/

mac-usb-serial.com logo

Mac OS X Drivers for CH340 / CH341 / PL2303 USB to RS-232 Devices

Serial Port Programming in Swift for Mac OS X

https://www.mac-usb-serial.com/wordpress/serial-port-programming-swift-mac-os-x/

Prolific Technology

USB to Serial/Parallel

http://www.prolific.com.tw/US/ShowProduct.aspx?pcid=41&showlevel=0041

For only the PCB, try a search at AliExpress for

Free shipping PL2303SA USB PCBA prototype customized manfacturing

in

Alibaba Group

CHENONN Electronic Limited - Small Orders Online Store, Hot Selling diy project,pcb phone,diy steam and more on Aliexpress.com

http://www.aliexpress.com/store/125918?spm=2114.10010108.0.610.e96QIV

Prolific USA

PL2303SA USB to Serial Bridge Controller

http://prolificusa.com/portfolio/pl2303sa-usb-serial-bridge-controller/

Edit : PL2303SA - strike throughs, URL

"Dare to be naïve." - Buckminster Fuller

Last Edited: Thu. Jan 14, 2016 - 09:33 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

KerimF

Are you there?

May I ask you a question at PM?

I have a short MP3 of an Arabic music. trying to find the original music but...

 

Sorry for off-topic question.

I thought probably it's better to get a permission before sending PM.

"One's value is inherent; money is not inherent"

 

Chuck, you are in my heart!