Cov txheej txheem:

ColorCube: 7 Kauj Ruam (nrog Duab)
ColorCube: 7 Kauj Ruam (nrog Duab)

Video: ColorCube: 7 Kauj Ruam (nrog Duab)

Video: ColorCube: 7 Kauj Ruam (nrog Duab)
Video: Plab Plab Ntswg..(Pluav Pluav Ntswg) Maiv Twm New Song 2023-2024 2024, Kaum ib hlis
Anonim
Image
Image
XimCube
XimCube
XimCube
XimCube

Kuv ua lub teeb no rau kuv tus ntxhais xeeb ntxwv thaum nws kawm xim. Kuv tau tshoov siab nrog MagicCube txoj haujlwm tab sis thaum kawg tsim txhua qhov los ntawm qhov kos. Nws yog qhov yooj yim luam tawm thiab yooj yim rau sib sau ua ke thiab koj yuav tau txais kev paub tias gyro module ua haujlwm li cas.

Kauj ruam 1: Cov ntaub ntawv

Khoom siv
Khoom siv

Arduino ib feem:

  • Arduino Nano (zoo dua yam tsis muaj kab laug sab laug)
  • MPU-6050 3-Axis Gyro Module
  • TP4056 Micro USB Roj Teeb Charger Module
  • MT3608 Step Up Power Booster Module
  • LiPo Roj Teeb 902936 900mA lossis 503035 3.7V 500mA. Koj tuaj yeem siv ib lub roj teeb LiPo nrog 3, 7V thiab qhov loj me dua 35x30x15mm tab sis koj yuav tsum ruaj ntseg lub roj teeb hauv qhov.
  • PS-22F28 khawm tus kheej lossis PS-22F27 Tus kheej-khawm khawm ob qho tib si haum rau luam ib feem zoo kawg nkaus.
  • LED RGB WS2812B Ntiv Nplhaib - 16 LED 68mm txoj kab uas hla sab nrauv - koj tuaj yeem siv lub nplhaib txawm tias muaj tus lej sib txawv ntawm LEDs (yuav tsum hloov ib qho tsis tu ncua hauv tus lej - #define NUMPIXELS 16) nrog qhov siab tshaj plaws ntawm 76mm (koj tseem tuaj yeem siv Neopixel Stick nrog 8x LED lossis ib qho LED sawb nrog WS2812b).

Ntiv nplhaib piv txwv: 8 LED 32mm12 LED 38mm12 LED 50mm16 LED 60mm24 LED 66 mm16 LED 44mm

Rau kev txiav tawm koj tuaj yeem siv ib qho ntawm qhov uas luam tawm hauv ib nrab. Lawv npog yuav luag txhua qhov kev xaiv (tsis tas yuav tsum muaj lub nplhaib 100% nyob hauv nruab nrab).

Hlau

Lub voos xwmfab

  • PLA Filament rau sab saum toj ntawm lub voos xwmfab - siv xim dawb vim tias pob tshab tsis zoo (LEDs pom thiab xim tsis du), kuv qhov kev pom zoo yog Prusament Vanilla White
  • PLA Filament rau hauv qab, nruab nrab thiab ntu ntu - siv xim tsaus vim qee qhov Arduino cov qauv muaj teeb nyob saum thiab nws tsis haum nrog lub voos xwmfab LEDs xim, kuv qhov kev pom zoo yog Prusament Galaxy Black
  • 1x M3x5 Tus Kheej Ntsia Hlau Tus Kheej - Qhov ntev (10mm) thiab lub taub hau zoo li tsis tseem ceeb - ntsia hlau tsis pom
  • 2x M2x3 Tus Kheej Tus Kheej Ntsia Hlau - Qhov ntev (5mm) thiab lub taub hau zoo li tsis tseem ceeb - ntsia tsis pom

Cov cuab yeej

  • 3D Tshuab Luam Ntawv
  • Ntau lub 'meter'
  • Soldering hlau
  • Ntsia Hlau

Kauj ruam 2: Printing

Luam Ntawv
Luam Ntawv
Luam Ntawv
Luam Ntawv

Txhua qhov ntawm ColorCube tau tsim hauv Autodesk Fusion360. f3d cov ntaub ntawv txuas nrog.

Lub ColorCube tau luam tawm ntawm Prusa i3 MK3S lub tshuab luam ntawv nrog txhua qhov kev teeb tsa ua ntej thiab kuv tsis xav tias yuav muaj kev hloov pauv ntawm cov tshuab luam ntawv sib txawv. Siv koj qhov chaw nyiam rau PLA (yog tias luam tawm ntawm PLA, tsis muaj teeb meem siv PETG lossis ASA).

3d printing tsis:

  • Txheej 0.2 hli (0.2mm QUALITY settings on PrusaSlicer)
  • Prusament PLA Filament chaw ntawm PrusaSlicer
  • Infill 15%
  • Tsis Txhawb
  • Tsis Brim

Kauj ruam 3: Circuit Court

Circuit Court
Circuit Court

Kauj ruam 4: Soldering

Soldering
Soldering
Soldering
Soldering
Soldering
Soldering

Lus Ceeb Toom: Siv lub ntsuas ntsuas ntau kom paub tseeb tias DC-DC lub zog MT3608 tso tawm 5V. Ua ntej tshaj plaws - ua ntej ntsuas - tig lub laij lej raws qhov kawg (nyem). Thaum txuas qhov hluav taws xob (3, 7V) rau kev tawm tswv yim nws yuav tsum muab kwv yees tus nqi ib yam. Tig rov qab-clockwise (koj yuav xav tau 10-20 puv puv) thiab tam sim ntawd voltage nce. Teeb 5V ntawm cov khoom muag muag. (duab)

Ua tibzoo saib cov ntawv hauv qab ntawm lub voos xwmfab. Txhua tivthaiv muaj nws tus kheej lub qhov taub. Nws piav qhia ntev npaum li cas cov xov hlau nruab nrab ntawm txhua qhov khoom koj yuav xav tau (tsis txhob siv cov xov hlau ntev ntev ntxiv yog tias koj tau txais xaim hav zoov). (Yees duab)

Cov xov hlau txuas ntawm Arduino Nano thiab LED ntiv nplhaib nkaus xwb (3 xov hlau: liab 5V - 5V, dub GND - GND, xiav D6 - DI). Khiav LED ntiv tes ua haujlwm ntsuas los ntawm tshooj tom ntej. (Yees duab)

Yog tias txhua yam ua tau zoo txuas ntxiv nrog Gyro MPU6050 (5 xov hlau: liab 5V - VCC, dub GND - GND, xiav A4 - SDA, ntsuab A5 - SCL, daj D2 - INT). Rub tawm ColorCube.ino code thiab ntsuas (lwm yam khoom siv tsuas yog rau roj teeb thiab them nyiaj). (Yees duab)

Yog tias tag nrho OK ntxiv cov khoom seem. Tsuas muaj liab (+) thiab dub (-) xov hlau. Xaiv txoj cai pins ntawm tus kheej-khawm khawm (tsis txuas nrog thaum tsis nias). Kuaj kev ua haujlwm ntawm roj teeb thiab them roj teeb. (duab)

Liab LED teeb ntawm TP4056 thaum them nyiaj thiab xiav LED teeb thaum them tas. Lub qhov siab tshaj TP4056 hauv nruab nrab luam tawm ib feem dhau lub teeb ci LED mus rau sab saum toj ntawm ColorCube thiab koj tuaj yeem paub txog theem them nyiaj. (Yees duab)

Kauj ruam 5: Code

Ua ntej koj yuav tsum rub tawm cov tsev qiv ntawv tsim nyog.

Muaj cov lus qhia ntxaws rau Adafruit Neopixel lub tsev qiv ntawv:

LED ntiv tes ua haujlwm ntsuas: Koj tuaj yeem sim koj li Circuit Court los ntawm qhov piv txwv suav nrog hauv tsev qiv ntawv. Qhib cov ntawv los ntawm Cov Ntaub Ntawv/Piv Txwv/Adafruit NeoPixels/yooj yim thiab rub tawm (tsis txhob hnov qab teeb tsa txoj kab no kom raug los ntawm tus lej pixels koj siv: #define NUMPIXELS 16).

I2Cdev thiab MPU6050: Rub tawm thiab unzip i2cdevlib-master.zip cov ntaub ntawv los ntawm https://github.com/jrowberg/i2cdevlib. Luam daim ntawv unzipped folder i2cdevlib-master/Arduino ob lub subfolders: I2Cdev thiab MPU6050. Ob leeg theej rau Arduino IDE lub tsev qiv ntawv ntawv tais ceev tseg (Cov Ntaub Ntawv/Arduino/tsev qiv ntawv yog teeb tsa ua ntej).

Tsis txhob hnov qab rov pib dua Arduino IDE tom qab cov tsev qiv ntawv theej.

#include #ifdef _AVR_ #include // Yuav tsum tau rau 16 MHz Adafruit Trinket #endif #include "Wire.h" suav nrog "I2Cdev.h" #include "MPU6050_6Axis_MotionApps20.h" MPU6050 mpu; #define INTERRUPT_PIN 2 // siv tus pin 2 ntawm Arduino Uno & feem ntau cov laug cam #define PIN 6 #define NUMPIXELS 16 // Teeb tus lej raug ntawm LEDs Adafruit_NeoPixel pixels (NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); uint32_t activeColor, oldActiveColor = 0; bool dmpReady = tsis tseeb; uint8_t mpuIntStatus; uint8_t devStatus; uint16_t packetSize; uint16_t fifoCount; uint8_t fifoBuffer [64]; Quaternion q; VectorFloat lub ntiajteb txawj nqus; ntab rotace [3]; rau cov menyuam x, y, z; volatile bool mpuInterrupt = cuav; void dmpDataReady () {mpuInterrupt = tseeb; } tsis muaj teeb tsa teeb tsa () {Serial.begin (115200); pixels.begin (); pixels.clear (); pixels.setBrightness (128); #if txhais (_ AVR_ATtiny85_) && (F_CPU == 16000000) clock_prescale_set (clock_div_1); #endif // koom nrog I2C npav (I2Cdev tsev qiv ntawv tsis ua qhov no tau) #if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE Wire.begin (); Wire.setClock (400000); // 400kHz I2C moos. Tawm tswv yim kab ntawv no yog tias muaj teeb meem sau ua ke #elif I2CDEV_IMPLEMENTATION == I2CDEV_BUILTIN_FASTWIRE Fastwire:: teeb tsa (400, muaj tseeb); #endif thaum (! Serial); Serial.println (F ("Initializing I2C devices …")); mpu.initialize (); pinMode (INTERRUPT_PIN, INPUT); // txheeb xyuas kev sib txuas Serial.println (F ("Kuaj cov cuab yeej sib txuas …")); Serial.println (mpu.testConnection ()? F ("MPU6050 kev sib txuas ua tiav"): F ("MPU6050 kev sib txuas tsis tau tiav")); // tos kom npaj txhij // Serial.println (F ("\ n Xa ib lub cim los pib DMP lub cajmeem thiab ua qauv qhia:")); // thaum (Serial.available () && Serial.read ()); // khoob tsis // thaum (! Serial.available ()); // tos rau cov ntaub ntawv // thaum (Serial.available () && Serial.read ()); // khoob khoob dua // thauj khoom thiab teeb tsa DMP Serial.println (F ("Initializing DMP …")); devStatus = mpu.dmpInitialize (); // muab koj tus kheej gyro offsets ntawm no, ntsuas rau min rhiab heev mpu.setXGyroOffset (0); mpu.setYGyroOffset (0); mpu.setZGyroOffset (0); mpu.setZAccelOffset (1688); // 1688 lub hauv paus ua haujlwm rau kuv qhov kev sim nti // xyuas kom tseeb tias nws ua haujlwm (rov qab 0 yog li) yog (devStatus == 0) {// Lub Sijhawm Calibration: tsim offsets thiab ntsuas peb MPU6050 mpu. CalibrateAccel (6); mpu. CalibrateGyro (6); mpu. PrintActiveOffsets (); // qhib DMP, tam sim no nws tau npaj txhij Serial.println (F ("Enabling DMP …")); mpu.setDMPEnabled (muaj tseeb); // pab kom Arduino cuam tshuam kev txheeb xyuas Serial.print (F ("Pab kom cuam tshuam kev cuam tshuam (Arduino sab nraud cuam tshuam")); Serial.print (digitalPinToInterrupt (INTERRUPT_PIN)); Serial.println (F (") …")); attachInterrupt (digitalPinToInterrupt (INTERRUPT_PIN), dmpDataReady, RISING); mpuIntStatus = mpu.getIntStatus (); // teeb tsa peb DMP Npaj tus chij kom lub voj tseem ceeb () ua haujlwm paub nws tsis siv nws li Serial.println (F ("DMP npaj! Tos thawj qhov cuam tshuam …")); dmpReady = muaj tseeb; // tau txais kev cia siab DMP pob ntawv loj rau tom qab sib piv packetSize = mpu.dmpGetFIFOPacketSize (); } lwm {{ERROR! // 1 = thawj lub cim xeeb thauj khoom ua tsis tiav // 2 = DMP teeb tsa hloov tshiab tsis ua tiav // (yog tias nws yuav tawg, feem ntau cov cai yuav yog 1) Serial.print (F ("DMP Initialization Failed (code")); Serial. luam (devStatus); Serial.println (F (")")); }} void loop () {yog (! dmpReady) rov qab; yog (mpu.dmpGetCurrentFIFOPacket (fifoBuffer)) {// Tau txais cov pob ntawv kawg // tso saib Euler cov ces kaum hauv mpu.dmpGetQuaternion (& q, fifoBuffer); mpu.dmpGetGravity (& lub ntiajteb txawj nqus, & q); mpu.dmpGetYawPitchRoll (rotace, & q, & lub ntiajteb txawj nqus); } Serial.print ("X"); Serial.print (rotace [2] * 180/M_PI); Serial.print ("\ t Y"); Serial.print (rotace [1] * 180/M_PI); Serial.print ("\ t Z"); Serial.println (rotace [0] * 180/M_PI); x = rotace [2] * 180/M_PI; y = rotace [1] * 180/M_PI; z = rotace [0] * 180/M_PI; yog (abs (x) <45 && abs (y) 45 && abs (x) <135 && (abs (y) 135)) {activeColor = pixels. Color (255, 0, 0); // Liab thaum tig mus rau sab} lwm qhov yog (x <-45 && abs (x) <135 && (abs (y) 135)) {activeColor = pixels. Color (0, 255, 0); // Ntsuab thaum tig mus rau ob sab} lwm yog (y> 45 && abs (y) <135 && (abs (x) 135)) {activeColor = pixels. Color (255, 255, 0); // Daj thaum tig mus rau sab thib peb} yog tias (y <-45 && abs (y) <135 && (abs (x) 135)) {activeColor = pixels. Color (0, 0, 255); // Xiav thaum tig mus rau plaub sab} lwm yog (abs (y)> 135 && abs (x)> 135) {activeColor = pixels. Color (0, 0, 0); // Dub thaum upside down} yog (activeColor! = OldActiveColor) {pixels.clear (); pixels.fill (activeColor); pixels.show (); oldActiveColor = activeColor; }}

Thaum kawg koj tuaj yeem qhib thiab xa cov ntawv ColorCube.ino. Muab ColorCube ntawm lub tiaj tiaj thiab hloov nws. Tsis txhob txav nws kom txog thaum nws pib lub teeb nrog cov xim dawb tom qab ntsuas (ob peb feeb). Tom ntej no koj tuaj yeem tso ColorCube rau sab thiab xim yuav hloov - txhua sab nws muaj xim - liab, ntsuab, xiav, daj. ColorCube tawm mus thaum nws tig rov qab.

Kauj Ruam 6: assembling

Sib dhos
Sib dhos
Sib dhos
Sib dhos
Sib dhos
Sib dhos

Ua siab mos siab muag thaum sib dhos. Cov xov hlau thiab txhua ntu tsis nyiam tus cwj pwm ntxhib.

Khawm 3d luam tawm ib feem - maj mam muab khawm rau hauv lub qhov hauv qab luam tawm ib feem (raws li qhia hauv daim duab), nws yuav tsum nkag mus thiab tawm tau zoo, yog tias tsis siv rab riam los yog rab riam ntse lossis ntawv xuab zeb kom tshem tag nrho cov khoom seem (feem ntau sab hauv sab saum toj ntawm lub voj voos qhov hauv qab). (Yees duab)

Muab MPU-6050, Arduino Nano, TP4056 thiab MT3608 rau lawv qhov. Lub npov muaj qhov tawm hauv qab uas koj ntxig MPU-6050 thiab MT3608. Muab USB txuas ntawm Arduino Nano thiab TP4056 rau lawv lub qhov hauv sab phab ntsa ntawm lub thawv. (duab)

Siv 3d luam ntawv xauv txhawm rau txhim kho cov khoom siv (nco ntsoov tias txhua lub Cheebtsam tau tso rau hauv qab ib ntus kom nruj). Nws yog ib qho tseem ceeb vim tias qee leej yuav sim ua si nrog koj lub ColorCube ib yam li tsuav. (Yees duab)

Muab thiab ruaj ntseg roj teeb hauv nws lub qhov yog tias nws tsis tuav nruj.

Muab khawm khawm tus kheej rau hauv lub qhov npaj hauv qab ib feem. Kev kaw tus kheej lub pob yuav tsum nyob hauv txoj haujlwm ON (luv). Maj mam nias lub pob. Kuaj kev ua haujlwm nrog 3d luam ntawv khawm. (Duab)

Siv ob lub M2 ntsia hlau txhawm rau txhim kho LED Ntiv nplhaib rau nruab nrab luam ib feem. Nws yog qhov zoo los siv kev qhia ntawm lub nplhaib uas cov xov tooj sib txuas tau nyob hauv qhov sib npaug ntawm qhov nruab nrab luam tawm ib feem. (Duab)

Tsis teb los tau: Siv cov kua nplaum kub tso rau ntawm no thiab muaj - cov xov hlau txuas mus rau lub nplhaib, rau cov xov hlau ntev dhau, yog tias ib yam twg tsis nruj txaus thiab lwm yam.

Teem cov xov hlau sab hauv ntawm ColorCube kom tsis txhob pinched los ntawm cov ntawv luam tawm. Muab ib nrab mus rau ib qho hauv qab. Siv M3 hau ntswj los txhim kho nws. (duab)

Thaum kawg maj mam thawb sab sau rau ib sab hauv qab. (duab)

Kauj ruam 7: Ua tau

Nrog koj zoo siab. Muaj kev lom zem.

Pom zoo: