免费看aⅴ,天天插天天干天天射,呦女网,入逼逼

翠歐自控技術(shù)(上海)有限公司

當(dāng)前位置:首頁   >>   資料下載   >>   TRIO產(chǎn)品之間CAN總線通訊程序例子

TRIO產(chǎn)品之間CAN總線通訊程序例子

時(shí)間:2009/3/31閱讀:7517
分享:
  • 提供商

    翠歐自控技術(shù)(上海)有限公司
  • 資料大小

    0K
  • 資料圖片

  • 下載次數(shù)

    91次
  • 資料類型

    未傳
  • 瀏覽次數(shù)

    7517次

"-------------------------------------------------------------------------
" 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
 

會(huì)員登錄

×

請(qǐng)輸入賬號(hào)

請(qǐng)輸入密碼

=

請(qǐng)輸驗(yàn)證碼

收藏該商鋪

X
該信息已收藏!
標(biāo)簽:
保存成功

(空格分隔,最多3個(gè),單個(gè)標(biāo)簽最多10個(gè)字符)

常用:

提示

X
您的留言已提交成功!我們將在第一時(shí)間回復(fù)您~

以上信息由企業(yè)自行提供,信息內(nèi)容的真實(shí)性、準(zhǔn)確性和合法性由相關(guān)企業(yè)負(fù)責(zé),智能制造網(wǎng)對(duì)此不承擔(dān)任何保證責(zé)任。

溫馨提示:為規(guī)避購買風(fēng)險(xiǎn),建議您在購買產(chǎn)品前務(wù)必確認(rèn)供應(yīng)商資質(zhì)及產(chǎn)品質(zhì)量。

在線留言