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

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

?? bldc.c

?? 無刷電機驅動器源代碼。基于無傳感器方案的無刷電機啟動器。核心是換向角度檢測:即電機反電勢波形數據處理
?? C
?? 第 1 頁 / 共 3 頁
字號:
//*****************************************************************************//// bldc.c - Motor control application for a brushless DC motor.//// Copyright (c) 2005,2006 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.  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 196 of an01238.////*****************************************************************************#include <string.h>#include "../../hw_ints.h"#include "../../hw_memmap.h"#include "../../hw_pwm.h"#include "../../hw_types.h"#include "../../src/debug.h"#include "../../src/gpio.h"#include "../../src/interrupt.h"#include "../../src/pwm.h"#include "../../src/qei.h"#include "../../src/sysctl.h"#include "../../src/timer.h"#include "pid.h"#include "ui.h"#include "bldc.h"//*****************************************************************************//// This application is designed to drive a Pittman N2341S001 brushless DC// motor.  The commutation sequence and PID controller tuning may need to be// modified when using a different motor; the PID controller can be tuned for// different response behavior of the Pittman motor.//// The rotational speed of the motor is measured with either the quadrature// encoder module (if present in hardware) or a software interface to the// optical encoder.  When requested, the measured speed is used to perform// closed loop speed control of the motor.//// A simple user interface is provided on UART0 operating at 115,200, 8-N-1.// The status is provided in the following format:////     Cr s:1000 a:0996//     ab   cccc   dddd//// Where 'a' is "C" for closed loop operation and "O" for open loop operation,// 'b' is 'r' for running and 's' for stopped, 'cccc' is the target motor// speed, and 'dddd' is the measured motor speed.//// The following commands are available:////     r   Start/stop the motor.//     l   Toggle between open and closed loop operation.//     p   Set a new proportional gain factor for the motor speed PID//         controller.//     i   Set a new integral gain factor for the motor speed PID controller.//     d   Set a new differential gain factor for the motor speed PID//         controller.//     z   Display the current gain factors for the motor speed PID controller.//     D   Toggle display of each motor speed sample (every 1/100th of a//         second).//// See the accompanying application note for full details of these commands.////*****************************************************************************//*****************************************************************************//// One of the following must be defined to choose the system clock rate://      SYSTEM_CLOCK_6MHZ, SYSTEM_CLOCK_20MHZ, SYSTEM_CLOCK_25MHZ,//      SYSTEM_CLOCK_50MHZ////*****************************************************************************//#define SYSTEM_CLOCK_6MHZ#define SYSTEM_CLOCK_20MHZ//#define SYSTEM_CLOCK_25MHZ//#define SYSTEM_CLOCK_50MHZ//*****************************************************************************//// Clock and PWM dividers used depend on which system clock rate is chosen.////*****************************************************************************#if defined(SYSTEM_CLOCK_6MHZ)#define SYSDIV SYSCTL_SYSDIV_1#define PWMDIV SYSCTL_PWMDIV_1#define CLKUSE SYSCTL_USE_OSC#elif defined(SYSTEM_CLOCK_20MHZ)#define SYSDIV SYSCTL_SYSDIV_10#define PWMDIV SYSCTL_PWMDIV_2#define CLKUSE SYSCTL_USE_PLL#elif defined(SYSTEM_CLOCK_25MHZ)#define SYSDIV SYSCTL_SYSDIV_8#define PWMDIV SYSCTL_PWMDIV_2#define CLKUSE SYSCTL_USE_PLL#elif defined(SYSTEM_CLOCK_50MHZ)#define SYSDIV SYSCTL_SYSDIV_4#define PWMDIV SYSCTL_PWMDIV_2#define CLKUSE SYSCTL_USE_PLL#else#error "System clock speed is not defined!"#endif//*****************************************************************************//// These define the pair of PWM signals that correspond to each phase of the// motor.////*****************************************************************************#define PHASE_A                 (PWM_OUT_0_BIT | PWM_OUT_1_BIT)#define PHASE_B                 (PWM_OUT_2_BIT | PWM_OUT_3_BIT)#define PHASE_C                 (PWM_OUT_4_BIT | PWM_OUT_5_BIT)//*****************************************************************************//// These define the PWM signals that correspond to the high and low side FETs// for each phase of the motor.////*****************************************************************************#define PHASE_A_PLUS            PWM_OUT_0_BIT#define PHASE_A_MINUS           PWM_OUT_1_BIT#define PHASE_B_PLUS            PWM_OUT_2_BIT#define PHASE_B_MINUS           PWM_OUT_3_BIT#define PHASE_C_PLUS            PWM_OUT_4_BIT#define PHASE_C_MINUS           PWM_OUT_5_BIT//*****************************************************************************//// These define the GPIO pins that are used for the Hall effect sensors.////*****************************************************************************#define HALL_PORT               GPIO_PORTB_BASE#define HALL_INT                INT_GPIOB#define HALL_A                  GPIO_PIN_6#define HALL_B                  GPIO_PIN_5#define HALL_C                  GPIO_PIN_4#define HALL_SHIFT              4//*****************************************************************************//// The minimum allowed motor speed.  This is the slowest speed at which the// motor will be allowed to be run by this application.////*****************************************************************************#define MIN_APP_MOTOR_SPEED     200//*****************************************************************************//// The maximum allowed motor speed.  This is the fastest speed at which the// motor will be allowed to be run by this application.////*****************************************************************************#define MAX_APP_MOTOR_SPEED     7000//*****************************************************************************//// The number of lines in the quadrature encoder on the motor.////*****************************************************************************#define ENCODER_LINES           1000//*****************************************************************************////! Mapping from Hall effect sensor state to PWM drive state.//!//! This array maps the state of the Hall effect sensors on the motor to the//! set of PWM signals that should be driving at that time.  This mapping//! corresponds to the following table, taken from the data sheet for the//! motor://!//! \verbatim//!     Hall State    Winding State//!        100           B+, A-//!        110           C+, A-//!        010           C+, B-//!        011           A+, B-//!        001           A+, C-//!        101           B+, C-//! \endverbatim////*****************************************************************************static const unsigned long g_pulHallToPhase[] ={    0,    PHASE_A_PLUS | PHASE_C_MINUS,    PHASE_C_PLUS | PHASE_B_MINUS,    PHASE_A_PLUS | PHASE_B_MINUS,    PHASE_B_PLUS | PHASE_A_MINUS,    PHASE_B_PLUS | PHASE_C_MINUS,    PHASE_C_PLUS | PHASE_A_MINUS};//*****************************************************************************////! Determines if the motor is running.//!//! This variable contains the value of a state machine that handles//! transitioning the motor from a running to a non-running state.  This can//! have any of the following values://!//! \verbatim//!     MOTOR_STOPPED       The motor is stopped.//!     MOTOR_RUNNING       The motor is running.//!     MOTOR_STOPPING      The motor is stopping, and the high side switches//!                         have been turned off//!     MOTOR_STOP_DELAY    The motor is stopping, the high side switches have//!                         been turned off, and a delay time has expired (to//!                         prevent shoot-through on the inverter bridge).//! \endverbatim////*****************************************************************************#define MOTOR_STOPPED           0#define MOTOR_RUNNING           1#define MOTOR_STOPPING          2#define MOTOR_STOP_DELAY        3static int g_iRunning = 0;//*****************************************************************************////! Determines if the motor is rotating in the forward or reverse direction.//!//! This flag determines if the motor is rotating in the forward or reverse//! direction.  This determines the direction of current flow through the motor//! windings for each Hall effect state; reversing the current flow reverses//! the direction of rotation.////*****************************************************************************static tBoolean g_bReverse = false;//*****************************************************************************////! Determines if the motor is run open or closed loop.//!//! This flag determines if the motor is run open loop (i.e. with no feedback)//! or closed loop (with feedback from the quadrature encoder being used to//! track the motor speed to the target speed).////*****************************************************************************static tBoolean g_bOpenLoop = true;//*****************************************************************************////! A flag to indicate debug mode.//!//! This flag determines if the closed loop debug mode is enabled.  If it is,//! each speed measurement is printed out so that the performance of the PID//! gain factors can be evaluated.////*****************************************************************************static volatile tBoolean g_bDebug = false;//*****************************************************************************////! A flag to indicate the QEI type.//!//! This flag determines if software QEI is enabled.  If it is, the number of//! edges on a single encoder channel is counted via GPIO interrupts.////*****************************************************************************static tBoolean g_bSoftwareQEI = false;//*****************************************************************************////! The target speed.//!//! This variable contains the desired speed of the motor.  It is updated when//! the user requests a new speed for the motor.////*****************************************************************************static unsigned long g_ulTarget = 0;//*****************************************************************************////! The current speed.//!//! This variable contains the measured speed of the motor.  It is updated//! every 100th of a second.////*****************************************************************************static volatile unsigned long g_ulSpeed = 0;//*****************************************************************************////! The number of speed measurements.//!//! This variables contains the number of times the motor speed has been//! measured.  It is effectively a 100Hz counter.////*****************************************************************************static volatile unsigned long g_ulSpeedCount = 0;//*****************************************************************************////! The count of edges from the optical encoder.//!//! This variable contains the count of edges seen from the optical encoder//! during the current time period.  The count is incremented for each edge//! interrupt and copied/reset every 1/100th of a second; the number of edges//! per 1/100th of a second is used to compute the speed of the motor in RPM.////*****************************************************************************static unsigned long g_ulVelCount = 0;//*****************************************************************************////! The base PWM duty cycle.//!//! This variable contains the base PWM duty cycle.  This is the duty cycle//! that is used if the motor is being operated open-loop; this is the base//! duty cycle to which the error delta is added when operating closed-loop.////*****************************************************************************static unsigned long g_ulBaseDutyCycle = 0;//*****************************************************************************////! The period of the PWM generators.//!//! Calculated based on the system clock and the desired PWM frequency////*****************************************************************************static unsigned long g_ulPwmPeriod = 0;//*****************************************************************************////! PID algorithm state.//!//! This structure contains the state of the PID algorithm that is processing//! the speed feedback loop.////*****************************************************************************static tPIDState g_sPID;//*****************************************************************************////! Proportional gain factor.//!//! This variable contains the proportional gain factor for the PID algorithm.////*****************************************************************************static long g_lPGain = 25;//*****************************************************************************////! Integral gain factor.//!//! This variable contains the integral gain factor for the PID algorithm.////*****************************************************************************static long g_lIGain = 100;//*****************************************************************************////! Derivitive gain factor.//!//! This variable contains the derivitive gain factor for the PID algorithm.////*****************************************************************************static long g_lDGain = 25;//*****************************************************************************////! Linear speed mapping table.//!//! This table maps the desired motor speed to the PWM duty cycle required to//! achieve this speed.  These duty cycles assume no load on the motor and//! nominal operating conditions; this will result in the motor going//! approximately the desired speed.  The duty cycle is represented as a value//! ranging from 0 (0%) to 10000 (100%).////*****************************************************************************typedef struct{    unsigned long ulSpeed;    unsigned long ulDutyCycle;} tSpeedMap;static const tSpeedMap g_psSpeedMap[] ={    {  200, 2587 },    {  500, 3067 },    { 1000, 3733 },    { 1500, 4293 },    { 2000, 4773 },    { 2500, 5413 },    { 3000, 5820 },    { 3500, 6440 },    { 4000, 6940 },    { 4500, 7427 },    { 5000, 8057 },    { 5500, 8560 },    { 6000, 8933 },    { 6500, 9307 },    { 7000, 9627 },};#define SPEEDMAP_ENTRIES ((sizeof(g_psSpeedMap) / sizeof(tSpeedMap)) - 1)//*****************************************************************************////! Storage for the main user interface display.//!//! This contains the contents of the main display on the user interface;//! updates to this array are reflected to the user interface.////*****************************************************************************static char g_pcDisplay[20];//*****************************************************************************////! The user interface commands.//!//! This contains the list of commands supported by this application.////*****************************************************************************static void DebugHandler(unsigned long ulValue);static void RunHandler(unsigned long ulValue);static void SpeedHandler(unsigned long ulValue);static void LoopHandler(unsigned long ulValue);static void PGainHandler(unsigned long ulValue);static void IGainHandler(unsigned long ulValue);static void DGainHandler(unsigned long ulValue);static void StatusHandler(unsigned long ulValue);static const tUICommandList g_psCommands[] ={    { 'D', 0, 0, DebugHandler },    { 'r', 0, 0, RunHandler },    { 's', 1, "Speed: ", SpeedHandler },    { 'l', 0, 0, LoopHandler },    { 'p', 1, "PGain: ", PGainHandler },    { 'i', 1, "IGain: ", IGainHandler },    { 'd', 1, "DGain: ", DGainHandler },    { 'z', 0, 0, StatusHandler }};//*****************************************************************************////! The user interface description.//!//! This contains a description of the user interface.////*****************************************************************************static const tUIDescription g_sUI ={    g_pcDisplay, 8, g_psCommands};//*****************************************************************************//// The error routine that is called if the driver library encounters an error.////*****************************************************************************#ifdef DEBUGvoid__error__(char *pcFilename, unsigned long ulLine){}#endif//*****************************************************************************////! Interrupt handler for the Hall effect GPIO signals.//!//! Handles the interrupt generated by the GPIO block when one of the Hall//! effect sensors changes state.  The set of PWM signals to be driven is//! changed based on the new state of the Hall effect sensors, performing//! commutation of the motor.//!//! \return None.////*****************************************************************************voidGPIOIntHandler(void){    unsigned long ulHall, ulPWM;    //    // Clear the GPIO pin interrupts.    //

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产麻豆精品95视频| 在线免费观看日韩欧美| 成人激情小说网站| 在线免费不卡视频| 久久亚洲精品国产精品紫薇| 欧美成人一级视频| 亚洲欧美中日韩| 久久精品噜噜噜成人av农村| 成人av网站大全| 日韩精品中文字幕在线不卡尤物| 国产亚洲一区字幕| 三级久久三级久久久| 国产成人综合在线播放| 欧美三级韩国三级日本一级| 中文字幕乱码日本亚洲一区二区| 亚洲天堂a在线| 久久国产尿小便嘘嘘| 日本伦理一区二区| 久久久精品影视| 日韩电影在线免费看| 99久久久精品| 国产夜色精品一区二区av| 亚洲国产三级在线| 不卡高清视频专区| 精品少妇一区二区三区免费观看 | 一区二区三区四区在线播放| 蜜臀91精品一区二区三区| 91丨porny丨户外露出| 精品va天堂亚洲国产| 亚洲国产欧美在线| 91一区二区三区在线观看| 精品播放一区二区| 免费一级欧美片在线观看| 色一区在线观看| 欧美tk—视频vk| 午夜久久久影院| 在线观看亚洲一区| 亚洲欧洲av另类| 国产福利91精品一区二区三区| 这里只有精品视频在线观看| 亚洲色图在线播放| a在线欧美一区| 欧美老女人在线| 亚洲成人精品影院| 欧美日韩一区二区三区不卡| 国产欧美视频一区二区| 国产高清成人在线| 久久久激情视频| 91麻豆自制传媒国产之光| 久久久久一区二区三区四区| 日产国产欧美视频一区精品| 欧美人成免费网站| 天堂蜜桃91精品| 911精品产国品一二三产区| 亚洲一区二区三区四区不卡| av午夜一区麻豆| 国产精品视频一二三| 风流少妇一区二区| 国产精品全国免费观看高清| 国产suv一区二区三区88区| 中文子幕无线码一区tr| 99天天综合性| 亚洲午夜电影在线观看| 欧美军同video69gay| 日韩在线播放一区二区| 精品日产卡一卡二卡麻豆| 国内精品伊人久久久久av一坑| 国产午夜亚洲精品午夜鲁丝片 | 日本va欧美va精品| 精品88久久久久88久久久| 国产精品一区二区x88av| 日韩中文字幕区一区有砖一区| 久久九九国产精品| 欧美日韩亚洲高清一区二区| 国产原创一区二区| 亚洲美女在线一区| 精品国产亚洲在线| 欧美性猛交xxxxxx富婆| 狠狠色丁香婷婷综合| 亚洲三级久久久| 精品国产亚洲在线| 欧美调教femdomvk| 成人免费福利片| 蓝色福利精品导航| 亚洲福中文字幕伊人影院| 国产欧美一区二区三区网站| 欧美日韩一区二区电影| 成人综合激情网| 九色综合国产一区二区三区| 亚洲一区二区高清| **欧美大码日韩| 国产三级欧美三级日产三级99| 欧美日韩国产首页| 91丝袜美腿高跟国产极品老师| 韩日精品视频一区| 免费人成网站在线观看欧美高清| 亚洲一区免费视频| 亚洲视频免费观看| 国产精品污网站| 国产亚洲欧美一级| 欧美va在线播放| 日韩一区二区视频在线观看| 欧美日韩国产精品自在自线| 色综合久久88色综合天天| 成人福利电影精品一区二区在线观看| 久草精品在线观看| 美女尤物国产一区| 精品在线免费观看| 麻豆国产欧美一区二区三区| 日韩av不卡一区二区| 日韩精品免费专区| 奇米综合一区二区三区精品视频| 亚洲午夜日本在线观看| 一区二区免费看| 亚洲国产一区在线观看| 亚洲午夜精品17c| 亚洲福利电影网| 亚洲成人中文在线| 免费在线观看日韩欧美| 六月丁香婷婷久久| 国产一区二区女| 成人小视频免费观看| 99精品国产91久久久久久| 色婷婷香蕉在线一区二区| 欧美在线视频日韩| 制服丝袜成人动漫| 26uuu色噜噜精品一区二区| 久久网站最新地址| 欧美极品xxx| 亚洲三级视频在线观看| 亚洲国产综合色| 麻豆传媒一区二区三区| 成人h动漫精品一区二| 在线免费观看日本欧美| 欧美剧在线免费观看网站 | 亚洲国产欧美日韩另类综合| 亚洲国产日韩一级| 老鸭窝一区二区久久精品| 国产成人在线影院| 欧美天堂亚洲电影院在线播放| 欧美日韩国产另类不卡| 久久综合久久综合久久综合| 国产精品久久久久久妇女6080| 亚洲精品久久嫩草网站秘色| 亚州成人在线电影| 国产精品一区二区久激情瑜伽| 99国产欧美另类久久久精品| 欧美猛男男办公室激情| 久久久影视传媒| 亚洲自拍另类综合| 久久国产精品一区二区| 97se亚洲国产综合自在线观| 91麻豆精品国产综合久久久久久| 久久综合色8888| 亚洲国产欧美一区二区三区丁香婷| 狠狠色丁香久久婷婷综| 91麻豆自制传媒国产之光| 精品国产一区二区三区不卡| 亚洲欧美偷拍另类a∨色屁股| 日一区二区三区| 成人avav影音| 欧美不卡一区二区三区| 一区二区三区中文字幕电影 | 日本亚洲电影天堂| 99精品欧美一区二区蜜桃免费 | 欧美午夜宅男影院| 欧美激情资源网| 久久成人免费电影| 欧美在线色视频| 国产欧美日产一区| 日韩极品在线观看| 一本到一区二区三区| 国产午夜三级一区二区三| 午夜精品国产更新| 91麻豆免费在线观看| 亚洲国产精品精华液ab| 蜜桃一区二区三区在线| 欧美日韩综合一区| 中文字幕在线不卡视频| 国产高清精品久久久久| 日韩欧美在线123| 亚洲成av人片一区二区梦乃| 99久久伊人精品| 国产午夜精品在线观看| 狠狠色丁香久久婷婷综合_中 | 久久综合精品国产一区二区三区 | 综合激情成人伊人| 国产成人综合精品三级| 亚洲精品一区二区精华| 日韩电影免费在线| 欧美日韩不卡一区二区| 亚洲综合成人网| 欧美在线视频日韩| 亚洲综合自拍偷拍| 在线视频欧美精品| 亚洲国产视频网站| 在线观看欧美精品| 亚洲国产精品久久久男人的天堂| 91成人免费电影| 国产剧情一区在线|