litung
臺灣-李同在
級別: VIP會員
|
把異常集中在一點,是方便你對PLC程式除錯。 vb程式可以對你設定的異常點區域作搜尋比對,只要其中一個點=on,就是有異常。 底下部份程式給你參考看看。設一個time去掃程式。 Private Sub tmrAlarm_Timer() Dim I As Integer Dim J As Integer Dim sDATA(100) As String Dim mData(100) As Integer '讀取M值狀態 sDATA(0) = ReadM(300) gf = PLC.ReadDeviceRandom2(sDATA(0), CLng(10), mData(0)) sDATA(1) = ReadM(310) gf = PLC.ReadDeviceRandom2(sDATA(1), CLng(10), mData(10)) sDATA(2) = ReadM(320) gf = PLC.ReadDeviceRandom2(sDATA(2), CLng(10), mData(20)) sDATA(3) = ReadM(330) gf = PLC.ReadDeviceRandom2(sDATA(3), CLng(10), mData(30)) sDATA(4) = ReadM(340) gf = PLC.ReadDeviceRandom2(sDATA(4), CLng(10), mData(40)) sDATA(5) = ReadM(350) gf = PLC.ReadDeviceRandom2(sDATA(5), CLng(10), mData(50)) sDATA(6) = ReadM(360) gf = PLC.ReadDeviceRandom2(sDATA(6), CLng(10), mData(60)) sDATA(6) = ReadM(370) gf = PLC.ReadDeviceRandom2(sDATA(7), CLng(10), mData(70)) sDATA(8) = ReadM(380) gf = PLC.ReadDeviceRandom2(sDATA(8), CLng(10), mData(80)) For N = 0 To 9 M(300 + N) = mData(N) M(310 + N) = mData(N + 10) M(320 + N) = mData(N + 20) M(330 + N) = mData(N + 30) M(340 + N) = mData(N + 40) M(350 + N) = mData(N + 50) M(360 + N) = mData(N + 60) M(370 + N) = mData(N + 70) M(380 + N) = mData(N + 80) Next N lblAlarm = "" If M(301) Then lblAlarm = lblAlarm & "M301:送料口異常" If M(302) Then lblAlarm = lblAlarm & "M302:無料警告" If M(303) Then lblAlarm = lblAlarm & "M303:載臺異常" If M(304) Then lblAlarm = lblAlarm & "M304:推料異常" If M(305) Then lblAlarm = lblAlarm & "M305:夾料異常" If M(306) Then lblAlarm = lblAlarm & "M306:出料口異常" If M(307) Then lblAlarm = lblAlarm & "M307:定位異常" If M(308) Then lblAlarm = lblAlarm & "M308:底座異常" If M(309) Then lblAlarm = lblAlarm & "M309:車刀座異常" If M(320) Then lblAlarm = lblAlarm & "M320:無料警告" If M(321) Then lblAlarm = lblAlarm & "M321:載臺前進異常" If M(322) Then lblAlarm = lblAlarm & "M322:載臺後進異常" If M(323) Then lblAlarm = lblAlarm & "M323:推料定位異常" If M(324) Then lblAlarm = lblAlarm & "M324:推料前進異常" If M(325) Then lblAlarm = lblAlarm & "M325:推料後退異常" If M(326) Then lblAlarm = lblAlarm & "M326:夾料前進異常" If M(327) Then lblAlarm = lblAlarm & "M327:夾料後退異常" If M(328) Then lblAlarm = lblAlarm & "M328:定位前進異常" If M(329) Then lblAlarm = lblAlarm & "M329:定位後退異常" If M(330) Then lblAlarm = lblAlarm & "M330:底座前進異常" If M(331) Then lblAlarm = lblAlarm & "M331:底座後退異常" If M(332) Then lblAlarm = lblAlarm & "M332:車刀座前進異常" If M(333) Then lblAlarm = lblAlarm & "M333:車刀座後退異常" End Sub |
|
---|---|---|
|
litung
臺灣-李同在
級別: VIP會員
|
異常測試畫面參考 |
|
---|---|---|
|
lpcun
級別: 探索解密
|
|
---|---|
|
夏日雪夢
為了夢,夢一生
級別: VIP會員
|
謝謝 litung ,我要續好好學習。 litung 你好,我在使用中出現如圖所示問題。 [ 此帖被夏日雪夢在2009-11-18 21:08重新編輯 ] |
---|---|
|
litung
臺灣-李同在
級別: VIP會員
|
READ()程式我沒放上來。 只是給部份程式讓你參考而己。 程式如下: Public Function ReadM(NO As String) Dim sDATA As String Select Case NO Case 300: sDATA = "M300" & Chr(10) & "M301" & Chr(10) & "M302" & Chr(10) & "M303" & Chr(10) & "M304" & Chr(10) & "M305" & Chr(10) & "M306" & Chr(10) & "M307" & Chr(10) & "M308" & Chr(10) & "M309" & Chr(10) Case 310: sDATA = "M310" & Chr(10) & "M311" & Chr(10) & "M312" & Chr(10) & "M313" & Chr(10) & "M314" & Chr(10) & "M315" & Chr(10) & "M316" & Chr(10) & "M317" & Chr(10) & "M318" & Chr(10) & "M319" & Chr(10) Case 320: sDATA = "M320" & Chr(10) & "M321" & Chr(10) & "M322" & Chr(10) & "M323" & Chr(10) & "M324" & Chr(10) & "M325" & Chr(10) & "M326" & Chr(10) & "M327" & Chr(10) & "M328" & Chr(10) & "M329" & Chr(10) Case 330: sDATA = "M330" & Chr(10) & "M331" & Chr(10) & "M332" & Chr(10) & "M333" & Chr(10) & "M334" & Chr(10) & "M335" & Chr(10) & "M336" & Chr(10) & "M337" & Chr(10) & "M338" & Chr(10) & "M339" & Chr(10) Case 340: sDATA = "M340" & Chr(10) & "M341" & Chr(10) & "M342" & Chr(10) & "M343" & Chr(10) & "M344" & Chr(10) & "M345" & Chr(10) & "M346" & Chr(10) & "M347" & Chr(10) & "M348" & Chr(10) & "M349" & Chr(10) Case 350: sDATA = "M350" & Chr(10) & "M351" & Chr(10) & "M352" & Chr(10) & "M353" & Chr(10) & "M354" & Chr(10) & "M355" & Chr(10) & "M356" & Chr(10) & "M357" & Chr(10) & "M358" & Chr(10) & "M359" & Chr(10) Case 360: sDATA = "M360" & Chr(10) & "M361" & Chr(10) & "M362" & Chr(10) & "M363" & Chr(10) & "M364" & Chr(10) & "M365" & Chr(10) & "M366" & Chr(10) & "M367" & Chr(10) & "M368" & Chr(10) & "M369" & Chr(10) Case 370: sDATA = "M370" & Chr(10) & "M371" & Chr(10) & "M372" & Chr(10) & "M373" & Chr(10) & "M374" & Chr(10) & "M375" & Chr(10) & "M376" & Chr(10) & "M377" & Chr(10) & "M378" & Chr(10) & "M379" & Chr(10) Case 380: sDATA = "M380" & Chr(10) & "M381" & Chr(10) & "M382" & Chr(10) & "M383" & Chr(10) & "M384" & Chr(10) & "M385" & Chr(10) & "M386" & Chr(10) & "M387" & Chr(10) & "M388" & Chr(10) & "M389" & Chr(10) End Select ReadM = sDATA End Function |
|
---|---|---|
|
litung
臺灣-李同在
級別: VIP會員
|
有空你再自己簡化那二段程式。 |
|
---|---|---|
|