引用
引用第6樓夏日雪夢(mèng)于2009-11-16 15:30發(fā)表的 Re:Re:新手PLC仿真學(xué)習(xí)系統(tǒng) (感謝 litung xiaoqizi 幫助、指導(dǎo)) :
只要M301~M349其中有一點(diǎn)動(dòng)作,M300就ON,這個(gè)感覺容易做到;
直接M300從去找異常點(diǎn)的程式在那,這個(gè)有些不太明白,M300如何與故障點(diǎn)的程序連接,能否再詳細(xì)點(diǎn)說(shuō)明了。
把異常集中在一點(diǎn),是方便你對(duì)PLC程式除錯(cuò)。
vb程式可以對(duì)你設(shè)定的異常點(diǎn)區(qū)域作搜尋比對(duì),只要其中一個(gè)點(diǎn)=on,就是有異常。
底下部份程式給你參考看看。設(shè)一個(gè)time去掃程式。
Private Sub tmrAlarm_Timer()
Dim I As Integer
Dim J As Integer
Dim sDATA(100) As String
Dim mData(100) As Integer
'讀取M值狀態(tài)
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:無(wú)料警告"
If M(303) Then lblAlarm = lblAlarm & "M303:載臺(tái)異常"
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:無(wú)料警告"
If M(321) Then lblAlarm = lblAlarm & "M321:載臺(tái)前進(jìn)異常"
If M(322) Then lblAlarm = lblAlarm & "M322:載臺(tái)後進(jìn)異常"
If M(323) Then lblAlarm = lblAlarm & "M323:推料定位異常"
If M(324) Then lblAlarm = lblAlarm & "M324:推料前進(jìn)異常"
If M(325) Then lblAlarm = lblAlarm & "M325:推料後退異常"
If M(326) Then lblAlarm = lblAlarm & "M326:夾料前進(jìn)異常"
If M(327) Then lblAlarm = lblAlarm & "M327:夾料後退異常"
If M(328) Then lblAlarm = lblAlarm & "M328:定位前進(jìn)異常"
If M(329) Then lblAlarm = lblAlarm & "M329:定位後退異常"
If M(330) Then lblAlarm = lblAlarm & "M330:底座前進(jìn)異常"
If M(331) Then lblAlarm = lblAlarm & "M331:底座後退異常"
If M(332) Then lblAlarm = lblAlarm & "M332:車刀座前進(jìn)異常"
If M(333) Then lblAlarm = lblAlarm & "M333:車刀座後退異常"
End Sub