首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

用comm口与血压模块进行数据传输解决方法

2012-01-19 
用comm口与血压模块进行数据传输本人想通过VB的COMM口与指定的血压模块进行数据传输,其中包括通信检测,自

用comm口与血压模块进行数据传输
本人想通过VB的COMM口与指定的血压模块进行数据传输,其中包括通信检测自检信号的发送血压模块的充气请求复位测量结果的显示这五个部分,(之后会给出这五部分的参数)。在界面上会有一个self-check的commandbotton(控制自检信号的发送),一个充气请求的commandbotton,并配有一个下拉列表负责选择冲气模式(41=set 42=cont 43=automatic)和三个输入框负责输入三个数据(3x 3x 3x),一个复位的commandbotton,和三个结果显示框。以下是模块数据:
 1, Signal level: TTL.  
  Baud Rates: 4800bps
  1 start bit, 8 data bits, 1 stop bit
  2, Conditions for ZNIBP Measurement Start
  After the ZNIBP power is turned on, perform the following:
  (a) Send the SELF-CHECK RESULT REQUEST command and receive a  
  self-check result response.

  主机 -- > 血压模块 血压模块 -- > 主机
  (a) SELF-CHECK
  1A,60,04 1B,60,4X,04
  4X: 41 = Normal
  42 = RAM Error
  43 = ROM Error
  (b ) Inflation command
  1A,62,4X,3X,3X,3X,04 1B,62,3X,3X,3X,04 
  4X: 41 = SET mode 3X: Pressure value
  42 = CONT. Mode (data format: 3 digits)
  43 = AUTOMATIC Data is continuously sent
  Inflation value during the measurement,
  Setting mode until the blood pressure 
  3X: Inflation set value value is determined, or 
  Data format: 3 digits until the RESET command
  (ASCII) is given.
  (c) RESET command
  1A,63,04 1B,63,04
  (d) Measurement RESULT
  1B,67,3X,3X,3X,3X,3X,3X,
  3X,3X,3X,
  (1) SYS(收缩压) data format:
  3 digits (ASCII)
  (2) MEAN(舒张压) data format:
  3 digits (ASCII)
  (3) DIA(平均压) data format:
  3 digits (ASCII)
我知道东西可能比较多,如果各位高手觉得太麻烦,方便的话完成其中一个部分我也已经感激不尽了~



[解决办法]

引用楼主 barbaraandapple 的帖子:
.......
(d) Measurement RESULT
1B,67,3X,3X,3X,3X,3X,3X,
3X,3X,3X,
(1) SYS(收缩压) data format:
3 digits (ASCII)
(2) MEAN(舒张压) data format:
3 digits (ASCII)
(3) DIA(平均压) data format:
3 digits (ASCII)

[解决办法]
以下是按文本方式接收的代码:
VB code
Option Explicit    Dim strSj As StringPrivate Sub Form_Load()    'MSComm1初始化    MSComm1.CommPort = 1    MSComm1.Settings = "4800,n,8,2"    MSComm1.InputMode = comInputModeText 'ASCII接收    MSComm1.RThreshold = 1    MSComm1.PortOpen = TrueEnd SubPrivate Sub MSComm1_OnComm()    Dim inbuff() As Byte    Dim i As Integer    Select Case MSComm1.CommEvent        Case comEvReceive            strSj = strSj & MSComm1.Input            If Mid(strSj, 1, 2) = "1B" And Right(strSj, 2) = "04" Then '数据判断及处理                Text1 = strSj                If Mid(strSj, 5, 2) = "41" Then                    Label1.Caption = "normal"                ElseIf Mid(strSj, 5, 2) = "42" Then                    Label1.Caption = "RAM Error"                ElseIf Mid(strSj, 5, 2) = "43" Then                    Label1.Caption = "ROM Error"                End If                strSj = ""            End If    End SelectEnd SubPrivate Sub Command1_Click() '发送自检请求命令    Dim sendsj As String    sendsj = "1A6004"    MSComm1.Output = sendsjEnd Sub 

热点排行