差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

后一修订版
前一修订版
instru_protocol [2021/02/22 13:06]
gongyusu 创建
instru_protocol [2021/10/27 10:36] (当前版本)
gongyusu
行 1: 行 1:
-## 仪器用数据传输及控制协议+## 硬禾仪器用数据传输及控制协议 
 +本逻辑用于将高速ADC采集到的数据进行缓存,并根据上位机的需要,从缓存的数据中选出用于显示的部分进行传输,传输的方式可以是: 
 +  * 串口UART 
 +  * BLE 
 +  * WiFi 
 +  * SPI 
 + 
 +FPGA的作用负责解析控制器发来的控制字,并根据控制字的内容从缓存中选取需要的数据 
 +  - 由ADC获取的数据或送往DAC的数据:LVDS:250MHz/​8bits/​4Lanes, 并行:100MHz/​14bits 
 +  - 需要显示的数据:20帧/​秒 * 1KPoints/​帧 * 10bit/​points = 200kbps 
 +  - 存储深度:ADC - 8K * 10bits * 2(通道)= 20KBytes, DAC - 4K * 12bits * 2 = 12KByte,总计32KBytes  
 + 
 +未来在FPGA里面可以扩展的数据处理功能: 
 +  - FFT 
 +  - 数字滤波 
 +  - 模式识别 
 +  - 机器学习 
 + 
 +FPGA内部的框图如下: 
 +{{drawio>​instru_control_data_protocol}} ​ <WRAP centeralign>​ 数据采集FPGA逻辑功能</​WRAP>​ 
 + 
 +#### 参考文档: 
 +  * [[scope_verilog|基于FPGA逻辑的示波器设计]] 
 +  * [[up5k_scope|双通道50Msps/​10MHz口袋示波器]] 
 + 
 + 
 + 
 +### 示波器部分的功能 
 + 
 + 
 +主要分为两部分: 
 +#### 双口RAM 
 +根据FPGA的内部Block RAM或外扩的RAM的实际情况设定双口RAM的大小,一般我们使用的Lattice XO2系列的FPGA内带的Block RAM为96kbits,如果采用双通道8位的高速ADC,​则每个通道可以使用的RAM空间为48Kbits ~ 6KByte,考虑到高速ADC可以采用更高分辨率,比如12bit,96Kbits ~ 12bits * 2 * 4K,每个通道为4KB的存储深度。 
 + 
 +#### 并/​串变换及控制逻辑 
 + 
 +### 任意波形发生器部分 
 + 
 +### 直流稳压电源部分 
 + 
 + 
 +### Waveformlive的仪器控制协议参考 
 +  * 下面的JSON数据已扩展以提高可读性。在传输之前,应将所有JSON缩小(删除空白). 
 +  * 除非另有说明,否则使用HTTP时,所有命令均使用POST方法发送. 
 +  * 所有Digilent Instrumentation协议命令必须是JSON对象或分块传输:​ 
 +    * **JSON对象** 
 +      * 必须以'​{'​字符开头,并以'​}'​字符结尾. 
 +      * 可能后跟一个或多个'​\ r \ n'. 
 +    *  **大块转移** 
 +      * 由一个或多个块组成. 
 +      * 每个块必须以ASCII十六进制格式的块中的字节数开头,后跟一个'​\ r \ n'​,二进制数据和一个'​\ r \ n'. 
 +        * 块长度在块长度和数据之间不包含'​\ r \ n'. 
 +        * 块长度不包含二进制数据后的尾随'​\ r \ n'. 
 +      * 每个分块传输都以零长度的分块终止. 
 +      * Ex. 
 +<​code>​ 
 +6\r\n 
 +chunk1\r\n 
 +8\r\n 
 +somedata\r\n 
 +E\r\n 
 + ​in\r\n\r\nchunks.\r\n 
 +0\r\n 
 +\r\n 
 +</​code>​ 
 + 
 +#### 多命令 
 + 
 +---- 
 +可以使用多命令在单个事务中发送多个命令。 
 + 
 +##### 举例: 
 +<WRAP group> 
 +<WRAP half column>​ 
 +**Command** 
 +<​code>​ 
 +
 +   "​dc":​{ 
 +      "​1":​[ 
 +         { 
 +            "​command":"​setVoltage",​ 
 +            "​voltage":​3300 
 +         }, 
 +         { 
 +            "​command":"​getVoltage"​ 
 +         } 
 +      ], 
 +      "​2":​[ 
 +         { 
 +            "​command":"​setVoltage",​ 
 +            "​voltage":​5000 
 +         } 
 +      ] 
 +   } 
 +
 +</​code>​ 
 +</​WRAP>​ 
 +<WRAP half column>​**Response**</​WRAP>​ 
 +<​code>​ 
 +
 +   "​dc":​{ 
 +      "​1":​[ 
 +         { 
 +            "​command":"​setVoltage",​ 
 +            "​statusCode":​0,​ 
 +            "​wait":​500 
 +         }, 
 +         { 
 +            "​command":"​getVoltage",​ 
 +            "​statusCode":​0,​ 
 +            "​wait":​100, ​            
 +            "​voltage":​3300 
 +         } 
 +      ], 
 +      "​2":​[ 
 +         { 
 +            "​command":"​setVoltage",​ 
 +            "​statusCode":​0,​ 
 +            "​wait":​500 
 +         } 
 +      ] 
 +   } 
 +
 +</​code>​ 
 +</​WRAP>​ 
 +\\ 
 +\\ 
 + 
 + 
 +#### 波形发生器部分 
 +提供访问任意波形发生器的数据和功能的命令 
 + 
 +##### 获得当前状态 
 + 
 +获得仪器通道的当前状态、 
 + 
 +##### 命令 
 +  * ** awg ** - (Object) - 任意波形发生器的目标. 
 +    * ** # ** - (Array<​Object>​) - An array of command objects to apply to the awg channel. 
 +      * ** command ** - (String) - 获取当前状态的命令:​ “getCurrentState” 
 + 
 +##### 响应  
 +  * ** awg **  - (Object) - 任意波形发生器的目标 
 +    * ** # ** - (Array<​Object>​) - An array of command objects applied to the awg channel. 
 +      * ** command ** - (String) - The Get Current State command: “getCurrentState” 
 +      * ** statusCode ** - (Integer) - A numeric value representing the device status. ​  
 +      * ** wait ** - (Integer) - The number of ms to wait before the device is ready to process another command.  
 +      * ** state ** - (String) - The instrument channel state: "​idle"​ or "​running"​. 
 +      * ** waveType ** - (String) - The waveform type: "​sine",​ "​square",​ "​triangle",​ "​dc",​ "​sawtooth",​ "​arbitrary",​ or "​none"​. 
 +      * ** actualSignalFreq ** - (Integer) -  The actual waveform frequency in mHz. 
 +      * ** actualVpp ** - (Integer) - The actual peak-to-peak voltage in mV. 
 +      * ** actualVOffset ** - (Integer) - The actual voltage offset in mV. 
 + 
 + 
 +##### 例子 
 + 
 +<WRAP group> 
 +<WRAP half column>​ 
 + 
 +** 命令 ** 
 +<​code>​ 
 +
 +    "​awg":​ { 
 +        "​1":​ [ 
 +            { 
 +                "​command":​ "​getCurrentState"​ 
 +            } 
 +        ] 
 +    } 
 +
 +</​code>​ 
 +</​WRAP>​ 
 + 
 +<WRAP half column> ** 响应 ** </​WRAP>​ 
 +<​code>​ 
 +
 +    "​awg":​ { 
 +        "​1":​ [ 
 +            { 
 +                "​command":​ "​getCurrentState",​ 
 +                "​statusCode":​ 0,                 
 +                "​wait":​ 0, 
 +                "​state":​ "​running",​ 
 +                "​waveType":​ "​sine",​ 
 +                "​actualSignalFreq":​ 1000000, 
 +                "​actualVpp":​ 3000, 
 +                "​actualVOffset":​ 0 
 +            } 
 +        ] 
 +    } 
 +
 +</​code>​ 
 +</​WRAP>​ 
 +\\ 
 + 
 + 
 +##### 设置通用波形 
 + 
 + 
 +设置AWG的通道参数以输出正常的波形 
 + 
 +##### 命令 
 +  * **awg** - (Object) - The arbitrary waveform generator object. 
 +    * **#** - (Array<​Object>​) - An array of command objects to apply to the awg channel. 
 +      * **command** - (String) - The Set Regular Waveform command: “setRegularWaveform” 
 +      * **signalType** - (String) - The waveform type: “sine”, “square”,​ “triangle”,​ “dc”, “sawtooth”,​ “arbitrary”,​ or “none”. 
 +      * **signalFreq** - (Integer) - The signal frequency in mHz. 
 +      * **vpp** - (Integer) - The peak-to-peak voltage in mV. 
 +      * **vOffset** - (Integer) - The voltage offset in mV. 
 + 
 +##### 响应 
 +  * **awg** ​ - (Object) - The arbitrary waveform generator object. 
 +    * **#** - (Array<​Object>​) - An array of command objects applied to the awg channel. 
 +      * **command** - (String) - The Set Regular Waveform command: “setRegularWaveform” 
 +      * **statusCode** - (Integer) - A numeric value representing the device status. ​ See [[reference/​software/​digilent-instrumentation-protocol/​status-codes]] 
 +      * **wait** - (Integer) - The number of ms to wait before the device is ready to process another command. ​   
 +      * **actualSignalFreq** - (Integer) -  The actual waveform frequency in mHz. 
 +      * **actualVpp** - (Integer) - The actual peak-to-peak voltage in mV. 
 +      * **actualVOffset** - (Integer) - The actual voltage offset in mV. 
 + 
 + 
 +##### 举例(波形) 
 + 
 +--- 
 + 
 +<WRAP group> 
 +<WRAP half column>​ 
 +**Command** 
 +<​code>​ 
 +
 +   "​awg":​{ 
 +      "​1":​[ 
 +         { 
 +            "​command":"​setRegularWaveform",​ 
 +            "​signalType":"​sine",​ 
 +            "​signalFreq":​1000000,​ 
 +            "​vpp":​3000,​ 
 +            "​vOffset":​0  
 +         } 
 +      ] 
 +   } 
 +
 +</​code>​ 
 +</​WRAP>​ 
 + 
 +<WRAP half column> **Response** </​WRAP>​ 
 +<​code>​ 
 +{   
 +   "​awg":​{ ​  
 +      "​1":​[ ​  
 +         ​{ ​  
 +            "​command":"​setRegularWaveform",​ 
 +            "​statusCode":​0, ​            
 +            "​wait":​0,​ 
 +            "​actualSignalFreq":​ 1000000, 
 +            "​actualVpp":​ 3000, 
 +            "​actualVOffset":​0 
 +         } 
 +      ] 
 +   } 
 +
 +</​code>​ 
 +</​WRAP>​ 
 +\\ \\  
 + 
 +##### 运行 
 + 
 +运行AWG通道 
 + 
 +##### 命令 
 +  * **awg** - (Object) - The arbitrary waveform generator object. 
 +    * **#** - (Array<​Object>​) - An array of command objects to apply to the awg channel. 
 +      * **command** - (String) - The Run command: “run” 
 + 
 +##### 响应  
 +  * **awg** ​ - (Object) - The arbitrary waveform generator object. 
 +    * **#** - (Array<​Object>​) - An array of command objects applied to the awg channel. 
 +      * **command** - (String) - The Run command: “run” 
 +      * **statusCode** - (Integer) - A numeric value representing the device status. ​ See [[reference/​software/​digilent-instrumentation-protocol/​status-codes]] 
 +      * **wait** - (Integer) - The number of ms to wait before the device is ready to process another command. ​   
 + 
 + 
 +#### 举例: 
 + 
 +<WRAP group> 
 +<WRAP half column>​ 
 +**Command** 
 +<​code>​ 
 +
 +   "​awg":​{ 
 +      "​1":​[ 
 +         { 
 +            "​command":"​run"​ 
 +         } 
 +      ] 
 +   } 
 +
 +</​code>​ 
 +</​WRAP>​ 
 + 
 +<WRAP half column>​**Response**</​WRAP>​ 
 +<​code>​ 
 +
 +   "​awg":​{ 
 +      "​1":​[ 
 +         { 
 +            "​command":"​run",​ 
 +            "​statusCode":​0,​ 
 +            "​wait":​0 
 +         } 
 +      ] 
 +   } 
 +
 +</​code>​ 
 +</​WRAP>​ 
 +\\ 
 +\\ 
 + 
 +##### 停止 
 + 
 +---- 
 +停止AWG通道 
 + 
 +#### 命令 
 +  * **awg** - (Object) - The arbitrary waveform generator object. 
 +    * **#** - (Array<​Object>​) - An array of command objects to apply to the awg channel. 
 +      * **command** - (String) - The Stop command: “stop” 
 + 
 +#### 响应 
 +  * **awg** ​ - (Object) - The arbitrary waveform generator object. 
 +    * **#** - (Array<​Object>​) - An array of command objects applied to the awg channel. 
 +      * **command** - (String) - The Stop command: “stop” 
 +      * **statusCode** - (Integer) - A numeric value representing the device status. ​ See [[reference/​software/​digilent-instrumentation-protocol/​status-codes]] 
 +      * **wait** - (Integer) - The number of ms to wait before the device is ready to process another command. ​   
 + 
 + 
 +#### 举例: 
 + 
 +<WRAP group> 
 +<WRAP half column>​ 
 +**Command** 
 +<​code>​ 
 +
 +   "​awg":​{ 
 +      "​1":​[ 
 +         { 
 +            "​command":"​stop"​ 
 +         } 
 +      ] 
 +   } 
 +
 +</​code>​ 
 +</​WRAP>​ 
 + 
 +<WRAP half column>​**Response**</​WRAP>​ 
 +<​code>​ 
 +
 +   "​awg":​{ 
 +      "​1":​[ 
 +         { 
 +            "​command":"​stop",​ 
 +            "​statusCode":​0,​ 
 +            "​wait":​0 
 +         } 
 +      ] 
 +   } 
 +
 +</​code>​ 
 +</​WRAP>​ 
 +\\ 
 +\\ 
 + 
 + 
 +#### 直流电压 
 + 
 +提供访问直流电压数据和函数的命令 
 + 
 +##### 获取当前状态 
 + 
 +---- 
 +Get the current state of the instrument'​s channel 
 + 
 +#### 命令 
 +  * **dc** - (Object) - The DC power supply object. 
 +    * **#** - (Array<​Object>​) - An array of command objects to apply to the DC power supply channel. 
 +      * **command** - (String) - The Get Current State command: “getCurrentState” 
 + 
 +#### 响应 
 +  * **gpio** - (Object) - The DC power supply object. 
 +    * **#** - (Array<​Object>​) - An array of command objects applied to the DC power supply ​ channel. 
 +      * **command** - (String) - The Get Current State command: “getCurrentState” 
 +      * **statusCode** - (Integer) - A numeric value representing the device status. ​ See [[reference/​software/​digilent-instrumentation-protocol/​status-codes]] 
 +      * **wait** - (Integer) - The number of ms to wait before the device is ready to process another command. ​   
 +      * **state** - (String) - The current state of the channel: "​idle"​ or "​running"​. 
 +      * **voltage** - (Integer) - The current measured value of the channel in mV. 
 + 
 +   
 +#### 举例 
 + 
 +<WRAP group> 
 +<WRAP half column>​ 
 +**命令** 
 +<​code>​ 
 +
 +    "​dc":​ { 
 +        "​1":​ [ 
 +            { 
 +                "​command":"​getCurrentState"​ 
 +            } 
 +        ] 
 +    } 
 +
 +</​code>​ 
 +</​WRAP>​ 
 +<WRAP half column>​**响应**</​WRAP>​ 
 +<​code>​ 
 +
 +    "​dc":​ { 
 +        "​1":​ [ 
 +            { 
 +                "​command":​ "​getCurrentState",​ 
 +                "​statusCode":​ 0, 
 +                "​wait":​ 0, 
 +                "​state":​ "​idle",​ 
 +                "​voltage":​ 3300                 
 +            } 
 +        ] 
 +    } 
 +
 +</​code>​ 
 +</​WRAP>​ 
 +\\ 
 + 
 +##### 获取电压值 
 + 
 +---- 
 + 
 +Get the output voltage(s) of the specified DC power supply channel(s). 
 + 
 +#### 命令 
 + 
 +  * **dc** - (Object) - The DC power supply object. 
 +    * **#** - (Array<​Object>​) - An array of command objects to apply to the DC power supply channel. 
 +      * **command** - (String) - The Get Voltage command: “getVoltage” 
 + 
 +#### 响应 
 +  * **gpio** - (Object) - The DC power supply object. 
 +    * **#** - (Array<​Object>​) - An array of command objects applied to the DC power supply ​ channel. 
 +      * **command** - (String) - The Get Voltage command: “getVoltage” 
 +      * **statusCode** - (Integer) - A numeric value representing the device status. ​ See [[reference/​software/​digilent-instrumentation-protocol/​status-codes]] 
 +      * **wait** - (Integer) - The number of ms to wait before the device is ready to process another command. ​   
 +      * **voltage** ​ - (Integer) - The current measured value of the channel in mV. 
 + 
 +#### 举例 
 + 
 +<WRAP group> 
 +<WRAP half column>​ 
 +**命令** 
 +<​code>​ 
 +
 +   "​dc":​{ 
 +      "​1":​[ 
 +         { 
 +            "​command":"​getVoltage"​ 
 +         } 
 +      ] 
 +   } 
 +
 +</​code>​ 
 +</​WRAP>​ 
 +<WRAP half column>​**Response**</​WRAP>​ 
 +<​code>​ 
 +
 +   "​dc":​{ 
 +      "​1":​[ 
 +         { 
 +            "​command":"​getVoltage",​ 
 +            "​statusCode":​0,​ 
 +            "​wait":​100,​ 
 +            "​voltage":​3300 
 +         } 
 +      ]       
 +   } 
 +
 +</​code>​ 
 +</​WRAP>​ 
 +\\ 
 +\\ 
 + 
 +##### 设置电压 
 + 
 +---- 
 + 
 +Set the output voltage(s) of the specified DC power supply channel(s). 
 + 
 +#### 命令 
 +  * **dc** - (Object) - The DC power supply object. 
 +    * **#** - (Array<​Object>​) - An array of command objects to apply to the DC power supply channel. 
 +      * **command** - (String) - The Set Current State command: "​setCurrentState” 
 +      * **voltage** - (Integer) - The desired voltage in mV. 
 + 
 +#### 响应 
 + 
 +  * **gpio** - (Object) - The DC power supply object. 
 +    * **#** - (Array<​Object>​) - An array of command objects applied to the DC power supply ​ channel. 
 +      * **command** - (String) - The Set Current State command: "​setCurrentState” 
 +      * **statusCode** - (Integer) - A numeric value representing the device status. ​ See [[reference/​software/​digilent-instrumentation-protocol/​status-codes]] 
 +      * **wait** - (Integer) - The number of ms to wait before the device is ready to process another command. ​   
 + 
 +#### 举例: 
 + 
 +<WRAP group> 
 +<WRAP half column>​ 
 +**Command** 
 +<​code>​ 
 +
 +   "​dc":​{ 
 +      "​1":​[ 
 +         { 
 +            "​command":"​setVoltage",​ 
 +            "​voltage":​3300 
 +         } 
 +      ] 
 +   } 
 +
 +</​code>​ 
 +</​WRAP>​ 
 +<WRAP half column>​**Response**</​WRAP>​ 
 +<​code>​ 
 +
 +   "​dc":​{ 
 +      "​1":​[ 
 +         { 
 +            "​command":"​setVoltage",​ 
 +            "​statusCode":​0,​ 
 +            "​wait":​500 
 +         } 
 +      ] 
 +   } 
 +
 +</​code>​ 
 +</​WRAP>​ 
 +\\ 
 +\\
  
-{{drawio>​instru_control_data_protocol}}