
串口数据采集后如何用VB显示成波形图? 20
串口数据采集后如何用VB显示成波形图?是在picture显示,还有就是怎么才能动态显示?(比如每秒采样一次),还有就是怎么保存波形图和采样数据?用什么控件?可以设定保存后...
串口数据采集后如何用VB显示成波形图?是在picture显示,还有就是怎么才能动态显示?(比如每秒采样一次),还有就是怎么保存波形图和采样数据?用什么控件?可以设定保存后的格式吗?(比如在文本文件,保存的数据格式可在VB中提前设定好吗?)
: 多谢各位大虾指点!
: 在线等
感谢不尽啊。。。。。。 展开
: 多谢各位大虾指点!
: 在线等
感谢不尽啊。。。。。。 展开
展开全部
数据可保存于数据库也可保存于文本文件,各自实现代码不同.
使用TIMER控件定时保存数据代码:
Private Sub Timer3_Timer()
If Label5.Caption <> CStr(Time$) Then
Label5.Caption = Time$
sum_zj = sum_zj + 1
'校准
If sum_zj >= 60 Then
sum_zj = sum_zj - 60 '每分钟记录一组数据
Adodc1.Recordset.AddNew
Adodc1.Recordset(0) = shiyan_sj(0)
Adodc1.Recordset(1) = Mid(Date$, 3, 2) & Mid(Date$, 6, 2) & Mid(Date$, 9, 2) & "-" & Time$ 'Mid(Time$, 1, 2) & Mid(Time$, 4, 2) & Mid(Time$, 7, 2) '记录time
Adodc1.Recordset(2) = Val(Label3(0).Caption) '记录数据
Adodc1.Recordset(3) = Val(Label3(1).Caption) '记录数据
Adodc1.Recordset.Update
End If
End If
End Sub
只要数据能保存于数据库.曲线图无须保存,通过数据检索画图:
Private Sub numChaxun_Click()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\HXMdi.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from jilu_sj where date like'%" & Text1.Text & "%' order by time"
Adodc1.Refresh
zsl = Adodc1.Recordset.RecordCount
If zsl > 0 Then
numPrint.Enabled = True
numPrintData.Enabled = True
numData.Enabled = True
For i = 0 To zsl - 1
quexian(1, i) = Adodc1.Recordset(1)
For j = 2 To 9
quexian(j, i) = Adodc1.Recordset(j)
Next j
Adodc1.Recordset.MoveNext
Next i
Picture2.Height = 6765
Picture1.Visible = False
Text2 = Right(quexian(1, 0), 8)
Text3 = Right(quexian(1, zsl - 1), 8)
Text1.SelStart = 8
Text1.SelLength = 2
DataGrid1.Visible = False
Adodc1.Visible = False
Picture2.Height = 7245
Picture1.Visible = True
Picture1.Cls
colvb = vbBlue
xx = 100
yy = 150
txt = "℃"
wp = xp(colvb, xx, yy, txt)
xx = 200
yy = 350
txt = "300"
wp = xp(colvb, xx, yy, txt)
yy = 1350
xx = 200
txt = "250"
wp = xp(colvb, xx, yy, txt)
xx = 200
yy = 2350
txt = "200"
wp = xp(colvb, xx, yy, txt)
yy = 3350
xx = 200
txt = "150"
wp = xp(colvb, xx, yy, txt)
yy = 4350
xx = 200
txt = "100"
wp = xp(colvb, xx, yy, txt)
yy = 5350
xx = 200
txt = " 50"
wp = xp(colvb, xx, yy, txt)
xx = 200
yy = 6350
txt = "0"
wp = xp(colvb, xx, yy, txt)
'Time坐标
colvb = vbRed
yy = 6500
xx = 400
txt = "0"
wp = xp(colvb, xx, yy, txt)
xx = 1300
txt = "2"
wp = xp(colvb, xx, yy, txt)
xx = 2200
txt = "4"
wp = xp(colvb, xx, yy, txt)
xx = 3100
txt = "6"
wp = xp(colvb, xx, yy, txt)
xx = 4000
txt = "8"
wp = xp(colvb, xx, yy, txt)
xx = 4900
txt = "10"
wp = xp(colvb, xx, yy, txt)
xx = 5800
txt = "12 小时"
wp = xp(colvb, xx, yy, txt)
xx = 6700
txt = "14"
wp = xp(colvb, xx, yy, txt)
xx = 7600
txt = "16"
wp = xp(colvb, xx, yy, txt)
xx = 8500
txt = "18"
wp = xp(colvb, xx, yy, txt)
xx = 9400
txt = "20"
wp = xp(colvb, xx, yy, txt)
xx = 10300
txt = "22"
wp = xp(colvb, xx, yy, txt)
xx = 11200
txt = "24"
wp = xp(colvb, xx, yy, txt)
'画格
Picture1.DrawWidth = 1 ' = dash
Picture1.DrawStyle = 0
Picture1.ForeColor = vbBlue
Picture1.DrawStyle = 2
For i = 0 To 12
Picture1.Line (450, 400 + i * 500)-(11300, 400 + i * 500)
Next
For i = 0 To 12
Picture1.Line (500 + i * 900, 400)-(500 + i * 900, 6400)
Next
Picture1.DrawStyle = 0
For j = 0 To zsl - 2
If Int(j / 30) - j / 30 = 0 Then
Picture1.DrawWidth = 1 ' = dash
Picture1.Line (j * 15 + 470, quexian(6, j) * -20 + 6400)-(j * 15 + 530, quexian(6, j) * -20 + 6400), vbGreen ', BF
Picture1.Line (j * 15 + 500, quexian(6, j) * -20 + 6435)-(j * 15 + 500, quexian(6, j) * -20 + 6435), vbGreen ', BF
Picture1.Line (j * 15 + 470, quexian(7, j) * -20 + 6435)-(j * 15 + 470, quexian(7, j) * -20 + 6435), vbBlue ', BF
Picture1.Line (j * 15 + 470, quexian(7, j) * -20 + 6435)-(j * 15 + 530, quexian(7, j) * -20 + 6435), vbBlue ', BF
Picture1.Line (j * 15 + 530, quexian(7, j) * -20 + 6435)-(j * 15 + 530, quexian(7, j) * -20 + 6385), vbBlue ', BF
Picture1.Line (j * 15 + 470, quexian(7, j) * -20 + 6415)-(j * 15 + 530, quexian(7, j) * -20 + 6385), vbBlue ', BF
Picture1.DrawWidth = 2 ' = dash
Picture1.Line (j * 15 + 475, quexian(4, j) * -20 + 6430)-(j * 15 + 525, quexian(4, j) * -20 + 6370), vbBlack
Picture1.Line (j * 15 + 475, quexian(4, j) * -20 + 6370)-(j * 15 + 525, quexian(4, j) * -20 + 6430), vbBlack
Picture1.DrawWidth = 1 ' = dash
Picture1.Line (j * 15 + 500, quexian(3, j) * -20 + 6385)-(j * 15 + 469, quexian(3, j) * -20 + 6417), vbCyan ', BF
Picture1.Line (j * 15 + 500, quexian(3, j) * -20 + 6385)-(j * 15 + 531, quexian(3, j) * -20 + 6417), vbCyan ', BF
Picture1.Line (j * 15 + 469, quexian(3, j) * -20 + 6417)-(j * 15 + 531, quexian(3, j) * -20 + 6417), vbCyan ', BF
Picture1.DrawWidth = 1 ' = dash
Picture1.Line (j * 15 + 490, quexian(2, j) * -20 + 6380)-((j + 1) * 15 + 510, quexian(2, j + 1) * -20 + 6370), vbRed, BF
Picture1.DrawWidth = 1
Picture1.Circle (j * 15 + 500, quexian(5, j) * -20 + 6400), 30, vbMagenta
Else
Picture1.DrawWidth = 1
Picture1.Line (j * 15 + 500, quexian(2, j) * -20 + 6400)-((j + 1) * 15 + 500, quexian(2, j + 1) * -20 + 6400), vbRed ', BF
Picture1.Line (j * 15 + 500, quexian(3, j) * -20 + 6400)-((j + 1) * 15 + 500, quexian(3, j + 1) * -20 + 6400), vbCyan ', BF
Picture1.Line (j * 15 + 500, quexian(4, j) * -20 + 6400)-((j + 1) * 15 + 500, quexian(4, j + 1) * -20 + 6400), vbBlack ', BF
Picture1.Line (j * 15 + 500, quexian(5, j) * -20 + 6400)-((j + 1) * 15 + 500, quexian(5, j + 1) * -20 + 6400), vbMagenta ', BF
Picture1.Line (j * 15 + 500, quexian(6, j) * -20 + 6400)-((j + 1) * 15 + 500, quexian(6, j + 1) * -20 + 6400), vbGreen ', BF
Picture1.Line (j * 15 + 500, quexian(7, j) * -20 + 6400)-((j + 1) * 15 + 500, quexian(7, j + 1) * -20 + 6400), vbBlue ', BF
End If
Next
Else
numData.Enabled = False
numPrint.Enabled = False
numPrintData.Enabled = False
End If
End Sub
http://zhidao.baidu.com/question/13677837.html
使用TIMER控件定时保存数据代码:
Private Sub Timer3_Timer()
If Label5.Caption <> CStr(Time$) Then
Label5.Caption = Time$
sum_zj = sum_zj + 1
'校准
If sum_zj >= 60 Then
sum_zj = sum_zj - 60 '每分钟记录一组数据
Adodc1.Recordset.AddNew
Adodc1.Recordset(0) = shiyan_sj(0)
Adodc1.Recordset(1) = Mid(Date$, 3, 2) & Mid(Date$, 6, 2) & Mid(Date$, 9, 2) & "-" & Time$ 'Mid(Time$, 1, 2) & Mid(Time$, 4, 2) & Mid(Time$, 7, 2) '记录time
Adodc1.Recordset(2) = Val(Label3(0).Caption) '记录数据
Adodc1.Recordset(3) = Val(Label3(1).Caption) '记录数据
Adodc1.Recordset.Update
End If
End If
End Sub
只要数据能保存于数据库.曲线图无须保存,通过数据检索画图:
Private Sub numChaxun_Click()
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\HXMdi.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from jilu_sj where date like'%" & Text1.Text & "%' order by time"
Adodc1.Refresh
zsl = Adodc1.Recordset.RecordCount
If zsl > 0 Then
numPrint.Enabled = True
numPrintData.Enabled = True
numData.Enabled = True
For i = 0 To zsl - 1
quexian(1, i) = Adodc1.Recordset(1)
For j = 2 To 9
quexian(j, i) = Adodc1.Recordset(j)
Next j
Adodc1.Recordset.MoveNext
Next i
Picture2.Height = 6765
Picture1.Visible = False
Text2 = Right(quexian(1, 0), 8)
Text3 = Right(quexian(1, zsl - 1), 8)
Text1.SelStart = 8
Text1.SelLength = 2
DataGrid1.Visible = False
Adodc1.Visible = False
Picture2.Height = 7245
Picture1.Visible = True
Picture1.Cls
colvb = vbBlue
xx = 100
yy = 150
txt = "℃"
wp = xp(colvb, xx, yy, txt)
xx = 200
yy = 350
txt = "300"
wp = xp(colvb, xx, yy, txt)
yy = 1350
xx = 200
txt = "250"
wp = xp(colvb, xx, yy, txt)
xx = 200
yy = 2350
txt = "200"
wp = xp(colvb, xx, yy, txt)
yy = 3350
xx = 200
txt = "150"
wp = xp(colvb, xx, yy, txt)
yy = 4350
xx = 200
txt = "100"
wp = xp(colvb, xx, yy, txt)
yy = 5350
xx = 200
txt = " 50"
wp = xp(colvb, xx, yy, txt)
xx = 200
yy = 6350
txt = "0"
wp = xp(colvb, xx, yy, txt)
'Time坐标
colvb = vbRed
yy = 6500
xx = 400
txt = "0"
wp = xp(colvb, xx, yy, txt)
xx = 1300
txt = "2"
wp = xp(colvb, xx, yy, txt)
xx = 2200
txt = "4"
wp = xp(colvb, xx, yy, txt)
xx = 3100
txt = "6"
wp = xp(colvb, xx, yy, txt)
xx = 4000
txt = "8"
wp = xp(colvb, xx, yy, txt)
xx = 4900
txt = "10"
wp = xp(colvb, xx, yy, txt)
xx = 5800
txt = "12 小时"
wp = xp(colvb, xx, yy, txt)
xx = 6700
txt = "14"
wp = xp(colvb, xx, yy, txt)
xx = 7600
txt = "16"
wp = xp(colvb, xx, yy, txt)
xx = 8500
txt = "18"
wp = xp(colvb, xx, yy, txt)
xx = 9400
txt = "20"
wp = xp(colvb, xx, yy, txt)
xx = 10300
txt = "22"
wp = xp(colvb, xx, yy, txt)
xx = 11200
txt = "24"
wp = xp(colvb, xx, yy, txt)
'画格
Picture1.DrawWidth = 1 ' = dash
Picture1.DrawStyle = 0
Picture1.ForeColor = vbBlue
Picture1.DrawStyle = 2
For i = 0 To 12
Picture1.Line (450, 400 + i * 500)-(11300, 400 + i * 500)
Next
For i = 0 To 12
Picture1.Line (500 + i * 900, 400)-(500 + i * 900, 6400)
Next
Picture1.DrawStyle = 0
For j = 0 To zsl - 2
If Int(j / 30) - j / 30 = 0 Then
Picture1.DrawWidth = 1 ' = dash
Picture1.Line (j * 15 + 470, quexian(6, j) * -20 + 6400)-(j * 15 + 530, quexian(6, j) * -20 + 6400), vbGreen ', BF
Picture1.Line (j * 15 + 500, quexian(6, j) * -20 + 6435)-(j * 15 + 500, quexian(6, j) * -20 + 6435), vbGreen ', BF
Picture1.Line (j * 15 + 470, quexian(7, j) * -20 + 6435)-(j * 15 + 470, quexian(7, j) * -20 + 6435), vbBlue ', BF
Picture1.Line (j * 15 + 470, quexian(7, j) * -20 + 6435)-(j * 15 + 530, quexian(7, j) * -20 + 6435), vbBlue ', BF
Picture1.Line (j * 15 + 530, quexian(7, j) * -20 + 6435)-(j * 15 + 530, quexian(7, j) * -20 + 6385), vbBlue ', BF
Picture1.Line (j * 15 + 470, quexian(7, j) * -20 + 6415)-(j * 15 + 530, quexian(7, j) * -20 + 6385), vbBlue ', BF
Picture1.DrawWidth = 2 ' = dash
Picture1.Line (j * 15 + 475, quexian(4, j) * -20 + 6430)-(j * 15 + 525, quexian(4, j) * -20 + 6370), vbBlack
Picture1.Line (j * 15 + 475, quexian(4, j) * -20 + 6370)-(j * 15 + 525, quexian(4, j) * -20 + 6430), vbBlack
Picture1.DrawWidth = 1 ' = dash
Picture1.Line (j * 15 + 500, quexian(3, j) * -20 + 6385)-(j * 15 + 469, quexian(3, j) * -20 + 6417), vbCyan ', BF
Picture1.Line (j * 15 + 500, quexian(3, j) * -20 + 6385)-(j * 15 + 531, quexian(3, j) * -20 + 6417), vbCyan ', BF
Picture1.Line (j * 15 + 469, quexian(3, j) * -20 + 6417)-(j * 15 + 531, quexian(3, j) * -20 + 6417), vbCyan ', BF
Picture1.DrawWidth = 1 ' = dash
Picture1.Line (j * 15 + 490, quexian(2, j) * -20 + 6380)-((j + 1) * 15 + 510, quexian(2, j + 1) * -20 + 6370), vbRed, BF
Picture1.DrawWidth = 1
Picture1.Circle (j * 15 + 500, quexian(5, j) * -20 + 6400), 30, vbMagenta
Else
Picture1.DrawWidth = 1
Picture1.Line (j * 15 + 500, quexian(2, j) * -20 + 6400)-((j + 1) * 15 + 500, quexian(2, j + 1) * -20 + 6400), vbRed ', BF
Picture1.Line (j * 15 + 500, quexian(3, j) * -20 + 6400)-((j + 1) * 15 + 500, quexian(3, j + 1) * -20 + 6400), vbCyan ', BF
Picture1.Line (j * 15 + 500, quexian(4, j) * -20 + 6400)-((j + 1) * 15 + 500, quexian(4, j + 1) * -20 + 6400), vbBlack ', BF
Picture1.Line (j * 15 + 500, quexian(5, j) * -20 + 6400)-((j + 1) * 15 + 500, quexian(5, j + 1) * -20 + 6400), vbMagenta ', BF
Picture1.Line (j * 15 + 500, quexian(6, j) * -20 + 6400)-((j + 1) * 15 + 500, quexian(6, j + 1) * -20 + 6400), vbGreen ', BF
Picture1.Line (j * 15 + 500, quexian(7, j) * -20 + 6400)-((j + 1) * 15 + 500, quexian(7, j + 1) * -20 + 6400), vbBlue ', BF
End If
Next
Else
numData.Enabled = False
numPrint.Enabled = False
numPrintData.Enabled = False
End If
End Sub
http://zhidao.baidu.com/question/13677837.html

2023-06-12 广告
单片机汇编程序是用汇编语言编写的程序,用于控制单片机的操作。汇编语言是一种比较接近计算机硬件语言的低级语言,相对于高级语言来说更容易理解和实现。下面是单片机汇编程序的基本步骤:1. 将代码和数据汇编到规定的段中。2. 在存储器中用未初始化的...
点击进入详情页
本回答由意法半导体(中国)投资有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询