- 积分
- 28524
- 回帖
- 0
- 西莫币
-
- 贡献
-
- 威望
-
- 存款
-
- 阅读权限
- 120
- 最后登录
- 1970-1-1
该用户从未签到
|
楼主 |
发表于 2015-6-29 09:40
|
显示全部楼层
来自: 中国安徽合肥
如何计算永磁同步电机最大去磁工作点及仿真部分退磁后电机的性能
源码如下:
''''''''''dim input'''''''''''''''''
Dim U, e0, xad, xaq, r1, x1, theta As Double
Dim xd, xq, id, iq, i1, fai, fainei As Double
''''''''''dim viction'''''''''''''''
Dim ve0x, ve0y, vxadx, vxady, vxaqx, vxaqy, vr1x, vr1y, vx1x, vx1y, vi1x, vi1y, vux, vuy As Double
''''''''''dim location'''''''''''''''
Dim cuxi, movey, ox, oy, e0x, e0y, xadx, xady, xaqx, xaqy, r1x, r1y, x1x, x1y, i1x, i1y, ux, uy As Double
''''''''''loadform'''''''''''''''
Private Sub Form_Load()
'读取数据,初始化窗口用
Textu.Text = 219
Texte0.Text = 223
Textxad.Text = 2.37
Textxaq.Text = 6.57
Textr1.Text = 0.0743
Textx1.Text = 0.228
Texttheta.Text = 56.5
myinput
'初始化窗口
cuxi = 2
Form1.Height = 8000
Form1.Width = 16000
Form1.ScaleHeight = U * 1.8
Form1.ScaleWidth = U * 3.6
Form1.DrawWidth = cuxi
'定义控件初始值
movey = 20
Labeltxt.Caption = "说明:" & (Chr(13) + Chr(10)) & "1.点击【计算】绘制图形,操作进度条观看动画;" _
& (Chr(13) + Chr(10)) & "2.点击【导出计算结果】计算工作特性保存在当前目录的txt文件中;" _
& (Chr(13) + Chr(10)) & "3.程序为个人学习电机设计所用,未经严密验证。" _
& (Chr(13) + Chr(10)) & " ——李孟德@明腾永磁技术部"
End Sub
'''''''''help'''''''''''''''''
Private Sub Command2_Click()
Labeltxt.Caption = "说明:" & (Chr(13) + Chr(10)) & "1.点击【计算】绘制图形,操作进度条观看动画;" _
& (Chr(13) + Chr(10)) & "2.点击【导出计算结果】计算工作特性保存在当前目录的txt文件中;" _
& (Chr(13) + Chr(10)) & "3.程序为个人学习电机设计所用,未经严密验证。" _
& (Chr(13) + Chr(10)) & " ——李孟德@明腾永磁技术部"
End Sub
''''input''''''''''''''''''
Sub myinput()
U = CDbl(Textu.Text)
e0 = CDbl(Texte0.Text)
xad = CDbl(Textxad.Text)
xaq = CDbl(Textxaq.Text)
r1 = CDbl(Textr1.Text)
x1 = CDbl(Textx1.Text)
theta = CDbl(Texttheta.Text) * 3.14159 / 180
End Sub
''''''''calc''''''''
Sub calc()
myinput
'calc variable
xd = x1 + xad
xq = x1 + xaq
id = (r1 * U * Cos(theta + 3.14159 / 2) + xq * (U * Sin(theta + 3.14159 / 2) - e0)) / (r1 ^ 2 + xq * xd)
iq = -(xd * U * Cos(theta + 3.14159 / 2) - r1 * (U * Sin(theta + 3.14159 / 2) - e0)) / (r1 ^ 2 + xq * xd)
i1 = (id ^ 2 + iq ^ 2) ^ 0.5
fainei = -Atn(id / iq) * 180 / 3.14159
fai = fainei - theta * 180 / 3.14159
'calc viction
ve0x = 0
ve0y = e0
vxadx = 0
vxady = xad * id
vxaqx = -iq * xaq
vxaqy = 0
vr1x = r1 * id
vr1y = r1 * iq
vx1x = -iq * x1
vx1y = id * x1
vi1x = id
vi1y = iq
vux = U * Cos(theta + 3.14159 / 2)
vuy = U * Sin(theta + 3.14159 / 2)
'calc lacation
ox = Form1.ScaleWidth / 3
oy = Form1.ScaleHeight * 9 / 10 * (movey / 20)
e0x = ox + ve0x
e0y = oy - ve0y
xadx = ox + ve0x + vxadx
xady = oy - ve0y - vxady
xaqx = ox + ve0x + vxadx + vxaqx
xaqy = oy - ve0y - vxady - vxaqy
r1x = ox + ve0x + vxadx + vxaqx + vr1x
r1y = oy - ve0y - vxady - vxaqy - vr1y
x1x = ox + ve0x + vxadx + vxaqx + vr1x + vx1x
x1y = oy - ve0y - vxady - vxaqy - vr1y - vx1y
i1x = ox + vi1x
i1y = oy - vi1y
ux = ox + vux
uy = oy - vuy
End Sub
'''''''''''SHOUW'''''''''''''
Sub output()
Labeltxt.Caption = "id=" & Format(id, "0.00E+00") & " " _
& "iq=" & Format(iq, "0.00E+00") & " " _
& "i1=" & Format(i1, "0.00E+00") & " " _
& "id*xad=" & Format(id * xad, "0.00E+00") & (Chr(13) + Chr(10)) _
& "iq*xaq=" & Format(iq * xaq, "0.00E+00") & " " _
& "i1*r1=" & Format(i1 * r1, "0.00E+00") & " " _
& "i1*x1=" & Format(i1 * x1, "0.00E+00") & " " _
& "u=" & Format(U, "0.00E+00") & (Chr(13) + Chr(10)) _
& "fainei=" & Format(fainei, "0.00E+00") & " " _
& "fai=" & Format(fai, "0.00E+00")
End Sub
''''''''DRAW''''''''''''
Sub draw()
Cls
'画坐标轴
Dim x As Integer
Dim y As Integer
Form1.DrawWidth = 1.2
'画x轴坐标系
Form1.Line (ox, oy)-(ox + Form1.ScaleWidth / 4, oy), vbBlue
Form1.ForeColor = vbBlue
Form1.Print "X"
'画x坐标点
Form1.DrawWidth = 4
For y = 0 To 10 Step 1
Form1.PSet (ox + Form1.ScaleWidth / 4 * y / 10, oy)
Next y
'画y轴坐标系
Form1.DrawWidth = 1.2
Form1.Line (ox, oy)-(ox, 1 / 10 * oy), vbBlue
Form1.ForeColor = vbBlue
Form1.Print "Y"
'画y坐标点(以1小时为1个单位)
Form1.DrawWidth = 4
For x = 0 To 15 Step 1
Form1.PSet (ox, oy - 9 / 150 * oy * x)
Next x
'指定位置显示原点o
Form1.CurrentX = ox
Form1.CurrentY = oy
Form1.Print "0"
'画向量
Form1.DrawWidth = cuxi
'i1
Form1.Line (ox, oy)-(i1x, i1y), RGB(128, 0, 255)
'e0
Form1.Line (ox, oy)-(e0x, e0y), RGB(255, 0, 0)
'xad
'Form1.Line (e0x, e0y)-(xadx, xady), RGB(0, 255, 0)
Form1.Line (e0x - Form1.DrawWidth - 1, e0y)-(xadx - Form1.DrawWidth - 1, xady), RGB(255, 128, 0) '偏移防止重合
'xaq
Form1.Line -(xaqx, xaqy), RGB(255, 255, 0)
'r1
Form1.Line -(r1x, r1y), RGB(0, 255, 0)
'x1
Form1.Line -(x1x, x1y), RGB(0, 255, 255)
'u
'Form1.Line -(ox, oy), RGB(255, 0, 0)
'u
Form1.Line (ox, oy)-(ux, uy), RGB(0, 0, 255)
End Sub
''''''''绘制图形''''''''''''''''''''''
Private Sub Command1_Click()
calc
draw
output
End Sub
'''''''''自动绘图参考''''''''''''''''''''''''
Private Sub VScroll1_Change()
theta = VScroll1.Value * 3.14159 / 180
Texttheta.Text = theta * 180 / 3.14159
Command1_Click
End Sub
'''''''''自动绘图1''''''''''''''''''''''''
Private Sub HScrollu_Change()
U = HScrollu.Value / 100 * CDbl(Text1.Text)
Textu.Text = U
Command1_Click
End Sub
'''''''''自动绘图2''''''''''''''''''''''''
Private Sub HScrolle0_Change()
e0 = HScrolle0.Value / 100 * CDbl(Text2.Text)
Texte0.Text = e0
Command1_Click
End Sub
'''''''''自动绘图3''''''''''''''''''''''''
Private Sub HScrollxad_Change()
xad = HScrollxad.Value / 100 * CDbl(Text3.Text)
Textxad.Text = xad
Command1_Click
End Sub
'''''''''自动绘图4''''''''''''''''''''''''
Private Sub HScrollxaq_Change()
xaq = HScrollxaq.Value / 100 * CDbl(Text4.Text)
Textxaq.Text = xaq
Command1_Click
End Sub
'''''''''自动绘图5''''''''''''''''''''''''
Private Sub HScrollr1_Change()
r1 = HScrollr1.Value / 100 * CDbl(Text5.Text)
Textr1.Text = r1
Command1_Click
End Sub
'''''''''自动绘图6''''''''''''''''''''''''
Private Sub HScrollx1_Change()
x1 = HScrollx1.Value / 100 * CDbl(Text6.Text)
Textx1.Text = x1
Command1_Click
End Sub
'''''''''自动绘图7''''''''''''''''''''''''
Private Sub HScrolltheta_Change()
theta = HScrolltheta.Value / 100 * CDbl(Text7.Text) * 3.14159 / 180
Texttheta.Text = theta * 180 / 3.14159
Command1_Click
End Sub
'''''''''清除窗口'''''''''''''''''
Private Sub Command4_Click()
Cls
End Sub
'''''''''放大图形'''''''''''''''''
Private Sub Command5_Click()
Form1.ScaleHeight = 0.9 * Form1.ScaleHeight
Form1.ScaleWidth = 0.9 * Form1.ScaleWidth
Command1_Click
End Sub
'''''''''缩小图形'''''''''''''''''
Private Sub Command6_Click()
Form1.ScaleHeight = 1.1 * Form1.ScaleHeight
Form1.ScaleWidth = 1.1 * Form1.ScaleWidth
Command1_Click
End Sub
'''''''''上移图形'''''''''''''''''
Private Sub Command9_Click()
movey = movey - 1
Command1_Click
End Sub
'''''''''下移图形'''''''''''''''''
Private Sub Command10_Click()
movey = movey + 1
Command1_Click
End Sub
'''''''''加粗图形'''''''''''''''''
Private Sub Command8_Click()
cuxi = cuxi + 1
Command1_Click
End Sub
'''''''''初始化图形'''''''''''''''''
Private Sub Command7_Click()
myinput
Form1.Height = 8000
Form1.Width = 16000
Form1.ScaleHeight = U * 1.8
Form1.ScaleWidth = U * 3.6
cuxi = 2
movey = 20
Command1_Click
End Sub
''''''''''''''导出计算结果‘’‘’‘’‘’‘’‘’
Private Sub Commandexport_Click()
Open App.Path & "\" & "永磁电机不同功角电学参数.txt" For Output As #1
Print #1, " theta i1 id iq fainei fai " & (Chr(13) + Chr(10))
For i = 0 To 90
'CALC
theta = i * 3.14159 / 180
Texttheta.Text = theta * 180 / 3.14159
Command1_Click
'RECORD
Labeltxt.Caption = Format(theta * 180 / 3.14159, "0.00E+00") & " " _
& Format(i1, "0.00E+00") & " " _
& Format(id, "0.00E+00") & " " _
& Format(iq, "0.00E+00") & " " _
& Format(fainei, "0.00E+00") & " " _
& Format(fai, "0.00E+00") & " " _
& (Chr(13) + Chr(10))
'SAVEFILE
Print #1, Labeltxt.Caption
Next i
Close #1
End Sub
|
评分
-
查看全部评分
|