在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

電子發燒友App

硬聲App

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示
電子發燒友網>電子資料下載>電子資料>用于Arduino的BGT60雷達傳感器

用于Arduino的BGT60雷達傳感器

2022-10-26 | zip | 0.02 MB | 次下載 | 免費

資料介紹

描述

在本教程結束時,您將能夠檢測運動及其方向,并根據檢測到的運動觸發中斷。

BGT60LTR11AIP 防護罩

我們的防護罩使用 60GHz 雷達技術來檢測 7m 范圍內的運動及其方向。它提供僅 20x6.25mm 的小尺寸和低功耗,為許多應用創造了創新、直觀的傳感功能。小型運動傳感器集成天線并在內部處理原始雷達信號,無需任何外部微控制器即可操作設備。

pYYBAGNX-4qAMWG-AADDij3Ub4o746.png
雷達 BGT60 引腳分配
?

僅使用四個引腳就可以非常輕松地與防護罩連接:

  • 接地
  • 輸入電壓 (1.5V - 5V)
  • P out (= 運動方向)
  • T out (= 運動檢測)

帶有 GND 和 Vin(1.5V 至 5V)的電源可以連接到微控制器引腳 Vcc 和 GND。相位檢測輸出 (P out) 引腳表示方向,而目標檢測輸出 (T out) 引腳表示雷達傳感器檢測到的運動。BGT60 可以輕松插入 Arduino MKR1000 板的接頭(Vcc、GND、T out - A1 和 P out - A2)

?

用于 Arduino 的英飛凌 60GHz 庫

我們為 60GHz 雷達屏蔽開發的庫稱為“radar-bgt60”。使用 Arduino IDE,通過 Sketch -> Include library -> Library Manager 安裝 Radar 庫。雷達庫包括八個基本 API 函數,我們稍后會在各種示例中使用它們。

  • Bgt60() - Arduino Bgt60 對象的構造函數
  • ~Bgt60() - Arduino Bgt60 對象的析構函數
  • init() - 初始化 Bgt60 類對象
  • deinit() - 取消初始化 Bgt60 類對象
  • getMotion() - 讀出目標檢測引腳
  • getDirection() - 讀出相位檢測引腳
  • enableInterrupt() - 啟用硬件中斷
  • disableInterrupt() - 禁用硬件中斷

在我們的Arduino API 描述中找到更多詳細信息

要將草圖上傳到您的板上,您必須先選擇所需的平臺。在此示例中,我們使用 Arduino MKR1000 板。轉到工具 -> 董事會 -> 董事會經理。在那里你搜索你的“Arduino MKR1000”,你會找到需要安裝的包“Arduino SAMD Boards”。

poYBAGNX-5CAb4z7AABrXgGLvb8234.png
?

為了現在上傳草圖,您還必須選擇正確的 COM 端口有一個非常簡單的方法可以做到這一點。拔下連接的 Arduino,然后檢查Tool -> Port下可用的 COM-Ports 現在連接您的 Arduino 并再次檢查端口。現在你應該看到一個新的,以前沒有的。這是正確的,請選擇它。

運動

在第一個簡單示例中,我們想使用 getMotion() 函數來識別傳感器環境中的運動。從文件 -> 示例 -> 雷達-bgt60 -> 運動檢測中獲取代碼。

