Cov txheej txheem:

Xim Hloov Hmo Teeb Siv Ardruino 101: 4 Cov Kauj Ruam (nrog Duab)
Xim Hloov Hmo Teeb Siv Ardruino 101: 4 Cov Kauj Ruam (nrog Duab)

Video: Xim Hloov Hmo Teeb Siv Ardruino 101: 4 Cov Kauj Ruam (nrog Duab)

Video: Xim Hloov Hmo Teeb Siv Ardruino 101: 4 Cov Kauj Ruam (nrog Duab)
Video: Dais thiab nab qa sib xeem tsheb kauj vab 2024, Kaum ib hlis
Anonim
Image
Image
Xim Hloov Hmo Teeb Siv Ardruino 101
Xim Hloov Hmo Teeb Siv Ardruino 101

Hauv txoj haujlwm no koj yuav ua lub teeb hmo ntuj siv ardruino, Adafruit neo rgb Strips thiab lub tshuab luam ntawv 3D.

Nco ntsoov tias qhov kev nkag siab no tsuas yog siv rau kuv txoj haujlwm hauv tsev kawm ntawv. Cov cai rau txoj haujlwm no yog ua los ntawm lwm qhov haujlwm. Nrog qhov hais tias kuv tsis yog tus kws tshaj lij thaum nws los txog rau Ardruino.

Kauj ruam 1: Yuav tsum tau ua

Yuav tsum muaj
Yuav tsum muaj
Yuav tsum muaj
Yuav tsum muaj
Yuav tsum muaj
Yuav tsum muaj

Txog qhov haujlwm no xav tau cov cuab yeej thiab cov cuab yeej hauv qab no

Kho vajtse:

1 - A ardruino101 (hauv Asmeskas) lossis Genuino101 (rau sab nraud Asmeskas).

2 - NeoPixel rgb coj ib daim hlab los ntawm adafruit (5 volt).

3 - A ardruino usb txuas (hom B rau A txuas).

4 - A software los ntawm Ardruino, Ardruino IDE Hauv qhov kev qhia no peb xav siv 1.8.5 version. Cov tsev qiv ntawv xav tau software yog: 101, Adafruit NeoPixel thiab Madgwick.

5 -Txhua yam khoom siv los kho koj lub cuab yeej. Hauv qhov no kuv yuav siv lub tshuab luam ntawv 3D. Cov ntaub ntawv rau 3D luam ntawv no nyob hauv cov lus piav qhia hu ua "Lub Taub Hau Teeb". Nco ntsoov tias hom ntawv no tsis yog 3D luam npaj txhij. Nyob ntawm koj lub tshuab luam ntawv 3D koj yuav tsum xub ua tus tsim 3d luam software ntawm cov khoom 3D ua ntej. Qee zaum qhov ntsuas ntawm 3D luam ntawv yuav rov pib dua. yog li ua kom ntseeg tau tias txoj kab uas hla tau teev rau 11 cm los ntawm 11 cm.

6 - Cov khoom siv yooj yim soldering.

Kauj Ruam 2: Nkag Siab Hardware thiab Software

Ardruin/Genuino101

Tsuas yog los piav qhia Ardruino101 thiab genuino101 yog qhov zoo ib yam ib sab ntawm cov npe. Ob leeg muaj qhov tshwj xeeb tshwj xeeb thiab siv tib lub software.

Ardruino101 muaj cov kev qhia tshwj xeeb zoo li ardruino UNO thiab ntau dua. Lub ntsiab tseem ceeb ntawm ardruino101 yog lub ntsuas cua thiab ntsuas lub ntsej muag uas peb xav tau siv hauv peb txoj haujlwm. Tsis tas li no hom ardruino muaj nws lub tsev qiv ntawv tshwj xeeb hu ua CurrieIMU (Kev ntsuas sab hauv) uas suav nrog hauv lub tsev qiv ntawv txuas ntxiv 101.

Nrog qhov hais ntawd cia tham txog software.

Software thiab tsev qiv ntawv

Ardruino IDE siv nab hab sej raws li nws yog lub hauv paus tseem ceeb. nws tseem yog tus lej tseem ceeb platvorm qhov twg feem ntau ardruino sau. Muaj ntau ntau cov kev qhia hauv online yuav siv lub software no li cas kuv thiaj pom zoo koj tshawb fawb thawj zaug yog tias koj yog tus tshiab rau txoj haujlwm no.

Nrog qhov hais tias cov tsev qiv ntawv peb siv yog cov hauv qab no:

Los ntawm cov ntawv qhia zaub mov Sketch,> suav nrog Lub Tsev Qiv Ntawv> Tswj Tsev Qiv Ntawv … Hauv cov ntawv nkag lub npov ntaus hauv

- 101 Ntawm qhov zoo tshaj plaws ardruino 101 tsis suav nrog rau hauv ardruino IDE. Peb xav tau lub tsev qiv ntawv txuas ntxiv no txhawm rau txhawm rau cim peb hom ardruino.

-Adafruit NeoPixel txhawm rau txhawm rau cim peb Neo pixel strips.

-Madgwick Txhawm rau nyeem cov ntaub ntawv nyoos thiab suav cov ntaub ntawv no rau raw, suab thiab yob.

Neo RGB strips

Hom kuv xav siv yog 5 voltage lossis 5v type. Nrog rau 5v no kuv tsis xav tau lub zog txuas ntxiv los tswj kuv cov kab. Hloov chaw kuv xav siv kuv li ardruino ua lub zog siv los tswj thiab teeb lub strips.

Nov yog qee cov lus qhia koj yuav tsum paub ua ntej koj pib ntawm cov kab no.

Ua ntej koj yuav xav tau Neodigital RGB coj kab txaij los ntawm adafruit. Cov kab ntawv no yog cotrolable siv cov lej. Tom ntej no koj yuav tsum paub yog tias muaj sab nraub qaum thiab sab xub ntiag ntawm cov kab no. Lub nraub qaum thiab sab xub ntiag no tseem ceeb heev rau cov laug. Xyuas kom tseeb tias koj muab cov laug tso rau sab xub ntiag qhov twg tus yuam sij xub taw tawm ntawm qhov taub.

Nov yog phau ntawv qhia yuav siv lawv li cas.

Muaj 3 tus lej taw tes koj yuav tsum nco ntsoov Kev sib txuas hauv av (GND), Kev txuas hluav taws xob (V) thiab Pin txuas (DIN).

Kauj Ruam 3: Teeb Cov Cheebtsam

Teeb Cov Cheebtsam
Teeb Cov Cheebtsam
Teeb Cov Cheebtsam
Teeb Cov Cheebtsam
Teeb Cov Cheebtsam
Teeb Cov Cheebtsam

Ua ntej koj yuav xav tau 3d luam tawm cov khoom uas koj tuaj yeem pom hauv qhov xav tau. Hauv qhov no kuv xav siv PLA. Nco ntsoov tias txoj kab uas hla ntawm qhov khoom loj yog 11cm txog 11cm. Qhov no yuav ua kom ntseeg tau tias ardruino thiab cov hlua yuav haum rau hauv shpere. Nco ntsoov tias txhua lub tshuab luam ntawv 3D siv difrent softwares los xam nws cov txheej txheem luam ntawv. Nrog qhov hais tias cov ntaub ntawv koj siv yuav raug ntsuas sib txawv yog li nco ntsoov qhov ntawd.

Thib ob tom qab luam tawm kom ntseeg tau tias cov khoom tuaj yeem kaw tau. Cov 3D luam tawm ua ke ua ib tus kheej. Lawv yuav tsum haum zoo. Yog hais tias lub componten yuav plam ces tshaj tawm ib co kab xev rau sab hauv sab kom lub hau puv. Thiab yog tias nws yog tuab siv cov ntawv txhuam.

Qhov thib peb skematichs rau ardruino thiab cov kab txaij yog yooj yim haum. Koj yuav tau siv 3 xaim txuas cov kab xev rau ardruino. Nco ntsoov tias tsuas yog cov chaw kuv tau siv kab laug sab nyob ntawm kab ntawv. tsis nyob ntawm Ardruino nws tus kheej.

GND mus rau GND

DIN mus rau Tus Pin (hauv peb kis pin6 ntawm ardruino)

5V mus rau 5V

Xyuas kom tseeb tias tus lej ntawm cov hlua uas koj siv yog lub hau ntawm 30. Tsis tas li ntawd ces thiab nws yuav tsis ua kom raug cai. Koj tuaj yeem yooj yim txiav ntawm ib qho uas tsis muaj kab txaij tso tawm nrog lub cim txiab.

Plaub Qhov Evrything yuav tsum haum zoo hauv tus kheej. Koj tuaj yeem zoo li kuv tau ua kev sib tshuam nruab nrab ntawm 1 ntawm 3d luam ntawv txhawm rau pom lub qhov nqaj thiab tso lub pom yas yas rau saum.

Kauj ruam 4: Coding

Yog li tam sim no koj yuav tsum muaj tag nrho cov khoom siv xav tau hauv koj lub tsev qiv ntawv.

Nov yog tus lej koj xav tau txhawm rau txhawm rau ua haujlwm. Qhov tshwm sim yuav tsum zoo li qhov txuas video uas kuv xa hauv nplooj ntawv no.

Lub hauv paus ntawm txoj cai no tuaj yeem pom ntawm no. Txoj haujlwm no tseem suav nrog cov kauj ruam tsis tu ncua txhawm rau txhawm rau nkag siab cov cai thiab algaritme tom qab siv.

#include #include #include #include

#define PIN 6 // 11 pixels NeoPixel Sawb

#define PIN1 7 // 1 pixel NeoPixel Sawb #define NUMPIXELS 30 // Tus lej ntawm píxels #define SAMPLE_RATE 25 // Kev ntsuas tus qauv rau kev ntsuas thiab ntsuas lub ntsej muag

// Madgwick teeb tsa

Madgwick lim; unsigned ntev microsPerReading, microsPrevious; ntab accelScale, gyroScale;

// NeoPixel teeb tsa

Adafruit_NeoPixel pixels = Adafruit_NeoPixel (NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); Adafruit_NeoPixel pixelsStatus = Adafruit_NeoPixel (1, 7, NEO_GRB + NEO_KHZ800);

// Xim qhov chaw

RGBConverter rgbConverter; ob h = 1; ob s = 1; ob v = 1; byte rgb [3];

// Teeb Meem Teeb Teeb

// Xeev 0 -> Xaiv Hue -Pitch // Xeev 1 -> Xaiv Saturation -Roll // Xeev 2 -> Xaiv Tus Nqi -Yaw // Xeev 3 -> Txhim kho xim tsis hloov pauv raws li statusLamp = 0;

void teeb tsa () {

Serial.begin (9600);

// pib IMU thiab lim

CurieIMU.begin (); CurieIMU.setGyroRate (SAMPLE_RATE); CurieIMU.setAccelerometerRate (SAMPLE_RATE); filter.begin (SAMPLE_RATE);

// Teeb tsa qhov ntsuas qhov ntsuas mus rau 2G

CurieIMU.setAccelerometerRange (2); // Teem lub gyroscope ntau txog 250 degrees/thib ob CurieIMU.setGyroRange (250);

CurieIMU.autoCalibrateAccelerometerOffset (X_AXIS, 0);

CurieIMU.autoCalibrateAccelerometerOffset (Y_AXIS, 0); CurieIMU.autoCalibrateAccelerometerOffset (Z_AXIS, 1); CurieIMU.autoCalibrateGyroOffset ();

CurieIMU.attachInterrupt (eventCallback);

CurieIMU.setDetectionThreshold (CURIE_IMU_TAP, 950); CurieIMU. cuam tshuam (CURIE_IMU_TAP);

// pib qhov hloov pauv kom hloov kho tshiab kom raug tus nqi

microsPerReading = 1000000 / SAMPLE_RATE; microsPrevious = micros ();

// Pib NeoPixel 11

pixels.begin (); pixels.show ();

// Pib NeoPixel 1

pixelsStatus.begin (); pixels.show ();

// Qhia xwm txheej hauv px

setStatusPixel (teeb tsa teeb); }

void voj () {

koj aix, aiy, aiz; // accelerometer int gix, giy, giz; ntab ax, ay, az; ntab gx, gy, gz; ntab ntab, suab, yaw; zoo li qub tsis tau kos npe ntev microsNow;

// kos yog nws yog lub sijhawm los nyeem cov ntaub ntawv thiab hloov kho lub lim

microsNow = micros (); yog (microsNow - microsPrevious> = microsPerReading) {

// nyeem cov ntaub ntawv nyoos los ntawm CurieIMU

CurieIMU.readMotionSensor (aix, aiy, aiz, gix, giy, giz, giz);

// hloov pauv los ntawm cov ntaub ntawv raw mus rau lub ntiajteb txawj nqus thiab qib/chav nyob thib ob

taus = convertRawAcceleration (aix); ay = convertRawAcceleration (aiy); az = convertRawAcceleration (aws); gx = convertRawGyro (gix); gy = convertRawGyro (giy); gz = convertRawGyro (txz);

// hloov kho lub lim, uas suav cov kev taw qhia

lim.updateIMU (gx, gy, gz, ax, ay, az);

// luam tawm lub ncauj lus, suab thiab yob

yob = filter.getRoll (); suab = filter.getPitch (); yaw = filter.getYaw ();

// nce lub sijhawm dhau los, yog li peb ua kom nrawm

microsPrevious = microsPrevious + microsPerReading;

// Tsuas yog hloov Hue, Saturation lossis Value

yog (statusLamp xaiv Hue yog (suab>> -90 && suab <= 90 && statusLamp == 0) {// Hloov lub suab kaum = suab + 90; // Tau txais cov xim sib txuas los ntawm cov ces kaum h = suab / 180.0;}

// Cov txwv txwv

// yob nkaus xwb -90º txog 90º = 180º // Xeev 1 -> xaiv Saturation yog (yob> = -90 && yob <= 90 && statusLamp == 1) {// Hloov lub kaum yob = yob + 90; // Tau txais cov xim xim los ntawm cov ces kaum s = yob / 180.0; }

// Xeev 2 -> xaiv Tus Nqi

if (statusLamp == 2) {// yaw 0º to 360º v = yaw / 360.0; }

Hloov mus rau rgb

rgbConverter.hsvToRgb (h, s, v, rgb); /* Serial.print ("Xim:"); Serial.print (h); Serial.print (" -"); Serial.print (s); Serial.print (" -"); Serial.print (v); Serial.println ("");

Serial.print ("Kev taw qhia:");

Serial.print (yaw); Serial.print (""); Serial.print (suab); Serial.print (""); Serial.println (yob); */

// Hloov xim ntawm pixels

rau (int px = 0; px <NUMPIXELS; px ++) {pixels.setPixelColor (px, pixels. Color (rgb [0], rgb [1], rgb [2])); pixels.show (); }}

// Qhia xwm txheej hauv px

setStatusPixel (teeb tsa teeb); }}

ntab convertRawAcceleration (int aRaw) {

// txij li peb tab tom siv 2G ntau yam // -2g daim duab qhia chaw rau tus nqi nyoos ntawm -32768 // +2g daim duab qhia chaw rau tus nqi nyoos ntawm 32767

ntab a = (aRaw * 2.0) / 32768.0;

rov qab a; }

ntab convertRawGyro (int gRaw) {

// txij li peb tau siv 250 degrees/vib nas this // -250 daim duab qhia chaw rau tus nqi nyoos ntawm -32768 // +250 daim duab qhia chaw rau tus nqi nyoos ntawm 32767

ntab g = (gRaw * 250.0) / 32768.0;

rov g; }

zoo li qub tsis muaj dab tsi eventCallback ()

{// Tshawb nrhiav kais hauv txhua lub axis yog (CurieIMU.getInterruptStatus (CURIE_IMU_TAP)) {Serial.print ("Kais kuaj pom lub teeb:"); Serial.println (xwm txheej teeb);

// Hloov lub xeev

statusLamp ++;

// Thawj lub xeev

yog (statusLamp> 3) {statusLamp = 0; }}}

void setStatusPixel (int statusPx)

{hloov (statusPx) {rooj plaub 0: pixelsStatus.setPixelColor (0, pixelsStatus. Color (150, 0, 0))); pixelsStatus.show (); tawg; rooj plaub 1: pixelsStatus.setPixelColor (0, pixelsStatus. Color (0, 150, 0)); pixelsStatus.show (); tawg; rooj plaub 2: pixelsStatus.setPixelColor (0, pixelsStatus. Color (0, 0, 150)); pixelsStatus.show (); tawg; rooj plaub 3: pixelsStatus.setPixelColor (0, pixelsStatus. Color (0, 0, 0)); pixelsStatus.show (); tawg;

}

}

Pom zoo: