| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 395 人关注过本帖
标题:采集两个数据的问题
只看楼主 加入收藏
lvguidong123
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2012-10-24
结帖率:100%
收藏
 问题点数:0 回复次数:0 
采集两个数据的问题
各位大神,帮忙解决一下如何在一个坐标系中显示两个及两个以上采集信号的曲线图。这是我采集一个信号的曲线图部分程序:Private Sub MSComm1_OnComm()
With MSComm1
Select Case
Case comEvReceive '是接收事件
Buffer = MSComm1.Input '读取一个字节
ab(1) = Buffer(0) '转换字节数据类型数组
If ab(1) = &HFF Then '判断是否为数据开始标志
MSComm1.RThreshold = 0 '关闭OnComm 事件接收
Do
DoEvents
Loop Until MSComm1.InBufferCount >= 4
Buffer = MSComm1.Input
ab(2) = Buffer(0) - 48
Buffer = MSComm1.Input
ab(3) = Buffer(0) - 48
Buffer = MSComm1.Input
ab(4) = Buffer(0) - 48
Buffer = MSComm1.Input
ab(5) = Buffer(0) - 48
b1 = CInt(ab(2))
b2 = CInt(ab(3))
b3 = CInt(ab(4))
b4 = CInt(ab(5))
Data = 20 * (b1 + b2 / 10 + b3 / 100 + b4 / 1000)
DataFromCom = 100 * Data
MSComm1.RThreshold = 1 '打开OnComm 事件接收
End If
Text1.Text = Data
Case Else
End Select
End With
End Sub

Private Sub Timer1_Timer()
Picture1.Cls
DataFromComLast = DataFromCom
Randomize
Picture1.ScaleMode = 0
Picture1.Scale (-30, 10500)-(760, -1000)
Picture1.Line (750, 0)-(-30, 0), vbBlack
Picture1.Line (0, 10000)-(0, -1000)
Dim i As Integer
'标x轴刻度
For i = 0 To 750 Step 30
Picture1.Line (i, 10000)-(i, 0)
Picture1.CurrentX = i - 16: Picture1.CurrentY = -200: Picture1.Print i
Next i
'标y轴刻度
For i = 0 To 10000 Step 1000
Picture1.Line (750, i)-(0, i)
Next i
If TimeCount >= 0 And TimeCount <= 750 Then
For u = TimeCount To TimeCount
x = u
px(u) = x '给各数据点横坐标赋值
py(u) = DataFromCom  '给各数据点纵坐标赋值
Next u
Else
For t = 1 To 749
py(t) = py(t + 1)
px(t) = t
Next t
py(750) = DataFromCom
End If
TimeCount = TimeCount + 1
DrawRealLine Picture1, TimeCount, DataFromCom, DataFromComLast, DataFromCom1, DataFromComLast1 '画出实时的曲线
Print #1, TimeCount / 2, Data
 Text2.Text = k
End Sub
Private Sub DrawRealLine(picX As PictureBox, TimeCountX As Integer, DataFromComX As Integer, DataFromComLastX As Integer)
If TimeCountX - 1 > 0 And TimeCountX - 1 < 749 Then
For i = 1 To TimeCountX
picX.Line -(px(i - 1), py(i - 1)), vbRed
Next i
Else
For i = 1 To 750
picX.Line -(px(i - 1), py(i - 1)), vbRed
Next i
End If
End Sub
搜索更多相关主题的帖子: 坐标系 曲线图 
2012-12-20 13:50
快速回复:采集两个数据的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026096 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved