新聞中心

        EEPW首頁 > 嵌入式系統 > 設計應用 > stm32 霍爾傳感器接口

        stm32 霍爾傳感器接口

        作者: 時間:2016-11-18 來源:網絡 收藏
        13.3.18 與霍爾傳感器的接口

        使用高級控制定時器(TIM1或TIM8)產生PWM信號驅動馬達時,可以用另一個通用TIMx(TIM2、TIM3、TIM4或TIM5)定時器作為“接口定時器”來連接霍爾傳感器,見圖93,3個定時器輸入腳(CC1、CC2、CC3)通過一個異或門連接到TI1輸入通道(通過設置TIMx_CR2寄存器中的TI1S位來選擇),“接口定時器”捕獲這個信號。

        本文引用地址:http://www.104case.com/article/201611/315856.htm

        從模式控制器被配置于復位模式,從輸入是TI1F_ED。每當3個輸入之一變化時,計數器從新從0開始計數。這樣產生一個由霍爾輸入端的任何變化而觸發的時間基準。 “接口定時器”上的捕獲/比較通道1配置為捕獲模式,捕獲信號為TRC(見圖76)。捕獲值反映了兩個輸入變化間的時間延遲,給出了馬達速度的信息。 “接口定時器”可以用來在輸出模式產生一個脈沖,這個脈沖可以(通過觸發一個COM事件)用于改變高級定時器TIM1或TIM8各個通道的屬性,而高級控制定時器產生PWM信號驅動馬達。因此“接口定時器”通道必須編程為在一個指定的延時(輸出比較或PWM模式)之后產生一個正脈沖,這個脈沖通過TRGO輸出被送到高級控制定時器TIM1或TIM8。 舉例:霍爾輸入連接到TIMx定時器,要求每次任一霍爾輸入上發生變化之后的一個指定的時刻,改變高級控制定時器TIMx的PWM配置。

        ● 置TIMx_CR2寄存器的TI1S位為’1’,配置三個定時器輸入邏輯或到TI1輸入,

        ● 時基編程:置TIMx_ARR為其最大值(計數器必須通過TI1的變化清零)。設置預分頻器得到一個最大的計數器周期,它長于傳感器上的兩次變化的時間間隔。

        ● 設置通道1為捕獲模式(選中TRC):置TIMx_CCMR1寄存器中CC1S=01,如果需要,還可以設置數字濾波器。

        ● 設置通道2為PWM2模式,并具有要求的延時:置TIMx_CCMR1寄存器中的OC2M=111和CC2S=00。

        ● 選擇OC2REF作為TRGO上的觸發輸出:置TIMx_CR2寄存器中的MMS=101。 在高級控制寄存器TIM1中,正確的ITR輸入必須是觸發器輸入,定時器被編程為產生PWM信號,捕獲/比較控制信號為預裝載的(TIMx_CR2寄存器中CCPC=1),同時觸發輸入控制COM事件(TIMx_CR2寄存器中CCUS=1)。在一次COM事件后,寫入下一步的PWM控制位(CCxE、OCxM),這可以在處理OC2REF上升沿的中斷子程序里實現。 下圖顯示了這個實例


        無刷電機每運行一圈,霍爾有六個狀態,在每個狀態均會進入一次中斷,
        正常運轉的時候電機是按照1,3,2,6,4,5

        http://www.ourdev.cn/bbs/bbs_content.jsp?bbs_sn=3764371&bbs_page_no=1&search_mode=1&search_text=hall&bbs_id=3020

        Setting up the system when using Hall-effect sensors
        Hall-effect sensors are devices capable of sensing the polarity of the rotor’s magnetic field;
        they provide a logic output, which is 0 or 1 depending on the magnetic pole they face and
        thus, on the rotor position.
        Typically, in a three-phase PM motor three Hall-effect sensors are used to feed back the
        rotor position information. They are usually mechanically displaced by either 120° or 60° and
        the presented firmware library was designed to support both possibilities. To set up the
        PMSM FOC software library for use with three Hall sensors, simply modify the
        stm32f10x_MCconf.h and MC_hall_param.h header files according to the indications given
        in Section 4.1 and Section 4.4, respectively.
        As shown in Figure 30, the typical waveforms can be visualized at the sensor outputs in
        case of 60° and 120° displaced Hall sensors. More particularly, Figure 30 refers to an
        electrical period (i.e. one mechanical revolution in case of one pole pair motor).
        Figure 30. 60° and 120° displaced Hall sensor output waveforms

        Since the rotor position information they provide is absolute, there is no need for any initial
        rotor prepositioning. Particular attention must be paid, however, when connecting the
        sensors to the proper microcontroller inputs.
        In fact, as stated in Section 3.11, this software library assumes that the positive rolling
        direction is the rolling direction of a machine that is fed with a three-phase system of positive
        sequence. In that case to properly work, the software library expects the Hall sensor signal
        transitions to be in the sequence shown in Figure 30 for both 60° and 120° displaced Hall
        sensors.
        For these reasons, it is suggested to follow the instructions given below when connecting a
        Hall-sensor equipped PM motor to your board:

        1. Turn the rotor by hand in the direction assumed to be positive and look at the B-emf
        induced on the three motor phases. For this purpose if the real neutral point is not
        available, it can be reconstructed by means of three resistors for instance.
        2. Connect the motor phases to the hardware respecting the positive sequence. Let
        “Phase A”, “Phase B” and “Phase C” be the motor phases driven by TIM1_CH1,
        TIM1_CH2 and TIM1_CH3, respectively (e.g. when using the MB459 board, a positive
        sequence of the motor phases could be connected to J5 2,1 and 3).
        3. Turn the rotor by hand in the direction assumed to be positive, look at the three Hall
        sensor outputs (H1, H2 and H3) and connect them to the selected timer on channels 1,
        2 and 3, respectively, making sure that the sequence shown in Figure 30 is respected.
        4. Measure the delay in electrical degrees betweenthe maximum of the B-emf induced on
        Phase Aandthe first rising edge of signal H1. Enter it in the MC_hall_param.h header
        file (HALL_PHASE_SHIFT). For your convenience, an example with
        HALL_PHASE_SHIFT equal to –90 °C is illustrated in Figure 31.



        評論


        技術專區

        關閉
        主站蜘蛛池模板: 巫溪县| 佛教| 望城县| 夏河县| 科技| 台前县| 洱源县| 崇州市| 独山县| 叶城县| 深泽县| 奈曼旗| 响水县| 丹阳市| 泗阳县| 万全县| 睢宁县| 静宁县| 城固县| 博爱县| 大宁县| 黄龙县| 乐陵市| 依安县| 南江县| 宜兴市| 汉中市| 蛟河市| 璧山县| 西和县| 东乌珠穆沁旗| 宝丰县| 三台县| 黔西| 丰县| 永平县| 凤冈县| 册亨县| 宜宾县| 罗田县| 孟州市|