Fubarino SD USB Serial.write transfer rate

Post Reply
MpaoDG
Posts: 2
Joined: Tue Jun 30, 2015 8:26 am

Fubarino SD USB Serial.write transfer rate

Post by MpaoDG » Tue Jun 30, 2015 8:33 am

HI,
I'm developing a simple ccd vision system and I need to rapidly transfer about 17Mb of data ( 2574 x 6896 bytes with pixel values ) from the Fubarino SD to a VB PC application.

I get an acceptable transfer rate interfacing the Fubarino SD board to a FTDI FT2232H reading pixel values from a PORT and writing them to the FTDI chip in FIFO mode. In this configuration the VB.NET application reads buffers ranging from a few hundred to a few thousand of bytes, as from the log file :
....
18:40:08.657 ImageArray Get buffer length :420
18:40:08.659 ImageArray Get buffer length :1012
18:40:08.662 ImageArray Get buffer length :1206
18:40:08.663 ImageArray Get buffer length :208
18:40:08.670 ImageArray Get buffer length :2952
18:40:08.671 ImageArray Get buffer length :1036
18:40:08.672 ImageArray Get buffer length :106
18:40:08.672 ImageArray Get buffer length :308
....

To reduce components count, I tried to do the same with the embedded USB port in the Fubarino SD board. After opening the port with Serial.begin(), I send data with this code :

for (nlinee=0; nlinee < 2574; nlinee++)
{
Serial.write(valCol,6896);
}

where valCol is a byte array of 6896 values.

Log file now gives :
....
07:49:35.178 ImageArray Get buffer length :63
07:49:35.178 ImageArray Get buffer length :63
07:49:35.179 ImageArray Get buffer length :29
07:49:35.179 ImageArray Get buffer length :63
07:49:35.179 ImageArray Get buffer length :63
07:49:35.179 ImageArray Get buffer length :63
07:49:35.180 ImageArray Get buffer length :126
07:49:35.180 ImageArray Get buffer length :63
07:49:35.180 ImageArray Get buffer length :126
07:49:35.181 ImageArray Get buffer length :63
07:49:35.181 ImageArray Get buffer length :63
....

and the transfer rate is of course not acceptable.

I tried to feed serial.write with bytes, bytes arrays, strings, but there are just minor changes in the transfer behavior. The received buffer length remains of 63 bytes, with few longer buffers of 63*2 or 63*3 bytes.

As far as I know, the PIC32MX795F512H in Fubarino SD 1.5 has a full speed USB port and I hope there is a way to improve the transfer speed, either using serial.write or bypassing it.
Any hint ?

The environment is:
Windows 7 Home Premium SP1
MPIDE : 0023 - windows - 20140821
Driver : Stk500v2 - 31/3/2013 - vers. 1.1.0.0. Schmalz Haus
VB - Visual Studio Community 2013

Thanks !
Marco

EmbeddedMan
Posts: 597
Joined: Tue May 24, 2011 9:24 pm
Location: Minneapolis, MN
Contact:

Re: Fubarino SD USB Serial.write transfer rate

Post by EmbeddedMan » Tue Jul 07, 2015 7:45 pm

Marco,

I'll bet you can do much faster than that. I think the trick is in how you read out the data from the USB buffer on the PC side. How often are you calling Read() in your PC code?

*Brian

GrahamM242
Posts: 65
Joined: Fri Feb 21, 2014 6:48 pm

Re: Fubarino SD USB Serial.write transfer rate

Post by GrahamM242 » Wed Jul 08, 2015 12:19 pm

It'll be interesting to see what kind of tricks can be used to improve speed, as I'm looking at doing something similar. Sadly I don't know enough about how USB works (yet) to know how much tuning can be done on the host or device end.

EmbeddedMan
Posts: 597
Joined: Tue May 24, 2011 9:24 pm
Location: Minneapolis, MN
Contact:

Re: Fubarino SD USB Serial.write transfer rate

Post by EmbeddedMan » Wed Jul 08, 2015 3:29 pm

Here's some good information : https://www.pjrc.com/teensy/benchmark_u ... ceive.html

*Brian

MpaoDG
Posts: 2
Joined: Tue Jun 30, 2015 8:26 am

Re: Fubarino SD USB Serial.write transfer rate

Post by MpaoDG » Thu Jul 09, 2015 12:18 pm

Brian,

on the PC side there is a loop that will read from the serial port until the number of received bytes (S_Inc) is equal to the pixel number of the image (S_Len). The incoming buffer is appended to a StringBuilder object (SB) that manipulates strings very fast.
This is the code :

Code: Select all

            
            SB.Clear()
            Do                                     
                Incoming = objSerial.Receive()                         
                Lbytes = Incoming.Length                          
                SB.Append(Incoming)                            
                S_Inc = S_Inc + Lbytes                   
            Loop Until S_Inc >= S_Len
However in the meantime, I've done some similar tests with the Teensy 3.1 board, using the same acquisition software. In this case, on the PC side, length of the input buffer is consistently ot 4096 bytes per read and transfer time is accordingly much shorter :

10:43:54.905 ImageArray Get buffer length :4096
10:43:54.905 ImageArray Get buffer length :4096
10:43:54.920 ImageArray Get buffer length :4096
10:43:54.920 ImageArray Get buffer length :4096
10:43:54.920 ImageArray Get buffer length :4096
10:43:54.920 ImageArray Get buffer length :4096
10:43:54.936 ImageArray Get buffer length :4096
10:43:54.936 ImageArray Get buffer length :4096
10:43:54.936 ImageArray Get buffer length :4096
10:43:54.936 ImageArray Get buffer length :4096
10:43:54.951 ImageArray Get buffer length :4096
10:43:54.951 ImageArray Get buffer length :4096
10:43:54.951 ImageArray Get buffer length :4096

Marco

Post Reply