怎样制作动态曲线图像示波器一样的

yuanchao1985 2010-08-08 11:02:33
加精
我要做一个温度—时间的曲线图,是下载控件呢?还是自己画,类似示波器,一直在更新

横坐标作为时间,纵坐标作温度
数据的来源是传感器采集的
...全文
7203 224 打赏 收藏 转发到动态 举报
写回复
用AI写文章
224 条回复
切换为时间正序
请发表友善的回复…
发表回复
fhuang321 2013-03-22
  • 打赏
  • 举报
回复
请问楼主,你的那个程序有没有做出来了,能不能发给我 fhuang321@sina.cn
fhuang321 2013-03-22
  • 打赏
  • 举报
回复
请问:怎样从传感器接收数据,可以向示波器那样显示动态曲线,求大神解答。邮箱:fhuang321@sina.cn 能不能发给我一个完整的可运行程序
fhuang321 2013-03-22
  • 打赏
  • 举报
回复
请问164楼的那个效果是怎么做出来的,有没有源代码,能发我邮箱不?fhuang321@sina.cn
panxinlong7373 2012-06-01
  • 打赏
  • 举报
回复
好帖子,学习了。。正在用这个,有了例子一下就会了。。谢谢给位楼上的兄弟了
mezhe 2011-07-27
  • 打赏
  • 举报
回复
学习了!顶下
myrice01 2011-06-09
  • 打赏
  • 举报
回复
很好很强大
wzmlwx 2011-05-21
  • 打赏
  • 举报
回复
直接用picturebox控件绘制,如果要移动肯定有闪烁,这个我试过。在内存中画,然后bitblt到picturebox中。
  • 打赏
  • 举报
回复
要做的话还是用MATLAB比较好吧,可以直接用的
dianyancao 2011-03-08
  • 打赏
  • 举报
回复
tongfeng1981 2010-09-07
  • 打赏
  • 举报
回复
学习了
FXC929 2010-09-04
  • 打赏
  • 举报
回复
可以用,picturebox控件啊
taotong1984 2010-08-27
  • 打赏
  • 举报
回复
本来想帮楼主的 看这么多牛人回帖 就算了 顺带学习下
yaozha 2010-08-22
  • 打赏
  • 举报
回复
在内存中画,然后bitblt到picturebox
没有放大缩小功能,所以不需要坐标实时变换,很简单了
pair00 2010-08-19
  • 打赏
  • 举报
回复
楼主做出来了吗?使用什么方法的做的。
KiteGirl 2010-08-18
  • 打赏
  • 举报
回复
我的代码不是画线,而是直接根据一维8Bit信号成像。
输入512个8Bit元素的Buffer,根据改变量成像到512×256的8Bit点阵里。
然后再将8Bit点阵按256色位图显示到PictureBox里。

这玩意儿暂时只适合显示比较高速的实时信号。不过它可以改进成许多种形式。
KiteGirl 2010-08-18
  • 打赏
  • 举报
回复
这是我的示波器代码。

它使用一个Byte类型的Buffer数组保存信号采样。
可以将512个Buffer成像到一个PictureBox里(PictureBox必须是512宽、256高)。

测试代码

Private Sub Command1_Click()
Dim tBitMapInfo As tpBitMapInfo256
Dim tPixels() As Byte
Dim tBuffer() As Byte
Dim tIndex As Long
Dim tGDIMs As Long

ReDim tBuffer(511)

tBitMapInfo = BitMapCreate()

With tBitMapInfo.bmiHeader
ReDim tPixels(.biWidth * .biHeight - 1)
End With

picWaveScreen.Line (0, 0)-(512, 255)

For tIndex = 0 To 511
tBuffer(tIndex) = 127 + Int(Rnd * (Sin(tIndex * 20 * 3.14 / 180) * Sin((tIndex + Timer * 100) * 3.14 / 180) * 64))
Next

PixelsGetByBuffer tBuffer(), tPixels(), 255, 512

BitMapShow picWaveScreen.hDC, tBitMapInfo, tPixels()
End Sub

Private Sub Form_Load()
Form1.Show
End Sub


模块代码

Option Explicit

Public Type tpBitMapFileHeader
bfType As Integer
bfSize As Long
bfReserved1 As Integer
bfReserved2 As Integer
bfOffBits As Long
End Type

Public Type tpBitMapInfoHeader
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type

Public Type tpRGBQuad
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
End Type

Public Type tpBitMapHeader
bhFileHeader As tpBitMapFileHeader
bhInfoHeader As tpBitMapInfoHeader
End Type

Public Type tpBitMapInfo256
bmiHeader As tpBitMapInfoHeader
bmiColors(255) As tpRGBQuad
End Type

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Public Declare Function StretchDIBits Lib "gdi32" (ByVal hDC As Long, ByVal X As Long, ByVal Y As Long, ByVal dx As Long, ByVal dy As Long, ByVal SrcX As Long, ByVal SrcY As Long, ByVal wSrcWidth As Long, ByVal wSrcHeight As Long, lpBits As Any, lpBitsInfo As tpBitMapInfo256, ByVal wUsage As Long, ByVal dwRop As Long) As Long

Public Const DIB_PAL_COLORS = 1

Public Const DIB_RGB_COLORS = 0

Public Const SRCCOPY = &HCC0020

Public Sub PixelsGetByBuffer(ByRef pBuffer() As Byte, ByRef pPixel() As Byte, ByVal pColor As Byte, Optional ByVal pW As Long = 512)
Dim tBuffer_Index As Long, tBuffer_Length As Long
tBuffer_Length = UBound(pBuffer())
For tBuffer_Index = 1 To tBuffer_Length
PixelsDrawRow pPixel(), pColor, pW, tBuffer_Index, pBuffer(tBuffer_Index - 1), pBuffer(tBuffer_Index)
Next
End Sub

Public Sub PixelsDrawRow(ByRef pPixels() As Byte, ByVal pColor As Byte, ByVal pW As Long, ByVal pX As Long, ByVal pYs As Long, ByVal pYe As Long)
Dim tY As Long, tI As Long
If Not pYe = pYs Then
For tY = pYs To pYe Step Sgn(pYe - pYs)
tI = tY * pW + pX
pPixels(tI) = pColor
Next
Else
tI = pYs * pW + pX
pPixels(tI) = pColor
End If
End Sub

Public Function BitMapCreate(Optional ByVal pWidth As Long = 512, Optional ByVal pHeight As Long = 256) As tpBitMapInfo256
Dim tBitMapInfo As tpBitMapInfo256
Dim tIndex As Long

With tBitMapInfo
For tIndex = 0 To 255
.bmiColors(tIndex).rgbBlue = 0
.bmiColors(tIndex).rgbGreen = tIndex
.bmiColors(tIndex).rgbRed = 0
Next
End With

With tBitMapInfo.bmiHeader
.biBitCount = 8
.biClrImportant = 0
.biClrUsed = 0
.biCompression = 0
.biHeight = pHeight
.biPlanes = 1
.biSize = 40
.biSizeImage = 0
.biWidth = pWidth
.biXPelsPerMeter = 0
.biYPelsPerMeter = 0
End With

BitMapCreate = tBitMapInfo
End Function

Public Function BitMapShow(ByVal pDC As Long, ByRef pBitMapInfo As tpBitMapInfo256, ByRef pPixels() As Byte)
With pBitMapInfo.bmiHeader
BitMapShow = StretchDIBits(pDC, 0, 0, .biWidth, .biHeight, 0, 0, .biWidth, .biHeight, pPixels(0), pBitMapInfo, DIB_RGB_COLORS, SRCCOPY)
End With
End Function
shenbingyi 2010-08-18
  • 打赏
  • 举报
回复
不错,有时间学一下
aiwenbupt 2010-08-18
  • 打赏
  • 举报
回复
嗯 很不错 谢谢
fzx4936 2010-08-18
  • 打赏
  • 举报
回复
1个难点在于图像的滚动
而所谓的滚动 其实就是不断的重绘图像
每次重绘都要clear一次 然后按坐标数组重绘 如果频率很快 一定会闪的

另一个难点在于数组的处理
每次获得了新的数据后 坐标数组的元素都需要一次向后移动一次(丢弃第1个 在最后增加新数据)
如果图像不是很大 即需要的数据不是很多还好
如果图像很大 需要使用的数据量很大 在元素移动时可能会造成停顿(但这种可能性不大)
supview 2010-08-17
  • 打赏
  • 举报
回复
用第3方控件的话,TChart不错,测控行业用的比较多!
加载更多回复(170)

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