How to improve the data rate in USB bulk transfer?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
S3159
Level 2
Level 2
10 replies posted 5 questions asked 5 replies posted

Attachment is my project. 

I want to sample 26 channels and send these data to PC by USBFS.

Now the data rate in Streamer.exe is 700KByte/s. (about 8.5Mbps in wireshark. )

0 Likes
3 Replies
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

@S3159 ,

I'm not your bulk transfer USB expert.

However I do have some experience with the PSoC ADC.

Based on your current project settings:

  • You are use two sequencing SARs
    • ADC_SAR_Seq_1 => 26 channels at 12-bit res.  Sampling rate: 25,641 sps for all channels.
    • ADC_SAR_Seq_2 => 2 channels at 12-bit res.  Sampling rate: 333,333 sps for all channels.
  • At 12-bit resolution, the maximum per channel rate is 666,666 cps (channels per sec).
  • At 12-bit resolution and 2-bytes per sample, you would need, at minimum, a transfer rate of (666,666 x 2 bytes 😃 1.333 MBps. (Not achievable with USB 2.0).
  • At 12-bit resolution and 1.5-bytes per sample, you would need, at minimum, a transfer rate of (666,666 x 1.5 bytes 😃 1.000 MBps. (Still not achievable with USB 2.0).  Note:  This  byte packing technique requires CPU intervention for every sample and will probably take longer than straight DMA of 2-bytes.

Suggestions:

#1

Logically, the best you can hope to do if you can achieve near the 700KBps from the USB is half the channel sampling rate. (ie. 333,333 cps)  At 2-byte transfers, this should require 666,666 Bps.

#2

No matter what CPU platform you are using analog and digital noise is going to be present in your analog signal and in your ADC count result.   The higher your resolution the more bits will be available to convert the noise.

I recommend in order to lower your USB transfer rate, to take multiple samples for each channel and average the result.   This averaged result can be the data you transfer over the USB.  It is a common practice that averaging a signal across multiple samples can lower the effective noise measured.

In a previous project of mine, I simplified the averaging done on the PSoC.  I accumulated 8 samples per channel and added them together.   Once I had all 8 samples added, I performed a logical right shift by 3 (>>3)  Since the number of samples were 2 to the 'nth' power, I logically shifted the result by the 'nth' therefore it did not require a more complex and time consuming division.

Since you are capturing a 12-bit signal, if you are willing to send the 2-byte accumulated multiple sample WITHOUT any averaging on the PSoC, you can perform the averaging on the host side by knowing how many samples were accumulated.   This may allow you to get a more accurate result by using extended integer or floating point math on the host.  This may improve your effective resolution beyond 12-bit.  Note:  The maximum number of samples per channel you can acquire is 16.   Anything beyond that might overrun a 2-byte accumulator if the sample is near full-scale.

One more note:  Using the sample averaging method listed in #2 allows to to acquire samples at the maximum conversion rate.  The issues dealt with in #1 may not apply since you are keeping the data on the PSoC and averaging BEFORE transferring to USB.

#3

The USB HW on the PSoC is only capable of 64 byte transfers at a time.   This is due in part to the HW only having a 64 byte FIFO.   You can send more than 64 bytes but it will get broken up as separate data packets.

#4

I looked up Streamer.exe on the internet.   There were some concerns and cautions on using this executable.

Apparently there might be multiple companies using this executable name (including Cypress Semiconductor).  There were warnings of a potential virus being introduced.  I don't know if it applies in this case.

 

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

There were many threads discussing USBFS bulk and isochronous data transfer to PC. They discuss the limitations in speed and possible solutions. You may find some older links here

Re: ADC Data to PC via USBUART  

 

One possibility is to use ADC_SAR parallel output bus and external bus-to-USB chip to transfer data to PC 

Re: PSOC5LP SPI Interface maximum transfer rate  

Digital comparator and ADC  

 

0 Likes
Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

@S3159 ,

I almost forgotten.  The USB has a 16-bit transfer mode.   This may provide an increase in overall transfer rate.  However I've never used that mode.  Maybe someone else can enlighten us.

Len
"Engineering is an Art. The Art of Compromise."
0 Likes