您好, 歡迎來到智能制造網(wǎng)! 登錄| 免費(fèi)注冊| 產(chǎn)品展廳| 收藏商鋪|
提供商
翠歐自控技術(shù)(上海)有限公司資料大小
0K資料圖片
下載次數(shù)
91次資料類型
未傳瀏覽次數(shù)
7512次"-------------------------------------------------------------------------
" module: trio_can_net version: v1.0 date: 14/11/2006
" author: wang ye
" rev date: 14 nov 2006
"=========================================================================
" revision history:
" v1.0 original release for communicating between mc2xx each other by can net.
"
"=========================================================================
" copyright (c)1999 trio motion technology ltd
" unit 2, empire way, gloucester, gl2 5hy
" : sales@
"=========================================================================
"desc-ription:
"1) set up a network of up to 16 mc2xx units on can.
"2) each module will use the vr area from "vbase" to "vbase+180".
"3) each module have a special area in the vr for sending.(the area is 10 datas)
" the area start address can be gotten by the parameter "can_id" and "vbase":
" start_address=vbase+10*(can_id-1)
" the map of vr allocated for each module based can_id can be listed:
" can_id vr() memory address
" 1 vbase->vbase+9
" 2 vbase+10->vbase+19
" 3 vbase+20->vbase+29
" 4 vbase+30->vbase+39
" 5 vbase+40->vbase+49
" 6 vbase+50->vbase+59
" 7 vbase+60->vbase+69
" 8 vbase+70->vbase+79
" 9 vbase+80->vbase+89
" 10 vbase+90->vbase+99
" 11 vbase+100->vbase+109
" 12 vbase+110->vbase+119
" 13 vbase+120->vbase+129
" 14 vbase+130->vbase+139
" 15 vbase+140->vbase+149
" 16 vbase+150->vbase+159"
"
"4) so, you can get datas from any other mc module just by reading the corresponding vr.
" for example: set the can_id of current module is 2, vbase=100
" you modify the vr(110)=100, then you could read the value of vr(110)
" from others module of this can network, if all others module set the vbase=100.
"5) note: each module of can networks must set different can_id.
" the value of can_id from 1 to 16. don"t over this value.
" as long as don"t over the limit of can_id, you can use any more mc2xx in the networks. as well as
" set any value for can_id.
" don"t use the area from vbase+160 to vbase+180, because it will be used by system.
"
"=========================================================================
can_id=15 " the can identifer of trio can network
mctype=0 " if it"s mc206x, the value=1; otherwise=0
vbase=100
interval=100
gosub initcan
while true
gosub send_proc
gosub receive_proc
wend
initcan:
canio_enable=off
"init the baud rate
can(-1,2,1)
"init the message
for i=0 to 15
if mctype=1 then
if(i=can_id-1) then
can(-1,5,i,i+1,5,1) "send
else
can(-1,5,i,i+1,5,0)
endif
else
if(i=can_id-1) then
can(-1,5,i,i+1,5) "send
else
can(-1,5,i,i+1,5)
endif
endif
next i
return
send_proc:
if ticks<=0 then
for i=0 to 9
vr(vbase+160+i)=vr(vbase+10*(can_id-1)+i)
b0=ieee_out(vr(vbase+160+i),0)
b1=ieee_out(vr(vbase+160+i),1)
b2=ieee_out(vr(vbase+160+i),2)
b3=ieee_out(vr(vbase+160+i),3)
for n=1 to 16
if n=can_id then
can(-1,7,n-1,i,b0,b1,b2,b3)
endif
next n
ticks=interval
next i
else
for i=0 to 9
if vr(vbase+160+i)<>vr(vbase+10*(can_id-1)+i) then
vr(vbase+160+i)=vr(vbase+10*(can_id-1)+i)
b0=ieee_out(vr(vbase+160+i),0)
b1=ieee_out(vr(vbase+160+i),1)
b2=ieee_out(vr(vbase+160+i),2)
b3=ieee_out(vr(vbase+160+i),3)
for n=1 to 16
if n=can_id then
can(-1,7,n-1,i,b0,b1,b2,b3)
endif
next n
endif
next i
endif
return
receive_proc:
for i=0 to 15
" if (i<>can_id) then
if can(-1,3,i) then
can(-1,6,i,vbase+10*17)
id=vr(vbase+10*17)
offset=vr(vbase+10*17+1)
b0=vr(vbase+10*17+2)
b1=vr(vbase+10*17+3)
b2=vr(vbase+10*17+4)
b3=vr(vbase+10*17+5)
res=ieee_in(b0,b1,b2,b3)
vr(vbase+10*(id-1)+offset)=res
endif
" endif
next i
return
請輸入賬號
請輸入密碼
請輸驗(yàn)證碼
以上信息由企業(yè)自行提供,信息內(nèi)容的真實(shí)性、準(zhǔn)確性和合法性由相關(guān)企業(yè)負(fù)責(zé),智能制造網(wǎng)對此不承擔(dān)任何保證責(zé)任。
溫馨提示:為規(guī)避購買風(fēng)險,建議您在購買產(chǎn)品前務(wù)必確認(rèn)供應(yīng)商資質(zhì)及產(chǎn)品質(zhì)量。