First experiments using native USB CDC (communications device class) on STM32's, using the CubeMX libraries:
It's been surprisingly straightforward to get working. I basically just followed this video from ST, with a few minor changes. I've been able to hit up to 650 kilobytes/s transfer (micro to computer) which seems to be the limit for the ST libraries. Put another way, I can log ~160 floats at 1 kHz. Although not nearly as fast as USB Full Speed can be, it's way faster than serial, it's non-blocking, has CRC error checking with auto-retry, variable packet size, and so on. Overall a very nice data transfer experience. It's great to not have to think about packet structure, accidentally being off by one byte, error checking, and all the other headaches that usually go along with serial.
The gif is a PyQt GUI using PyUSB for USB data transfer, using pyqtgraph for plotting, same as the dynamometer GUI. Plotting performance is a little disappointing. I get ~9 FPS plotting 19 traces at 2000 points/trace. Performance seems to scale linearly with number of traces, but not with number of points, which is kind of interesting - plotting 1/5 as many points only increases the frame rate by 50%.
No comments:
Post a Comment