DCS工程实践报告_第1页
DCS工程实践报告_第2页
DCS工程实践报告_第3页
DCS工程实践报告_第4页
DCS工程实践报告_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、一.系统简介用 VB 设计管理程序作为工程实践训练。设计好的通信程序嵌入到DCS 集散系统中去,通过实际调试掌握在局域网上的计算机之间进行实现数据通讯方法。工作站连载局域网上,为工作站编写的通信程序能实现如下要求:1. 一对与控制管理机进行通讯(经网卡)的收发按钮。2. 当点击该收发按钮时,工作站与控制室管理机建立连接。3. 可以接受控制管理机转发的监控对象的状态信息, 并将这些状态信息用图像或图形显示。4. 在控制管理机授予该工作站控制权限的前提下, 该工作站对监控对象有控制信号。这些信号经控制管理机盒下位机发送至监控对象。5. 该通讯程序用 VB 来实现。上位机(控制室管。理机)工作站通信

2、模块总线下位机双五自动层生气层产体流电车水线库梯硬件图DCS工程实践设计报告二.调试情况Q1:使用 winsock与服务方连接时,发送的数据有时可以收到有时收不到解决方法 :1)确认接受和发送的Text 文本框名字是否正确。2)设备的端口号是否正确,聆听程序为10023)然后确认发送数据前“查询连接”是否已经建立。把发送数据部分代码贴到“IfWinsock1.State = sckConnected Then”后。Q2:用按键数组控件时赋值出错。解决方法 :因为控件数组是用 “索引 index ”来确定是数组中哪个控件按下。 故确认好 index 后再次赋值就正确了。具体参照下例:Privat

3、e Sub Command1_Click(Index As Integer) 定义按钮控件数组sum1 = 0 并用索引来确定是这组数组中的哪个按键被按下If Index = 0 Then c1(0) = 1c1(0)上行启动指令信号If Index = 1 Then c1(1) = 2c1(1)下行启动指令信号sum1 = c1(0) + c1(1) + c1(2) + c1(3)End SubQ3:16 进制转换成为字符串时出错。解决方法 :用“ & ”符号替代“ +”后解决。Q4:1 )在编写电梯监控部分时,同时编写了运行的逻辑的部分,导致通讯后运行混乱。2 )在聆听程序中按下“ X 输

4、入”端子的上下行和开关门后,组态软件会随之一起动。解决方法 :经过老师指点理解到我们所编写的仅仅是监控程序,只负责收发数据,而无需控制电2DCS工程实践设计报告梯 ,具体控制逻辑是PLC 控制器来实现的.于是把相应逻辑部分删除后程序正确运行。Q5:虽然电梯有调速,但是当有“门已关”信号时,组态软件的电梯门并没有关起来。解决方法 :因为电梯的开关门速度和程序中开关门速度是不一样的。在门已关的信号下,就算组态软件中电梯门没有关上,也需要将它复位成“门已关”状态。故后加入程序实现的正确的“门已关” 。三 .主程序1) 程序界面及对应元件号3DCS工程实践设计报告2) 全部源代码Dim Y(31) A

5、s IntegerDim c1(3) As Integer 用来放X 后的 8 位 16 进制数,分别对应不同的控件按钮Dim c2(3) As Integer 用来放X 后的 8 位 16 进制数Dim c3(3) As Integer 用来放X 后的 8 位 16 进制数Dim c4(3) As Integer 用来放 X 后的 8 位 16 进制数Dim c5(3) As Integer 用来放 X 后的 8 位 16 进制数Dim c6(3) As Integer 用来放X 后的 8 位 16 进制数Dim c7(3) As Integer 用来放X 后的 8 位 16 进制数Dim

6、c8(3) As Integer 用来放X 后的 8 位 16 进制数Dim receive1x As StringDim receive2x As StringDim receive4x As StringDim receive9x As StringDim receive10x As StringDim receive13x As StringDim receive14x As StringDim receive19x As StringDim receive20x As StringDim receive2y As StringDim receive3y As StringDim rec

7、eive4y As StringDim receive5y As StringDim receive6y As String4DCS工程实践设计报告Dim receive7y As StringDim receive8y As StringDim receive9y As StringDim receive10y As StringDim receive11y As IntegerDim receive12y As IntegerDim receive13y As IntegerDim receive14y As IntegerDim receive15y As IntegerDim rece

8、ive16y As IntegerDim receive17y As IntegerDim receive18y As IntegerPublic sum1 As IntegerPublic sum2 As IntegerPublic sum3 As IntegerPublic sum4 As IntegerPublic sum5 As IntegerPublic sum8 As IntegerPrivate Sub Command1_Click(Index As Integer) 定义按钮控件数组sum1=0 并用索引来确定是这组数组中的哪个按键被按下If Index = 0 Then c1

9、(0) = 1c1(0)上行启动指令信号If Index = 1 Then c1(1) = 2c1(1)下行启动指令信号sum1 = c1(0) + c1(1) + c1(2) + c1(3)End SubPrivate Sub Command10_Click() 断开Winsock1.CloseCommand9.Enabled = TrueCommand10.Enabled = FalseEnd SubPrivate Sub Command11_Click() 退出If Winsock1.State sckClosed Then Winsock1.CloseEndEnd SubPrivate

10、 Sub Command2_Click(Index As Integer)sum2 = 05DCS工程实践设计报告If Index = 3 Then c2(3) = 81 楼上召信号sum2 = c2(0) + c2(1) + c2(2) + c2(3)End SubPrivate Sub Command3_Click(Index As Integer)sum3 = 0If Index = 0 Then c3(0) = 12楼上召信号If Index = 1 Then c3(1) = 22楼下召信号If Index = 2 Then c3(2) = 43楼上召信号If Index = 3 Th

11、en c3(3) = 83楼下召信号sum3 = c3(0) + c3(1) + c3(2) + c3(3)End SubPrivate Sub Command4_Click(Index As Integer)sum4 = 0If Index = 0 Then c4(0) = 14楼上召信号If Index = 1 Then c4(1) = 24楼下召信号If Index = 2 Then c4(2) = 45楼下召信号If Index = 3 Then c4(3) = 81楼指令信号sum4 = c4(0) + c4(1) + c4(2) + c4(3)End SubPrivate Sub

12、Command5_Click(Index As Integer)sum5 = 0If Index = 0 Then c5(0) = 12楼指令信号If Index = 1 Then c5(1) = 23楼指令信号If Index = 2 Then c5(2) = 44楼指令信号If Index = 3 Then c5(3) = 85楼指令信号sum5 = c5(0) + c5(1) + c5(2) + c5(3)End SubPrivate Sub Command8_Click(Index As Integer)sum8 = 0If Index = 1 Then c8(1) = 2 开门信号I

13、f Index = 2 Then c8(2) = 4 关门信号sum8 = c8(1) + c8(2)End SubPrivate Sub Command9_Click()Winsock1.RemoteHost = Text1.Text 定义远端 IP 和端口号Winsock1.RemotePort = 1002Winsock1.LocalPort = 0Winsock1.Connect6DCS工程实践设计报告Command9.Enabled = FalseCommand10.Enabled = TrueEnd SubPrivate Sub HScroll1_Change()Timer2.In

14、terval = HScroll1.Value改变电梯开关门速度End SubPrivate Sub HScroll2_Change()Timer3.Interval = HScroll2.Value改变电梯上下行速度End SubPrivate Sub Text3_Change()If Winsock1.State = sckConnected Then Winsock1.SendData Text3.Text 把数据传送到 PLC(聆听程序 )End SubPrivate Sub Timer1_Timer()w = Hex(sum5) & Hex(sum4) & Hex(sum3) & H

15、ex(sum2) & Hex(sum1)z = Hex(sum8)Text3.T ext = receive1x & z & receive2x & w & receive2yIf Y(3)= 1Then Shape8.FillStyle = 0 Else Shape8.FillStyle = 1 电梯运行显示If Y(6)= 1Then Shape9(0).FillStyle = 0: Picture3.Left =-760: Picture4.Left = 1200Else Shape9(0).FillStyle = 1 门已开显示If Y(7)= 1Then Shape9(1).Fill

16、Style = 0: Picture3.Left = -10: Picture4.Left = 600 ElseShape9(1).FillStyle = 1 门已关显示If Y(10) = 1 Then Picture1.Top = 7560: Picture1.Left = 240 轿厢到 1楼If Y(11) = 1Then Picture1.Top = 5640: Picture1.Left = 240 轿厢到 2楼If Y(12) = 1Then Picture1.Top = 3840: Picture1.Left = 240 轿厢到 3楼If Y(13) = 1Then Pictu

17、re1.Top = 2040: Picture1.Left = 240 轿厢到 4楼If Y(14) = 1Then Picture1.Top = 240: Picture1.Left = 240 轿厢到 5楼End SubPrivate Sub Timer2_Timer() 用来控制电梯的开关门If Y(0) = 1 And Picture3.Left = -760 And Picture4.Left = 1200 Then Picture3.Left =Picture3.Left - 10: Picture4.Left = Picture4.Left + 10 开门If Y(1) = 1

18、And Picture3.Left = 600 Then Picture3.Left =Picture3.Left + 10: Picture4.Left = Picture4.Left - 10 关门7DCS工程实践设计报告End SubPrivate Sub Timer3_Timer()If Y(26) = 1And Picture1.Top = 240 Then Picture1.Top = Picture1.Top20 电梯上行If Y(27) = 1And Picture1.Top = 7560 Then Picture1.Top = Picture1.Top + 20 电梯下行En

