关于DSP图像采集在VB显示的问题
本人是VB的新手,做毕业设计时遇到了问题,求高手指导!上位机向下位机传送数据,通过VB对于下位机送上来的数据进行曲线的绘制,这是关于永磁同步电机的速度环,位置环,电流环的三个曲线的显示。这是我做的程序,能否需要某个曲线时候就能得到呢?如果不能应该怎么样修改?
Private Sub MSComm1_OnComm()
Dim dnumber As Integer
Dim av As Variant
Dim times As Integer
Dim Firstrun As Integer
Dim ab(2) As Byte
Dim IP(4000) As Double
Dim DCVol As Double
Dim Volampoff As Double
Dim KpOff As Double
Dim TimeWind As Double
Dim KiOff As Double
Dim i As Integer
Dim AX As Double
Dim axis1 As Double
HScroll2(0).Enabled = False
Select Case MSComm1.CommEvent
Case comEvReceive
MSComm1.RThreshold = 0
i = 0
Firstrun = 0
For i = 0 To (xtime_temp - NumByteOne - 1) Step 1
If (Firstrun = 0) Then
Do
av = MSComm1.Input
Loop Until av(0) = 255
Firstrun = 1
Else
av = MSComm1.Input
End If
IP(i) = av(0)
If IP(i) > 127 Then
IP(i) = 256 - IP(i)
IP(i) = -IP(i)
End If
Next i
'axis1 = 2580
AX = 1200
If (ProjectNum = 8) Then
ProjectNum = 1
Shape1.Refresh
For i = 0 To (xtime_temp - NumByteOne - 1) Step NumByteOne
axis1 = 2580
Line (AX, axis1 - (yamplitude / 1100) * IP(i + 1) * 17.2)-(AX + 10440 / xtime_temp, axis1 - (yamplitude / 1100) * IP(i + 1 + NumByteOne) * 17.2), RGB(255, 0, 0)
axis1 = 2580
Line (AX, axis1 - (yamplitude / 1100) * IP(i + 2) * 17.2)-(AX + 10440 / xtime_temp, axis1 - (yamplitude / 1100) * IP(i + 2 + NumByteOne) * 17.2), RGB(0, 255, 0)
AX = AX + 10440 / ((xtime_temp - NumByteOne) / NumByteOne) '17.2对应4.3安培电流,4.3A对应DSP传到PC机上为68
Text3(2).Text = Str(IP(i + 3) / 64) '单位:欧母
Text3(3).Text = Str(IP(i + 4) * 1000 / 8192) '单位:mH
DCVol = 64 '直流母线电压,单位V
Volampoff = DCVol / 1250 '电压放大倍数
KpOff = (IP(i + 4) / 8192) / (2 * Volampoff * (0.00005 * 1) * (2 ^ 20)) '对应模拟系统电流PI比例系数,0.00005*1(s)表示闭环上最小环节时间常数之和,需要微调
If ((IP(i + 3) * IP(i + 4)) <> 0) Then
TimeWind = (IP(i + 4) / 8192) / (IP(i + 3) / 64) '绕组时间常数,单位s
KiOff = KpOff / TimeWind '对应模拟系统电流PI积分系数
End If
Text2(2) = Str(KpOff)
Text2(3) = Str(KiOff)
Next i
Else
ProjectNum = ProjectNum + 1
End If
Text7(0).Text = Str(0)
Text7(1).Text = Str(((xtime_temp - NumByteOne) / NumByteOne) * 0.005 * NumByteDSPOne * 1)
Text7(2).Text = Str(((xtime_temp - NumByteOne) / NumByteOne) * 0.005 * NumByteDSPOne * 2)
Text7(3).Text = Str(((xtime_temp - NumByteOne) / NumByteOne) * 0.005 * NumByteDSPOne * 3)
Text7(4).Text = Str(((xtime_temp - NumByteOne) / NumByteOne) * 0.005 * NumByteDSPOne * 4)
Text7(5).Text = Str(((xtime_temp - NumByteOne) / NumByteOne) * 0.005 * NumByteDSPOne * 5)
Text7(6).Text = Str(((xtime_temp - NumByteOne) / NumByteOne) * 0.005 * NumByteDSPOne * 6)
Text7(7).Text = Str(((xtime_temp - NumByteOne) / NumByteOne) * 0.005 * NumByteDSPOne * 7)
Text7(8).Text = Str(((xtime_temp - NumByteOne) / NumByteOne) * 0.005 * NumByteDSPOne * 8)
Text7(9).Text = Str(((xtime_temp - NumByteOne) / NumByteOne) * 0.005 * NumByteDSPOne * 9)
Text7(10).Text = Str(((xtime_temp - NumByteOne) / NumByteOne) * 0.005 * NumByteDSPOne * 10)
Text5(1).Text = Str((MaxCurrent / 5) * 4 * 2 / (yamplitude / 1100))
Text5(2).Text = Str((MaxCurrent / 5) * 3 * 2 / (yamplitude / 1100))
Text5(3).Text = Str((MaxCurrent / 5) * 2 * 2 / (yamplitude / 1100))
Text5(4).Text = Str((MaxCurrent / 5) * 1 * 2 / (yamplitude / 1100))
Text5(5).Text = Str((MaxCurrent / 5) * 0 * 2 / (yamplitude / 1100))
Text5(6).Text = Str((MaxCurrent / 5) * -1 * 2 / (yamplitude / 1100))
Text5(7).Text = Str((MaxCurrent / 5) * -2 * 2 / (yamplitude / 1100))
Text5(8).Text = Str((MaxCurrent / 5) * -3 * 2 / (yamplitude / 1100))
Text5(9).Text = Str((MaxCurrent / 5) * -4 * 2 / (yamplitude / 1100))
Do
DoEvents
Loop Until Startrun = 1
Case Else
End Select
xtime_temp = xtime
MSComm1.RThreshold = xtime_temp
HScroll2(0).Enabled = True
End Sub
[解决办法]
上面的程序肯定不能实现,因为上面的代码不全,只有个串口接收事件过程,
没有其他过程,既然不完整,肯定不能实现。
即使你贴出完整过程,不知道你的设备通讯协议和数据格式,也不能判断你的
通讯过程是否符合你的硬件标准,所以也无法判断是否可行。
再者就是参数特性,你取得的参数具体数据如何?范围和边界如何?单位是什么?
要以什么计量单位计算显示?这些不清楚,也不会知道你图形上的计算是否正确。