/*!
 * \name        motionDetection
 * \author      Infineon Technologies AG
 * \copyright   2021 Infineon Technologies AG
 * \brief       This example detects the motion of an object
 * \details     This example demonstrates how to detect a moving object while the
 *              BGT60LTR11AIP shield is connected to Arduino compatible
 *              boards using polling method.
 *
 *              Connection details:
 *              --------------------------------------------------
 *              Pin on shield   Connected to pin on Arduino
 *              --------------------------------------------------
 *              TD                  depends on Arduino board
 *              PD                  depends on Arduino board
 *              GND                 GND
 *              Vin                 VCC (3.3V or 5V - depends on Arduino board)
 *              --------------------------------------------------
 *
 *              Decoding on-board LED output of BGT60LTR11AIP shield:
 * 
 *              - Red LED indicates the output of direction of motion once target is detected (PD)
 *              ---------------------------------------------
 *              LED    State    Output explanation
 *              ---------------------------------------------
 *              Red     ON       Departing target
 *                      OFF      Approaching target
 *              ---------------------------------------------
 *
 *              - Green LED indicates the output of target in motion detection (TD)
 *              ---------------------------------------------
 *              LED    State    Output explanation
 *              ---------------------------------------------
 *              Green    ON       Moving target detected
 *                       OFF      No target detected
 *              ---------------------------------------------
 *
 * SPDX-License-Identifier: MIT
 */

#include 
/* Include library main header */
#include 
/* Include Arduino platform header */
#include 

/*
* In case no supported platform is defined, the
* PD and TD pin will be set to the values below.
*/
#ifndef TD
#define TD  15
#endif

#ifndef PD
#define PD  16
#endif

/* Create radar object with following arguments:
 *  TD : Target Detect Pin
 *  PD : Phase Detect Pin */
Bgt60Ino radarShield(TD, PD);

/* Begin setup function - takes care of initializations and executes only once post reset */
void setup()
{
    /* Set the baud rate for sending messages to the serial monitor */
    Serial.begin(9600);
    // Configures the GPIO pins to input mode
    Error_t init_status = radarShield.init();
    /* Check if the initialization was successful */
    if (OK != init_status) {
        Serial.println("Init failed.");
    }
    else {
        Serial.println("Init successful.");
    }
}

/* Begin loop function - this part of code is executed continuously until external termination */
void loop()
{
    /* Initialize the variable to NO_MOTION to be able to record new events */
    Bgt60::Motion_t motion = Bgt60::NO_MOTION;

   /* The getMotion() API does two things:
        1. Returns the success or failure to detect moving object as a message of type Error_t.
           Any value other than OK indicates failure
        2. Sets recent event in "motion" variable. Events can be: NO_MOTION or MOTION */
    Error_t err = radarShield.getMotion(motion);

    /* Check if API execution is successful */
    if(err == OK)
    {
        /* Cases based on value set in motion variable */
        switch (motion)
        {
            /* Variable "motion" is set to MOTION when moving target is detected */
            case Bgt60::MOTION:
                Serial.println("Target in motion detected!");
                break;
            /*  Variable "motion" is set to NO_MOTION when moving target is not present */
            case Bgt60::NO_MOTION:
                Serial.println("No target in motion detected.");
                break;
        }
    }
    /*  API execution returned error */
    else {
        Serial.println("Error occurred!");
    }

    /* Reducing the frequency of the measurements */
    delay(500);
}

沒有注釋,代碼只有 50 行。在我們逐步討論之后,我們將上傳示例。

#include 
#include 
#include 

首先,我們包含了來自 Arduino 的主庫和用于 BGT60 雷達傳感器的庫。

#ifndef TD
#define TD  15
#endif

#ifndef PD
#define PD  16
#endif

Bgt60Ino radarShield(TD, PD);

if 條件檢查是否定義了 TD 和 PD。它們代表我們的引腳相位檢測和硬件的目標檢測。在我們的例子中,它們已經設置好了,因為我們之前定義了支持的平臺 Arduino MKR1000。如果我們選擇另一個微控制器(不是來自 Arduino),這一步是指定未知引腳的必要步驟。行“Bgt60Ino radarShield(TD, PD);” 使用教練用兩個針創建一個雷達對象。

void setup()
{
    Serial.begin(9600);
    // Configures the GPIO pins to input mode
    Error_t init_status = radarShield.init();
    if (OK != init_status) {
        Serial.println("Init failed.");
    }
    else {
        Serial.println("Init successful.");
    }
}

在函數“setup”中是我們程序的初始化。當我們上傳草圖時它只執行一次。“Serial.begin()”函數設置波特率,它定義了向監視器發送消息的傳輸速度。現在我們使用庫的 API 函數之一“intit()”來初始化之前的 Bgt60 類對象“radarShield”。因此,引腳將設置為輸入模式。如果初始化成功,函數返回“OK”。為了以用戶身份查看初始化是否有效,我們打印 init 函數的結果。

void loop()
{
    Bgt60::Motion_t motion = Bgt60::NO_MOTION;

    Error_t err = radarShield.getMotion(motion);

“loop()”函數是代碼的一部分,它一遍又一遍地重復。首先,我們拒絕變量“運動”以保存檢測到的運動。有兩種可能的狀態。一開始我們將其設置為“Bgt60::NO_MOTION”。

在下一行中,我們在“radarShield”對象上使用函數“getMotion()”。該函數的傳遞參數是運動變量。當傳感器檢測到運動時,該函數將變量設置為“Bgt60::MOTION” . 如果整個函數成功,“OK”將保存在“Error_t”變量中。

if(err == OK)
    {
        switch (motion)
        {
            case Bgt60::MOTION:
                Serial.println("Target in motion detected!");
                break;
            case Bgt60::NO_MOTION:
                Serial.println("No target in motion detected.");
                break;
        }
    }
    else {
        Serial.println("Error occurred!");
    }
    delay(500);
}

在最后一部分,我們檢查函數是否成功。在這種情況下,如果變量“motion”是“Bgt60::MOTION”或“Bgt60::NO_MOTION”,我們將啟動 switch case 條件并打印解決方案。最后我們開始一個延遲,它代表兩個循環段落之間的暫停。

pYYBAGNX-5KATxMyAAA2UShhZ2U458.png
工具欄
?

現在我們了解了整個代碼并準備上傳它。如果到目前為止還沒有完成,您可以編譯按鈕 1 上的代碼。使用 2 將草圖上傳到板上。要查看我們打印的內容以及傳感器是否檢測到運動,您必須在 3 上打開顯示器。

當周圍的一切完全靜止時,您可以在監視器上讀取“未檢測到運動中的目標”。但是,如果您在距離傳感器 5 米的范圍內有運動,您的輸出就是“檢測到運動中的目標!”。

方向

在成功檢測到運動之后,我們還想知道這個運動的方向。因此,庫、對象創建和設置功能完全相同。

Bgt60::Direction_t direction = Bgt60::NO_DIR;

Error_t err = radarShield.getDirection(direction);

循環中的代碼也和之前類似,但現在我們為方向做。首先我們需要一個變量來存儲方向。其次,我們使用 API 函數“getDirection()”。

if (err == OK)
{
    switch (direction)
    {
        case Bgt60::APPROACHING:
            Serial.println("Target is approaching!");
            break;
        case Bgt60::DEPARTING:
            Serial.println("Target is departing!");
            break;
        case Bgt60::NO_DIR:
            Serial.println("Direction cannot be determined since no motion was detected!");
            break;
    }
}
else{
Serial.println("Error occurred!");
}

方向變量有三種可能的狀態。我們有兩個不同的方向:接近和離開。也有可能,我們根本沒有運動,因此沒有方向。如果 API 函數有效,它會為錯誤變量返回“O??K”。只有當它成功時,我們才會開始一個 switch-case 條件,我們在離開、接近和無方向之間做出決定。每次延遲后都會打印當前狀態。

poYBAGNX-5WAKQuSAACR9Lzzthw603.png
可能的監視器輸出方向檢測
?

可能的監視器輸出在上圖中。要創建它,您首先將手移向傳感器,然后再移開。

打斷

作為最后一個例子,讓我們展示如何使用中斷功能。當您啟用中斷時,處理器會停止其當前活動并保存其狀態。相反,它同時執行一個稱為中斷服務程序 (ISR) 的功能。在我們的示例中,當檢測到的運動或方向的狀態發生變化時會觸發中斷。因此,代碼中的庫和對象創建仍然與上兩個示例中的相同。

init_status = radarShield.enableInterrupt(cBackFunct);

if (OK != init_status)
    Serial.println("Interrupt init failed.");
else
    Serial.println("Interrupt init successful.");
}

在 setup 函數中,我們像以前一樣設置波特率并初始化我們的對象。此外,我們現在激活中斷。函數“enableInterrupt()”打開硬件中斷。“cBackFunct”函數從中斷開始。此外,我們得到一個狀態變量,我們可以使用它檢查啟用中斷的 API 函數是否有效。

/* Definition and initialization of the interrupt active flag */
volatile static bool intActive = false;

/* User defined callback function */
void cBackFunct(void)
{
    if ( ! intActive ) {

        /* Set the interrupt active flag to avoid parallel execution of this function multiple times. */
        intActive = true;

        /* Create variables to store the state of the motion as well as the direction */
        Bgt60::Motion_t motion = Bgt60::NO_MOTION;
        Bgt60::Direction_t direction = Bgt60::NO_DIR;

        /* Now check what happend, first check if a motion was detected or is
not detected anymore */
        Error_t err = radarShield.getMotion(motion);

        /* Check if API execution is successful */
        if(OK == err)
        {
            /* In case motion is detected */
            if(Bgt60::MOTION == motion){
                Serial.println("Target in motion was detected!");

                /* Check the direction of the detected motion */
                err = radarShield.getDirection(direction);
                if(OK == err)
                {
                    /* In case the target is approaching */
                    if(Bgt60::APPROACHING == direction){
                        Serial.println("The target is approaching!");
                    }
                    /* In case the target is departing */
                    else{
                        Serial.println("The target is departing!");
                    }
                }
            /* API execution returned error */
            else{
                Serial.println("Error has occurred during the determination of the direction!");
            }
        }
        /* No motion is detected */
        else{
            Serial.println("No target in motion detected!");
        }
    }
    /* API execution returned errord */
    else {
        Serial.println("Error has occurred during the determination of the direction!");
    }

    Serial.println("\n--------------------------------------\n");

    /* Release the interrupt active flag to allow a new call of this callback function. */
    intActive = false;
    }
}

“cBackFunct”代表中斷服務程序(ISR)。我們將它寫在 setup 函數之前的單獨函數中。還。我們有一個局部變量,它是中斷的活動標志。因此,它在 ISR 開始時設置為活動,在函數結束時設置為非活動。為避免多次并行執行此函數,“cBackFunct”檢查活動標志之前是否處于非活動狀態。該函數中的其他所有內容都類似于方向檢測。我們首先使用已知函數來檢查運動,然后分離運動的兩個方向。我們打印相應的運動狀態和方向。之后,我們打印一個視覺邊框以保持概覽。

void loop()
{
    // Here you can do something else in parallel while waiting for an interrupt.
    delay(1000);
}

在我們的循環函數中,我們現在只有延遲。我們可以在那里放置任何代碼,這些代碼應該在沒有發生運動或方向變化的情況下執行。為了更容易理解中斷的工作方式,您也可以在循環中打印一些內容。

poYBAGNX-5iARMpqAABwjzGHWPw709.jpg
?

監視器輸出在每個邊界后發生變化。這是因為我們只有在發生變化時才開始中斷。打印輸出之間的時間不再像以前那樣有規律,現在取決于中斷。

如果我們不再需要中斷,例如一段時間后,我們可以使用函數“disableInterrupt()”禁用它。之后只有我們在循環中的代碼會被執行。


下載該資料的人也在下載 下載該資料的人還在閱讀
更多 >

評論

查看更多

下載排行

本周

  1. 1DD3118電路圖紙資料
  2. 0.08 MB   |  1次下載  |  免費
  3. 2AD庫封裝庫安裝教程
  4. 0.49 MB   |  1次下載  |  免費
  5. 3PC6206 300mA低功耗低壓差線性穩壓器中文資料
  6. 1.12 MB   |  1次下載  |  免費
  7. 4網絡安全從業者入門指南
  8. 2.91 MB   |  1次下載  |  免費
  9. 5DS-CS3A P00-CN-V3
  10. 618.05 KB  |  1次下載  |  免費
  11. 6海川SM5701規格書
  12. 1.48 MB  |  次下載  |  免費
  13. 7H20PR5電磁爐IGBT功率管規格書
  14. 1.68 MB   |  次下載  |  1 積分
  15. 8IP防護等級說明
  16. 0.08 MB   |  次下載  |  免費

本月

  1. 1貼片三極管上的印字與真實名稱的對照表詳細說明
  2. 0.50 MB   |  103次下載  |  1 積分
  3. 2涂鴉各WiFi模塊原理圖加PCB封裝
  4. 11.75 MB   |  89次下載  |  1 積分
  5. 3錦銳科技CA51F2 SDK開發包
  6. 24.06 MB   |  43次下載  |  1 積分
  7. 4錦銳CA51F005 SDK開發包
  8. 19.47 MB   |  19次下載  |  1 積分
  9. 5PCB的EMC設計指南
  10. 2.47 MB   |  16次下載  |  1 積分
  11. 6HC05藍牙原理圖加PCB
  12. 15.76 MB   |  13次下載  |  1 積分
  13. 7802.11_Wireless_Networks
  14. 4.17 MB   |  12次下載  |  免費
  15. 8蘋果iphone 11電路原理圖
  16. 4.98 MB   |  6次下載  |  2 積分

總榜

  1. 1matlab軟件下載入口
  2. 未知  |  935127次下載  |  10 積分
  3. 2開源硬件-PMP21529.1-4 開關降壓/升壓雙向直流/直流轉換器 PCB layout 設計
  4. 1.48MB  |  420064次下載  |  10 積分
  5. 3Altium DXP2002下載入口
  6. 未知  |  233089次下載  |  10 積分
  7. 4電路仿真軟件multisim 10.0免費下載
  8. 340992  |  191390次下載  |  10 積分
  9. 5十天學會AVR單片機與C語言視頻教程 下載
  10. 158M  |  183342次下載  |  10 積分
  11. 6labview8.5下載
  12. 未知  |  81588次下載  |  10 積分
  13. 7Keil工具MDK-Arm免費下載
  14. 0.02 MB  |  73815次下載  |  10 積分
  15. 8LabVIEW 8.6下載
  16. 未知  |  65989次下載  |  10 積分
主站蜘蛛池模板: 在线视频免费观看 | 四虎影永久地址www 四虎影永久在线观看精品 四虎影永久在线观看网址 四虎影院.com | 1024 cc香蕉在线观看看中文 | 久久精品视频免费播放 | 久热福利 | 一级毛片免费全部播放完整 | 两性色午夜视频免费国产 | аⅴ天堂 在线 | 一本大道加勒比久久综合 | 操白虎美女 | 午夜在线视频国产 | 午夜欧美电影 | 色视频在线免费观看 | 在线观看日本一区 | 婷婷色天使在线视频观看 | 伊人网亚洲 | 一级特黄a大片免费 | 亚洲一一在线 | 女人张开腿让男人做爽爽 | 97国内精品久久久久久久影视 | 免费h视频网站 | 在线女同免费观看网站 | 天堂在线中文字幕 | 四虎永久网址在线观看 | 啪啪调教所29下拉式免费阅读 | 性色影院| 二十年等一人小说在线观看 | 夜夜夜夜夜夜夜工噜噜噜 | 美女视频很黄很暴黄是免费的 | 伊人久久大香线蕉综合高清 | 久久久久久夜精品精品免费 | 午夜禁片 | 色一情一乱一乱91av | 日本色图在线 | 久久婷婷五综合一区二区 | 成视频年人黄网站免费视频 | 特黄aa级毛片免费视频播放 | 视色4se在线视频播放 | 亚洲一区二区三区电影 | 欧美成人午夜毛片免费影院 | 色婷丁香 |