23
\$\begingroup\$

I want to build a USB oscilloscope. I was reading about different USB transfer types. Which transfer type is best to transfer the collected ADC samples from a USB oscilloscope to a PC?

Below are a few of my findings. Please correct me and also it would be good if anyone could suggest a good transfer type.

  1. Isochronous transfer - Possible loss of data. Not good for an oscilloscope since each data item is valuable. How much data could be lost?
  2. Interrupt mode - I have no idea if it would flood the USB connection
  3. Bulk mode - Seems the best to me since no loss of data
  4. Control transfer - not suitable since it is not meant for transfering data
\$\endgroup\$
3
  • 2
    \$\begingroup\$ From what I've read, most scopes with usb use bulk mode to send screenshots of the scope. \$\endgroup\$
    – Passerby
    Sep 8, 2015 at 12:20
  • \$\begingroup\$ Presumably if you go with isochronous mode you could reserve a bit of extra bandwidth for error correction. \$\endgroup\$
    – user253751
    Sep 9, 2015 at 9:33
  • \$\begingroup\$ Or for gross overkill, PCIe DMA tickles my fancy. \$\endgroup\$
    – Mitch
    Sep 9, 2015 at 16:11

4 Answers 4

28
\$\begingroup\$

Bulk transfers do not lose data, but they have no guaranteed minimum bandwidth. (On the other hand, they can reach higher speeds, because they are able to use all the bandwidth not actually used by any other transfers.)

What happens when your oscilloscope's data transfers are delayed (either because of errors, or because of other devices), and new data is piling up? Do you stop the device until the old data is transmitted, or do you throw away the old data to be able to transmit the current data?

Isochronous transfers are designed for 'real-time' data. You get no choice about the error handling, but your bandwidth is reserved on the bus.

  • If you want to display the recorded data in real time, you should use isochronous transfers.
  • If you want to transfer the recorded data to the PC after the measurements have finished, you should use bulk transfers.
\$\endgroup\$
10
\$\begingroup\$

The question is almost completely independent of your use as an oscilloscope, and is completely governed by the types of communications you are asking USB to do. For example:

  • An oscilloscope which has a large (multi-megabyte) buffer internally and is designed to run a short test first, then upload the data, would use entirely bulk transfer. It has no need for guaranteed bandwidth, so the high volume with error checking of bulk transfer will be best.
  • An oscilloscope which is designed to be continuously hooked up to circuit under test on a continuous basis and must operate in "real time" (read: deterministic run time) would choose isochronus. Bulk offers no deterministic runtime guarantees, and you cannot set up your pipe to have reserved bandwidth. You'll have to do your own error corrections, but at least they can be done deterministically.
  • An oscilloscope with a "live" feed for human viewing plus a high speed capture on a trigger may set up two endpoints, one isochronus to keep up with the live feed and bulk transfer for the triggered data. For human consumption, losing a frame or two is not a big deal, so there's no reason to worry about the lack of error checking on isochronus. However, when it comes to the actual data, you transfer it in bulk for error correction.
  • One might use this circuit as part of a live system. It might not only be the oscilloscope but also a safeguard against signals that indicate the circuit is leaving operating ranges and needs to be shut down by the computer. In this case, you may add an interrupt endpoint to the system, to get a guaranteed latency (and some well defined error handling) to make sure the issue gets serviced before it breaks circuits.

Once you know what sort of data you are transmitting, and the Quality of Service (QoS) terms that data needs to arrive under, then you can decide which USB transfer mechanism to do. You will know that you are ready to make these decisions when the word "oscilloscope" is no longer required to describe the data and QoS you need. Then you know it is in objective enough words to start addressing these issues.

\$\endgroup\$
4
\$\begingroup\$

For an oscilloscope, the bandwidth of the transfer is the parameter you want to maximize. Bulk transfer is designed specifically for high bandwidth, so that is the correct choice. While isochronous and interrupt transfers put bounds on latency, they are only intended for low- to medium-bandwidth data streams.

\$\endgroup\$
3
\$\begingroup\$

Just use bulk transfers. An oscilloscope is not actually a high data rate device. Unless you are planning on making a digital phosphor type design, an oscilloscope is really just a window into a very small part of a waveform. For example, let's say you want to show 1000 horizontal pixels and refresh the display at around 30Hz. If the samples are 8-bit each (this is typical) and there are two channels, you are looking at only 60,000 bytes/second. Full speed USB can do about 1,000,000 bytes/sec, so you are using less than 6% of bus throughput capacity. That gives plenty of time for letting the bulk transfer mode do its thing (correct errors, work around other bus traffic), and it is unlikely you will ever encounter a real-life bus configuration that won't be able to allocate you enough bandwidth for that much data.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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