亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? brake.c

?? Luminary Micro BLDC motor control software
?? C
字號:
//*****************************************************************************
//
// brake.c - Dynamic braking control routines.
//
// Copyright (c) 2007-2008 Luminary Micro, Inc.  All rights reserved.
// 
// Software License Agreement
// 
// Luminary Micro, Inc. (LMI) is supplying this software for use solely and
// exclusively on LMI's microcontroller products.
// 
// The software is owned by LMI and/or its suppliers, and is protected under
// applicable copyright laws.  All rights are reserved.  You may not combine
// this software with "viral" open-source software in order to form a larger
// program.  Any use in violation of the foregoing restrictions may subject
// the user to criminal sanctions under applicable laws, as well as to civil
// liability for the breach of the terms and conditions of this license.
// 
// THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
// OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
// LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
// CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
// 
// This is part of revision 716 of the BLDC motor application.
//
//*****************************************************************************

#include "../../DriverLib/hw_memmap.h"
#include "../../DriverLib/hw_types.h"
#include "../../DriverLib/src/gpio.h"
#include "adc_ctrl.h"
#include "brake.h"
#include "pins.h"
#include "pwm_ctrl.h"
#include "ui.h"

//*****************************************************************************
//
//! \page brake_intro Introduction
//!
//! Dynamic braking is the application of a power resistor across the DC bus in
//! order to control the increase in the DC bus voltage.  The power resistor
//! reduces the DC bus voltage by converting current into heat.
//!
//! The dynamic braking routine is called every millisecond to monitor the DC
//! bus voltage and handle the dynamic brake.  When the DC bus voltage gets too
//! high, the dynamic brake is applied to the DC bus.  When the DC bus voltage
//! drops enough, the dynamic brake is removed.
//!
//! In order to control heat buildup in the power resistor, the amount of time
//! the brake is applied is tracked.  If the brake is applied for too long, it
//! will be forced off for a period of time (regardless of the DC bus voltage)
//! to prevent it from overheating.  The amount of time on and off is tracked
//! as an indirect measure of the heat buildup in the power resistor; the heat
//! increases when on and decreases when off.
//!
//! The code for handling dynamic braking is contained in <tt>brake.c</tt>,
//! with <tt>brake.h</tt> containing the definitions for the functions exported
//! to the remainder of the application.
//
//*****************************************************************************

//*****************************************************************************
//
//! \defgroup brake_api Definitions
//! @{
//
//*****************************************************************************

//*****************************************************************************
//
//! The dynamic brake is turned off.  The bus voltage going above the trigger
//! level will cause a transition to the #STATE_BRAKE_ON state.
//
//*****************************************************************************
#define STATE_BRAKE_OFF         0

//*****************************************************************************
//
//! The dynamic brake is turned on.  The bus voltage going below the trigger
//! level will cause a transition to the #STATE_BRAKE_OFF state, and the brake
//! being on for too long will cause a transition to #STATE_BRAKE_COOL.
//
//*****************************************************************************
#define STATE_BRAKE_ON          1

//*****************************************************************************
//
//! The dynamic brake is forced off to allow the power resistor to cool.  After
//! the minimum cooling period has expired, an automatic transition to
//! #STATE_BRAKE_OFF will occur if the bus voltage is below the trigger level
//! and to #STATE_BRAKE_ON if the bus voltage is above the trigger level.
//
//*****************************************************************************
#define STATE_BRAKE_COOL        2

//*****************************************************************************
//
//! The current state of the dynamic brake.  Will be one of #STATE_BRAKE_OFF,
//! #STATE_BRAKE_ON, or #STATE_BRAKE_COOL.
//
//*****************************************************************************
static unsigned long g_ulBrakeState;

//*****************************************************************************
//
//! The number of milliseconds that the dynamic brake has been on.  For each
//! brake update period, this is incremented if the brake is on and decremented
//! if it is off.  This effectively represents the heat buildup in the power
//! resistor; when on heat will increase and when off it will decrease.
//
//*****************************************************************************
static unsigned long g_ulBrakeCount;

//*****************************************************************************
//
//! Updates the dynamic brake.
//!
//! This function will update the state of the dynamic brake.  It must be
//! called at the PWM frequency to provide a time base for determining when to
//! turn off the brake to avoid overheating.
//!
//! \return None.
//
//*****************************************************************************
void
BrakeTick(void)
{
    //
    // See if the bus voltage exceeds the voltage required to turn on the
    // dynamic brake.
    //
    if(g_ulBusVoltage >= g_sParameters.ulBrakeOnV)
    {
        //
        // The bus voltage is too high, so see if the brake is currently off.
        //
        if((g_ulBrakeState == STATE_BRAKE_OFF) &&
           (HWREGBITH(&(g_sParameters.usFlags), FLAG_BRAKE_BIT) ==
            FLAG_BRAKE_ON))
        {
            //
            // Turn on the dynamic brake.
            //
            GPIOPinWrite(PIN_BRAKE_PORT, PIN_BRAKE_PIN, 0);

            //
            // Change the brake state to on.
            //
            g_ulBrakeState = STATE_BRAKE_ON;
        }
    }

    //
    // Otherwise, see if the dynamic brake is on and the bus voltage is less
    // than the voltage required to turn it off.
    //
    else if((g_ulBusVoltage < g_sParameters.ulBrakeOffV) &&
            (g_ulBrakeState == STATE_BRAKE_ON))
    {
        //
        // Turn off the dynamic brake.
        //
        GPIOPinWrite(PIN_BRAKE_PORT, PIN_BRAKE_PIN, PIN_BRAKE_PIN);

        //
        // Change the brake state to off.
        //
        g_ulBrakeState = STATE_BRAKE_OFF;
    }

    //
    // See if the dynamic brake is on.
    //
    if(g_ulBrakeState == STATE_BRAKE_ON)
    {
        //
        // Increment the number of brake ticks that the dynamic brake has been
        // on.
        //
        g_ulBrakeCount++;

        //
        // See if the dynamic brake has been on for too long.
        //
        if(g_ulBrakeCount == g_sParameters.ulBrakeMax)
        {
            //
            // Turn off the dynamic brake.
            //
            GPIOPinWrite(PIN_BRAKE_PORT, PIN_BRAKE_PIN, PIN_BRAKE_PIN);

            //
            // Change the brake state to cool to allow the braking resistor to
            // cool off (to avoid overheating).
            //
            g_ulBrakeState = STATE_BRAKE_COOL;
        }
    }

    //
    // Otherwise, see if the dynamic brake tick count is non-zero.
    //
    else if(g_ulBrakeCount != 0)
    {
        //
        // Decrement the number of brake ticks that the dynamic brake has been
        // off.
        //
        g_ulBrakeCount--;

        //
        // See if the dynamic brake is in the cooling state and has cooled off
        // for long enough.
        //
        if((g_ulBrakeState == STATE_BRAKE_COOL) &&
           (g_ulBrakeCount == g_sParameters.ulBrakeCool))
        {
            //
            // The dynamic brake has cooled off enough, so see if the bus
            // voltage exceeds the voltage required to turn it on.
            //
            if(g_ulBusVoltage >= g_sParameters.ulBrakeOnV)
            {
                //
                // Turn on the dynamic brake.
                //
                GPIOPinWrite(PIN_BRAKE_PORT, PIN_BRAKE_PIN, 0);

                //
                // Change the brake state to on.
                //
                g_ulBrakeState = STATE_BRAKE_ON;
            }

            //
            // Otherwise, the voltage is low enough that the brake should
            // remain off.
            //
            else
            {
                //
                // Change the brake state to off.
                //
                g_ulBrakeState = STATE_BRAKE_OFF;
            }
        }
    }
}

//*****************************************************************************
//
//! Initializes the dynamic braking control routines.
//!
//! This function initializes the ADC module and the control routines,
//! preparing them to monitor currents and voltages on the motor drive.
//!
//! \return None.
//
//*****************************************************************************
void
BrakeInit(void)
{
    //
    // Configure the brake control pin as an open-drain output, allowing the
    // signal to float high in the "1" state (Brake disabled).
    //
    GPIOPinTypeGPIOOutputOD(PIN_BRAKE_PORT, PIN_BRAKE_PIN);
    GPIOPinWrite(PIN_BRAKE_PORT, PIN_BRAKE_PIN, PIN_BRAKE_PIN);

    //
    // The initial brake state is off.
    //
    g_ulBrakeState = STATE_BRAKE_OFF;

    //
    // The initial brake count is zero.
    //
    g_ulBrakeCount = 0;
}

//*****************************************************************************
//
// Close the Doxyen group.
//! @}
//
//*****************************************************************************

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
粗大黑人巨茎大战欧美成人| 国产精品18久久久久久久久久久久| 日欧美一区二区| 国产精品99久久久久| 91豆麻精品91久久久久久| 精品久久久三级丝袜| 亚洲一区二区三区美女| 国产精品资源在线看| 欧美卡1卡2卡| 亚洲男人的天堂一区二区| 精品一区二区三区免费毛片爱| 色狠狠综合天天综合综合| 国产清纯在线一区二区www| 国内精品自线一区二区三区视频| 成人aa视频在线观看| 欧美videos大乳护士334| 亚洲一区在线播放| 一本大道久久a久久精二百| 欧美国产乱子伦| 久久精品久久精品| 制服丝袜中文字幕亚洲| 一区二区三区精品在线| bt欧美亚洲午夜电影天堂| 久久久美女毛片| 男人操女人的视频在线观看欧美| 色88888久久久久久影院按摩| 国产无遮挡一区二区三区毛片日本| 日韩黄色片在线观看| 欧美日韩中文字幕一区| 亚洲欧美一区二区三区极速播放| 国产精品1024| 精品国产乱码91久久久久久网站| 日本不卡的三区四区五区| 欧美三级午夜理伦三级中视频| 亚洲天堂免费看| 不卡的av网站| 亚洲欧洲日本在线| 99久久精品免费| 国产精品久久久久三级| 丁香六月综合激情| 国产精品美女久久福利网站| 成人一道本在线| 国产精品视频一二| 不卡av在线免费观看| 日韩一区日韩二区| 91视频国产资源| 亚洲激情自拍视频| 欧美少妇性性性| 日本伊人午夜精品| 制服丝袜中文字幕一区| 另类小说图片综合网| 欧美成人猛片aaaaaaa| 国产在线精品一区二区| 久久精品无码一区二区三区| 东方欧美亚洲色图在线| 中文字幕在线播放不卡一区| 色诱视频网站一区| 午夜精彩视频在线观看不卡| 欧美一区二区视频在线观看 | 亚洲一区二区在线免费观看视频 | 91无套直看片红桃| 亚洲色图在线视频| 国产精品美女www爽爽爽| 亚洲一级二级在线| 国产一区二区三区免费看| 成人免费毛片嘿嘿连载视频| 日韩午夜av一区| 五月激情六月综合| 99热在这里有精品免费| 欧美亚洲国产一区二区三区 | 久久久精品黄色| 国产精品久久久久久久久图文区| 亚洲色图欧美偷拍| 欧美日韩一二三| 91视频在线观看免费| 五月天中文字幕一区二区| 51午夜精品国产| 激情六月婷婷久久| 中文字幕一区av| 91精品国产高清一区二区三区| 国产一二精品视频| 亚洲精品视频在线观看免费| 欧美一区二视频| 成人av网站在线| 蜜臀av性久久久久蜜臀aⅴ流畅| 国产精品视频免费| 日韩免费福利电影在线观看| 91亚洲国产成人精品一区二区三| 日韩成人av影视| 亚洲伦在线观看| 欧美成人精品福利| 欧美日韩国产影片| 99久久精品免费看| 国产精品一区二区免费不卡| 婷婷中文字幕综合| 亚洲视频一区在线| 欧美激情一区二区在线| 日韩一卡二卡三卡四卡| 在线免费观看视频一区| 国产精品亚洲午夜一区二区三区| 性做久久久久久久久| 中文在线免费一区三区高中清不卡| 欧美日韩国产123区| a级精品国产片在线观看| 狠狠色狠狠色综合日日91app| 亚洲图片一区二区| 中文字幕一区二区三区av| 久久一留热品黄| 正在播放亚洲一区| 欧美日韩一区二区欧美激情| 色天使久久综合网天天| 欧美伦理影视网| 91免费看`日韩一区二区| 粉嫩av一区二区三区粉嫩| 黑人巨大精品欧美黑白配亚洲| 男男成人高潮片免费网站| 婷婷国产在线综合| 亚洲r级在线视频| 亚洲第一精品在线| 亚欧色一区w666天堂| 偷拍一区二区三区| 亚洲bdsm女犯bdsm网站| 亚洲sss视频在线视频| 亚洲va中文字幕| 欧美日韩大陆在线| 99国产一区二区三精品乱码| 亚洲精品国产一区二区精华液| 欧美日韩卡一卡二| 91在线porny国产在线看| 麻豆精品久久久| 日韩高清电影一区| 视频一区中文字幕国产| 中文字幕亚洲在| 国产精品视频看| 国产精品美女一区二区在线观看| 欧美日韩视频专区在线播放| 久久激情五月激情| 蜜桃视频在线观看一区| 日韩av中文字幕一区二区三区| 亚洲猫色日本管| 亚洲国产精品一区二区久久恐怖片| 久久久久久黄色| 久久精品视频一区二区三区| 性感美女极品91精品| 欧美日韩综合在线| 久久久久国产一区二区三区四区| 国内国产精品久久| 亚洲一区二区三区影院| 免费人成黄页网站在线一区二区| 狠狠色2019综合网| 成人免费看片app下载| 欧美亚洲国产一区二区三区va| 欧美久久免费观看| 久久精品人人做| 一个色妞综合视频在线观看| 久久99久久久久久久久久久| 成人丝袜18视频在线观看| 欧美日韩免费观看一区三区| 欧美xxxxx牲另类人与| 亚洲精品videosex极品| 国产一区二区女| 在线观看日韩国产| 精品国产sm最大网站免费看| 国产精品不卡在线观看| 午夜欧美电影在线观看| 成人v精品蜜桃久久一区| 欧美日韩国产一区二区三区地区| 国产日韩综合av| 丝袜a∨在线一区二区三区不卡| 国产一区欧美二区| 91精品久久久久久久久99蜜臂| 亚洲女性喷水在线观看一区| 久久精品国产精品亚洲红杏| 色域天天综合网| 国产色爱av资源综合区| 婷婷久久综合九色综合绿巨人 | 欧美精品一区二区不卡 | www.亚洲色图.com| 欧美日韩一本到| 亚洲日穴在线视频| 风间由美性色一区二区三区| 波多野结衣中文字幕一区二区三区| 91精品视频网| 男人的j进女人的j一区| 777久久久精品| 日韩电影在线观看一区| 欧美日韩一本到| 国产大陆a不卡| 欧美三级视频在线播放| 亚洲一区二区在线免费看| 99精品热视频| 久久久久久久电影| 国产成人亚洲综合色影视| 久久久综合精品| 成人精品视频一区二区三区| 亚洲欧美偷拍卡通变态| 91麻豆免费看片| 亚洲欧洲av一区二区三区久久| 狠狠色丁香九九婷婷综合五月| 欧美视频在线一区二区三区|