DCS工程實踐報告_第1頁
DCS工程實踐報告_第2頁
DCS工程實踐報告_第3頁
DCS工程實踐報告_第4頁
DCS工程實踐報告_第5頁
已閱讀5頁,還剩6頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

1、一.系統(tǒng)簡介用 VB 設計管理程序作為工程實踐訓練。設計好的通信程序嵌入到DCS 集散系統(tǒng)中去,通過實際調試掌握在局域網(wǎng)上的計算機之間進行實現(xiàn)數(shù)據(jù)通訊方法。工作站連載局域網(wǎng)上,為工作站編寫的通信程序能實現(xiàn)如下要求:1. 一對與控制管理機進行通訊(經(jīng)網(wǎng)卡)的收發(fā)按鈕。2. 當點擊該收發(fā)按鈕時,工作站與控制室管理機建立連接。3. 可以接受控制管理機轉發(fā)的監(jiān)控對象的狀態(tài)信息, 并將這些狀態(tài)信息用圖像或圖形顯示。4. 在控制管理機授予該工作站控制權限的前提下, 該工作站對監(jiān)控對象有控制信號。這些信號經(jīng)控制管理機盒下位機發(fā)送至監(jiān)控對象。5. 該通訊程序用 VB 來實現(xiàn)。上位機(控制室管。理機)工作站通信

2、模塊總線下位機雙五自動層生氣層產(chǎn)體流電車水線庫梯硬件圖DCS工程實踐設計報告二.調試情況Q1:使用 winsock與服務方連接時,發(fā)送的數(shù)據(jù)有時可以收到有時收不到解決方法 :1)確認接受和發(fā)送的Text 文本框名字是否正確。2)設備的端口號是否正確,聆聽程序為10023)然后確認發(fā)送數(shù)據(jù)前“查詢連接”是否已經(jīng)建立。把發(fā)送數(shù)據(jù)部分代碼貼到“IfWinsock1.State = sckConnected Then”后。Q2:用按鍵數(shù)組控件時賦值出錯。解決方法 :因為控件數(shù)組是用 “索引 index ”來確定是數(shù)組中哪個控件按下。 故確認好 index 后再次賦值就正確了。具體參照下例:Privat

3、e Sub Command1_Click(Index As Integer) 定義按鈕控件數(shù)組sum1 = 0 并用索引來確定是這組數(shù)組中的哪個按鍵被按下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 )在編寫電梯監(jiān)控部分時,同時編寫了運行的邏輯的部分,導致通訊后運行混亂。2 )在聆聽程序中按下“ X 輸

4、入”端子的上下行和開關門后,組態(tài)軟件會隨之一起動。解決方法 :經(jīng)過老師指點理解到我們所編寫的僅僅是監(jiān)控程序,只負責收發(fā)數(shù)據(jù),而無需控制電2DCS工程實踐設計報告梯 ,具體控制邏輯是PLC 控制器來實現(xiàn)的.于是把相應邏輯部分刪除后程序正確運行。Q5:雖然電梯有調速,但是當有“門已關”信號時,組態(tài)軟件的電梯門并沒有關起來。解決方法 :因為電梯的開關門速度和程序中開關門速度是不一樣的。在門已關的信號下,就算組態(tài)軟件中電梯門沒有關上,也需要將它復位成“門已關”狀態(tài)。故后加入程序實現(xiàn)的正確的“門已關” 。三 .主程序1) 程序界面及對應元件號3DCS工程實踐設計報告2) 全部源代碼Dim Y(31) A

5、s IntegerDim c1(3) As Integer 用來放X 后的 8 位 16 進制數(shù),分別對應不同的控件按鈕Dim c2(3) As Integer 用來放X 后的 8 位 16 進制數(shù)Dim c3(3) As Integer 用來放X 后的 8 位 16 進制數(shù)Dim c4(3) As Integer 用來放 X 后的 8 位 16 進制數(shù)Dim c5(3) As Integer 用來放 X 后的 8 位 16 進制數(shù)Dim c6(3) As Integer 用來放X 后的 8 位 16 進制數(shù)Dim c7(3) As Integer 用來放X 后的 8 位 16 進制數(shù)Dim

6、c8(3) As Integer 用來放X 后的 8 位 16 進制數(shù)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) 定義按鈕控件數(shù)組sum1=0 并用索引來確定是這組數(shù)組中的哪個按鍵被按下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 把數(shù)據(jù)傳送到 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 位轉換成數(shù)值 把 X 的第 9 位轉換成數(shù)值 把 X 的第 10 位轉換成數(shù)值 取 Y 后的字符 取 Y的 21位 取 Y的 20位 取 Y的 19位 取 Y的 18位 取 Y的 17位 取 Y的 16位 取 Y的 15位 取Y的14位 把 Y 的 21 位轉換成數(shù)值 把 Y 的 20 位轉換成數(shù)值 把 Y 的 19 位轉換成數(shù)值 把 Y 的 18 位轉換成數(shù)值 把 Y 的 17 位轉換成數(shù)值 把 Y 的 16 位轉換成數(shù)值8DCS工程實踐設計報告receive17y = Val(&H + receive9y) 把 Y 的 15 位轉換成數(shù)值receive1

23、8y = Val(&H + receive10y) 把 Y 的 14 位轉換成數(shù)值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) 用來控制燈內(nèi)部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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論