内容简介:本文介绍了使用Altium Designer脚本程序生成Y型天线的过程,在窗体中线宽、迭代次数,边框长度可以直接设置。Y分形天线用户界面由一个窗体、1个TImage控件、3个TLable控件、3个TEdit控件、一个TButton控件构成,
Y分形的平面微带天线生成过程
本文介绍了使用Altium Designer脚本程序生成Y型天线的过程,在窗体中线宽、迭代次数,边框长度可以直接设置。
Y分形天线用户界面由一个窗体、1个TImage控件、3个TLable控件、3个TEdit控件、一个TButton控件构成,
窗体步骤如下 :
- 新建一个 VB Script Form文件,保存脚本文件,将文件命名为Y分形天线设计。
- 将窗体的 Caption属性改为“Y分形天线设计”。
- 在窗体中添加 1个TImage控件、3个TLable控件、3个TEdit控件、一个TButton控件。
- 在 TImage控件中加入图片,将3个TLable控件的Caption分别改为“边长(mm):”、“线宽(mm):”、“迭代次数:”。将3个TEdit控件的Text属性分别改为“100”、“2”、“4”,将TButton控件的Caption属性改为“生成”。
窗体如下图所示
图元分析:
Y分形天线的基本结构如 下 所示。基本的图元由主干 M、左分支L、右分支R构成,再一次迭代以左分支的终点和右分支的终点上增加一个基本Y型图元。
Y分形天线 的基本图元为 Y型,上下左右四个方向都向前生长Y型的分支,向上Y型每次迭代主干M都是垂直向上,左、下、右Y型分支和上Y型分支相同,可由上Y型生成之后将坐标依次变换一下,得到左、下、右Y型分支,生成的图像如下图所示,源码附后 。
源程序:
PI = 3.1415926
Sub Start_PCBServer()
Call Client.StartServer("PCB")
PcbFileName = "PCB1.PcbDoc"
Set Document = Client.OpenDocument("PCB", PcbFileName)
If Not (Document Is Nothing) Then
'Add this schematic sheet in the newly created PCB project in DXP.
Set Workspace = GetWorkspace
If Not (Workspace Is Nothing) Then
Workspace.DM_FocusedProject.DM_AddSourceDocument(Document.FileName)
End If
Client.ShowDocument(Document)
End If
End Sub
'Draw Line Function
Sub Paint_Line(x1,y1,x2,y2)
Dim Board
Dim Track
Set Board = PCBServer.GetCurrentPCBBoard
Track = PCBServer.PCBObjectFactory(eTrackObject,eNoDimension,eCreate_Default)
Track.X1 = MMsToCoord(CLng(x1)+Board.GetState_XOrigin/10000*0.0254)
Track.Y1 = MMsToCoord(CLng(y1)+Board.GetState_XOrigin/10000*0.0254)
Track.X2 = MMsToCoord(CLng(x2)+Board.GetState_XOrigin/10000*0.0254)
Track.Y2 = MMsToCoord(CLng(y2)+Board.GetState_XOrigin/10000*0.0254)
Track.Layer = eTopLayer
Track.Width = MMsToCoord(Round(Edit2.Text))
Board.AddPCBObject(Track)
Board.LayerIsDisplayed(ALayer) = True
End Sub
'Draw rectangle Function
Sub Paint_Rectangle(x1,y1,x2,y2)
call Paint_Line(x1,y1,x2,y1)
call Paint_Line(x1,y1,x1,y2)
call Paint_Line(x1,y2,x2,y2)
call Paint_Line(x2,y1,x2,y2)
End Sub
Sub Action_Redraw()
Call Client.SendMessage("PCB:Zoom","Action=Redraw", 255, Client.CurrentView)
Call Client.SendMessage("PCB:Zoom","Action=All", 255, Client.CurrentView)
End Sub
'SetState_Origin
Sub Set_Origin()
Set Board = PCBServer.GetCurrentPCBBoard
Board.SetState_YOrigin(80000000)
Board.SetState_XOrigin(80000000)
End Sub
Sub Board_Shape()
Call AddStringParameter("Scope", "All")
RunProcess("PCB:Select")
Call AddStringParameter("Mode", "BOARDOUTLINE_FROM_SEL_PRIMS")
RunProcess("PCB:PlaceBoardOutline")
Call AddStringParameter("Size", "2.500MM")
RunProcess("PCB:SnapGrid")
Call AddStringParameter("MeasurementUnit", "Toggle")
RunProcess("PCB:DocumentPreferences")
End Sub
Sub Button1Click(Sender)
call Start_PCBServer() 'Start PCBServer
Board_chang = Round(Edit1.Text)
Iter_Num = Round(Edit3.Text) 'Get Iteration Number
call Set_Origin() 'Set Shape Relative to the origin
call Paint_Rectangle(-Board_chang/2,-Board_chang/2,Board_chang/2,Board_chang/2)
Call Board_Shape()
Call Y_Shape(0,0,30,4)
Action_Redraw()
Close
End Sub
Sub Y_Shape(x,y,L,Iter_Num)
a = PI/4
L1=L*2/3
If Iter_Num=0 Then 'If Iter_Num = 0
Call Y_Xing(x,y,L,L1,a) 'Draw Y
Else
Call Y_Xing(x,y,L,L1,a) 'Draw Y
Call Y_Shape(x-L1*sin(a),y+L+L1*cos(a),L/2,Iter_Num-1)
Call Y_Shape(x+L1*sin(a),y+L+L1*cos(a),L/2,Iter_Num-1)
End If
End Sub
Sub Y_Xing(x,y,L,L1,a)
Call Paint_Line(x,y,x,y+L) 'Draw Vertical Line
Call Paint_Line(x,y+L,x-L1*sin(a),y+L+L1*cos(a)) 'Draw Left Diagonal Line
Call Paint_Line(x,y+L,x+L1*sin(a),y+L+L1*cos(a)) 'Draw Right Diagonal Line
'Draw Left Y
Call Paint_Line(-y,x,-(y+L),x) 'Draw Vertical Line
Call Paint_Line(-(y+L),x,-(y+L+L1*cos(a)),x-L1*sin(a)) 'Draw Left Diagonal Line
Call Paint_Line(-(y+L),x,-(y+L+L1*cos(a)),x+L1*sin(a)) 'Draw Right Diagonal Line
'DraW Down Y
Call Paint_Line(x,-y,x,-(y+L)) 'Draw Vertical Line
Call Paint_Line(x,-(y+L),x-L1*sin(a),-(y+L+L1*cos(a))) 'Draw Left Diagonal Line
Call Paint_Line(x,-(y+L),x+L1*sin(a),-(y+L+L1*cos(a))) 'Draw Right Diagonal Line
'Draw Right Y
Call Paint_Line(y,-x,y+L,-x) 'Draw Vertical Line
Call Paint_Line(y+L,-x,y+L+L1*cos(a),-(x-L1*sin(a))) 'Draw Left Diagonal Line
Call Paint_Line(y+L,-x,y+L+L1*cos(a),-(x+L1*sin(a))) 'Draw Right Diagonal Line
End Sub
参考资料:
[1]付丽华.一种基于Y分形的平面微带天线设计与优化[EB/OL].http://www.elecfans.com/soft/69/2019/20190412905256.html,2019.
[2] Altium Limited.PCB API Design Objects Interfaces[EB/OL].https://techdocs.altium.com/display/SCRT/PCB+API+Design+Objects+Interfaces,2017-9-13.
以上所述就是小编给大家介绍的《Y分形的平面微带天线生成过程》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- DIY天线+SDR+GNURadio实现低成本接收解码韩国GK-2A气象卫星信号
- 实战生成对抗网络(二):生成手写数字
- 实战生成对抗网络[2]:生成手写数字
- 020.Python生成器和生成器函数
- faker生成器生成虚拟数据的Python模块
- 利用代码生成工具生成基于ABP框架的代码
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Web Design Handbook
Baeck, Philippe de 编 / 2009-12 / $ 22.54
This non-technical book brings together contemporary web design's latest and most original creative examples in the areas of services, media, blogs, contacts, links and jobs. It also traces the latest......一起来看看 《Web Design Handbook》 这本书的介绍吧!