Cov txheej txheem:

Xbox 360 Controller Accelerometer/gyro Steering Mod: 7 Kauj Ruam
Xbox 360 Controller Accelerometer/gyro Steering Mod: 7 Kauj Ruam

Video: Xbox 360 Controller Accelerometer/gyro Steering Mod: 7 Kauj Ruam

Video: Xbox 360 Controller Accelerometer/gyro Steering Mod: 7 Kauj Ruam
Video: F1 23 Controller Settings Guide – in under 5 Minutes! 2024, Kaum ib hlis
Anonim
Xbox 360 Tus Tswj Accelerometer/gyro Steering Mod
Xbox 360 Tus Tswj Accelerometer/gyro Steering Mod

Kuv tau ua si Assetto Corsa nrog kuv tus Xbox 360 maub los. Hmoov tsis zoo, kev taw qhia nrog cov lus sib piv tsis yooj yim, thiab kuv tsis muaj qhov chaw rau teeb tsa lub log. Kuv tau sim xav txog txoj hauv kev kuv tuaj yeem khau khau lub zog ua haujlwm zoo dua rau hauv tus tswj, thaum nws tshwm sim rau kuv tias kuv tuaj yeem siv tag nrho cov maub los ua lub kauj.

Cov analogue stick muaj ob lub hwj chim. Ib qho ntsuas kev txav mus los ntsug, thiab ib qho ntsuas kev txav mus los. Nws tso 1.6V los ntawm txhua qhov thiab ntsuas qhov hluav taws xob tsim tawm ntawm lub wiper los txiav txim siab ntau npaum li cas tus pas tau txav mus. Qhov no txhais tau tias nws muaj peev xwm tswj tau lub zog txav los ntawm kev pub zaub mov tshwj xeeb rau lub wiper tus pin. (xov xwm ntau ntxiv ntawm no:

Qhov kev hloov pauv no siv Arduino los xam lub kaum sab xis los ntawm kev nyeem nrawm thiab hloov nws mus rau qhov sib thooj lo ntawm DAC. Yog li ntawd, nws yuav tsum ua haujlwm nrog txhua qhov kev ua si uas siv cov lus sib piv ua cov tswv yim.

Kauj ruam 1: Koj Yuav Tsum Tau:

Cov Cuab Yeej:

  • Soldering hlau
  • Solder
  • Solder nqus/braid
  • Hlau stripper
  • Tus ntswj ntsia hlau, tej zaum Torx ib tus nyob ntawm cov ntsia hlau hauv koj tus tswj (kuv lub taub hau hla)
  • Cov kua nplaum (tshwj xeeb tshaj yog tsis muaj kua nplaum muaj zog yog li nws tuaj yeem muab sib nrug tom qab)
  • USB rau txuas txuas txuas mus rau program Arduino

Cov ntaub ntawv:

  • Xbox 360 Controller (duh!)
  • Arduino Pro Mini (lossis clone) (zoo dua 3.3V. Yog tias koj siv 5V version koj yuav zaum yuav xav tau nce qib hloov hluav taws xob)
  • MPU-6050 gyroscope/accelerometer
  • MCP4725 DAC (ob yog tias koj xav tswj ob qho tib si)
  • Qee cov xov hlau nyias
  • Lub khob cij yog li koj tuaj yeem sim txhua yam ua ntej koj yuav laug (yeem, tab sis pom zoo)

Kauj Ruam 2: Tshem Tawm Tus Tswj

Tshem Tawm Tus Tswj
Tshem Tawm Tus Tswj
Tshem Tawm Tus Tswj
Tshem Tawm Tus Tswj
Tshem Tawm Tus Tswj
Tshem Tawm Tus Tswj

Muaj xya tus screws koj yuav tsum tshem tawm. Rau ntawm lawv yog qhov pom tseeb, tab sis lub xya yog tom qab daim ntawv nplaum. Kuv xav tias tshem nws voids koj qhov kev lees paub, yog li ua raws koj tus kheej txoj kev pheej hmoo. Ntau cov lus qhia hais tias koj xav tau Torx ntswj ntsia hlau, tab sis kuv lub taub hau hla, yog li xyuas koj tus tswj.

Tom qab ntawd, ua tib zoo ntxig rau sab nraub qaum. Yog tias koj khawm tawm ntawm sab xub ntiag cov nyees khawm yuav tawg tawm thiab tej zaum yuav mus thoob plaws hauv chav. Nqa nws los hauv qab. Tom qab ntawd tshem tawm ob lub cav kev co. (ib qho nrog qhov hnyav me me yuav tsum nyob rau sab laug, thiab ib qho nrog qhov hnyav loj ntawm sab xis) Nqa PCB tawm thiab tshem cov roj hmab lub kaus mom ntawm cov khoom sib thooj. Lawv yooj yim rub tawm.

Qhov txuas ntxiv yog tshem tawm cov lus sib piv sab laug kom nws tsis cuam tshuam nrog peb cov tswv yim, tab sis lub tshuab ua haujlwm sab laug yog txoj hauv kev. Txhawm rau tshem nws, koj yuav tsum desolder peb tus pin los ntawm lub hwj chim los ntawm sab xub ntiag ntawm lub rooj tsavxwm, tom qab ntawd kaw lub tshuab los ntawm PCB.

Tom ntej no, desolder 14 tus pin tuav sab laug analogue lo. Tom qab ntawd rub tus pas tawm.

Kauj Ruam 3: Muab cov Cheebtsam tso rau hauv qhov chaw

Khaws cov Cheebtsam hauv Qhov Chaw
Khaws cov Cheebtsam hauv Qhov Chaw
Khaws cov Cheebtsam hauv Qhov Chaw
Khaws cov Cheebtsam hauv Qhov Chaw

Koj yuav pom tias muaj ntau qhov kev tshem tawm ntawm sab nraum qab ntawm PCB thiab rooj plaub. Qhov no ua rau nws muaj peev xwm tso tag nrho cov cuab yeej kho mob hauv rooj plaub yam tsis tau tshem dab tsi.

Kuv tsuas yog pom tom qab, tab sis qhov no yuav yog lub sijhawm zoo rau desolder khawm rov pib dua ntawm Arduino. Yog tias koj tsis ua, nws yuav nias rau sab nraum qab ntawm rooj plaub thiab ua rau txoj haujlwm tsis ua haujlwm yog tias koj kaw ib qho ntawm cov ntsia hlau ntau dhau thaum rov ua nws dua.

Kuv glued daim npav nyias rau sab nraum qab ntawm txhua PCB kom tiv thaiv nws, tom qab ntawd lo rau tus tswj hwm PCB. Kuv tsis kam siv kua nplaum, tab sis tsis tuaj yeem xav txog txoj hauv kev zoo dua los ua nws.

Cov haujlwm hauv daim duab yog qhov ua ke zoo tshaj plaws uas kuv tuaj yeem pom. Arduino nyob ntawm sab laug, nrog ntug nrog khawm rov pib dua yaug tawm tsam cov yas los ntawm txoj hauv kev ua kom zoo, nrog rau lwm sab hauv qab xaim thiab nrog lub ces kaum ze rau qhov txuas dawb li sai tau. Muaj qhov nce me ntsis hauv rooj plaub, tab sis kuv nrhiav tsis tau qhov chaw zoo dua los tso nws.

Tus ntsuas hluav taws xob yog nyob sab xis ntawm xaim. Nws yuav tsum ua kom tiaj thiab ncaj li sai tau, txwv tsis pub koj yuav tau sau qee cov cai tom qab los txhawm rau txhawm rau txhawm rau. Nco ntsoov tias muaj qee cov yas nthuav tawm rau tom qab ntawm rooj plaub uas koj yuav tsum tau ceev faj kom zam. Kuv tau pom tias koj tuaj yeem tso qee yam nplaum thiab muaj xim, zoo li daim di ncauj, ntawm cov yas nthuav tawm tom qab ntawd muab lub hau npog rov qab los saib qhov twg nws tawm cov cim.

DAC (s) mus rau hauv qab kaum sab tes xis. Muaj kev tshem tawm txaus ntawm no los teeb tsa ob DACs, ib qho nyob rau lwm qhov, yog tias koj xav tswj ob txoj kab. Koj tsis tas yuav lo lawv. Lawv yuav nyob qhov twg lawv nyob nrog tsuas yog cov txuas txuas. Yog tias koj tab tom ua daim npav nruab nrab ntawm lawv kom paub tseeb tias koj txiav daim npav kom tawm ntawm SCL, SDA, VCC thiab GND siv tau, vim tias koj yuav nkag mus tau los ntawm ob sab.

Yog tias koj siv ob DACs, tsis txhob hnov qab hloov qhov chaw nyob jumper thiab kaw qhov rub tawm cov neeg tawm tsam ntawm ib ntawm lawv, raws li tau piav qhia ntawm no: https://learn.sparkfun.com/tutorials/mcp4725-digital-to-analog -converter-hookup-qhia

Kauj Ruam 4: Muab cov hlua txuas rau

Solder Cov Hlau Nyob
Solder Cov Hlau Nyob
Solder Cov Hlau Nyob
Solder Cov Hlau Nyob
Solder Cov Hlau Nyob
Solder Cov Hlau Nyob

Tam sim no koj yuav tsum txuas txhua yam. VCC, GND, SDA thiab SCL los ntawm txhua 2/3 cov cuab yeej yuav tsum txuas nrog VCC, GND, A4 thiab A5 ntawm Arduino, feem. DACs yog qhov nyuaj tshaj plaws. Yog tias koj muaj ob qho, koj yuav tsum txuas lawv ua ke, thaum tawm hauv qhov chaw koj tuaj yeem txuas lub zog thiab kab mus rau tus ntsuas hluav taws xob, thaum khaws cov xov hluav taws xob sib cais.

Tus OUT tus pin ntawm DAC yuav tsum txuas nrog tus pin ntawm tus tswj hwm PCB uas siv los rau nruab nrab kab rov tav potentiometer tus pin rau qhov sib piv. Ntawd yog, qhov twg qhov sib thooj lo yog, muaj kab ntawm peb tus pin rau saum. Txuas nws mus rau ib nrab. Yog tias koj muaj lwm DAC txuas nws mus rau tus pin potentiometer ntsug (kab rau sab laug) ib yam nkaus. Koj yuav tsis tuaj yeem nkag mus rau tus pin los ntawm sab nraub qaum thaum lub hloov pauv, yog li koj yuav tsum tau xaim xov mus rau ntawm lub hauv ntej ntawm pawg thawj coj saib. Muaj cov yas yas "phab ntsa" nyob ib puag ncig thaj chaw sib thooj, tab sis hmoov zoo muaj qhov sib txawv yooj yim hauv nws uas koj tuaj yeem tso xov hlau hla. Nco ntsoov tias cov xov hlau tsis nyob rau hauv txoj hauv kev ntawm cov ntsia hlau ncej ntawm sab xub ntiag ntawm rooj plaub.

Kuv thawj lub tswv yim yog ua kom lub zog Arduino nrog 5V los ntawm USB cable txuas nrog RAW tus pin, tab sis thaum kuv sim nws, nws tsis ua haujlwm. Arduino tsis tau ua dab tsi, thiab ob qho tib si Arduino thiab tus tswj tau kaw tom qab ob peb feeb. Txawm li cas los xij, Kuv pom tias muaj qhov ruaj khov 3.3V tso tawm los ntawm ob lub pins nyob rau sab xub ntiag ntawm pawg thawj coj saib ze rau lub qhov hluav taws xob ntsaws ntsaws dub, xav tias yog lub zog rau ib puag ncig. Nws ua haujlwm nrog ob VCC thiab RAW, tab sis kuv tau xaiv VCC vim tias nws twb yog qhov hluav taws xob raug thiab vim nws tso cai rau kuv los txuas nws rau VCC xaim ntawm DAC uas twb nyob ze rau hauv qab ntawm pawg thawj coj thiab txuag ntawm cov xov hlau.

Ceev faj tias muaj ntau qhov yas ntim tawm los ntawm rooj plaub uas koj yuav tsum ua haujlwm ib puag ncig, tab sis yog tias koj lo cov xov hlau nyob hauv qhov chaw, koj tsuas yog yuav tsum txhawj xeeb txog lawv ib zaug.

Txhua yam no nyuaj piav nrog cov lus, yog li kuv tau suav nrog cov duab thiab daim duab kos.

Kauj ruam 5: Program Arduino

Tam sim no koj yuav tsum program Arduino. Qhov no yuav tsum tau txav lub USB cable ntawm tus tswj kom koj tuaj yeem nkag mus rau tus lej txuas ntawm Arduino. Kuv tau suav nrog cov cai kuv siv. Nws xav tau Adafruit MCP4725 lub tsev qiv ntawv, uas tuaj yeem pom ntawm no:

Raws li yog, txoj cai tso cai rau koj hla txhua qhov kev txav ntawm cov lus sib piv sib npaug los ntawm kev txav tus tswj 90 degrees mus rau sab laug rau 90 degrees mus rau sab xis, thiab khaws nws nyob hauv nruab nrab los ntawm kev tuav nws tiaj.

Nws tau txais lub kaum sab xis ntawm tus tswj hwm los ntawm kev suav qhov sib piv tangent ntawm X axis g-quab yuam faib los ntawm Z axis g-quab yuam. Qhov no txhais tau tias nws ua haujlwm yog tias tus tswj hwm ntsug, tiaj, lossis ib lub kaum sab xis nruab nrab. (xav paub ntau ntxiv ntawm no:

Nws ua haujlwm ntawm kuv tus tswj hwm, tab sis lwm tus tswj hwm yuav xav tau qhov sib txawv, tso nws tawm ntawm kev sib koom ua ke. Kuv xav tias txoj hauv kev zoo tshaj los nrhiav qhov voltage ntau yog nrog kev sim thiab yuam kev. Ntau qhov kev ua si yuav qhia koj tus slider rau qhov sib piv ntawm qhov txav, tab sis txoj kev raug tshaj plaws uas kuv tau pom los txiav txim siab txav yog nrog jstest ntawm Linux. (https://wiki.archlinux.org/index.php/Gamepad#Joystick_API) Nws muab koj tus lej nruab nrab ntawm -32, 767 thiab 32, 767 ntau dua li daim duab, yog li koj paub tseeb tias tus pas nyob qhov twg. Txuas ob qho tib si tus tswj hwm thiab Arduino USB rau txuas txuas, ntsaws jstest thiab sim sib txawv DAC qhov txiaj ntsig kom txog thaum koj mus txog rau saum thiab hauv qab ntawm qhov ntau, thiab sau tseg ntawm txhua tus. Rau kuv nws yog 1, 593 - 382.

Tshwj xeeb txaus siab yog kab 36:

dacvalue = (controllerangle + 2.5617859169446084418) / 0.0025942135867793503208 + 0.5;

Nws tsis pom tseeb tam sim nws ua dab tsi. Yooj yim, nws siv lub kaum sab xis ntawm tus tswj (ntsuas hauv radians thiab nruab nrab ntawm ~ 1.57 thiab ~ -1.57) thiab hloov nws mus rau tus nqi nruab nrab ntawm 1, 593 thiab 382 rau DAC. Yog tias koj muaj DAC ntau yam sib txawv, koj yuav tsum hloov txoj kab ntawd.

Kab ntawv tuaj yeem sau ua:

dacvalue = (controllerangle +) / + 0.5;

Nrog thiab ua tus lej koj yuav tsum hloov pauv. yog sib npaug rau qhov ntau ntawm cov tswj lub kaum ntse ntse (pi) faib los ntawm tag nrho ntau yam ntawm DAC qhov tseem ceeb. (sab saum toj ntawm qhov rho tawm hauv qab ntawm qhov ntau) Qhov no tau txais koj kom deb li deb hloov qhov hluav taws xob, txawm hais tias cov txiaj ntsig yuav nyob sab nraum qhov koj xav tau. Yog vim li cas koj thiaj xav tau. yog sib npaug sib npaug hauv qab ntawm qhov ntau ntxiv ib nrab ntawm cov lus tsa suab ntawm tus tswj. (pi / 2) Ntxiv ib nrab ntawm cov lus tsa suab ua kom ntseeg tau tias nws tsis yog tus lej tsis zoo, thiab ntxiv kev sib tw hauv qab ntawm qhov ntau kom ntseeg tau tias nws tau ua tiav nrog qhov koj xav tau.

Thaum hloov cov zauv zauv rau tus lej, C ++ tsis hloov pauv. Nws hloov qhov txiav tawm zauv, yog li 9.9 dhau los ua 9. Ntxiv 0.5 ntawm qhov kawg ua kom ntseeg tau tias muaj dab tsi saum ib nrab mus rau tus lej tom ntej, yog li nws ua puag ncig.

Thaum koj tau tshaj tawm koj qhov program, xyuas kom nws ua haujlwm nrog jstest.

Kauj Ruam 6: Rov Ua Dua Tus Tswj

Muab tus maub los rov qab ua ke nyob rau hauv tib txoj kev uas koj tau muab nws sib nrug, rho tawm sab laug sab sib piv. Nws yuav tsum ua haujlwm tam sim no. Kuv pom tias tsis muaj qhov pom qeeb thiab nws zoo dua li siv cov khoom sib thooj. Vim tias nws siv lub ntsuas cua nrawm, nws cuam tshuam los ntawm kev txav mus sai, tab sis koj yuav tsum tawm ntawm koj txoj hauv kev kom pom nws.

Kauj Ruam 7: Kev Txhim Kho Tau

Muaj qee qhov kev txhim kho uas tuaj yeem ua tau. Cov no suav nrog:

  • Siv tsawg cumbersome hlau nplaum hlau
  • Etching txhua yam mus rau ib qho PCB uas tau tsim los kom haum rau hauv cov ntaub ntawv tswj
  • Rov saib dua sab laug qhov sib thooj sib txuas thiab txuas ob txhais ceg mus rau cov lus qhia sib piv ntawm Arduino yog li lawv tuaj yeem siv los kho Arduino
  • Tau txais cov ntaub ntawv thim rov qab rau lub wireless tswj thiab tso txoj haujlwm hauv lub roj teeb (qhov no yuav xav tau txiav lub qhov rau USB cable)

Pom zoo: