Cov txheej txheem:

Sparkfun CAN Bus Shield Tutorial: 6 Kauj Ruam
Sparkfun CAN Bus Shield Tutorial: 6 Kauj Ruam

Video: Sparkfun CAN Bus Shield Tutorial: 6 Kauj Ruam

Video: Sparkfun CAN Bus Shield Tutorial: 6 Kauj Ruam
Video: How To Track Orientation with Arduino | ADXL345 Accelerometer Tutorial 2024, Kaum ib hlis
Anonim
Sparkfun CAN Bus Shield Tutorial
Sparkfun CAN Bus Shield Tutorial

Tau txais thiab xa xov siv Sparkfun CAN Bus Shield

CAN yog dab tsi?

Lub npav CAN tau tsim los ntawm BOSCH ua tus tswv ntau tus, tshaj tawm xov xwm uas qhia meej txog qhov siab tshaj plaws ntawm 1 megabit per second (bps). Tsis zoo li cov kev sib txuas ib txwm muaj xws li USB lossis Ethernet, CAN tsis xa cov ntaub ntawv loj taw tes-rau-taw tes los ntawm ntawm A mus rau ntawm B raws li kev saib xyuas ntawm tus tswv tsheb loj. Hauv CAN network, ntau cov lus luv luv xws li ntsuas kub lossis RPM tau tshaj tawm rau tag nrho lub network, uas muab cov ntaub ntawv sib xws hauv txhua qhov ntawm qhov system.

Kauj Ruam 1: Cov Ntaub Ntawv Xav Tau

2 - Sparkfun CAN Bus Shield

2 - Arduino UNO

2 - 120 ohm resistors

1 - Daim ntawv qhia zaub mov

Jumper Hlau

CAN Bus Shield Library Download:

drive.google.com/open?id=1Mnf2PN_fAQFpo1ID…

Advanced (CAN Bus):

DB9 (Poj niam)

RJ45

UTP Kab

RJ45 2-Txoj Kev Splitter

RJ45 Ncaj Txuas

Cov Cuab Yeej:

Ntsia Hlau

RJ45 Crimper

Soldering Hlau

Kauj Ruam 2: Tsim CAN Npav Npav ntawm Breadboard

Tsev CAN Npav Npav ntawm Breadboard
Tsev CAN Npav Npav ntawm Breadboard

1. Mount CAN Bus Shield rau ib Arduino txhua

2. Hlau CAN_H thiab CAN_L tus pin ntawm daim ntaub thaiv mus rau lub khob cij

3. Txuas 120-ohm tshem tawm cov neeg tawm tsam hla txhua qhov kawg ntawm CAN_H thiab CAN_L kab

Kauj ruam 3: Arduino Programming

Arduino Txoj Haujlwm
Arduino Txoj Haujlwm

1. Rub tawm thiab teeb tsa CAN Bus Shield Library los ntawm qhov txuas muab saum toj no

Kho 1 Arduino los nyeem CAN cov lus

2. Qhib Arduino IDE

3. Mus rau Cov Piv Txwv Cov Ntaub Ntawv SparkFun CAN-Bus CAN_Read_Demo

4. Xaiv qhov chaw nres nkoj tsim nyog ntawm Thawj Arduino thiab Tshaj Tawm

Kho qhov thib 2 Arduino kom xa CAN lus

5. Qhib Arduino IDE tshiab

6. Mus rau Cov Piv Txwv Cov Ntaub Ntawv SparkFun CAN-Bus CAN_Write_Demo

7. Xaiv qhov chaw nres nkoj tsim nyog ntawm Arduino Thib Ob thiab Upload

Kauj ruam 4: Xeem

/*Ntxiv cov duab piv txwv ua haujlwm*/

Tom qab tso qhov program rau ob Arduinos…

1. Qhib Serial Monitors ntawm Thawj thiab Thib Ob Arduino

2. Teem Tus Nqi Baud rau 9600

3. Txheeb xyuas yog tias Cov Ntaub Ntawv tau txais los ntawm Thawj Arduino

Yog tias tsis tau txais cov ntaub ntawv:

1. Txheeb xyuas seb puas tsim nyog Port thiab Baud Rate rau txhua Arduino

2. Txheeb xyuas qhov sib txuas ntawm kab CAN_H thiab CAN_L

3. Txheeb xyuas cov kev sib txuas ntawm qhov kev txiav tawm cov resistors

Kauj ruam 5: Tshawb nrhiav

Tsim kev cai CAN lus

Kho qhov CAN_Write_Demo Program rau…

  • hloov cov lus ID (message.id)
  • hloov RTR ntsis (message.header.rtr)
  • teev cov ntaub ntawv ntev (message.header.length)
  • nkag mus rau koj tus kheej cov ntaub ntawv (message.data [x])

Kho qhov CAN_Read_Demo txhawm rau hloov kho koj li cas koj cov ntaub ntawv

  • Luam cov lus ID (message.id)
  • Luam cov lus ntev (message.header.length)
  • Luam cov lus Cov Ntaub Ntawv (message.data [x])

Kauj Ruam 6: (Ntxiv) Tsim CAN Bus Siv UTP

(Ntxiv) Tsim CAN Bus Siv UTP
(Ntxiv) Tsim CAN Bus Siv UTP
(Ntxiv) Tsim CAN Bus Siv UTP
(Ntxiv) Tsim CAN Bus Siv UTP
(Ntxiv) Tsim CAN Bus Siv UTP
(Ntxiv) Tsim CAN Bus Siv UTP

CAN Bus siv hauv daim duab no yog 8-pin UTP cable.

Muaj ob hom kev sib txuas hauv daim duab no uas yog (DB9 - rau - RJ45) thiab (RJ45 - rau - RJ45)

DB9 rau RJ45

DB9 (pin 1- 8) = wO, O, wG, Bl, wBl, G, wBr, Br

RJ45 (pins 1-8) = wO, O, wG, Bl, wBl, G, wBr, Br

RJ45 - rau - RJ45 (Ncaj Ncaj)

RJ45 (pins 1-8) = wO, O, wG, Bl, wBl, G, wBr, Br

RJ45 (pins 1-8) = wO, O, wG, Bl, wBl, G, wBr, Br

RJ45 - rau - Terminator

RJ45 (pins 1-8) = wO, O, wG, Bl, wBl, G, wBr, Br

Terminator Resistor (wG, wBl)

Cov nodes tuaj yeem txuas nrog CAN Bus raws li koj nyiam thiab tus lej ntawm cov lej siv

Rau kev txuas ob -node, RJ45 Ncaj txuas tau siv nruab nrab ntawm (DB9 - rau - RJ45) Cables

Rau kev sib txuas 3 -node, 2 -Way splitter txuas ua ke nrog cov txuas ncaj kom ua "T" kev sib txuas ntawm txhua (DB9 - rau - RJ45) Cables

Rau 2+ node kev sib txuas (2 lossis ntau dua), 2-Way splitter tau txuas nrog lub txuas ncaj kom ua "T" txuas. Ib (RJ45 - rau - RJ45) Cable tau siv los txuas ob "T" nodes thiab a (DB9 - rau - RJ45) Cable tau siv los txuas "T" node rau CAN Bus Shield. RJ45 - rau - Terminator tau siv ntawm txhua "T" kawg ntawm CAN Bus

Pom zoo: