发表于:2005-11-29 13:14:00
1楼
我曾经用过一次,好象AB他有自己软件可以下载,不过比较贵,所以呢你可以通过电脑2000系统的超级终端来下载。例子程序么,谈不上例子。你可以参考一下。
1 REM File: Rack 1, Slot 1
2 REM Project: Delphi Multec III (5272)
3 REM Author: ATS, KRC
4 REM Date: Nov. 22, 2000
5 REM
6 REM Devices: Port1, Device 1:
7 REM Port1, Device 2: Load/Unload Tag Read/Writer
8 REM Port2, Device 1: N/A
9 REM Port2, Device 2: N/A
10 REM
11 REM ===================================================================
12 REM
13 REM
14 REM ===================================================================
15 MODE (PRT1,9600,N,8,1,N,R)
20 MODE (PRT2,9600,N,8,1,N,R)
25 MODE (DH485,9600,0,1,1,,R)
30 REM
99 REM Feedback to monitoring system
100 FOR I=1 TO 15 : PRINT : NEXT I
120 PRINT "Booting .......... Director Retainer Press Machine"
130 PRINT " Rack 1, Slot 1"
140 PRINT "Devices Supported: Balluff RF Code Tag Read/Write ",
150 PRINT "Controller"
151 REM
159 REM Clear all I/O buffers, Variables, Interrupts & Stacks
160 PUSH 2 : CALL 37 : PUSH 2 : CALL 96 : PUSH 3FH : CALL 120
170 CLEAR
171 REM
179 REM Set Variables
180 STRING 500,50 : DIM IN(8),TAG(128) : $(5)="1"
181 REM
189 REM Set LED's to indicate initialization
190 PUSH 1 : PUSH 1 : CALL 112
191 REM
199 REM Initialize Devices
200 CLEAR I : CLEAR S : TIME=0 : DBY(71)=0 : CLOCK 1 : ONTIME 20,200
210 REM DISABLE INTERUPTS
220 CALL 21
230 REM
249 REM Reset Balluff Controller
250 PRINT : PRINT "Resetting Balluff Controller..."
260 CLEAR I : CLEAR S : TIME=0 : DBY(71)=0 : CLOCK 1 : ONTIME 1,10200
261 PUSH IN(3) : PUSH 203 : CALL 24
262 PUSH IN(2) : PUSH 202 : CALL 24
263 PUSH IN(1) : PUSH 201 : CALL 24
264 CALL 54 : POP STATUS
265 PRINT #"Q",CHR(0DH)
275 PRINT "SLC: Q",CHR(0DH)
277 PRINT "BAL:",
280 DO : CH=GET# : WHILE (CH<>51H) : PRINT CH, : CH=GET# : PRINT CH
290 FOR I=1 TO 250 : NEXT I : PRINT "Unit reset...",
300 REM
310 REM Loop program
320 DO
340 REM Turn off internal clock
350 CLOCK 0 : PRINT " (",TIME,")"
360 REM
370 REM Send Message to SLC
380 PUSH IN(3) : PUSH 203 : CALL 24
390 PUSH IN(2) : PUSH 202 : CALL 24
400 PUSH IN(1) : PUSH 201 : CALL 24
410 CALL 54 : POP STATUS
420 REM
430 REM Dwell (allow Balluff to clear)
445 FOR I=1 TO 200 : NEXT I
450 REM CLEAR TRANSFER STATUS
452 IN(2)=0
454 PUSH IN(3) : PUSH 203 : CALL 24
455 PUSH IN(2) : PUSH 202 : CALL 24
456 PUSH IN(1) : PUSH 201 : CALL 24
458 CALL 54 : POP STATUS
460 REM Clear the Port #2 I/O buffers
470 PUSH 2 : CALL 37
480 REM Wait for execute flag
490 PRINT "=> ",
500 REM
510 REM Set LED's to indicate RUNNING
520 PUSH 1 : PUSH 0 : CALL 112
530 REM
540 REM Loop until Command Received
550 DO
560 DO
570 REM Check for New Command
580 CALL 51 : POP STATUS
590 WHILE (STATUS=0)
600 REM Get information for the CPU output image table
610 DO
620 CALL 53 : POP STATUS
630 WHILE STATUS<>0
640 REM Retrieve the information from the buffer
650 PUSH 201 : CALL 14 : POP IN(1)
660 UNTIL (IN(1).AND.0001H)=0001H
670 IF IN(1)=03H THEN 1000
680 IF IN(1)=05H THEN 2000
690 IF IN(1)=09H THEN 3000
700 IF IN(1)<>21H THEN PRINT : WHILE (1)
710 REM
1000 REM =============================================================
1010 REM == Port 1, Device 1 : READ BALLUFF TAG DATA =================
1020 REM =============================================================
1030 PRINT "Read Tag @ STN 3 Conveyor..."
1040 REM Handshake with SLC
1050 TIME=0 : DBY(71)=0 : PUSH 3 : PUSH 201 : CALL 24
1060 CALL 54 : POP STATUS : IN(1)=2
1070 REM Set LED's to indicate EXECUTING a command
1080 PUSH 0 : PUSH 1 : CALL 112
1090 REM Set Timer
1100 CLOCK 1 : ONTIME 5,10050
1110 REM Issue Read Command
1120 PRINT #"R00000072",CHR(0DH),
1130 REM PRINT "SLC:","R00000072","<CR>"
1140 REM Wait for <ACK>
1150 DO : ACK=GET# : WHILE (ACK=0) : ERR=GET# : CH=GET#
1160 REM PRINT "BAL:", : PH0. ACK, : PH0. ERR, : PH0. CH
1170 IF ACK=15H THEN 10500
1180 REM CLEAR INPUT BUFFER BEFORE TRANSFER
1190 PUSH 1 : CALL 37
1200 REM GET DATA DIRECT TO M-FILE
1210 REM Get the Tag Data 0 - 69 Bytes and Update Tag Data to M1 file
1220 PUSH 2 : REM PRT 2 ACTIVE FOR CALL 22
1230 PUSH 072 : REM RECIEVING 70 BYTES OF DATA MAXIMUM
1240 PUSH 0 : REM <CR> USED AS TERMINATOR
1250 PUSH 1 : REM send data to m1 file
1260 PUSH 0 : REM OFFSET INTO M1 FILE
1270 PUSH 0 : REM STRING NUMBER - NOT USED
1280 PUSH 0 : REM BYTE SWAPPING ENABLED
1290 CALL 22 : REM START TRANFER FROM PRT1 TO SLC M1 FILE
1300 POP STATUS : REM GET STATUS OF CALL 22 SETUP
1310 IF (STATUS<>0) THEN PRINT "Unsucessful CALL 22 Setup"
1320 REM Send Start Signal
1330 PRINT #CHR(02H),CHR(0DH)
1340 REM PRINT "<STX><CR>"
1350 DO : WHILE (DBY(200).AND.20H=0)
1360 DO : WHILE (DBY(200).AND.20H=1)
1370 CLOCK 0
1380 REM Process Tag Information
1390 REM PRINT " " : PRINT "COMPLETE"
1400 IN(2)=1
1410 WHILE (1)
2000 REM =============================================================
2010 REM == Port 1, Device 1 : WRITE BALLUFF TAG DATA ================
2020 REM =============================================================
2030 PRINT "Write Tag @ STN 3 Conveyor..."
2040 REM Handshake with SLC
2050 TIME=0 : DBY(71)=0 : PUSH 5 : PUSH 201 : CALL 24
2060 CALL 54 : POP STATUS : IN(1)=4
2070 REM Set LED's to indicate EXECUTING a command
2080 PUSH 1 : PUSH 0 : CALL 112
2090 REM SET TIMER
2100 CLOCK 1 : ONTIME 5,10050
2110 REM GET DATA TABLE FROM MO
2120 PUSH 30 : CALL 56 : POP STATUS
2130 IF (STATUS<>0) THEN PRINT "Unsucessful CALL 56"
2140 PUSH 100 : CALL 15 : POP MSV
2150 PUSH 101 : CALL 15 : POP STATE
2160 PUSH 102 : CALL 15 : POP RESULT
2170 S1=STATE.AND.255
2180 S2=STATE/255
2190 R1=RESULT.AND.255
2200 R2=RESULT/255
2210 REM **********************************************************
2220 REM ********* ISSUE WRITE COMMAND DATA SET #1 ************
2230 REM **********************************************************
2240 PRINT #"W00290001",CHR(0DH),
2250 REM PRINT "SLC:","W00290001","<CR>"
2260 REM WAIT FOR <ACK>
2270 DO : ACK=GET# : WHILE (ACK=0) : ERR=GET# : CH=GET#
2280 REM PRINT "BAL:", : PH0. ACK, : PH0. ERR, : PH0. CH
2290 IF ACK=15H THEN 10500
2300 FOR I=100 TO 102 : PUSH I : CALL 15 : POP X
2310 REM PRINT I,":",X," " : NEXT I
2320 REM SEND START SIGNAL
2330 PRINT #CHR(02H),
2340 REM SEND DATA
2350 PRINT #CHR(MSV),CHR(0DH),
2360 REM PRINT "SLC:","<STX>","DATA SENT...","<CR>"
2370 REM WAIT FOR <ACK>
2380 DO : ACK=GET# : WHILE (ACK=0) : ERR=GET# : CH=GET#
2390 REM PRINT "BAL:", : PH0. ACK, : PH0. ERR, : PH0. CH
2400 IF ACK=15H THEN 10500
2410 REM **********************************************************
2420 REM **********************************************************
2430 REM ********* ISSUE WRITE COMMAND DATA SET #2 ************
2440 REM **********************************************************
2450 PRINT #"W00680004",CHR(0DH),
2460 REM PRINT "SLC:","W00680004","<CR>"
2470 REM WAIT FOR <ACK>
2480 DO : ACK=GET# : WHILE (ACK=0) : ERR=GET# : CH=GET#
2490 REM PRINT "BAL:", : PH0. ACK, : PH0. ERR, : PH0. CH
2500 IF ACK=15H THEN 10500
2510 REM SEND START SIGNAL
2520 PRINT #CHR(02H),
2530 REM SEND DATA
2540 REM PRINT "Status:",STATE,"-",S2,",",S1
2550 REM PRINT "Result:",RESULT,"-",R2,",",R1
2560 PRINT #CHR(S2),CHR(S1),CHR(R2),CHR(R1),CHR(0DH),
2570 REM PRINT "SLC:","<STX>","DATA SENT...","<CR>"
2580 REM WAIT FOR <ACK>
2590 DO : ACK=GET# : WHILE (ACK=0) : ERR=GET# : CH=GET#
2600 REM PRINT "BAL:", : PH0. ACK, : PH0. ERR, : PH0. CH
2610 IF ACK=15H THEN 10500 ELSE IN(2)=1
2620 REM **********************************************************
2630 CLOCK 0
2640 REM PRINT "COMPLETE"
2650 WHILE (1)
3000 REM =============================================================
3010 REM == Port 2, Device 1 =========================================
3020 REM =============================================================
3030 PRINT "Not Confirgured=..."
3040 REM End Routine
3050 WHILE (1)
10000 REM =============================================================
10010 REM == Error Service Routines ===================================
10020 REM =============================================================
10030 REM Communications Timed-out
10050 PRINT "*** Balluff Communications Timed-out..."
10060 IN(2)=0002H : IN(3)=0102H : CLEAR S : CLEAR I : GOTO 250
10070 REM
10195 REM RESET BAUD RATE
10200 CLEAR I : COUNT=COUNT+1 : IF COUNT<5 THEN 250
10205 PRINT : PRINT "Resetting Unit using Default Protocol...",
10210 MODE (PRT2,9600,E,8,1,N,R)
10215 PRINT #"QQ",
10216 REM PRINT "QQ",
10220 TIME=0 : DBY(71)=0 : ONTIME 5,10250
10225 DO : CH=GET# : WHILE (CH<>51H)
10230 DO : CH=GET# : WHILE (CH=0)
10235 CLOCK 0
10250 CLEAR I : COUNT=0 : MODE (PRT2,9600,N,8,1,N,R) : GOTO 250
10290 REM
10495 REM
10500 PRINT "*** Balluff Device Error...",
10510 PH0. ERR,
10520 PRINT " - ",
10530 CLEAR S : IN(2)=0002H : IN(3)=0200H
10540 REM Distinguish Cause
10550 IF ERR=31H THEN IN(3)=0201H : PRINT "No Tag Present"
10560 IF ERR=32H THEN IN(3)=0202H : PRINT "Read Error"
10570 IF ERR=33H THEN IN(3)=0203H : PRINT "Tag Removed"
10580 IF ERR=34H THEN IN(3)=0204H : PRINT "Write Error" : REM IN(2)=1
10590 IF ERR=35H THEN IN(3)=0203H : PRINT "Tag Removed"
10600 IF ERR=36H THEN IN(3)=0206H : PRINT "Interface Error"
10610 IF ERR=37H THEN IN(3)=0207H : PRINT "Telegram Format Error"
10620 IF ERR=38H THEN IN(3)=0208H : PRINT "BCC Error"
10630 IF ERR=39H THEN IN(3)=0209H : PRINT "Cable Break"
10640 IF ERR=41H THEN IN(3)=020AH : PRINT "Read in Progress"
10650 IF ERR=42H THEN IN(3)=020BH : PRINT "Write in Progress"
10660 IF ERR=43H THEN IN(3)=020CH : PRINT "Head Select in Progress"
10670 IF ERR=45H THEN IN(3)=020EH : PRINT "Final Warning"
10680 IF ERR=48H THEN IN(3)=0211H : PRINT "Tag Type Error"
10690 IF ERR=56H THEN IN(3)=0213H : PRINT "Pre-Warning"
10700 CLOCK 0
10710 GOTO 250