USB interface
From PHCC
PHCC USB Interface
Speed Considerations
If you look at the (marketing) numbers of USB, it sounds great. For USB 1.1 those numbers are
- Low Speed: 1.5Mb/s
- Full Speed: 12Mb/s
and USB 2.0 adds a third speed:
- High Speed: 480Mb/s
Note: the above numbers with "Mb/s" are MegaBIT per second.
The problems here are:
- USB data rates are not per-device, but per bus (bandwidth)
- USB data rates are "raw". No device will ever get up to that number
- there is protocol overhead
- the protocol doesn't allow just blasting bits over the wire whenever the user feels like it. Packet size and frame transmit times are limited
- As more and more devices supporting USB make it to the market, people start using them
- This leads to lots of USB devices dangling from user's PCs.
- Since all devices on the bus share the bandwidth, things get slower with more devices
- some devices need lots of bandwidth, and if lots of data is transferred, the bandwidth is taken away from other devices
- webcams
- USB harddrives/cdroms
- USB card readers for compact flash, MMC, SD, ...
- digital cameras
- Many commerical USB devices with a higher bandwidth need use some nasty tricks to make USB faster. This, of course, can have adverse effects if you have other devices on the bus.
- one of the tricks seems to be to decrease the period of transmits (USB frame) from its defined value of 1ms to shorter periods. This violates the USB specs!
For more info, esp. on USB bandwith, check out the PDF from Microchip's Masters Conference 2004:
http://techtrain.microchip.com/masters2004/downloads/classes/858/858.htm
This contains some very good info.
USB vs. RS-232
If we were to compare the actual usable bandwidth of the RS-232 serial port and USB (low speed), RS-232 would clearly be the winner, even with (RS-232) speeds as low as 19200 bits/s.
We need at least the next USB speed class, full speed, to outperform RS-232. However, if there's a lot going on on that USB bus, effective data tranfer rates could drop below those of RS-232.
Here are a few quotes from the above mentioned document from Microchip:
Regarding Full Speed USB:
- "Realistic raw data throughput to a single peripheral is ~1.0 MB/s"
- "Only 64KB/s in many cases"
Regarding Low Speed USB:
- "8- byte data transfer every 10 ms"
- "= 800 Bytes/ second only"
USB and PHCC
To use PHCC effectively with USB, we should skip low speed USB entirely as its just not up to the task. High speed USB is only available on USB2.0, and, more importantly, microcontroller-based interface chips are harder to come by and more expensive. Of course, you would have to optimize your program to make use of the higher speed offered.
This leaves us with Full Speed USB. There are many chips that can be used, those from FTDI are good, easy to work with, cheap and they don't need to be programmed. Their FT232 series fits the bill perfectly as it can talk RS-232 on one side and USB on the other side. It doesn't need a whole lot of external components.
In fact, this chip is used in many of the commerical serial-to-USB converters found on the market.