Go Down

Topic: Transaction Speed (Read 146 times) previous topic - next topic

denschmitz

I'm working on a python conduit over USB and am running up against a weird speed limit. I'm exchanging 32 byte messages with the Arduino from my PC and am getting around 245 transactions/sec. However, with a baud rate set at 2000000, I expect it to be far faster.

I'm looking for suggestions where to look for speedup. The python code is pretty lean, and I've tried just sending hardcoded bytes (avoiding buffers and packets, etc) both ways with similar round trip times.

Is there a speed limit in the FTDI chips? Am I not really going at 2Mbaud?
 

Robin2

What's in the PNG? It looks like program code.

Please don't post pictures of text. Just copy an paste the text, and use the code button </> for programs

USB performs better with data packets that are 64 bytes or bigger - but without seeing your programs I can't say more than that.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

denschmitz

#2
Nov 17, 2018, 06:14 pm Last Edit: Nov 17, 2018, 06:32 pm by denschmitz
Sorry about that, I had to clean up some of the code before I'd let anyone see it. I put it in my github:

https://github.com/denschmitz/Pwnduino

The screencap is of a Jupyter notebook accessing the Arduino. Here it is in text:

Code: [Select]

In [1]: import os, time, serial
        from pwnduino import Pwnduino, INPUT, OUTPUT, HIGH, LOW, list_arduino_ports, com_grep

        ARDUINO_PORT = list_arduino_ports()[0] # find first arduino port, crash if none
In [2]: duino = Pwnduino(port=ARDUINO_PORT)
        assert duino.is_open
opened Arduino Mega 2560 on port COM13

In [3]: time.ctime(duino.time)
Out[3]: 'Wed Dec 31 19:00:00 1969'

In [4]: duino.time = time.time()
In [5]: time.ctime(duino.time)
Out[5]: 'Sat Nov 17 11:47:20 2018'

In [6]: t0 = time.time()
        for i in range(1000):
            x = duino.digitalRead(13)
        t = time.time() - t0

In [7]: print(1000/t)
241.7502510124071

In [8]: duino.close()
send thread killed
receive thread killed
closed Arduino Mega 2560 on port COM13...

In [9]: duino = Pwnduino(port=ARDUINO_PORT)
        assert duino.is_open
        opened Arduino Mega 2560 on port COM13

Robin2

#3
Nov 17, 2018, 06:30 pm Last Edit: Nov 17, 2018, 06:32 pm by Robin2
Sorry about that, I had to clean up some of the code before I'd let anyone see it. I put it in my github:
If you want me to look at it please post the code here.

Help us to help you.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up