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!