မိုက်ကရို ကွန်ထရိုလာတွေမှာ အသုံးများတဲ့ RS232 communication နဲ့ စာရင် CAN bus မှာ ကောင်းတဲ့ အချက်တွေ အများကြီး ရှိပါတယ်။
အမြန်နှုန်း
ဒေတာတွေကို ပိုတဲ့ အခါ အမြန်နှုန်း (Bit rates) က မီတာလေးဆယ်အောက် အကွာအဝေး ဆိုရင် 1 Mbit/s ထိမြန်အောင် ပို့နိုင်ပါတယ်။ကိရိယာ အရေအတွက်
ဝါယာလိုင်း တစ်ခုထဲမှာ ကိရိယာ အရေအတွက် တစ်ရာကျော် ထိ repeater တို့၊ bridge တို့ ဘာမှ မသုံးပဲနဲ့တန်း ဆက်နိုင်ပါတယ်။Frames
CAN bus မှာ message framing လုပ်တာ၊ အမှားပါမပါစစ်တာ၊ handshaking လုပ်ပြီး ပို့တာ မရောက်ရင် ပြန်ပို့တာ အဲဒါတွေ အားလုံး hardware ကပဲ အားလုံးတာဝန်ယူ ပြီး လုပ်သွားတာ ဆိုတော့ တော်တော် သက်သာပြီး မြန်ဆန်သွားပါတယ်။Microcontroller
8051 microcontroller ပေါ်မှာ CAN bus သုံးထားတာလေး နမူနာ ပြောချင်ပါတယ်။ Atmel ကထုတ်တဲ့ AT89C51CC03 မိုက်ကရို ကွန်ထရိုလာမှာ CAN controller တစ်ခါတည်း ပါပါတယ်။ သူ့ရဲ့ ဆားကစ် ပတ်လမ်း ကို အောက်မှာ ပြထားပါတယ်။ AT89C51CC03 ကိုသုံးပြီး CAN communication လုပ်တဲ့ နမူနာ C program ကို Atmel ရဲ့ ဝက်ဘ် စာမျက်နှာ (atmel.com) မှာ တွေ့နိုင်ပါတယ်။ သူ့ကို ပြုပြင်ထားတဲ့ C program ကို တော့ အောက်မှာ ပြထားပါတယ်။CAN Comm on GitHub
CAN frames တွေကို ပို့တဲ့ပုံ နမူနာ ကို အောက်မှာ ပြထားပါတယ်။
void FraSend2CAN(ui08 d[],ui08 len)//will loop until it is successfully sent
{
ui08 idata i,j;
//-------------------------------------------------------------------------
//For first acc data, 8 bytes
TB[0]=0;
TB[1]=0;
TB[2]=0;
TB[3]=0x10;//corresponds to id 2 in LabVIEW
for(i=0,j=4;i<8;i++) TB[j++]=d[i];
while(!CANTxString(12,TB));
//-------------------------------------------------------------------------
//For second acc data, 8 bytes
TB[0]=0;
TB[1]=0;
TB[2]=0;
TB[3]=0x20;//corresponds to id 4 in LabVIEW
for(i=8,j=4;i<16;i++) TB[j++]=d[i];
while(!CANTxString(12,TB));
//-------------------------------------------------------------------------
//For gyro data, 6 bytes
TB[0]=0;
TB[1]=0;
TB[2]=0;
TB[3]=0x30;//corresponds to id 6 in LabVIEW
for(i=16,j=4;i<len;i++) TB[j++]=d[i];
while(!CANTxString(10,TB));
}
LabVIEW
LabVIEW မှာ CAN ကို သုံးဖို့ ဆိုရင် xnet software ကို အရင် install လုပ်ထားဖို့လိုပါတယ်။ နောက် CAN communication အတွက် database တစ်ခုကို start->All Programs->National Instruments->NI-XNET->Database Editor မှာ ဖန်တီးဖို့ လိုပါတယ်။Example CAN Database and LabVIEW VI on GitHub




No comments:
Post a Comment