变送器软件 时间:2022-08-15 13:00:00 btl压力变送器3051dp2a差压变送器hd1电压变送器 主程序: Option Explicit Const NAME_COLUMN = 0 Const TYPE_COLUMN = 1 Const SIZE_COLUMN = 2 Const DATE_COLUMN = 3 Dim pre As Integer 读取参数-读取压力参数-标定 Dim tmp As Integer 温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度参数读取-温度-温度参数读-温度参-温度-温度参数读-温度-温度-温度-温度参数读-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度参数读-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度-温度 Private Sub Command_BUTTON_ALARM_Click() Dim count As Integer Dim send(9) As Byte 定义发送数组 Dim crc(1) As Byte Dim item(1) As Byte Dim address As Integer Dim stemp(3) As Byte Call WaitForScan send(0) = &HFF send(1) = &H10 Call ITB(ALARM, item()) send(2) = item(1) 寄存器地址 send(3) = item(0) send(4) = &H0 寄存器数量 send(5) = &H2 send(6) = &H4 '字节数 本地址存储下位机地址 为单字节 Call LTB(CByte(Text_ALARM.Text), stemp()) 写入标定压力值 send(7) = stemp(0) send(8) = stemp(1) send(9) = stemp(2) send(10) = stemp(3) Call CRC16(send(), 10, crc()) send(11) = crc(1) send(12) = crc(0) MSComm.Output = send TX_address = ALARM Call StartScan End Sub Private Sub Command_BUTTON_CLEARA_Click() If vbCancel = (MsgBox("电流校准数据是否清除?", vbOKCancel vbExclamation, "提示")) Then Exit Sub '如果 End If Command_BUTTON_DemarkA.Enabled = True Command_BUTTON_CLEARA.Enabled = False Call DemarkA(0#, 0#) End Sub Private Sub Command_BUTTON_DemarkA_Click() Command_BUTTON_DemarkA.Enabled = False Command_BUTTON_CLEARA.Enabled = True Call DemarkA(CSng(Text_4mA.Text), CSng(Text_20mA.Text)) End Sub Private Sub DemarkA(dat1 As Single, dat2 As Single) Dim count As Byte Dim position As Byte Dim send(16) As Byte 定义发送数组 Dim crc(1) As Byte Dim item(1) As Byte Dim stemp(3) As Byte Dim address As Integer Dim outpercent As Single Call WaitForScan send(0) = CByte(Combo_Meter.Text) send(1) = &H10 Call ITB(U4, item()) send(2) = item(1) send(3) = item(0) send(4) = &H0 send(5) = &H4 send(6) = &H8 Call STB(dat1, stemp()) 写入标定压力值 send(7) = stemp(0) send(8) = stemp(1) send(9) = stemp(2) send(10) = stemp(3) Call STB(dat2, stemp()) 写入标定压力值 send(11) = stemp(0) send(12) = stemp(1) send(13) = stemp(2) send(14) = stemp(3) Call CRC16(send(), 14, crc()) send(15) = crc(1) send(16) = crc(0) MSComm.Output = send TX_address = ADD Call StartScan End Sub Private Sub Command_BUTTON_DP1_Click() Call demarkp(1) End Sub Private Sub Command_BUTTON_DP10_Click() Call demarkp(10) End Sub Private Sub Command_BUTTON_DP2_Click() Call demarkp(2) End Sub Private Sub Command_BUTTON_DP3_Click() Call WaitForScan Call demarkp(3) End Sub Private Sub Command_BUTTON_DP4_Click() Call demarkp(4) End Sub Private Sub Command_BUTTON_DP5_Click() Call demarkp(5) End Sub Private Sub Command_BUTTON_DP6_Click() Call demarkp(6) End Sub Private Sub Command_BUTTON_DP7_Click() Call demarkp(7) End Sub Private Sub Command_BUTTON_DP8_Click() Call demarkp(8) End Sub Private Sub Command_BUTTON_DP9_Click() Call demarkp(9) End Sub '温度20度标定值 Private Sub Command_BUTTON_DT20_Click() Dim count As Byte Dim demark_A As Byte 轮寻标定位置 Dim send(12) As Byte 定义发送数组 Dim crc(1) As Byte Dim itemp(1) As Byte Dim ltemp(3) As Byte Dim stemp(3) As Byte Dim address As Integer Dim outpercent As Single Call WaitForScan For demark_A = 0 To 30 If Online(demark_A).address <= 0 Or Online(demark_A).address >= 255 Then 超出地址范围 则退出 Call StartScan Exit Sub End If send(0) = Online(demark_A).address send(1) = &H10 For count = 0 To 2 Call ITB(UT20, itemp()) '芯片地址 send(2) = itemp(1) send(3) = itemp(0) send(4) = &H0 寄存器数,字节数 send(5) = &H2 send(6) = &H4 Call LTB(Online(demark_A).temperature_AD, ltemp()) 写入电压值 send(7) = ltemp(0) send(8) = ltemp(1) send(9) = ltemp(2) send(10) = ltemp(3) Call CRC16(send(), 10, crc()) send(11) = crc(1) send(12) = crc(0) On Error GoTo ErrorHandler 错误捕捉串口操作 MSComm.Output = send TX_address = UT20 Sleep (sleeptime) Comerr = 10 位置错误标志 若通信成功 修改位置 On Error GoTo ErrorHandler Call MSComm_OnComm 调用串口数据处理函数 查询是否有中等发生 If Comerr = 10 And count = 2 Then '检测通讯错误 如果出错则退出操作 Call StartScan MsgBox "通讯出错,请检查连接", vbOKOnly + vbExclamation, "错误" Exit Sub ElseIf Comerr = 1 Then '通讯成功 则退出循环 Exit For End If Next count Next demark_A '仪表地址循环 Call StartScan Exit SubErrorHandler: '串口错误 Call StartScan MsgBox "请打开串口", vbOKOnly + vbExclamation, "错误" Comerr = 10 '置位错误状态 End SubPrivate Sub Command_BUTTON_DT60_Click() Dim count As Byte Dim demark_A As Byte '轮寻标定位置 Dim send(12) As Byte '定义发送数组 Dim crc(1) As Byte Dim itemp(1) As Byte Dim ltemp(3) As Byte Dim stemp(3) As Byte Dim address As Integer Dim outpercent As Single Call WaitForScan For demark_A = 0 To 30 If Online(demark_A).address <= 0 Or Online(demark_A).address >= 255 Then '地址超范围 则退出 Call StartScan Exit Sub End If send(0) = Online(demark_A).address send(1) = &H10 For count = 0 To 2 Call ITB(UT60, itemp()) '芯片地址 send(2) = itemp(1) send(3) = itemp(0) send(4) = &H0 '寄存器数,字节数 send(5) = &H2 send(6) = &H4 Call LTB(Online(demark_A).temperature_AD, ltemp()) '写入电压值 send(7) = ltemp(0) send(8) = ltemp(1) send(9) = ltemp(2) send(10) = ltemp(3) Call CRC16(send(), 10, crc()) send(11) = crc(1) send(12) = crc(0) On Error GoTo ErrorHandler '串口操作错误捕捉 MSComm.Output = send TX_address = UT60 Sleep (sleeptime) Comerr = 10 '置位错误标志 如果通讯成功 则本位置被修改 On Error GoTo ErrorHandler Call MSComm_OnComm '调用串口数据处理函数 查询是否有中断发生 If Comerr = 10 And count = 2 Then '检测通讯错误 如果出错则退出操作 Call StartScan MsgBox "通讯出错,请检查连接", vbOKOnly + vbExclamation, "错误" Exit Sub ElseIf Comerr = 1 Then '通讯成功 则退出循环 Exit For End If Next count Next demark_A '仪表地址循环 Call StartScan Exit SubErrorHandler: '串口错误 Call StartScan MsgBox "请打开串口", vbOKOnly + vbExclamation, "错误" Comerr = 10 '置位错误状态 End SubPrivate Sub Command_BUTTON_DTF_Click() Dim count As Byte Dim position As Byte '选择标定点 Dim demark_A As Byte '轮寻标定位置 Dim send(12) As Byte '定义发送数组 Dim sendt(10) As Byte Dim crc(1) As Byte Dim itemp(1) As Byte '将整形转换成2字节型数组 Dim ltemp(3) As Byte '将长整形转换成4字节数组 Dim stemp(3) As Byte '将浮点型转换成4字节数组 Call WaitForScan For count = 0 To 9 If Option_DT(count).Value = True Then position = count Exit For End If Next count For count = 0 To 1 Next count demark_A = 0 '置位轮寻标定位置 For demark_A = 0 To 30 If Online(demark_A).address <= 0 Or Online(demark_A).address >= 255 Then '地址超范围 则退出 Call StartScan Exit Sub End If For count = 0 To 2 send(0) = Online(demark_A).address '置位操作地址 send(1) = &H10 Call ITB(TF + 4 * position, itemp()) '芯片地址 send(2) = itemp(1) send(3) = itemp(0) send(4) = &H0 '寄存器数,字节数 send(5) = &H2 send(6) = &H4 Call STB(Online(demark_A).press, stemp()) '写入标定压力值 send(7) = stemp(0) send(8) = stemp(1) send(9) = stemp(2) send(10) = stemp(3) Call CRC16(send(), 10, crc()) send(11) = crc(1) send(12) = crc(0) MSComm.Output = send Sleep (sleeptime) Comerr = 10 '置位错误标志 如果通讯成功 则本位置被修改 Call MSComm_OnComm '调用串口数据处理函数 查询是否有中断发生 If Comerr = 10 And count = 2 Then '检测通讯错误 如果出错则退出操作 Call StartScan MsgBox "通讯出错,请检查连接", vbOKOnly + vbExclamation, "错误" Call StartScan Exit Sub ElseIf Comerr = 1 Then '通讯成功 则退出循环 Exit For End If Next count For count = 0 To 2 '写入温度 sendt(0) = Online(demark_A).address '置位操作地址 sendt(1) = &H10 Call ITB(TTEM + 2 * position, itemp()) '芯片地址 sendt(2) = itemp(1) sendt(3) = itemp(0) sendt(4) = &H0 '寄存器数,字节数 sendt(5) = &H1 sendt(6) = &H2 Call ITB(CInt(Online(demark_A).temperature * 10#), itemp()) '写入标定压力值 sendt(7) = itemp(0) sendt(8) = itemp(1) Call CRC16(sendt(), 8, crc()) sendt(9) = crc(1) sendt(10) = crc(0) MSComm.Output = sendt Sleep (sleeptime) Comerr = 10 '置位错误标志 如果通讯成功 则本位置被修改 Call MSComm_OnComm '调用串口数据处理函数 查询是否有中断发生 If Comerr = 10 And count = 2 Then '检测通讯错误 如果出错则退出操作 Call StartScan MsgBox "通讯出错,请检查连接", vbOKOnly + vbExclamation, "错误" Exit Sub ElseIf Comerr = 1 Then '通讯成功 则退出循环 Exit For End If Next count Next demark_A '仪表地址循环 Call StartScan End SubPrivate Sub Command_BUTTON_DTZ_Click() '零点标定 Dim count As Byte Dim position As Byte '选择标定点 Dim demark_A As Byte '轮寻标定位置 Dim send(12) As Byte '定义发送数组 Dim crc(1) As Byte Dim itemp(1) As Byte '将整形转换成2字节型数组 Dim ltemp(3) As Byte '将长整形转换成4字节数组 Dim stemp(3) As Byte '将浮点型转换成4字节数组 Call WaitForScan For count = 0 To 9 If Option_DT(count).Value = True Then position = count Exit For End If Next count demark_A = 0 '置位轮寻标定位置 For demark_A = 0 To 30 If Online(demark_A).address <= 0 Or Online(demark_A).address >= 255 Then '地址超范围 则退出 Call StartScan Exit Sub End If For count = 0 To 2 send(0) = Online(demark_A).address '置位操作地址 send(1) = &H10 Call ITB(TZ + 4 * position, itemp()) '芯片地址 send(2) = itemp(1) send(3) = itemp(0) send(4) = &H0 '寄存器数,字节数 send(5) = &H2 send(6) = &H4 Call STB(Online(demark_A).press, stemp()) '写入标定压力值 send(7) = stemp(0) send(8) = stemp(1) send(9) = stemp(2) send(10) = stemp(3) Call CRC16(send(), 10, crc()) send(11) = crc(1) send(12) = crc(0) MSComm.Output = send Sleep (sleeptime) Comerr = 10 '置位错误标志 如果通讯成功 则本位置被修改 Call MSComm_OnComm '调用串口数据处理函数 查询是否有中断发生 If Comerr = 10 And count = 2 Then '检测通讯错误 如果出错则退出操作 Call StartScan MsgBox "通讯出错,请检查连接", vbOKOnly + vbExclamation, "错误" Exit Sub ElseIf Comerr = 1 Then '通讯成功 则退出循环 Exit For End If Next count Next demark_A '仪表地址循环 Call StartScan End SubPrivate Sub Combo_com_Click() Command_BUTTON_Opencom.Caption = "打开串口" End SubPrivate Sub Command_BUTTON_DP0_Click() '写入标定0点 Call demarkp(0) End SubPrivate Sub Command_BUTTON_ExitA_Click() '退出固定电流输出模式 此功能与输出电流模式同 以后可精简 Dim crc(1) As Byte Dim item(1) As Byte Dim stemp(3) As Byte Dim send(12) As Byte '定义发送数组 Dim outpercent As Single Call WaitForScan outpercent = 200# '输出无效值 send(0) = CByte(Combo_Meter.Text) send(1) = &H10 Call ITB(IOUT, item()) send(2) = item(1) send(3) = item(0) send(4) = &H0 send(5) = &H2 send(6) = &H4 Call STB(outpercent, stemp()) '写入标定压力值 send(7) = stemp(0) send(8) = stemp(1) send(9) = stemp(2) send(10) = stemp(3) Call CRC16(send(), 10, crc()) send(11) = crc(1) send(12) = crc(0) MSComm.Output = send TX_address = ADD Call StartScan End SubPrivate Sub Command_BUTTON_OPENCOM_Click() If MSComm.PortOpen Then MSComm.PortOpen = False On Error GoTo ErrorHandler MSComm.CommPort = Combo_com.ListIndex + 1 MSComm.InputMode = comInputModeBinary MSComm.InputLen = 0 MSComm.RThreshold = 1 MSComm.SThreshold = 0 MSComm.PortOpen = True On Error GoTo ErrorHandler Command_BUTTON_Opencom.Caption = "串口已打开" Exit SubErrorHandler: MsgBox "打开串口时出错", vbOKOnly + vbExclamation, "错误" End SubPrivate Sub Command_BUTTON_OutA_Click() Dim count As Byte Dim position As Byte Dim send(12) As Byte '定义发送数组 Dim crc(1) As Byte Dim item(1) As Byte Dim stemp(3) As Byte Dim address As Integer Dim outpercent As Single Call WaitForScan For count = 0 To 6 If Option_IOut(count).Value = True Then position = count Exit For End If Next count '确定输出电流值 Select Case position '计算输出百分比 Case 0 outpercent = -0.0125 Case 1 outpercent = 0# Case 2 outpercent = 25# Case 3 outpercent = 50# Case 4 outpercent = 75# Case 5 outpercent = 100# Case 6 outpercent = 100.05 Case Else outpercent = -0.0125 End Select send(0) = CByte(Combo_Meter.Text) send(1) = &H10 Call ITB(IOUT, item()) 'ITB将整形转换成2字节型 send(2) = item(1) send(3) = item(0) send(4) = &H0 send(5) = &H2 send(6) = &H4 Call STB(outpercent, stemp()) '写入标定压力值 '将浮点型转换成4字节型 send(7) = stemp(0) send(8) = stemp(1) send(9) = stemp(2) send(10) = stemp(3) Call CRC16(send(), 10, crc()) send(11) = crc(1) send(12) = crc(0) MSComm.Output = send TX_address = ADD Call StartScan End SubPrivate Sub Command_Button_PR_Click() Label_RP1.Caption = "AD采集值" Label_RP2.Caption = "标定点" Label_RP3.Caption = "" Text_D03.Visible = False Text_D13.Visible = False Text_D23.Visible = False Text_D33.Visible = False Text_D43.Visible = False Text_D53.Visible = False Text_D63.Visible = False Text_D73.Visible = False Text_D83.Visible = False Text_D93.Visible = False Text_D103.Visible = False Text_D01.Visible = True Text_D02.Visible = True Command_BUTTON_TP(0).Visible = True Choose_TR_PR = 1 '当单击压力参数读取时,Choose_PR_TR=1 触发标志 Timer_press_AD.Enabled = True End SubPrivate Sub Command_BUTTON_READADD_Click() '采用公共地址读取仪表地址 Dim count As Integer Dim send(7) As Byte '定义发送数组 Dim crc(1) As Byte Dim item(1) As Byte Call WaitForScan Text_RAdd.Text = 0 send(0) = &HFF send(1) = &H3 Call ITB(ADD, item()) send(2) = item(1) send(3) = item(0) send(4) = &H0 send(5) = &H1 Call CRC16(send(), 5, crc()) send(6) = crc(1) send(7) = crc(0) MSComm.Output = send TX_address = ADD Call StartScan End Sub'芯片复位,本功能将清除芯片内所有数据Private Sub Command_BUTTON_RESET_Click() Dim count As Integer Dim send(9) As Byte '定义发送数组 Dim crc(1) As Byte Dim item(1) As Byte Dim address As Integer Call WaitForScan If vbCancel = (MsgBox("本功能将使芯片置于初始状态,芯片内所有数据都将被清除,是否继续", vbOKCancel + vbExclamation, "提示")) Then Exit Sub '询问是否继续清除 End If send(0) = &HFF send(1) = &H10 Call ITB(ULOCK, item()) send(2) = item(1) '寄存器地址 send(3) = item(0) send(4) = &H0 '寄存器数量 send(5) = &H1 send(6) = &H1 '字节数 本地址存储下位机地址 为单字节 send(7) = &H0 Call CRC16(send(), 7, crc()) send(8) = crc(1) send(9) = crc(0) MSComm.Output = send TX_address = ULOCK Call StartScan End SubPrivate Sub Command_BUTTON_Scan_Click() Call WaitForScan '停止其他扫描 Timer_SCAN.Enabled = True '扫描仪表 顺序扫描地址 End SubPrivate Sub Command_BUTTON_SETADD_Click() '采用公共地址设定仪表地址 Dim count As Integer Dim send(9) As Byte '定义发送数组 Dim crc(1) As Byte Dim item(1) As Byte Dim address As Integer Call WaitForScan send(0) = &HFF send(1) = &H10 Call ITB(ADD, item()) send(2) = item(1) '寄存器地址 send(3) = item(0) send(4) = &H0 '寄存器数量 send(5) = &H1 send(6) = &H1 '字节数 本地址存储下位机地址 为单字节 send(7) = CByte(Text_RAdd.Text) Call CRC16(send(), 7, crc()) send(8) = crc(1) send(9) = crc(0) MSComm.Output = send TX_address = ADD Call StartScan End SubPrivate Sub Command_Button_TR_Click() Label_RP1.Caption = "温度" Label_RP2.Caption = "零点" Label_RP3.Caption = "满程" Text_D03.Visible = True Text_D13.Visible = True Text_D23.Visible = True Text_D33.Visible = True Text_D43.Visible = True Text_D53.Visible = True Text_D63.Visible = True Text_D73.Visible = True Text_D83.Visible = True Text_D93.Visible = True Text_D103.Visible = True Text_D01.Visible = False Text_D02.Visible = False Text_D03.Visible = False Command_BUTTON_TP(0).Visible = False Choose_TR_PR = 0 '当单击温度参数读取时,Choose_PR_TR=0 触发标志 Timer_Temp_Read.Enabled = True End SubPrivate Sub Command19_Click() Dim data(3) As Byte Dim temp As Long data(0) = &H25 data(1) = &H52 data(2) = &H9A data(3) = &H44 temp = BTS(data()) temp = 0 End SubPrivate Sub Form_Load() Dim count As Integer Dim str As String str = "COM" For count = 1 To 12 '添加串口 Combo_com.AddItem str & count Next count scanaddP = 1 '置位扫描位置 End SubPrivate Sub M_ALL_Click() SSTab.Tab = 0 End SubPrivate Sub M_DI_Click() SSTab.Tab = 1 End SubPrivate Sub M_DP_Click() SSTab.Tab = 2 End SubPrivate Sub M_DT_Click() SSTab.Tab = 3 End SubPrivate Sub M_Exit_Click() Unload Form_main End SubPrivate Sub M_Online_Click() SSTab.Tab = 4 End SubPrivate Sub M_Parameter_Click() SSTab.Tab = 5 End SubPrivate Sub MSComm_OnComm() '串口数据接收函数 Dim count As Long Dim counttemp As Long Dim tmpBuf() As Byte Dim crc(1) As Byte Dim i As Integer Dim tmpData(1) As Byte '温度 Dim tmpDataZ(3) As Byte '零点 Dim tmpDataF(3) As Byte '满程 Dim preAdData(3) As Byte 'AD采集值 Dim preData(3) As Byte '标定点 Sleep (50) If MSComm.CommEvent = comEvReceive Then '接收数据流处理 Erase RxData '清空数组 Erase TxData '清空数组 tmpBuf = MSComm.Input counttemp = UBound(tmpBuf) For count = 0 To counttemp RxData(count) = tmpBuf(count) Next count '串口接收数据 If RxData(1) = &H3 Then '03读寄存器命令处理 Call CRC16(RxData(), RxData(2) + 2, crc()) If (RxData(RxData(2) + 4) = crc(0)) And (RxData(RxData(2) + 3) = crc(1)) Then 'CRC校验成功 Comerr = 1 '通讯正常 通过CRC校验判定写入是否成功 '综合参数设置--读取地址 If (TX_address = 40001) Or (TX_address = 0) Then '地址匹配成功 For count = 0 To 30 If (Online(count).address = 0) Or (Online(count).address = RxData(0)) Then '地址匹配 继续处理 Dim st2(1) As Byte Dim st4(3) As Byte Online(count).address = RxData(0) st4(3) = RxData(3) st4(2) = RxData(4) st4(1) = RxData(5) st4(0) = RxData(6) Online(count).final = BTS(st4) '数据转换 赋值给在线仪表 st4(3) = RxData(7) st4(2) = RxData(8) st4(1) = RxData(9) st4(0) = RxData(10) Online(count).temperature = BTS(st4) '数据转换 赋值给在线仪表 st4(3) = RxData(11) st4(2) = RxData(12) st4(1) = RxData(13) st4(0) = RxData(14) Online(count).press_AD = BTL(st4) '数据转换 赋值给在线仪表 st4(3) = RxData(15) st4(2) = RxData(16) st4(1) = RxData(17) st4(0) = RxData(18) Online(count).press = BTS(st4) '数据转换 赋值给在线仪表 st4(3) = RxData(19) st4(2) = RxData(20) st4(1) = RxData(21) st4(0) = RxData(22) Online(count).temperature_AD = BTL(st4) '数据转换 赋值给在线仪表 Exit For End If Next count ElseIf (TX_address <= &H10FF) And (TX_address >= &H1000) Then If TX_address = ADD Then '单表读取及设定地址处理 Text_RAdd.Text = RxData(3) Exit Sub End If For counttemp = 0 To 29 '选择当前操作地址 If Online(counttemp).address = RxData(0) Then Exit For End If Next counttemp Select Case Choose_TR_PR Case 0 '温度参数读取 For count = 0 To (RxData(2) - 1) '将数据转存 DemarcateT(counttemp).demarcate(TX_address - &H1000 + count) = RxData(3 + count) Next count For i = 0 To 9 tmpData(1) = DemarcateT(counttemp).demarcate(i * 2) tmpData(0) = DemarcateT(counttemp).demarcate(i * 2 + 1) tmpDataZ(0) = DemarcateT(counttemp).demarcate(i * 4 + 20) tmpDataZ(1) = DemarcateT(counttemp).demarcate(i * 4 + 21) tmpDataZ(2) = DemarcateT(counttemp).demarcate(i * 4 + 22) tmpDataZ(3) = DemarcateT(counttemp).demarcate(i * 4 + 23) tmpDataF(0) = DemarcateT(counttemp).demarcate(i * 4 + 60) tmpDataF(1) = DemarcateT(counttemp).demarcate(i * 4 + 61) tmpDataF(2) = DemarcateT(counttemp).demarcate(i * 4 + 62) tmpDataF(3) = DemarcateT(counttemp).demarcate(i * 4 + 63) DemarcateT(counttemp).temperature(i) = BTI(tmpData()) DemarcateT(counttemp).zero(i) = BTS(tmpDataZ()) DemarcateT(counttemp).full(i) = BTS(tmpDataF()) Next i Text_D11.Text = DemarcateT(counttemp).temperature(0) / 10 '溫度 Text_D21.Text = DemarcateT(counttemp).temperature(1) / 10 Text_D31.Text = DemarcateT(counttemp).temperature(2) / 10 Text_D41.Text = DemarcateT(counttemp).temperature(3) / 10 Text_D51.Text = DemarcateT(counttemp).temperature(4) / 10 Text_D61.Text = DemarcateT(counttemp).temperature(5) / 10 Text_D71.Text = DemarcateT(counttemp).temperature(6) / 10 Text_D81.Text = DemarcateT(counttemp).temperature(7) / 10 Text_D91.Text = DemarcateT(counttemp).temperature(8) / 10 Text_D101.Text = DemarcateT(counttemp).temperature(9) / 10 Text_D12.Text = Format(DemarcateT(counttemp).zero(0), "##0.00000") '零點 Text_D22.Text = Format(DemarcateT(counttemp).zero(1), "##0.00000") Text_D32.Text = Format(DemarcateT(counttemp).zero(2), "##0.00000") Text_D42.Text = Format(DemarcateT(counttemp).zero(3), "##0.00000") Text_D52.Text = Format(DemarcateT(counttemp).zero(4), "##0.00000") Text_D62.Text = Format(DemarcateT(counttemp).zero(5), "##0.00000") Text_D72.Text = Format(DemarcateT(counttemp).zero(6), "##0.00000") Text_D82.Text = Format(DemarcateT(counttemp).zero(7), "##0.00000") Text_D92.Text = Format(DemarcateT(counttemp).zero(8), "##0.00000") Text_D102.Text = Format(DemarcateT(counttemp).zero(9), "##0.00000") Text_D13.Text = Format(DemarcateT(counttemp).full(0), "##0.00000") '滿程 Text_D23.Text = Format(DemarcateT(counttemp).full(1), "##0.00000") Text_D33.Text = Format(DemarcateT(counttemp).full(2), "##0.00000") Text_D43.Text = Format(DemarcateT(counttemp).full(3), "##0.00000") Text_D53.Text = Format(DemarcateT(counttemp).full(4), "##0.00000") Text_D63.Text = Format(DemarcateT(counttemp).full(5), "##0.00000") Text_D73.Text = Format(DemarcateT(counttemp).full(6), "##0.00000") Text_D83.Text = Format(DemarcateT(counttemp).full(7), "##0.00000") Text_D93.Text = Format(DemarcateT(counttemp).full(8), "##0.00000") Text_D103.Text = Format(DemarcateT(counttemp).full(9), "##0.00000") Case 1 '压力参数读取 For count = 0 To (RxData(2) - 1) '将数据转存 DemarcateP(counttemp).demarcate(TX_address - &H1080 + count) = RxData(3 + count) Next count For i = 0 To 10 preAdData(0) = DemarcateP(counttemp).demarcate(i * 4) preAdData(1) = DemarcateP(counttemp).demarcate(i * 4 + 1) preAdData(2) = DemarcateP(counttemp).demarcate(i * 4 + 2) preAdData(3) = DemarcateP(counttemp).demarcate(i * 4 + 3) preData(0) = DemarcateP(counttemp).demarcate(i * 4 + 44) preData(1) = DemarcateP(counttemp).demarcate(i * 4 + 45) preData(2) = DemarcateP(counttemp).demarcate(i * 4 + 46) preData(3) = DemarcateP(counttemp).demarcate(i * 4 + 47) DemarcateP(counttemp).voltage(i) = BTL(preAdData()) DemarcateP(counttemp).offset(i) = BTS(preData()) Next i Text_D01.Text = DemarcateP(counttemp).voltage(0) 'AD采集值 Text_D11.Text = DemarcateP(counttemp).voltage(1) Text_D21.Text = DemarcateP(counttemp).voltage(2) Text_D31.Text = DemarcateP(counttemp).voltage(3) Text_D41.Text = DemarcateP(counttemp).voltage(4) Text_D51.Text = DemarcateP(counttemp).voltage(5) Text_D61.Text = DemarcateP(counttemp).voltage(6) Text_D71.Text = DemarcateP(counttemp).voltage(7) Text_D81.Text = DemarcateP(counttemp).voltage(8) Text_D91.Text = DemarcateP(counttemp).voltage(9) Text_D101.Text = DemarcateP(counttemp).voltage(10) Text_D02.Text = Format(DemarcateP(counttemp).offset(0), "##0.00000") '标定点 Text_D12.Text = Format(DemarcateP(counttemp).offset(1), "##0.00000") Text_D22.Text = Format(DemarcateP(counttemp).offset(2), "##0.00000") Text_D32.Text = Format(DemarcateP(counttemp).offset(3), "##0.00000") Text_D42.Text = Format(DemarcateP(counttemp).offset(4), "##0.00000") Text_D52.Text = Format(DemarcateP(counttemp).offset(5), "##0.00000") Text_D62.Text = Format(DemarcateP(counttemp).offset(6), "##0.00000") Text_D72.Text = Format(DemarcateP(counttemp).offset(7), "##0.00000") Text_D82.Text = Format(DemarcateP(counttemp).offset(8), "##0.00000") Text_D92.Text = Format(DemarcateP(counttemp).offset(9), "##0.00000") Text_D102.Text = Format(DemarcateP(counttemp).offset(10), "##0.00000") End Select End If End If End If If RxData(1) = &H10 Then '10写命令 Call CRC16(RxData(), 5, crc()) 'CRC校验 If RxData(6) = crc(1) And RxData(7) = crc(0) Then '校验成功 Comerr = 1 '通讯正常 End If End If End IfEnd SubPrivate Sub Online_Click() SSTab.Tab = 4 End SubPrivate Sub Option_0_06_Click() Text_D0.Text = Format(0, "##0.0") Text_D1.Text = Format(0.1, "##0.0") Text_D2.Text = Format(0.2, "##0.0") Text_D3.Text = Format(0.3, "##0.0") Text_D4.Text = Format(0.4, "##0.0") Text_D5.Text = Format(0.5, "##0.0") Text_D6.Text = Format(0.6, "##0.0") Text_D7.Text = Format(0, "##0.0") Text_D8.Text = Format(0, "##0.0") Text_D9.Text = Format(0, "##0.0") Text_D10.Text = Format(0, "##0.0") preAD = 0 End SubPrivate Sub Option_0_10_Click() Text_D0.Text = Format(0, "##0.0") Text_D1.Text = Format(1, "##0.0") Text_D2.Text = Format(2, "##0.0") Text_D3.Text = Format(3, "##0.0") Text_D4.Text = Format(4, "##0.0") Text_D5.Text = Format(5, "##0.0") Text_D6.Text = Format(6, "##0.0") Text_D7.Text = Format(7, "##0.0") Text_D8.Text = Format(8, "##0.0") Text_D9.Text = Format(9, "##0.0") Text_D10.Text = Format(10, "##0.0") preAD = 1 End SubPrivate Sub Option_0_100_Click() Text_D0.Text = Format(0#, "##0.0") Text_D1.Text = Format(1#, "##0.0") Text_D2.Text = Format(2#, "##0.0") Text_D3.Text = Format(3#, "##0.0") Text_D4.Text = Format(4#, "##0.0") Text_D5.Text = Format(5#, "##0.0") Text_D6.Text = Format(6#, "##0.0") Text_D7.Text = Format(7#, "##0.0") Text_D8.Text = Format(8#, "##0.0") Text_D9.Text = Format(9#, "##0.0") Text_D10.Text = Format(10#, "##0.0") preAD = 2 End SubPrivate Sub Option_0_1000_Click() Text_D0.Text = Format(0#, "##0.0") Text_D1.Text = Format(10#, "##0.0") Text_D2.Text = Format(20#, "##0.0") Text_D3.Text = Format(30#, "##0.0") Text_D4.Text = Format(40#, "##0.0") Text_D5.Text = Format(50#, "##0.0") Text_D6.Text = Format(60#, "##0.0") Text_D7.Text = Format(70#, "##0.0") Text_D8.Text = Format(80#, "##0.0") Text_D9.Text = Format(90#, "##0.0") Text_D10.Text = Format(100#, "##0.0") preAD = 3 End SubPrivate Sub Option_0_16_Click() Text_D0.Text = Format(0, "##0.0") Text_D1.Text = Format(0.2, "##0.0") Text_D2.Text = Format(0.4, "##0.0") Text_D3.Text = Format(0.6, "##0.0") Text_D4.Text = Format(0.8, "##0.0") Text_D5.Text = Format(1#, "##0.0") Text_D6.Text = Format(1.2, "##0.0") Text_D7.Text = Format(1.4, "##0.0") Text_D8.Text = Format(1.6, "##0.0") Text_D9.Text = Format(0#, "##0.0") Text_D10.Text = Format(0#, "##0.0") preAD = 4 End SubPrivate Sub Option_0_160_Click() Text_D0.Text = Format(0#, "##0.0") Text_D1.Text = Format(2#, "##0.0") Text_D2.Text = Format(4#, "##0.0") Text_D3.Text = Format(6#, "##0.0") Text_D4.Text = Format(8#, "##0.0") Text_D5.Text = Format(10#, "##0.0") Text_D6.Text = Format(12#, "##0.0") Text_D7.Text = Format(14#, "##0.0") Text_D8.Text = Format(16#, "##0.0") Text_D9.Text = Format(0#, "##0.0") Text_D10.Text = Format(0#, "##0.0") preAD = 5 End SubPrivate Sub Option_0_25_Click() Text_D0.Text = Format(0#, "##0.0") Text_D1.Text = Format(0.5, "##0.0") Text_D2.Text = Format(1#, "##0.0") Text_D3.Text = Format(1.5, "##0.0") Text_D4.Text = Format(2#, "##0.0") Text_D5.Text = Format(2.5, "##0.0") Text_D6.Text = Format(0#, "##0.0") Text_D7.Text = Format(0#, "##0.0") Text_D8.Text = Format(0#, "##0.0") Text_D9.Text = Format(0#, "##0.0") Text_D10.Text = Format(0#, "##0.0") preAD = 6 End SubPrivate Sub Option_0_250_Click() Text_D0.Text = Format(0#, "##0.0") Text_D1.Text = Format(5#, "##0.0") Text_D2.Text = Format(10#, "##0.0") Text_D3.Text = Format(15#, "##0.0") Text_D4.Text = Format(20#, "##0.0") Text_D5.Text = Format(25#, "##0.0") Text_D6.Text = Format(0#, "##0.0") Text_D7.Text = Format(0#, "##0.0") Text_D8.Text = Format(0#, "##0.0") Text_D9.Text = Format(0#, "##0.0") Text_D10.Text = Format(0#, "##0.0") preAD = 7 End SubPrivate Sub Option_0_40_Click() Text_D0.Text = Format(0#, "##0.0") Text_D1.Text = Format(0.5, "##0.0") Text_D2.Text = Format(1#, "##0.0") Text_D3.Text = Format(1.5, "##0.0") Text_D4.Text = Format(2#, "##0.0") Text_D5.Text = Format(2.5, "##0.0") Text_D6.Text = Format(3#, "##0.0") Text_D7.Text = Format(3.5, "##0.0") Text_D8.Text = Format(4#, "##0.0") Text_D9.Text = Format(0#, "##0.0") Text_D10.Text = Format(0#, "##0.0") preAD = 8 End SubPrivate Sub Option_0_400_Click() Text_D0.Text = Format(0#, "##0.0") Text_D1.Text = Format(5#, "##0.0") Text_D2.Text = Format(10#, "##0.0") Text_D3.Text = Format(15#, "##0.0") Text_D4.Text = Format(20#, "##0.0") Text_D5.Text = Format(25#, "##0.0") Text_D6.Text = Format(30#, "##0.0") Text_D7.Text = Format(35#, "##0.0") Text_D8.Text = Format(40#, "##0.0") Text_D9.Text = Format(0#, "##0.0") Text_D10.Text = Format(0#, "##0.0") preAD = 9 End SubPrivate Sub Option_0_60_Click() Text_D0.Text = Format(0#, "##0.0") Text_D1.Text = Format(1#, "##0.0") Text_D2.Text = Format(2#, "##0.0") Text_D3.Text = Format(3#, "##0.0") Text_D4.Text = Format(4#, "##0.0") Text_D5.Text = Format(5#, "##0.0") Text_D6.Text = Format(60#, "##0.0") Text_D7.Text = Format(0#, "##0.0") Text_D8.Text = Format(0#, "##0.0") Text_D9.Text = Format(0#, "##0.0") Text_D10.Text = Format(0#, "##0.0") preAD = 10 End SubPrivate Sub Option_0_600_Click() Text_D0.Text = Format(0#, "##0.0") Text_D1.Text = Format(10#, "##0.0") Text_D2.Text = Format(20#, "##0.0") Text_D3.Text = Format(30#, "##0.0") Text_D4.Text = Format(40#, "##0.0") Text_D5.Text = Format(50#, "##0.0") Text_D6.Text = Format(60#, "##0.0") Text_D7.Text = Format(0#, "##0.0") Text_D8.Text = Format(0#, "##0.0") Text_D9.Text = Format(0#, "##0.0") Text_D10.Text = Format(0#, "##0.0") preAD = 11 End Sub'压力仪表标定采用查询串口方式 '每次发送命令等待50mS读取数据,通讯成功则继续,否则重新发送,两次以上错误则认为仪表离线,提示检查连接 '按仪表循环标定,直至最后一个在线仪表写入完毕Private Sub demarkp(demarkp As Byte) '仪表压力标定 Dim demark_A As Byte '轮寻标定位置 Dim count As Integer Dim send(12) As Byte '定义发送数组 Dim crc(1) As Byte Dim itemp(1) As Byte '将整形转换成2字节型数组 Dim ltemp(3) As Byte '将长整形转换成4字节数组 Dim stemp(3) As Byte '将浮点型转换成4字节数组 Call WaitForScan demark_A = 0 '置位轮寻标定位置 For demark_A = 0 To 30 If Online(demark_A).address <= 0 Or Online(demark_A).address >= 255 Then '地址超范围 则退出 Call StartScan Exit Sub End If For count = 0 To 2 send(0) = Online(demark_A).address '置位操作地址 send(1) = &H10 Call ITB(LB + 4 * demarkp, itemp()) '芯片地址 send(2) = itemp(1) send(3) = itemp(0) send(4) = &H0 '寄存器数,字节数 send(5) = &H2 send(6) = &H4 Select Case demarkp Case 0 Call STB(CSng(Text_D0.Text), stemp()) '写入标定压力值 Case 1 Call STB(CSng(Text_D1.Text), stemp()) '写入标定压力值 Case 2 Call STB(CSng(Text_D2.Text), stemp()) '写入标定压力值 Case 3 Call STB(CSng(Text_D3.Text), stemp()) '写入标定压力值 Case 4 Call STB(CSng(Text_D4.Text), stemp()) '写入标定压力值 Case 5 Call STB(CSng(Text_D5.Text), stemp()) '写入标定压力值 Case 6 Call STB(CSng(Text_D6.Text), stemp()) '写入标定压力值 Case 7 Call STB(CSng(Text_D7.Text), stemp()) '写入标定压力值 Case 8 Call STB(CSng(Text_D8.Text), stemp()) '写入标定压力值 Case 9 Call STB(CSng(Text_D9.Text), stemp()) '写入标定压力值 Case 10 Call STB(CSng(Text_D10.Text), stemp()) '写入标定压力值 End Select send(7) = stemp(0) send(8) = stemp(1) send(9) = stemp(2) send(10) = stemp(3) Call CRC16(send(), 10, crc()) send(11) = crc(1) send(12) = crc(0) On Error GoTo ErrorHandler '串口操作错误捕捉 MSComm.Output = send Sleep (sleeptime) Comerr = 10 '置位错误标志 如果通讯成功 则本位置被修改 Call MSComm_OnComm '调用串口数据处理函数 查询是否有中断发生 If Comerr = 10 And count = 2 Then '检测通讯错误 如果出错则退出操作 Call StartScan MsgBox "通讯出错,请检查连接", vbOKOnly + vbExclamation, "错误" Exit Sub ElseIf Comerr = 1 Then '通讯成功 则退出循环 Exit For End If Next count For count = 0 To 2 Call ITB(LBIN + 4 * demarkp, itemp()) '芯片地址 send(2) = itemp(1) send(3) = itemp(0) send(4) = &H0 '寄存器数,字节数 send(5) = &H2 send(6) = &H4 Call LTB(Online(demark_A).press_AD, ltemp()) '写入电压值 send(7) = ltemp(0) send(8) = ltemp(1) send(9) = ltemp(2) send(10) = ltemp(3) Call CRC16(send(), 10, crc()) send(11) = crc(1) send(12) = crc(0) On Error GoTo ErrorHandler '串口操作错误捕捉 MSComm.Output = send Sleep (sleeptime) Comerr = 10 '置位错误标志 如果通讯成功 则本位置被修改 Call MSComm_OnComm '调用串口数据处理函数 查询是否有中断发生 If Comerr = 10 And count = 2 Then '检测通讯错误 如果出错则退出操作 Call StartScan MsgBox "通讯出错,请检查连接", vbOKOnly + vbExclamation, "错误" Exit Sub ElseIf Comerr = 1 Then '通讯成功 则退出循环 Exit For End If Next count Next demark_A '仪表地址循环 Call StartScan Exit SubErrorHandler: '串口错误 Call StartScan MsgBox "请打开串口", vbOKOnly + vbExclamation, "错误" Comerr = 10 '置位错误状态 End SubPrivate Sub Parameter_Click() SSTab.Tab = 5 End SubPrivate Sub Timer_LISTRENOVATE_Timer() '刷新列表及更新仪表数据 Dim count As Integer Dim itm As ListItem Dim send(7) As Byte '定义发送数组 Dim crc(1) As Byte ListView_Display.ListItems.Clear For count = 0 To 30 '更新仪表数据 If Online(count).address <> 0 Then Set itm = ListView_Display.ListItems.ADD() itm.Text = Online(count).address itm.SubItems(1) = Format(Online(count).final, "##0.00000") itm.SubItems(2) = Format(Online(count).press, "##0.00000") itm.SubItems(3) = Format(Online(count).temperature, "##0.00000") itm.SubItems(4) = Online(count).press_AD Else Exit For End If Next count If Online(scanaddP).address <> 0 Then send(0) = Online(scanaddP).address send(1) = &H3 send(2) = &H0 send(3) = &H0 send(4) = &H0 send(5) = &HA Call CRC16(send(), 5, crc()) send(6) = crc(1) send(7) = crc(0) On Error GoTo ErrorHandler scanaddP = scanaddP + 1 MSComm.Output = send TX_address = 0 Else scanaddP = 0 End IfExit Sub ErrorHandler: Call StartScan Timer_SCAN.Enabled = False MsgBox "请打开串口", vbOKOnly + vbExclamation, "错误" End SubPrivate Sub Timer_SCAN_Timer() '每500ms中断一次 按地址一次扫描 Dim count As Integer Dim send(7) As Byte '定义发送数组 Dim crc(1) As Byte If scanaddP < 31 Then send(0) = scanaddP scanaddP = scanaddP + 1 If ProgressBar.Value < 300 Then ProgressBar.Value = ProgressBar.Value + 10 End If Else scanaddP = 1 '将扫描到的地址填入地址栏 For count = 0 To 30 If Online(count).address <> 0 Then Combo_Meter.AddItem Online(count).address, count End If Next count ProgressBar.Value = 0 Timer_SCAN.Enabled = False MsgBox "扫描仪表结束", vbOKOnly, "提示" Timer_LISTRENOVATE.Enabled = True Exit Sub End If send(1) = &H3 send(2) = &H0 send(3) = &H0 send(4) = &H0 send(5) = &HA Call CRC16(send(), 5, crc()) send(6) = crc(1) send(7) = crc(0) On Error GoTo ErrorHandler MSComm.Output = send TX_address = 0 Exit SubErrorHandler: Call StartScan Timer_SCAN.Enabled = False MsgBox "请打开串口", vbOKOnly + vbExclamation, "错误" End SubPrivate Sub WaitForScan() Dim clearInput() As Byte Timer_LISTRENOVATE.Enabled = False Sleep (sleeptime) '发送命令之前停止扫描 Call MSComm_OnCommEnd SubPrivate Sub StartScan() Sleep (sleeptime) Timer_LISTRENOVATE.Enabled = True End Sub'参数读取--单点修改 Private Sub Command_BUTTON_TP_Click(Index As Integer) Dim count As Integer Select Case Choose_TR_PR Case 0 For count = 0 To 2 Call temp_ValueWrite(Index) Comerr = 10 '置位错误标志,如果通讯成功则本位置被修改 Call MSComm_OnComm '调用串口数据处理函数,查询是否有中断发生 If Comerr = 10 And count = 2 Then '检测通讯错误,如果出错则退出操作 Exit Sub ElseIf Comerr = 1 Then '通讯成功,退出循环 Exit For End If Next count For count = 0 To 2 Call tempZ_ValueWrite(Index) Comerr = 10 '置位错误标志,如果通讯成功则本位置被修改 Call MSComm_OnComm '调用串口数据处理函数,查询是否有中断发生 If Comerr = 10 And count = 2 Then '检测通讯错误,如果出错则退出操作 Exit Sub ElseIf Comerr = 1 Then '通讯成功,退出循环 Exit For End If Next count For count = 0 To 2 Call tempF_ValueWrite(Index) Comerr = 10 '置位错误标志,如果通讯成功则本位置被修改 Call MSComm_OnComm '调用串口数据处理函数,查询是否有中断发生 If Comerr = 10 And count = 2 Then '检测通讯错误,如果出错则退出操作 Exit Sub ElseIf Comerr = 1 Then '通讯成功,退出循环 Exit For End If Next count Case 1 For count = 0 To 2 Call press_ADValueWrite(Index) Comerr = 10 '置位错误标志,如果通讯成功则本位置被修改 Call MSComm_OnComm '调用串口数据处理函数,查询是否有中断发生 If Comerr = 10 And count = 2 Then '检测通讯错误,如果出错则退出操作 Exit Sub ElseIf Comerr = 1 Then '通讯成功,退出循环 Exit For End If Next count For count = 0 To 2 Call press_SpotWrite(Index) Comerr = 10 '置位错误标志,如果通讯成功则本位置被修改 Call MSComm_OnComm '调用串口数据处理函数,查询是否有中断发生 If Comerr = 10 And count = 2 Then '检测通讯错误,如果出错则退出操作 Exit Sub ElseIf Comerr = 1 Then '通讯成功,退出循环 Exit For End If Next count End Select End Sub'参数读取--压力参数读取--读出 Private Sub Timer_press_AD_Timer() Dim send(7) As Byte Dim crc(1) As Byte Dim itemp(1) As Byte Call WaitForScan send(0) = CByte(Val(Combo_Meter.Text)) '在线仪表首地址 If pre < 11 Then TX_address = &H1080 + pre * 10 send(1) = &H3 '03读寄存器命令 Call ITB(LBIN, itemp()) '压力AD采集值 地址 send(2) = itemp(1) send(3) = itemp(0) + pre * 10 send(4) = &H0 send(5) = &HA '寄存器数 Call CRC16(send(), 5, crc()) 'CRC校验 send(6) = crc(1) send(7) = crc(0) MSComm.Output = send Sleep 300 pre = pre + 1 Comerr = 10 '置位错误标志 如果通讯成功 则本位置被修改 Call MSComm_OnComm '调用串口数据处理函数 查询是否有中断发生 Else pre = 0 Timer_press_AD.Enabled = False End If Call StartScan End Sub'参数读取--温度参数读取--读出 Private Sub Timer_Temp_Read_timer() Dim send(7) As Byte Dim crc(1) As Byte Dim itemp(1) As Byte Call WaitForScan send(0) = CByte(Val(Combo_Meter.Text)) If tmp < 10 Then TX_address = &H1000 + tmp * 10 send(1) = &H3 '03读寄存器命令 Call ITB(TTEM, itemp()) send(2) = itemp(1) send(3) = itemp(0) + tmp * 10 send(4) = &H0 send(5) = &HA '寄存器数 Call CRC16(send(), 5, crc()) 'CRC校验 send(6) = crc(1) send(7) = crc(0) MSComm.Output = send Sleep 300 tmp = tmp + 1 Comerr = 10 '置位错误标志 如果通讯成功 则本位置被修改 Call MSComm_OnComm '调用串口数据处理函数 查询是否有中断发生 ElseIf tmp > 9 Then tmp = 0 Timer_Temp_Read.Enabled = False End If End Sub'参数读取--压力参数读取--AD采集值写入 Private Sub press_ADValueWrite(Index As Integer) Dim send(12) As Byte Dim itemp(1) As Byte Dim stemp(3) As Byte Dim crc(1) As Byte Dim count As Integer send(0) = CByte(Val(Combo_Meter.Text)) '在线仪表首地址 send(1) = &H10 '10写寄存器命令 Call ITB(LBIN + 4 * Index, itemp()) '地址,写压力 send(2) = itemp(1) send(3) = itemp(0) send(4) = &H0 send(5) = &H2 '寄存器数目 send(6) = &H4 '字节数 Select Case Index Case 0 Call LTB(CSng(Text_D01.Text), stemp()) Case 1 Call LTB(CSng(Text_D11.Text), stemp()) Case 2 Call LTB(CSng(Text_D21.Text), stemp()) Case 3 Call LTB(CSng(Text_D31.Text), stemp()) Case 4 Call LTB(CSng(Text_D41.Text), stemp()) Case 5 Call LTB(CSng(Text_D51.Text), stemp()) Case 6 Call LTB(CSng(Text_D61.Text), stemp()) Case 7 Call LTB(CSng(Text_D71.Text), stemp()) Case 8 Call LTB(CSng(Text_D81.Text), stemp()) Case 9 Call LTB(CSng(Text_D91.Text), stemp()) Case 10 Call LTB(CSng(Text_D101.Text), stemp()) End Select send(7) = stemp(0) send(8) = stemp(1) send(9) = stemp(2) send(10) = stemp(3) Call CRC16(send(), 10, crc()) 'CRC校验 send(11) = crc(1) send(12) = crc(0) MSComm.Output = send Sleep 500End Sub'参数读取--压力参数读取--标定点写入 Private Sub press_SpotWrite(Index As Integer) Dim send(12) As Byte Dim itemp(1) As Byte Dim stemp(3) As Byte Dim crc(1) As Byte Dim count As Integer send(0) = CByte(Val(Combo_Meter.Text)) '在线仪表首地址 send(1) = &H10 '10写寄存器命令 Call ITB(LB + 4 * Index, itemp()) '地址,写压力 send(2) = itemp(1) send(3) = itemp(0) send(4) = &H0 send(5) = &H2 '寄存器数目 send(6) = &H4 '字节数 Select Case Index Case 0 Call STB(CSng(Text_D02.Text), stemp()) Case 1 Call STB(CSng(Text_D12.Text), stemp()) Case 2 Call STB(CSng(Text_D22.Text), stemp()) Case 3 Call STB(CSng(Text_D32.Text), stemp()) Case 4 Call STB(CSng(Text_D42.Text), stemp()) Case 5 Call STB(CSng(Text_D52.Text), stemp()) Case 6 Call STB(CSng(Text_D62.Text), stemp()) Case 7 Call STB(CSng(Text_D72.Text), stemp()) Case 8 Call STB(CSng(Text_D82.Text), stemp()) Case 9 Call STB(CSng(Text_D92.Text), stemp()) Case 10 Call STB(CSng(Text_D102.Text), stemp()) End Select send(7) = stemp(0) send(8) = stemp(1) send(9) = stemp(2) send(10) = stemp(3) Call CRC16(send(), 10, crc()) 'CRC校验 send(11) = crc(1) send(12) = crc(0) MSComm.Output = send Sleep 500 End Sub'参数读取--温度参数读取--温度写入 Private Sub temp_ValueWrite(Index As Integer) Dim send(10) As Byte Dim itemp(1) As Byte Dim stemp(1) As Byte Dim crc(1) As Byte send(0) = CByte(Val(Combo_Meter.Text)) '在线仪表首地址 send(1) = &H10 '10写寄存器命令 Call ITB(TTEM + 2 * (Index - 1), itemp()) '地址,写温度 send(2) = itemp(1) send(3) = itemp(0) send(4) = &H0 send(5) = &H1 '寄存器数目 send(6) = &H2 '字节数 Select Case Index Case 1 Call ITB(CSng(Text_D11.Text), stemp()) Case 2 Call ITB(CSng(Text_D21.Text), stemp()) Case 3 Call ITB(CSng(Text_D31.Text), stemp()) Case 4 Call ITB(CSng(Text_D41.Text), stemp()) Case 5 Call ITB(CSng(Text_D51.Text), stemp()) Case 6 Call ITB(CSng(Text_D61.Text), stemp()) Case 7 Call ITB(CSng(Text_D71.Text), stemp()) Case 8 Call ITB(CSng(Text_D81.Text), stemp()) Case 9 Call ITB(CSng(Text_D91.Text), stemp()) Case 10 Call ITB(CSng(Text_D101.Text), stemp()) End Select send(7) = stemp(0) send(8) = stemp(1) Call CRC16(send(), 8, crc()) 'CRC校验 send(9) = crc(1) send(10) = crc(0) MSComm.Output = send Sleep 500 End Sub'参数读取--温度参数读取--零点写入 Private Sub tempZ_ValueWrite(Index As Integer) Dim send(12) As Byte Dim itemp(1) As Byte Dim stemp(3) As Byte Dim crc(1) As Byte send(0) = CByte(Val(Combo_Meter.Text)) '在线仪表首地址 send(1) = &H10 '10写寄存器命令 Call ITB(TZ + 4 * (Index - 1), itemp()) '地址,写温度 send(2) = itemp(1) send(3) = itemp(0) send(4) = &H0 send(5) = &H1 '寄存器数目 send(6) = &H2 '字节数 Select Case Index Case 1 Call STB(CSng(Text_D12.Text), stemp()) Case 2 Call STB(CSng(Text_D22.Text), stemp()) Case 3 Call STB(CSng(Text_D32.Text), stemp()) Case 4 Call STB(CSng(Text_D42.Text), stemp()) Case 5 Call STB(CSng(Text_D52.Text), stemp()) Case 6 Call STB(CSng(Text_D62.Text), stemp()) Case 7 Call STB(CSng(Text_D72.Text), stemp()) Case 8 Call STB(CSng(Text_D82.Text), stemp()) Case 9 Call STB(CSng(Text_D92.Text), stemp()) Case 10 Call STB(CSng(Text_D102.Text), stemp()) End Select send(7) = stemp(0) send(8) = stemp(1) send(9) = stemp(2) send(10) = stemp(3) Call CRC16(send(), 10, crc()) 'CRC校验 send(11) = crc(1) send(12) = crc(0) MSComm.Output = send Sleep 500 End Sub'参数读取--温度参数读取--满程写入 Private Sub tempF_ValueWrite(Index As Integer) Dim send(12) As Byte Dim itemp(1) As Byte Dim stemp(3) As Byte Dim crc(1) As Byte send(0) = CByte(Val(Combo_Meter.Text)) '在线仪表首地址 send(1) = &H10 '10写寄存器命令 Call ITB(TF + 4 * (Index - 1), itemp()) '地址,写温度 send(2) 锐单商城拥有海量元器件数据手册、IC替代型号,打造电子元器件IC百科大全! 相关文章 pic单片机p18f458A/D转换程序-采用中断方式MSP430单片机极低功耗数字温度计设计智能水位控制系统毕业设计HT1621 32字节×4位LCD液晶驱动芯片程序单片机抢答器程序单片机数字钟程序单片机复位电路作用原理以及与置位的区别单片机秒表设计程序P型半导体,N型半导体带正负电的问题体育审美教育 动态产品新闻电路图方案技术公告 英伟达“特供”AI芯片背后的阳谋2024年的AI服务器,相当于2018年的新能源车泼天的富贵,轮到AI服务器了吗?【铂电阻测温】铂电阻如何采集?需求复苏的苗头出现了!微芯、瑞昱、ST等热门芯片料号鉴定 意法半导体新无线充电器开发板面向工业、医疗和智能家居应用Molex莫仕发布新一代数据中心冷却解决方案中I/O模块的热管理挑战和机遇报告新闻稿发布:最新 imc STUDIO 2024测量控制管理软件TrendForce集邦咨询:第一季智能手机生产量呈现年增,预估第二季将季减5-10%Bourns 推出第二代符合 AEC-Q200 标准的高爬电/间隙距离汽车级隔离电源变压器 让“节能”贯穿服务器全生命周期,英特尔至强6能效核处理器的出众之处英特尔CEO帕特·基辛格:AI正推动业界进入创新黄金时代,影响力堪称空前英飞凌推出适用于物联网设备进行非接触式验证及安全配置的NFC I2C 桥接标签安森美推出提高数据中心能效的完整电源解决方案Molex莫仕在中国荣获通用汽车供应商质量卓越奖 光控式变调器电路晶闸管测试电路门控音乐门铃双音电子门铃碳膜式电子风琴电路 LLC 转换器测试电路Tektronix - 电化学测试方法详解基于 RTD 的测量系统的过压保护使用恒流 LED 驱动器所需的设计使用高级特性和建模技术模拟宽带隙功率电路 pic单片机p18f458A/D转换程序-采用中断方式MSP430单片机极低功耗数字温度计设计智能水位控制系统毕业设计HT1621 32字节×4位LCD液晶驱动芯片程序单片机抢答器程序 锐单2024年51劳动节放假通知锐单商城2024年清明节放假通知2024年春节锐单商城放假安排【通知】2024年元旦锐单商城放假安排2023年锐单商城国庆节放假通知