19、d SubPrivate Sub Winsock1_DataArrival(ByVal bytesTotal As Long)Dim receive As StringWinsock1.GetData receiveText2.T ext = receive 从 PLC(聆听程序处 ) 接收程序receive1x = Mid(receive, 1, 2)receive2x = Mid(receive, 4, 2)receive4x = Mid(receive, 4, 1)receive9x = Mid(receive, 9, 1)receive10x = Mid(receive, 10, 1)

20、receive14x = Val(&H + receive4x)receive19x = Val(&H + receive9x)receive20x = Val(&H + receive10x)receive2y = Mid(receive, 11, 11)receive3y = Mid(receive, 21, 1)receive4y = Mid(receive, 20, 1)receive5y = Mid(receive, 19, 1)receive6y = Mid(receive, 18, 1)receive7y = Mid(receive, 17, 1)receive8y = Mid(

21、receive, 16, 1)receive9y = Mid(receive, 15, 1)receive10y = Mid(receive, 14, 1)receive11y = Val(&H + receive3y)receive12y = Val(&H + receive4y)receive13y = Val(&H + receive5y)receive14y = Val(&H + receive6y)receive15y = Val(&H + receive7y)receive16y = Val(&H + receive8y) 取X的前2位 取X的45位 取X的第4位 取X的第9位 取

22、 X的第 10位 把 X 的第 4 位转换成数值 把 X 的第 9 位转换成数值 把 X 的第 10 位转换成数值 取 Y 后的字符 取 Y的 21位 取 Y的 20位 取 Y的 19位 取 Y的 18位 取 Y的 17位 取 Y的 16位 取 Y的 15位 取Y的14位 把 Y 的 21 位转换成数值 把 Y 的 20 位转换成数值 把 Y 的 19 位转换成数值 把 Y 的 18 位转换成数值 把 Y 的 17 位转换成数值 把 Y 的 16 位转换成数值8DCS工程实践设计报告receive17y = Val(&H + receive9y) 把 Y 的 15 位转换成数值receive1

23、8y = Val(&H + receive10y) 把 Y 的 14 位转换成数值For i = 0 To 3 此段 For 语句用来计算哪些灯应该亮(LED 楼层显示, 轿厢指令显示,外部呼叫显示)Form1.Shape1(i).FillStyle = (receive11y Mod 2)receive11y = (receive11y - Form1.Shape1(i).FillStyle) / 2If Form1.Shape1(i).FillStyle = 1 Then Form1.Shape1(i).FillStyle = 0 Else Form1.Shape1(i).FillStyl

24、e = 1Form1.Shape2(i).FillStyle = (receive12y Mod 2)receive12y = (receive12y - Form1.Shape2(i).FillStyle) / 2If Form1.Shape2(i).FillStyle = 1 Then Form1.Shape2(i).FillStyle = 0 Else Form1.Shape2(i).FillStyle = 1Form1.Shape3(i).FillStyle = (receive13y Mod 2)receive13y = (receive13y - Form1.Shape3(i).F

25、illStyle) / 2If Form1.Shape3(i).FillStyle = 1 Then Form1.Shape3(i).FillStyle = 0 Else Form1.Shape3(i).FillStyle = 1Form1.Shape4(i).FillStyle = (receive14y Mod 2)receive14y = (receive14y - Form1.Shape4(i).FillStyle) / 2If Form1.Shape4(i).FillStyle = 1 Then Form1.Shape4(i).FillStyle = 0 Else Form1.Sha

26、pe4(i).FillStyle = 1Form1.Shape5(i).FillStyle = (receive15y Mod 2)receive15y = (receive15y - Form1.Shape5(i).FillStyle) / 2If Form1.Shape5(i).FillStyle = 1 Then Form1.Shape5(i).FillStyle = 0 Else Form1.Shape5(i).FillStyle = 1Next iFor m = 0 To 3 此段计算出的Y(26)Y(27)用来控制电梯的上下行,Y(24)Y(25) 用来控制灯内部4,5 楼的指令显

27、示Y(m + 24) = (receive16y Mod 2)receive16y = (receive16y - Y(m + 24) / 29DCS工程实践设计报告Form1.Shape7(0).FillStyle = Y(24)Form1.Shape7(1).FillStyle = Y(25)IfForm1.Shape7(0).FillStyle=1ThenForm1.Shape7(0).FillStyle=0ElseForm1.Shape7(0).FillStyle = 1IfForm1.Shape7(1).FillStyle=1ThenForm1.Shape7(1).FillStyle

28、=0ElseForm1.Shape7(1).FillStyle = 1Y(m + 20) = (receive18y Mod 2)receive18y = (receive18y - Y(m + 20) / 2Form1.Shape10(0).FillStyle = Y(20)Form1.Shape10(1).FillStyle = Y(21)IfForm1.Shape10(0).FillStyle=1ThenForm1.Shape10(0).FillStyle=0ElseForm1.Shape10(0).FillStyle = 1IfForm1.Shape10(1).FillStyle=1ThenForm1.Shape10(1).FillStyle=0

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论