High Speed USB PHY
Posted: Wed Jul 10, 2019 4:29 pm
Hello all,
I am currently programming a Pyboard D SF3W for MHz ADC datalogging. I am writing data continuously to the PC over the USB serial connection, receiving it using Pyserial and writing to a numpy array on the PC, the code I am using for this operation is below.
1) main.py code:
2) receiving.py code:
The issue I am facing is that this operation takes 2.2 seconds to write/receive 1 second of data (time writing to the numpy array is negligible). It seems that the USB transfer rate ~7Mb/s, which appears typical of the USB FS connection from checking previous forum posts.
I have installed the pybcdc.inf drivers that come with the board and have included the
pyb.usb_mode('VCP+MSC', port=1)
line in boot.py. However switching between port = 0/1 makes no difference to the transfer rate. The USB port I am using on the PC is USB 3.0 l, version of MicroPython is v1.10-445-ga9b1d3ca3, baudrate is 115200 and hardware flow control is enabled on windows COM port properties.
Is there something I am missing to be able to use the HS USB PHY that comes with the board or is it the method of transfer which could be improved, what speeds should be achievable with HS enabled/optimised?
Thanks!
I am currently programming a Pyboard D SF3W for MHz ADC datalogging. I am writing data continuously to the PC over the USB serial connection, receiving it using Pyserial and writing to a numpy array on the PC, the code I am using for this operation is below.
1) main.py code:
Code: Select all
*imports
usb = USB_VCP()
adc = ADC(Pin('X12'))
reads = 1000
buf = array("H",[0]*1000)
t = pyb.Timer(1,freq=1000000)
for term in range(reads):
adc.read_timed(buf,t)
usb.write(buf)
Code: Select all
*imports
reads = 1000
data = numpy.zeros((reads,1000),dtype='uint16')
ser = serial.Serial('COM7', 115200,timeout=0.5)
read = bytearray(2000)
for x in range(reads):
ser.readinto(read)
data[x,:] = numpy.frombuffer(read,dtype='uint16')
I have installed the pybcdc.inf drivers that come with the board and have included the
pyb.usb_mode('VCP+MSC', port=1)
line in boot.py. However switching between port = 0/1 makes no difference to the transfer rate. The USB port I am using on the PC is USB 3.0 l, version of MicroPython is v1.10-445-ga9b1d3ca3, baudrate is 115200 and hardware flow control is enabled on windows COM port properties.
Is there something I am missing to be able to use the HS USB PHY that comes with the board or is it the method of transfer which could be improved, what speeds should be achievable with HS enabled/optimised?
Thanks!