Table of Contents - TG Drives

Table of Contents - TG Drives Table of Contents - TG Drives

28.11.2012 Views

180 SAnyBus ; Start .define cSTART_INIT = 1 .define cANYBUS_INIT = 2 .define cSET_ETN_CONFIG = 3 .define cCONNECT_TIMEOUT = 4 .define cEND_INIT = 5 .define cNoModule = 0 .define cProfibusDB = 1 EXTENDED REGISTER GROUPS gosub SRou_SAnyBusInit ;init the module wait 1=2 ; ; ; Give the fieldbus module time to start. ; SRou_SAnyBusInit: SAnybus.TimeOut,50 clr rOnLine clr tmr.t0 wait SAnybus.FBType cNoModule if SAnybus.FBType = cProfibusDB then ProfibusDP clr tmr.t0 wait tmr.t0 > 100 return ;================== ; ; ProfiBus-DP ; ProfibusDP: Vector.SAnybus, @IRou_ProfiBus ;set vector or int.sysmask, 4096 ;enable interrupt SAnybus.HasMail, 0 ; Clear mailbox flag SAnybus.Mode, 1+2+4+8+16 ; Enable SANYBUS and all interrupts and reverse ;read gosub SendStartInit ; gosub SendInit64_64 ; gosub SendEndInit return ; ;Interrupt entry for profibus ;Remember that the ABOut buffer is holds the OUTPUT FROM the Anybus module ;seen frombthe PL2 side. ;The ABIn buffer holds the INPUT TO the Anybus module seen from the PL2 side. IRou_ProfiBus: if SAnybus.HasOutput = 0 then isrProfibus00 ;test if any data in output ;buffer SAnybus.HasOutput, 0 ; Clear flag ; User's Manual 5.1 Inmotion Technologies AB Doc. No.9032 0027 01 (B), Rev. 11.07.2001

EXTENDED REGISTER GROUPS SAnyBus ; Copy return data anybusout getlong rTmp91,0 ;read byte 0 - 3 into reg anybusout getint rTmp92,4 ;read byte 4 - 5 into reg anybusout getbyte rTmp93,6 ;read byte 6 into reg anybusin putlong rTmp91,0 ;write back first long AnybusIO Send ;send it back isrProfibus00: if SAnybus.HasMail = 0 then isrProfibus10 ; We handle this in code. But we show it here anyway. ; disp SAnybus.HasMail isrProfibus10: if SAnybus.OnLine = rOnLine then isrProfibus20 ; disp SAnybus.OnLine rOnLine, SAnybus.OnLine isrProfibus20: ireturn sys 4096 ; ; START_INIT ; SendStartInit : rProtNumber, cSTART_INIT SAnybus.Command, 1 ; Prepare START_INIT mail message wait SAnybus.Command = 0 ; Wait for it to be done SAnybus.Command, 7 ; Send to fieldbus module wait SAnybus.HasMail = 1 ; Wait for response mail ; Investigate response mail for errors here if ABOutMail.MessageInfo < 0 then ErrorProt SAnybus.HasMail, 0 return ; Clear mailbox flag SendInit64_64: rProtNumber, cANYBUS_INIT SAnybus.Command, 3 ; Prepare ANYBUS_INIT mail message wait SAnybus.Command = 0 ; Wait for it to be done ; Modify default values here in ABInMail ; Length in bytes! ; PBIn.InIOLen, 64 PBIn.InDPRAMLen, 64 PBIn.InTotalLen, 64 PBIn.OutIOLen, 64 PBIn.OutDPRAMLen, 64 PBIn.OutTotalLen, 64 ABInMail.ModuleStatus, 512+2 ; default value (you must keep 512) User's Manual 5.1 Inmotion Technologies AB Doc. No.9032 0027 01 (B), Rev. 11.07.2001 181

180<br />

SAnyBus<br />

; Start<br />

.define cSTART_INIT = 1<br />

.define cANYBUS_INIT = 2<br />

.define cSET_ETN_CONFIG = 3<br />

.define cCONNECT_TIMEOUT = 4<br />

.define cEND_INIT = 5<br />

.define cNoModule = 0<br />

.define cPr<strong>of</strong>ibusDB = 1<br />

EXTENDED REGISTER GROUPS<br />

gosub SRou_SAnyBusInit ;init the module<br />

wait 1=2 ;<br />

;<br />

; Give the fieldbus module time to start.<br />

;<br />

SRou_SAnyBusInit:<br />

SAnybus.TimeOut,50<br />

clr rOnLine<br />

clr tmr.t0<br />

wait SAnybus.FBType cNoModule<br />

if SAnybus.FBType = cPr<strong>of</strong>ibusDB then Pr<strong>of</strong>ibusDP<br />

clr tmr.t0<br />

wait tmr.t0 > 100<br />

return<br />

;==================<br />

;<br />

; Pr<strong>of</strong>iBus-DP<br />

;<br />

Pr<strong>of</strong>ibusDP:<br />

Vector.SAnybus, @IRou_Pr<strong>of</strong>iBus ;set vector<br />

or int.sysmask, 4096 ;enable interrupt<br />

SAnybus.HasMail, 0 ; Clear mailbox flag<br />

SAnybus.Mode, 1+2+4+8+16 ; Enable SANYBUS and all interrupts and<br />

reverse ;read<br />

gosub SendStartInit ;<br />

gosub SendInit64_64 ;<br />

gosub SendEndInit<br />

return<br />

;<br />

;Interrupt entry for pr<strong>of</strong>ibus<br />

;Remember that the ABOut buffer is holds the OUTPUT FROM the Anybus module<br />

;seen frombthe PL2 side.<br />

;The ABIn buffer holds the INPUT TO the Anybus module seen from<br />

the PL2 side.<br />

IRou_Pr<strong>of</strong>iBus:<br />

if SAnybus.HasOutput = 0 then isrPr<strong>of</strong>ibus00 ;test if any data in output<br />

;buffer<br />

SAnybus.HasOutput, 0 ; Clear flag<br />

;<br />

User's Manual 5.1 Inmotion Technologies AB<br />

Doc. No.9032 0027 01 (B), Rev. 11.07.2001

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!