Cov txheej txheem:

Kev Cai Arduino Kom Ua Tau CAN Steering Log Khawm Nrog Lub Tsheb Tshiab Lub Stereo: 9 Cov Kauj Ruam (nrog Duab)
Kev Cai Arduino Kom Ua Tau CAN Steering Log Khawm Nrog Lub Tsheb Tshiab Lub Stereo: 9 Cov Kauj Ruam (nrog Duab)

Video: Kev Cai Arduino Kom Ua Tau CAN Steering Log Khawm Nrog Lub Tsheb Tshiab Lub Stereo: 9 Cov Kauj Ruam (nrog Duab)

Video: Kev Cai Arduino Kom Ua Tau CAN Steering Log Khawm Nrog Lub Tsheb Tshiab Lub Stereo: 9 Cov Kauj Ruam (nrog Duab)
Video: Аномально вкусно‼️ ЧЕХОСЛОВАЦКИЙ СУП ИЗ ФАРША. Жена Липована в шоке. 2024, Kaum ib hlis
Anonim
Kev Cai Arduino Kom Ua Tau CAN Steering Log Khawm Nrog Lub Tsheb Tshiab Lub tso suab
Kev Cai Arduino Kom Ua Tau CAN Steering Log Khawm Nrog Lub Tsheb Tshiab Lub tso suab
Kev Cai Arduino Kom Ua Tau CAN Steering Log Khawm Nrog Lub Tsheb Tshiab Lub tso suab
Kev Cai Arduino Kom Ua Tau CAN Steering Log Khawm Nrog Lub Tsheb Tshiab Lub tso suab
Kev Cai Arduino Kom Ua Tau CAN Steering Log Khawm Nrog Lub Tsheb Tshiab Lub tso suab
Kev Cai Arduino Kom Ua Tau CAN Steering Log Khawm Nrog Lub Tsheb Tshiab Lub tso suab

Kuv txiav txim siab hloov lub tsheb qub hauv kuv lub Volvo V70 -02 nrog lub tso suab tshiab yog li kuv yuav muaj peev xwm txaus siab rau cov khoom xws li mp3, bluetooth thiab tsis muaj tes.

Kuv lub tsheb muaj qee lub hauv paus tswj hwm lub tso suab uas kuv xav tseem yuav siv tau. Kuv tsis tau cia siab tias yuav yog qhov teeb meem vim tias muaj ntau qhov hloov pauv ntawm lub khw uas yuav tsum sib haum nrog kuv lub tsheb. Txawm li cas los tsis ntev kuv pom tias lawv tsis yog! (Nws zoo li cov hloov pauv rau V70 yuav muaj teeb meem nrog -02 lub tsheb vim qhov sib txawv me ntsis CAN raws tu qauv.)

Yog li ntawd yuav ua li cas? Khaws lub tso suab qub? Ua lub neej nrog cov nyees khawm tsis ua haujlwm? Tau kawg tsis! Yog tias tsis muaj lub adapter ua haujlwm ntawm kev ua lag luam ces peb yuav tsum tsim ib qho!

Cov lus qhia no tuaj yeem siv tau (nrog qee qhov kev hloov pauv) rau cov tsheb uas cov khawm khawm khawm sib txuas lus hla CAN npav.

Kauj Ruam 1: Tshawb Nrhiav Yuav Ua Li Cas Xa Cov Lus txib rau Lub Stereo

Tshawb Nrhiav Yuav Ua Li Cas Xa Cov Lus txib rau Lub Stereo
Tshawb Nrhiav Yuav Ua Li Cas Xa Cov Lus txib rau Lub Stereo
Tshawb Nrhiav Yuav Ua Li Cas Xa Cov Lus txib rau Lub Stereo
Tshawb Nrhiav Yuav Ua Li Cas Xa Cov Lus txib rau Lub Stereo

Thawj qhov koj yuav tsum tau ua yog txhawm rau txheeb xyuas seb yam khoom siv nyob deb li cas lub tso suab xav tau. Feem ntau cov tuam txhab tsim khoom yuav tsis qhia koj txog qhov ntawd thiab tej zaum koj tsis muaj kev nkag mus rau kev ua haujlwm tswj chaw taws teeb rau kev thim rov qab engineering.

