批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程
[批处理文件精品]批处理版照片整理器[批处理文件精品]纯批处理备份&还原驱动在线第三方下载
返回列表 发帖

[文件操作] 求助!利用现有函数通信COM串口,控制串口设备。

本帖最后由 vince 于 2019-6-11 12:24 编辑

下面是该软件的命令函数和结构,希望有大神能帮我做个基本代码架构,可以通信COM串口,我本地的串口端是COM4。
这个设备是马达旋转台的设备,一共有6个旋转等级。
  1. Software Control
  2. 1. Application Software Operation
  3. The FW102C(NEB) and FW212C(NEB) come with a CD-ROM that contains application software to control the unit using USB 2.0, or RS232, from a PC. (See Thorlabs Motorized Filter Wheel Software Manual).
  4. Minimum PC Requirements
  5. The application program requires a minimum of a Pentium-class machine running Windows XP or newer.
  6. Command Line Interface
  7. The FW102C can also be controlled by a command line language through the USB or RS232 ports. This is offered to enable operation through a terminal interface or for those who may want to write their own program to control the wheel. Prior to running the command line interface, the unit should be powered, and a USB or RS232 cable should be connected between the FW102C and the host. The terminal emulator should be configured as follows:
  8. Parameter      Setting
  9. Baud Rate      115.2 K Bits per Second
  10. Data Bits        8
  11. Parity             None
  12. Stop Bits        1
  13. Flow Control   None
  14. If the connection is correct, you will see the following message after pushing the Enter key:
  15. 2. Command error CMD_NOT_DEFINED
  16. This message will be followed immediately by the prompt:
  17. >
  18. The basic structure of the interface is a keyword followed by either an equals sign “=” or a question mark “?”. The“=” or “?” will determine if the string is a command or a query. All strings (commands and queries) must be terminated by a carriage return (CR) or pressing the ENTER key on the computer.
  19. 2.1. Command Structure
  20. Keyword = argument (CR)
  21. Here, keyword defines the function, and argument is a numerical value followed y a carriage return (CR).
  22. 2.2. Query Structure
  23. Keyword? (CR)
  24. Keyword defines the function, and the question mark (?) indicates a query. The string is terminated with a carriage
  25. return (CR). Exceptions to this and unique shortcut keys are given in the table on page 11.
  26. The prompt symbol “>” will appear on power-up and after a command is accepted by the FW102C and indicatesthat the FW102C is ready to receive another command line.
  27. 2.3. Keywords (Commands and Queries)
  28. The following table describes all of the available commands and queries:
  29. Command              Syntax               Description
  30. Get ID                   *idn?                  Returns the model number and firmware version
  31. Set Position            pos=n                moves the wheel to filter position n
  32. Get Position            pos?                   Position Query
  33. Set Position Count   pcount=n           Sets the wheel type where n is 6 or 12
  34. Get Position Count   pcount?              Returns the wheel type
  35. Set Trigger Mode     trig=0                Sets the external trigger to the input mode
  36. ~                            trig=1                Sets the external trigger to the output mode
  37. Get Trigger Mode     Trig?                  Returns the trigger mode
  38. Set Speed Mode        speed=0           Sets the move profile to slow speed
  39. ~                             speed=1            Sets the move profile to high speed
  40. Get Speed Mode        speed?             Returns the move profile mode
  41. Set Sensor Mode       sensors=0        Sensors turn off when wheel is idle to eliminate stray light
  42. ~                             sensors=1        Sensors remain active
  43. Get Sensor Mode       sensors?           Returns the sensor mode
  44. Set Baud Rate           baud=0            Sets the baud rate to 9600
  45. ~                              baud=1           Sets the baud rate to 115200
  46. Get Baud Rate           baud?              Returns the baud rate where 0 = 9600 and 1 =115200
  47. Save Settings            save                 This will save all the settings as default on power up
  48. "All commands and queries are in lower case letters.
  49. If the keyword, format, or argument are incorrect or out of range, the unit will return an errorstring.
  50. In addition to the commands given above, there is also special functionality added to thearrow keys of the computer’s keyboard:
  51. Key                     Description
  52. Up Arrow             Increments the filter position by 1
  53. Down Arrow         Decrements the filter position by 1
复制代码
I’m from tomorrow.
Will go to the future.

什么叫 “基本代码架构”?
根据你的文档描述,
1.设备的随机光盘就已经有应用程序可以控制操作设备了。
2. 串口命令行的操作命令也详细说明了。  应该虚拟终端串口连接上,按命令语法就可以操作了。

TOP

回复 2# cfwyy77_bat

现在是有软件可以控制这个设备的,想做个可以自动化脚本来控制这个设备,可以通过代码来控制旋转平台。
I’m from tomorrow.
Will go to the future.

TOP

FW102C是THorlabs的电动滤光轮?
如果是的话,官方的软件帮助目录里面提供了开发的SDK
里面有底层的dll库,demo的C++源码,有了这些你想干嘛都可以,可以做一个命令行工具能接受一些参数,然后bat或者命令行去调用它。或者直接用其它脚本语言如python,vb等去调dll库。

TOP

返回列表