Go Down

Topic: fast SerialUSB for Arduino DUE (Read 10736 times) previous topic - next topic

sined23

Hi guys! Does anybody know fast SerialUSB library for Arduino DUE?
Current SerialUSB read data at 1Mbit/s but can be at 10Mbit/s easily.

ghlawrence2000

I DO get about 10mbit.... over 1MB per second......

It is down to what payload you transfer.

Regards,

Graham
UTFT_SdRaw now included in library manager!! ;) High speed image drawing from SD card to UTFT displays for Mega & DUE.
UTFT_GHL - a VASTLY upgraded version of UTFT_CTE. Coming soon to a TFT near you! 8) Shipping April 1 2016!

sined23

Hi Graham! I used in PC the following python script:


import serial
import sys

ser = serial.Serial(
   port = '/dev/ttyACM0',
   baudrate = 115200,
   parity = serial.PARITY_NONE,
   stopbits = serial.STOPBITS_ONE,
   bytesize = serial.EIGHTBITS
)

if ser.isOpen() == False :
   ser.open()
   if ser.isOpen() == False :
      print "Can't open serial port"
      sys.exit(1)


for i in range(100000) :
      ser.write('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')



In Arduino Due:

char buffer[48];

void setup() {
        SerialUSB.begin(115200);
}
 
void loop() {
   if (SerialUSB.available() > 0) {
              SerialUSB.readBytes(buffer, 48);
   }
}



Speed of read is around 1Mbit/s

How to make 10Mbit/s ? What's wrong may be in my scripts?

ghlawrence2000

Try lifting your read buffer to 256....

Regards,

Graham
UTFT_SdRaw now included in library manager!! ;) High speed image drawing from SD card to UTFT displays for Mega & DUE.
UTFT_GHL - a VASTLY upgraded version of UTFT_CTE. Coming soon to a TFT near you! 8) Shipping April 1 2016!

sined23

#4
Apr 07, 2016, 08:06 am Last Edit: Apr 07, 2016, 09:46 am by sined23
I did test. This is my results:

buffer 48:  121kByte/s=0,95Mbit/s
buffer 256: 129kByte/s=1Mbit/s


So, reading speed of SerialUSB is not very good.

You can look at comparing test results from the Internet:



It's very terrible that Arduino Due has so powerful hardware and so not optimal libraries.
Guys, let's fix it pls.

I found one solution here http://forum.arduino.cc/index.php?topic=339067.0
But I haven't so deeply knowledge to change libraries and provide it for all.
Can anybody from Arduino's experts optimize SerialUSB for fast reading?
Thanks in advance!

RayLivingston

The data rate is determined FAR more by the HOST device than the target device....

Regards,
Ray L.

sined23

#6
Apr 08, 2016, 11:23 am Last Edit: Apr 08, 2016, 11:38 am by sined23
it's 100% arduino's problem. I connected USB-RS485 adapter to PC and used the same python script. Speed was 2,5Mbit/s (and can be higher I think).
With arduino - max 1Mbit/s.

Can anybody pls help to optimize SerialUSB.read?

ghlawrence2000

Sorry sined23 for misleading you, my write speed is >10mb, my read speed is comparable with yours (133174 bytes/second). :(

I will see if I can make sense of the link you gave.

Regards,

Graham
UTFT_SdRaw now included in library manager!! ;) High speed image drawing from SD card to UTFT displays for Mega & DUE.
UTFT_GHL - a VASTLY upgraded version of UTFT_CTE. Coming soon to a TFT near you! 8) Shipping April 1 2016!

sined23

Graham, thank you! I will wait :)

Actually I also got write speed >10Mbit, even 40Mbit. But read speed is low :(

westfw

Quote
I connected USB-RS485 adapter to PC and used the same python script. Speed was 2,5Mbit/s (and can be higher I think).
Same Driver?  I believe the Due uses Windows built-in CDC driver, which is reported to be "not that great."  If your USB/RS485 driver has an FTDI or other chip that has its own driver, direct comparisons could be invalid.

Could be fun to poke at the Due code and see what changes have any effects...

ghlawrence2000

@westfw,

You have previously mentioned the thesycon driver, have you personally tried it?

@sined123,

The link you sent with those changes to USBcore etc, I tried what he suggested, and the difference is amazing, BUT it makes the received data unreliable....  Not suitable if your data is critical.

Regards,

Graham
UTFT_SdRaw now included in library manager!! ;) High speed image drawing from SD card to UTFT displays for Mega & DUE.
UTFT_GHL - a VASTLY upgraded version of UTFT_CTE. Coming soon to a TFT near you! 8) Shipping April 1 2016!

sined23

Graham, but is it possible to increase read speed without bit error?
I think it must be some way.

ghlawrence2000

Hi sined,

Yes it should be, but I am thinking this is over my head too..... Take a look at this document from Atmel, I think the problem is a poorly implemented USB/CDC core by the Arduino gang.... I am just reading it now to see if I can make head or tail of it...  :o

Regards,

Graham
UTFT_SdRaw now included in library manager!! ;) High speed image drawing from SD card to UTFT displays for Mega & DUE.
UTFT_GHL - a VASTLY upgraded version of UTFT_CTE. Coming soon to a TFT near you! 8) Shipping April 1 2016!

sined23

#13
Apr 09, 2016, 09:16 pm Last Edit: Apr 09, 2016, 09:24 pm by sined23
Graham, oh, it would very cool if you can deal with it

BTW: I found author of the usb libraries. It's Peter Barrett.
Also there are contributors:





Do you know somebody from them? May be they can join us?

sined23

#14
Apr 13, 2016, 11:34 am Last Edit: Apr 13, 2016, 04:49 pm by sined23
Perhaps my knowledge was enough :)
I increased USB read speed up to 8Mbit/s.
Speed can be increased more, but need optimize libraries more.

Pls, help to test it.

unzip fast_usbread.zip into hardware/sam/1.6.7/cores/arduino

after that you can use SerialUSB.readBlock(buffer, length) with high read speed

P.S. fast_usbread.zip is updated again

Go Up