Cov chaw taws teeb rau kuv lub tso suab tshiab (Kenwood) suav nrog ib lub xov hlau thiab kuv tsis muaj peev xwm nrhiav tau cov ntaub ntawv hais txog nws ua haujlwm li cas. Txawm li cas los xij nws kuj tseem muaj lub hli 3.5 hli rau cov tswv yim nyob deb. Kuv tsis pom dab tsi txog qhov ntawd ib yam. Tab sis muaj qee cov ntaub ntawv hais txog 3.5 hli nkaus rau lwm lub npe hais qhia tias cov lus txib sib txawv tau txheeb xyuas los ntawm kev siv qhov tshwj xeeb tiv taus ntawm qhov taub thiab lub tes tsho (thiab xaiv tau ntawm lub nplhaib thiab lub tes tsho). Piv txwv li https://forum.arduino.cc/index.php?topic=230068.0. Yog li kuv txiav txim siab muab qhov kev sim ntawd, nruab nrog lub khob cij, ib pawg ntawm cov neeg tawm tsam thiab 3.5 hli ntsaws ntsaws rau hauv lub tso suab thiab txuas nrog lub rooj noj mov. Tsis muaj dab tsi tau lees paub thaum xub thawj, tab sis lub tso suab muaj "kev kawm hom" ntawv qhia zaub mov thiab muaj cov lus txib tuaj yeem teeb tsa tau zoo thaum thov kev tawm tsam ntau yam. Ua tau zoo!

Txawm li cas los xij tom qab kuv pom tias kuv tau ua yuam kev ntawm no: Tsis yog txhua cov lus txib uas lub tso suab zoo li kawm paub yuav ua haujlwm tiag tiag. Piv txwv li 30 kOhm tau pom hauv kev kawm hom tab sis tsis ua haujlwm tom qab thiab rau qee qhov lus txib kuv teeb tsa qhov kev tawm tsam sib txawv me me uas tom qab ntawd cov lus txib tsis raug tau tshwm sim.

Yog li kuv pom zoo tias koj siv lub khob cij nrog cov tiv thaiv thiab hloov cov nyees khawm rau txhua cov lus txib nyob deb uas koj xav lis thiab sim ua tiag tias txhua tus ntawm lawv yuav ua haujlwm.

Yog tias koj lub tsheb tso suab tsis tuaj yeem txais cov lus tawm hauv tib txoj kev ces koj yuav tsum txiav txim siab seb nws ua haujlwm li cas koj thiaj tuaj yeem hloov kho qhov kev daws teeb meem no. Yog tias koj tsis tuaj yeem txiav txim siab txhua lub sijhawm koj muaj teeb meem.

Kauj Ruam 2: Nrhiav Qhov Chaw Txuas Rau CAN Bus

Nrhiav Qhov Chaw Txuas Mus Rau CAN Bus
Nrhiav Qhov Chaw Txuas Mus Rau CAN Bus

Koj yuav tsum nrhiav qhov chaw zoo los txuas rau CAN npav. Txij li thaum koj tab tom hloov lub tso suab qub uas sib txuas lus nrog CAN koj yuav tsum muaj peev xwm nrhiav tau tom qab lub tso suab. Lub npav CAN muaj ob txoj hlua sib txuas (CAN-L thiab CAN_H). Tham nrog kab duab kab rau koj lub tsheb kom paub tseeb.

Kauj Ruam 3: Rov Ua Haujlwm Engineering ntawm CAN Messages

Rov Qab Engineering ntawm CAN Cov Lus
Rov Qab Engineering ntawm CAN Cov Lus

Tshwj tsis yog Google tuaj yeem qhia koj li cas CAN cov lus koj yuav tsum mloog rau tom qab ntawd koj yuav tsum txuas mus rau CAN npav thiab ua qee yam thim rov qab. Kuv siv Arduino Uno thiab CAN ntaub thaiv npog. (Koj tsis tas yuav xav tau daim thaiv npog CAN, zoo li koj yuav pom tom qab koj tuaj yeem siv qee yam khoom pheej yig ntawm lub khob cij hloov.)

Tham nrog Google kom paub seb tus nqi baud koj yuav tsum siv thaum txuas rau koj lub tsheb. (Feem ntau koj yuav pom tias muaj qhov nrawm thiab nrawm CAN net. Koj tab tom txuas rau qhov qis qis.)

Koj kuj tseem yuav xav tau program Arduino txhawm rau nkag mus rau txhua qhov lus CAN dhau ntawm tus lej sib txuas kom koj tuaj yeem txuag lawv rau hauv cov ntaub ntawv teev cia hauv koj lub computer. Tus txheej txheem Arduino IDE yuav tsis khaws cov ntaub ntawv rau hauv cov ntaub ntawv teev npe tab sis koj tuaj yeem siv piv txwv. Putty xwb.

Ua ntej koj pib sau koj qhov program koj yuav tsum teeb tsa CAN_BUS_Shield library.

Nov yog qee qhov pseudo chaws los pab koj pib nrog koj li haujlwm:

teeb ()

{init serial txuas txuas pib CAN lub tsev qiv ntawv} voj () {yog CAN cov lus tau txais {nyeem CAN cov lus hom nkag mus nkag sau sau nkag nkag mus rau ntu}}

Cov lus qhia:

Koj yuav siv qhov piv txwv ntawm chav kawm MCP_CAN txhawm rau nkag mus rau CAN lub tsev qiv ntawv ua haujlwm tau zoo:

MCP_CAN m_can;

Thawj CAN:

thaum (m_can.begin ()! = CAN_OK)

{ncua (1000); }

Txheeb xyuas thiab nyeem CAN cov lus:

thaum (m_can.checkReceive () == CAN_MSGAVAIL)

{// Tau CAN id, lus ntev thiab cov ntaub ntawv xov m_can.readMsgBufID (& m_canId, & m_msgLen, m_msgBuf); // Ua qee yam nrog cov ntaub ntawv xov ntawm no}

Yog tias koj xav tau kev pab ntau ntxiv koj tuaj yeem nrhiav qhov txuas rau kuv qhov program hauv qib tom ntej. CAN ntaub thaiv npog tsev qiv ntawv kuj suav nrog qhov piv txwv. Lossis tshawb xyuas mviljoen2 cov lus qhia uas suav nrog cov kauj ruam zoo sib xws.

Ua ntej koj yuav xav tau cov ntaub ntawv siv los pab koj lim cov ntaub ntawv. Hloov qhov hluav taws xob mus rau hom xov tooj cua thiab teev txhua yam rau ob peb feeb yam tsis tau kov ib qho khawm.

Tom qab ntawd rau txhua tus ntawm cov nyees khawm, pib nkag mus, thawb lub pob thiab nres kev nkag mus.

Thaum koj ua tiav koj yuav tsum lim tawm txhua yam uas nyob hauv koj lub cav siv los ntawm koj lub cav cav kom pom koj cov neeg sib tw. Kuv pom tias tseem tshuav cov lus tseem tshuav ntau yog li kuv tau sau ntau ntxiv thiab tom qab ntawv xav kom "cov neeg sib tw rau A yuav tsum muaj nyob hauv txhua lub pob-A-cov ntaub ntawv thiab tsis muaj cov ntaub ntawv siv". Qhov ntawd ua rau kuv tsuas muaj ob peb txoj hauv kev los sim.

Cov cav yuav muaj ntau cov lus yog li koj yuav tsum sau qee qhov haujlwm rau qhov no lossis siv tau Excel. (Kuv tau siv ib qhov program nrog nyuaj nyuaj rau cov xwm txheej rau kuv xav tau yog li kuv ntshai kuv tsis tuaj yeem muab txoj haujlwm koj tuaj yeem siv.)

Ib lo lus ceeb toom: Koj tsis tuaj yeem ntseeg tau tias lub pob yuav ib txwm tsim cov lus zoo ib yam. Qee qhov khoom yuav suav nrog suav cov lej ntxiv thiab lwm yam. (Koj tuaj yeem zam cov lus id kom zoo ib yam nkaus.)

Yog tias koj muaj Volvo V70 -02 qhov no yog qhov koj ua tom qab:

  • Message id: 0x0400066Byte0: 0x00, 0x40, 0x80 or 0xc0 (tsis quav ntsej)
  • Byte1: 0x00 (tsis quav ntsej)
  • Byte2: 0x00 (tsis quav ntsej)
  • Byte3: 0x00-0x07 (tsis quav ntsej)
  • Byte4: 0x1f (tsis quav ntsej)
  • Byte5: 0x40 (tsis quav ntsej)
  • Byte6: 0x40 (tsis quav ntsej)
  • Byte7: Khawm tus cim: 0x77 = ntim nce, 0x7b = ntim qis, 0x7d = kab ntawv tom ntej, 0x7e = yav dhau los.

Thaum koj ntseeg tias koj tau pom cov lus txib nws yuav yog lub tswv yim zoo los hloov kho qhov program kom nws tsuas yog sau cov lus ntxim nyiam. Saib ntawm lub qhov rooj nkag mus thaum koj nias lub pob kom paub tseeb tias koj tau txheeb xyuas cov lus raug.

Kauj Ruam 4: Cov Txheej Txheem Kho Vajtse

Kev Kho Vajtse Prototype
Kev Kho Vajtse Prototype

Koj lub khoos phis tawj yuav tsum muaj peev xwm:

  1. Txheeb cov lus txib uas tau txais ntawm CAN npav
  2. Xa cov lus txib hauv lwm hom ntawv mus rau lub tso suab

Yog tias koj muaj chaw txaus koj tuaj yeem siv Arduino thiab CAN ntaub thaiv npog rau thawj ntu thiab txuas qee qhov kho vajtse ntxiv rau qhov thib ob. Txawm li cas los xij, muaj qee qhov tsis zoo:

  • Tus nqi ntawm CAN ntaub thaiv npog
  • Loj
  • Arduino lub zog xa khoom yuav tsis zoo siab yog tias nws txuas ncaj qha rau koj lub tsheb 12V (nws yuav zaum ua haujlwm tab sis nws lub neej yuav zoo li luv).

Yog li hloov kuv siv cov hauv qab no:

  • Atmega 328, "Arduino lub hlwb". (Muaj qee qhov sib txawv, tau txais ib qho uas sib npaug rau ib qho ntawm Arduino Uno. Koj tuaj yeem yuav nws nrog lossis tsis muaj Arduino boot loader.)
  • 16 MHz siv lead ua + capacitors rau lub moos teeb liab.
  • MCP2551 CAN transceiver.
  • MCP2515 CAN tswj.
  • TSR1-2450, hloov 6.5-36V rau 5V. (Tsis siv nyob rau hauv tsab ntawv vim tias software yuav tsis saib xyuas txog lub hwj chim.)
  • CD4066B hloov pauv uas yuav siv thaum xa cov lus txib mus rau lub tso suab.
  • Ob peb ntawm resistors. (Cov txiaj ntsig tuaj yeem pom hauv Eagle schematics hauv qib tom ntej.)

Ib qho zoo nrog kev teeb tsa no yog tias nws ua tiav nrog Arduino thiab CAN daim ntaub thaiv lub tsev qiv ntawv.

Yog tias koj xav tuav ntau dua plaub lub khawm koj yuav xav txiav txim siab siv lwm yam dua li CD4066B. CD4066B tuaj yeem piav qhia ua plaub qhov hloov pauv hauv ib qho, txhua tus tswj los ntawm ib qho ntawm Atmegas GPIO pins. Rau txhua qhov hloov pauv muaj tus tiv thaiv txuas nrog uas tuaj yeem siv los tswj qhov tsis kam siv los ua tswv yim rau lub tso suab. Yog li qhov no tuaj yeem siv tau yooj yim los xa plaub lo lus txib sib txawv. Yog tias lawv sib xyaw ua ke tom qab ntawd qhov txiaj ntsig ntxiv tuaj yeem tau txais. Nov yog qhov yuam kev uas kuv tau hais ua ntej tuaj. Kuv muaj plaub lub nyees khawm, tab sis kuv tau npaj los siv ob qho ntawm lawv kom ntev thiab luv nias kom muab rau kuv rau qhov lus txib sib txawv. Tab sis thaum kawg kuv pom tias kuv nrhiav tsis tau cov tshuaj tiv thaiv ua ke uas yuav muab rau kuv rau ua haujlwm ua ke. Nws yuav yog qhov ua tau los txuas cov teeb liab tawm mus rau lub tso suab (3.5 hli taub hau) hloov chaw. (Nco ntsoov tias Atmega tsis muaj qhov tseeb analog tawm pins yog li yuav tsum tau kho vajtse ntxiv.)

Rau kev sim lub hom phiaj Kuv kuj tau ua qhov yooj yim "tsheb thiab lub tso suab" sim txuas mus rau kuv tus qauv. Nws ua kom debugging yooj yim dua thiab tshwj tsis yog koj nyiam zaum hauv koj lub tsheb thiab qhov program kuv tuaj yeem pom zoo.

Daim ntawv qhia ua piv txwv los ntawm lub khob cij hauv qab hauv daim duab. Rau lub zog siv hluav taws xob, cov phiaj xwm thiab cov ntawv txiav nws tau txuas nrog Arduino Uno qhov twg Atmega nti tau raug tshem tawm.

Lub khob cij sab saud yog lub tsheb + lub tso suab simulator uas yuav siv rau kev sim thawj zaug ntawm tus qauv.

Cov qauv + simulation yog npaj ua haujlwm zoo li no:

  • Nias ib qho ntawm cov khawm hloov ntawm lub simulator board. (Cov no yog koj lub khawm khawm.)
  • Thaum qhov kev sim ua haujlwm pom lub pob nyem nws yuav xa cov lus CAN sib txuas txhua 70 ms tsuav yog lub pob raug thawb. (Vim tias cov cav kuv tau ua yav dhau los tau qhia tias yog nws ua haujlwm li cas hauv kuv lub tsheb.) Nws tseem yuav xa ntau yam "tsis zoo" CAN cov lus los sim ua lwm yam kev mus los ntawm lub npav.
  • CAN cov lus raug xa ntawm CAN npav.
  • CAN cov lus tau txais los ntawm tsab ntawv.
  • MCP2515 cuam tshuam tag nrho cov lus tsis muaj feem cuam tshuam raws tus lej ID.
  • Thaum MCP2515 tau txais cov lus uas yuav tsum tau daws nws yuav qhia tias nws muaj cov lus tshaj tawm.
  • Atmega yuav nyeem cov lus thiab txiav txim siab lub pob twg uas yuav tsum tau txiav txim siab ua haujlwm.
  • Atmega tseem yuav taug qab thaum twg cov lus kawg tau txais, tom qab qee lub sijhawm khawm yuav raug txiav txim siab tso tawm. (Cov lus CAN tsuas yog qhia tias lub pob poob qis, tsis yog nws tau raug thawb lossis tso tawm.)
  • Yog tias lub pob tau txiav txim siab ua haujlwm ces ib lossis ntau qhov hloov pauv hauv CD4066B yuav raug qhib.
  • Lub simulator (tam sim no ua raws li koj lub tso suab) yuav pom tias qhov kev tiv thaiv tau siv ntawm qhov taub thiab lub tes tsho. (Cov lus taw qhia txuas nrog 3.3V thiab dhau los ntawm tus tiv thaiv mus rau tus lej nkag sib piv. Thaum tsis muaj qhov hais kom ua tus lej no yuav nyeem 3.3V, thaum kev hais kom ua haujlwm tus nqi yuav qis dua thiab txheeb xyuas cov lus txib.
  • Thaum cov lus txib tseem ua haujlwm, coj coj los kuj tseem yuav raug qhib. (Muaj rau lub leds vim tias kuv tau npaj siv sib txawv ntev / luv nias rau ob ntawm kuv cov nyees khawm.)

Yog xav paub ntau ntxiv txog cov cuab yeej tsim qauv, saib Eagle schematics hauv qib tom ntej.

Cov ncauj lus ntxiv txog cov cuab yeej simulator board:

  • 16 MHz siv lead ua
  • 22 pF capacitors
  • LED resistors yuav tsum raug xaiv raws li cov khoom siv LED
  • Resistor txuas nrog A7 thiab 3.3V, xaiv xws li 2kOhm (tsis tseem ceeb).
  • Resistors txuas nrog MCP2551 thiab MCP2515 yog rub tawm / rub tawm. Xaiv xws li 10 kwm.

(Los yog koj tuaj yeem siv CAN daim thaiv rau "CAN ib feem" ntawm qhov kev sim yog tias koj xav tau.)

Nws yog qhov tseem ceeb uas koj paub tias Atmega pins tau teeb tsa rau Arduino pins thaum koj tsim kho vajtse.

(Tsis txhob txuas ib qho leds ncaj qha rau CD 4066B, nws tsuas tuaj yeem ua haujlwm tsis zoo tam sim no. Kuv tau sim qhov ntawd thaum kuv xub sim ntsuas qhov tso tawm thiab cov nti ua tsis muaj txiaj ntsig. Qhov zoo yog tias kuv tau yuav ob peb ntawm lawv xwb vim tias lawv yog li pheej yig.)

Kauj Ruam 5: Fuse Programming

Tej zaum koj tau pom hauv cov kauj ruam dhau los uas tsab ntawv tsis muaj cov khoom sib cais los tsim lub moos teeb liab mus rau MCP2515. Qhov ntawd yog vim twb muaj 16 MHz siv lead ua siv los ua Atmega moos teeb liab uas peb siv tau. Tab sis peb tsis tuaj yeem txuas nws ncaj qha rau MCP2515 thiab los ntawm lub neej ntawd tsis muaj lub moos tawm teeb liab ntawm Atmega.

(Yog tias koj xav tau koj tuaj yeem hla cov kauj ruam no thiab ntxiv cov cuab yeej moos ntxiv.

Txawm li cas los xij peb tuaj yeem siv qee yam hu ua "fuse programming" los ua kom lub moos tawm teeb liab ntawm ib qho ntawm GPIO pins.

Ua ntej koj yuav tsum nrhiav cov ntaub ntawv npe "boards.txt" siv los ntawm koj li Arduino IDE. Koj yuav tsum luam daim ntawv nkag mus rau Arduino Uno, muab nws lub npe tshiab thiab hloov tus nqi rau low_fuses.

Kuv lub rooj tsavxwm tshiab zoo li no:

####################################### #############Raws li Arduino Uno#Kev hloov pauv:#low_fuses hloov pauv los ntawm 0xff rau 0xbf kom ua haujlwm 16 MHz moos#tawm ntawm Atmega PB0/tus pin 14 = Arduino D8

clkuno.name = Clock tawm (Arduino Uno)

clkuno.upload.protocol = arduino clkuno.upload.maximum_size = 32256 clkuno.upload.speed = 115200 clkuno.bootloader.low_fuses = 0xbf clkuno.bootloader.high_fuses = 0xde clkuno.bootloader.extended_fuses.bootloader.file = optiboot_atmega328.hex clkuno.bootloader.unlock_bits = 0xff clkuno.bootloader.lock_bits = 0xcf clkuno.build.mcu = atmega328p clkuno.build.f_cpu = 16000000L clkuno.build.core = standard

##############################################################

Nco ntsoov tias lub moos tawm tau qhib los ntawm kev teeb tsa nws cov kev tswj me ntsis rau 0.

Thaum koj tau tsim lub rooj tsav xwm tshiab hauv cov ntawv teeb tsa lub rooj zaum koj yuav tsum hlawv lub khau raj tshiab rau Atmega. Muaj ntau txoj hauv kev los ua qhov no, Kuv tau siv txoj kev piav qhia hauv

Tom qab koj tau ua tiav qhov no, nco ntsoov xaiv koj hom pawg thawj coj tshiab thiab tsis yog Arduino Uno thaum koj tso qhov program rau Atmega.

Kauj ruam 6: Software

Lub Software
Lub Software

Lub sijhawm los ua kom cov cuab yeej tsis paub zoo los ntawm kev ntxiv qee cov software.

Nov yog qee qhov pseudo code rau tsab ntawv:

lastReceivedTime = 0

lastReceivedCmd = tsis muaj cmdTimeout = 100 teeb tsa () {pab saib xyuas teeb tsa pins D4-D7 raws li cov pins tso tawm pib CAN teeb tsa CAN lim} voj () {rov pib saib xyuas yog (CAN cov lus tau txais) {rau txhua kab lus txib khawm hais kom ua {lastReceivedTime = tam sim no lastReceivedCmd = cmd}} yog tias tam sim no> lastReceivedTime + cmdTimeout {lastReceivedCmd = tsis muaj} rau txhua lub khawm hais kom ua {yog lastReceivedCmd yog khawm hais kom ua {teeb tsa tus lej pin tso tawm = ntawm} lwm tus {teeb tsa tus lej pin tso tawm = tawm }}}

cmdTimeout txiav txim siab ntev npaum li cas peb yuav tsum tau tos ua ntej peb txiav txim siab zaum kawg khawm tso tawm. Vim tias khawm CAN cov lus txib raug xa tawm kwv yees li txhua 70 ms nws xav tau kom loj dua qhov ntawd nrog qee qhov npoo. Tab sis yog tias nws loj yuav muaj kev paub lag. Yog li 100 ms zoo li yog tus neeg sib tw zoo.

Tab sis dab tsi yog tus saib xyuas? Nws yog qhov muaj txiaj ntsig kho vajtse me me uas tuaj yeem txuag peb thaum muaj kev sib tsoo. Xav txog tias peb muaj kab laum ua rau txoj haujlwm poob thaum lub ntim ntim tau hais kom ua haujlwm. Tom qab ntawd peb yuav xaus nrog lub tso suab ntawm qhov ntim ntau! Tab sis yog tias tus saib xyuas tsis rov pib dua rau lub sijhawm tshwj xeeb nws yuav txiav txim siab tias qee yam tsis tau xav txog tau tshwm sim thiab tsuas yog teeb tsa rov pib dua.

void teeb tsa ()

{// pub max 250 ms rau lub voj wdt_enable (WDTO_250MS); // lwm yam khoom siv} void loop () {wdt_reset (); // ua cov khoom}

CAN lim? Zoo, koj tuaj yeem teeb tsa CAN tus tswj kom tshem tawm txhua cov lus uas tsis sib xws rau lub lim dej kom lub software tsis tas yuav nkim sijhawm ntawm cov lus peb tsis quav ntsej txog.

daim npog ntev tsis tau kos npe = 0x1fffffff; // Suav tag nrho 29 lub hauv paus hauv qhov ncauj

unsigned ntev filterId = 0x0400066; // Peb tsuas yog saib xyuas qhov CAN message id m_can.init_Mask (0, CAN_EXTID, daim npog ntsej muag); // Mask 0 siv rau lim 0-1 m_can.init_Mask (1, CAN_EXTID, daim npog ntsej muag); // Daim npog 1 siv rau lim 2-5 m_can.init_Filt (0, CAN_EXTID, filterId); m_can.init_Filt (1, CAN_EXTID, filterId); m_can.init_Filt (2, CAN_EXTID, filterId); m_can.init_Filt (3, CAN_EXTID, filterId); m_can.init_Filt (4, CAN_EXTID, filterId); m_can.init_Filt (5, CAN_EXTID, filterId);

Txheeb xyuas CAN tsev qiv ntawv tus lej thiab CAN cov ntaub ntawv tswj hwm kom paub meej ntxiv txog yuav teeb tsa lim + daim npog ntsej muag li cas.

Koj tseem tuaj yeem teeb tsa CAN maub los txhawm rau cuam tshuam thaum tau txais cov lus (uas tsis tau lim tawm). (Tsis suav nrog hauv qhov piv txwv saum toj no tab sis muaj qee qhov chaws rau nws hauv kuv qhov haujlwm.) Hauv qhov no nws tsis tau ntxiv ib qho txiaj ntsig twg thiab nws yuav tsis meej pem yog tias koj tsis tau siv rau kev ua haujlwm.

Yog li ntawd yog cov qauv software hauv cov ntsiab lus. Tab sis peb xav tau qee cov cai rau pawg tswj hwm kev sim ib yam nkaus:

lastSentTime = 0

minDelayTime = 70 teeb tsa () {teeb tsa pins A0-A5 raws li cov pins teeb tsa tus pin D4-D7 ua cov pins nkag nrog rub tawm sab hauv. init CAN} loop () {xa "qua ntxi" tuaj yeem msg teeb tsa activeButton = tsis muaj rau txhua khawm {yog khawm raug thawb {teeb tsa activeButton = khawm}} yog activeButton! = tsis muaj {yog tam sim no> lastSentTime + minDelayTime {xa khawm hais kom tuaj yeem xa xov } teeb tsa lastSentTime = tam sim no} inval = nyeem tus pin A7 foreach (cmd) {yog (min <inval <max) {coj rau} lwm tus {coj tawm}} tos 1 ms}

Qhov no yuav txuas ntxiv xa "cov khoom tsis zoo" CAN cov lus kwv yees txhua txhua ms thiab thaum lub pob raug thawb cov lus txib sib hais txhua 70 ms.

Koj yuav xav tau nkag mus rau tus lej nkag ntawm tus pin A7 thaum nias lub pob sib txawv kom paub qhov tsim nyog tsim nyog rau qhov tsawg kawg thiab qhov sib txawv ntawm tus tswv ntawm txhua lub khawm. (Los yog koj tuaj yeem suav nws, tab sis qhov tseeb nyeem cov lus tawm tswv yim yuav ua rau koj muaj qhov tseeb ntau dua.)

Koj yuav tsum tau ceev faj me ntsis thaum koj tab tom ua haujlwm tus qauv pin. Yog tias koj yuam kev teeb tsa tus pin xav siv sab hauv rub tawm raws li cov pins tso tawm ces koj yuav tsim qhov muaj peev xwm luv uas yuav ua rau koj Arduino puas tsuaj thaum koj teeb tsa cov zis siab.

Yog tias koj xav tshuaj xyuas kuv cov program lawv tuaj yeem rub tawm ntawm no:

  • CAN messages log program
  • Qhov program rau lub rooj tsavxwm simulator
  • Program rau tsab ntawv / pawg thawj coj saib zaum kawg

Koj yuav tsum paub tias cov program no tsis sib haum nrog tus lej pseudo ntawm no, lawv muaj ntau yam "ntxiv" yam uas tsis xav tau tiag tiag thiab yog tias koj tsis paub txog cov phiaj xwm phiaj xwm nws yuav zaum nyuaj me ntsis nyeem.

Kauj Ruam 7: Kho Vajtse Kawg

Kawg Kho Vajtse
Kawg Kho Vajtse
Kawg Kho Vajtse
Kawg Kho Vajtse
Kawg Kho Vajtse
Kawg Kho Vajtse

Thaum koj zoo siab nrog koj txoj haujlwm (nco ntsoov sim ua tus qauv hauv lub tsheb tom qab kuaj zaum kawg nrog lub rooj tsav xwm simulation) nws yog lub sijhawm los tsim kho vajtse tiag.

Koj muaj peb txoj kev xaiv ntawm no:

  • Ceev thiab qias neeg - muab cov khoom sib dhos ua ke ntawm PCB pawg thawj coj.
  • Hardcore DIY - etch koj tus kheej PCB.
  • Txoj kev tub nkeeg - xaj ib tus kws tshaj lij PCB txhawm rau muab cov khoom sib txuas rau.

Yog tias koj tsis maj nrawm kuv tuaj yeem qhia qhov kev xaiv kawg. Yog tias koj tsuas xav tau PCB me me zoo li qhov no nws pheej yig heev los xaj nws los ntawm Tuam Tshoj. (Thiab tom qab ntawd koj yuav zaum tau kaum daim los yog li ntawd koj thiaj tuaj yeem them taus qee qhov ua yuam kev.)

Txhawm rau xaj PCBs koj yuav tsum xa koj tus qauv tsim hauv Gerber hom. Muaj ntau yam software rau qhov no. Kuv siv Eagle uas kuv tuaj yeem pom zoo. Koj tuaj yeem cia siab ob peb teev los kawm nws tab sis tom qab ntawd nws ua haujlwm zoo. Rau cov laug cam me me zoo li no koj tuaj yeem siv nws dawb.

Ceev faj thaum koj ua tus tsim. Koj tsis xav tos plaub lub lis piam rau kev xa khoom tsuas yog pom tias koj tau ua qee yam tsis raug.

(Yog tias koj muaj cov txuj ci zoo soldering koj tuaj yeem tsim rau cov khoom siv sab nrauv thiab tau txais lub adapter me me tiag tiag. Kuv tsis tau.)

Tom qab ntawv xaj ntawm eg https://www.seeedstudio.com/fusion_pcb.html. Ua raws cov lus qhia yuav ua li cas los tsim Gerber cov ntaub ntawv los ntawm koj tus qauv. Koj tseem tuaj yeem tau txais kev saib ua ntej ntawm qhov tshwm sim kom ntseeg tau tias nws zoo.

(Thaum kawg kuv yuav tsum xaiv lwm tus tiv thaiv rau R4-R7 dua li tau teev tseg hauv daim duab duab. Xwb kuv siv 2k, 4.7k, 6.8k thiab 14.7k.)

Thiab nco ntsoov - tsis txhob yuam kev tus lej Atmega nrog tus lej Arduino!

Kuv pom zoo tias koj tsis siv lub Atmega nti ncaj qha tab sis siv lub qhov (socket). Tom qab ntawd koj tuaj yeem tshem nws tau yooj yim yog tias koj xav tau rov ua dua nws.

Kauj Ruam 8: Tsheb Mounting

Tsheb Mounting
Tsheb Mounting
Tsheb Mounting
Tsheb Mounting

Tam sim no rau qhov lom zem tshaj plaws - teeb nws hauv koj lub tsheb thiab pib siv nws! (Tom qab koj tau ua / yuav rooj plaub rau nws.)

Yog tias koj twb tau kuaj tag nrho cov qauv hauv koj lub tsheb txhua yam yuav tsum ua haujlwm zoo.

(Raws li kuv tau hais ua ntej kuv tsis tau yog li kuv yuav tsum hloov qee qhov tiv thaiv thiab ua qee qhov kev hloov pauv hauv kuv qhov haujlwm.)

Kuj xav txog yog tias koj yuav tsum teeb nws tom qab lub tso suab lossis lwm qhov. Kuv pom qhov chaw zoo nyob saum kuv lub hnab looj tes uas kuv tuaj yeem ncav nws los ntawm sab hauv lub hnab looj tes yam tsis muaj ib qho sib nrug. Qhov ntawd yuav muaj txiaj ntsig yog tias kuv txiav txim siab hloov kho nws tom qab.

Thaum kawg kuv cov nyees khawm rov ua haujlwm dua! Kuv yuav ua li cas thiaj muaj sia nyob tau ob lub hlis yam tsis muaj lawv?

Kauj Ruam 9: Kev txhim kho yav tom ntej

Raws li tau hais, yog tias kuv ua qhov version 2.0 ntawm qhov no kuv yuav hloov 4066B nrog lwm yam (tej zaum yog lub tshuab hluav taws xob digital) kom yooj yim dua.

Kuj tseem muaj ntau yam ntxiv uas koj tuaj yeem ua tau. Piv txwv li ntxiv bluetooth module thiab ua lub app tswj chaw taws teeb rau koj lub xov tooj. Los yog gps module, tom qab ntawd thaum koj nyob ze tsev koj tuaj yeem nce ntim thiab xa "windows down" CAN message kom txhua tus neeg nyob ze tuaj yeem txaus siab rau koj cov nkauj zoo.

Pom zoo: