中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. "); //-->

        博客專欄

        EEPW首頁(yè) > 博客 > DIY Arduino萬(wàn)向節(jié)|自穩(wěn)平臺(tái)

        DIY Arduino萬(wàn)向節(jié)|自穩(wěn)平臺(tái)

        發(fā)布人:電子資料庫(kù) 時(shí)間:2023-03-19 來(lái)源:工程師 發(fā)布文章

        在本教程中,我們將學(xué)習(xí)如何建立一個(gè)Arduino萬(wàn)向節(jié)或一個(gè)帶有伺服電機(jī)的自穩(wěn)定平臺(tái)。本教程實(shí)際上是先前關(guān)于 .

        概述

        我用三維建模軟件設(shè)計(jì)了萬(wàn)向節(jié)。它由3臺(tái)MG996R伺服電機(jī)組成,用于3軸控制,以及MPU6050傳感器、Arduino和電池的底座。


        您可以在以下位置找到并下載此三維模型以及用于三維打印的STL文件:

        使用我的,我3D打印了所有的部件,它們都非常完美。


        裝配

        組裝萬(wàn)向節(jié)很容易。我從安裝偏航伺服開(kāi)始。我用M3螺栓和螺母把它固定在底座上。


        下一步,我用同樣的方法固定了滾動(dòng)伺服。這些零件是專門設(shè)計(jì)的,以方便安裝MG996R伺服系統(tǒng)。


        為了將零件相互連接,我使用了圓喇叭,它作為伺服系統(tǒng)的附件。


        首先,我們需要用兩個(gè)螺栓將圓喇叭固定在底座上,然后用另一個(gè)螺栓將其連接到之前的伺服系統(tǒng)上。


        我重復(fù)了這個(gè)過(guò)程,組裝其余的組件,變槳伺服和頂部平臺(tái)。


        下一步,我通過(guò)伺服線通過(guò)支架的開(kāi)口,以保持他們的組織。然后我插入MPU6050傳感器,用螺栓和螺母將其固定在底座上。


        為了給這個(gè)項(xiàng)目供電,我用了2節(jié)鋰離子電池,我把它們放在這個(gè)電池架上。我用兩個(gè)螺栓和螺母把電池座固定在底座上。


        2節(jié)鋰離子電池將產(chǎn)生約7.4V的電壓,但我們需要5伏的電壓來(lái)為Arduino和伺服系統(tǒng)供電。


        這就是為什么我使用了一個(gè)降壓轉(zhuǎn)換器,將7.4伏轉(zhuǎn)換為5伏。

        Arduino萬(wàn)向節(jié)電路圖

        現(xiàn)在剩下的,就是把一切聯(lián)系起來(lái)。這里的電路圖和所有的電路圖都需要連接起來(lái)。


        您可以從以下鏈接獲取本Arduino教程所需的組件:

        MPU6050 IMU

        MG996R伺服

        降壓轉(zhuǎn)換器

        Arduino Uno

        試驗(yàn)板和跨接導(dǎo)線

        最后,我把電子元件和電線壓入底座,用底部的蓋子蓋住它們。


        有了這個(gè),自平衡平臺(tái)或Arduino萬(wàn)向節(jié)就完成了,它的工作和預(yù)期一樣好。剩下的就是看看程序。


        Arduino代碼

        本例中的Arduino代碼是對(duì)MPU6050 U DMP6示例的修改 .

        代碼說(shuō)明:所以,我們使用輸出可讀的偏航,俯仰和橫搖。

        // Get Yaw, Pitch and Roll values

        #ifdef OUTPUT_READABLE_YAWPITCHROLL

        mpu.dmpGetQuaternion(&q, fifoBuffer);

        mpu.dmpGetGravity(&gravity, &q);

        mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);

        // Yaw, Pitch, Roll values - Radians to degrees

        ypr[0] = ypr[0] * 180 / M_PI;

        ypr[1] = ypr[1] * 180 / M_PI;

        ypr[2] = ypr[2] * 180 / M_PI;

        // Skip 300 readings (self-calibration process)

        if (j <= 300) {

        correct = ypr[0]; // Yaw starts at random value, so we capture last value after 300 readings

        j++;

        }

        // After 300 readings

        else {

        ypr[0] = ypr[0] - correct; // Set the Yaw to 0 deg - subtract the last random Yaw value from the currrent value to make the Yaw 0 degrees

        // Map the values of the MPU6050 sensor from -90 to 90 to values suatable for the servo control from 0 to 180

        int servo0Value = map(ypr[0], -90, 90, 0, 180);

        int servo1Value = map(ypr[1], -90, 90, 0, 180);

        int servo2Value = map(ypr[2], -90, 90, 180, 0);

        // Control the servos according to the MPU6050 orientation

        servo0.write(servo0Value);

        servo1.write(servo1Value);

        servo2.write(servo2Value);

        }

        #endif

        一旦我們得到這些值,首先我們把它們從弧度轉(zhuǎn)換成度。

        // Yaw, Pitch, Roll values - Radians to degrees

        ypr[0] = ypr[0] * 180 / M_PI;

        ypr[1] = ypr[1] * 180 / M_PI;

        ypr[2] = ypr[2] * 180 / M_PI;

        然后我們等待或讀取300個(gè)讀數(shù),因?yàn)樵诖似陂g傳感器仍處于自校準(zhǔn)過(guò)程中。另外,我們捕捉偏航值,它在開(kāi)始時(shí)不像俯仰和橫搖值為0,而是總是一些隨機(jī)值。

        // Skip 300 readings (self-calibration process)

        if (j <= 300) {

        correct = ypr[0]; // Yaw starts at random value, so we capture last value after 300 readings

        j++;

        }

        在300個(gè)讀數(shù)之后,首先我們通過(guò)減去上面捕獲的隨機(jī)值將偏航設(shè)置為0。然后我們將偏航、俯仰和橫搖的值從-90度映射到0到180度,這些值用于驅(qū)動(dòng)伺服系統(tǒng)。

        // After 300 readings

        else {

        ypr[0] = ypr[0] - correct; // Set the Yaw to 0 deg - subtract the last random Yaw value from the currrent value to make the Yaw 0 degrees

        // Map the values of the MPU6050 sensor from -90 to 90 to values suatable for the servo control from 0 to 180

        int servo0Value = map(ypr[0], -90, 90, 0, 180);

        int servo1Value = map(ypr[1], -90, 90, 0, 180);

        int servo2Value = map(ypr[2], -90, 90, 180, 0);

        // Control the servos according to the MPU6050 orientation

        servo0.write(servo0Value);

        servo1.write(servo1Value);

        servo2.write(servo2Value);

        }

        最后利用寫函數(shù),把這些值作為控制信號(hào)發(fā)送給伺服系統(tǒng)。當(dāng)然,你可以禁用偏航伺服,如果你只想穩(wěn)定的X和Y軸,并使用這個(gè)平臺(tái)作為相機(jī)常平架。

        請(qǐng)注意這遠(yuǎn)不是好的相機(jī)萬(wàn)向節(jié)。運(yùn)動(dòng)不平穩(wěn),因?yàn)檫@些伺服不是為了這樣的目的。真正的相機(jī)萬(wàn)向節(jié)使用一種特殊類型的為了獲得流暢的動(dòng)作。所以,考慮這個(gè)項(xiàng)目只是為了教育目的。


        *博客內(nèi)容為網(wǎng)友個(gè)人發(fā)布,僅代表博主個(gè)人觀點(diǎn),如有侵權(quán)請(qǐng)聯(lián)系工作人員刪除。



        關(guān)鍵詞: 自穩(wěn) 平臺(tái)

        相關(guān)推薦

        技術(shù)專區(qū)

        關(guān)閉