为了满足伺服数据采集系统数据传输的需要,设计了一种USB接口方案。针对以STM32为主控芯片的伺服驱动器,根据其集成的USB模块的特点,采用虚拟串口传输方式,设计了基于通信设备类(CDC)的USB通信模块;根据伺服运行的特点,优化了USB模块在主程序中的集成方式;定义了与上位机通信的帧格式,并设计帧解析与响应的状态机。实际测试结果表明,方案能有效用于伺服数据采集,为伺服性能分析与调试提供了极大便利。
Aiming at meeting the data transmission requirement for the servo data acquisition sys- tem,a kind of USB interface scheme was designed. In allusion to servo drivers which were built up with STM32 microprocessor,the interface was recognized as a virtual serial port and USB communication was designed based on the communication equipment class(CDC) when taking the STM32 intergraded USB module' s characteristics into account. The task schedulers of USB module were optimized considering the servo characteristics. Several kinds of frames were defined to communi- cate with the PC, furthermore, a related state ma- chine was realized. The test results indicate that, the scheme can be effectively used in the servo data collection and it is convenient to analyze and tune the property of servo drivers.