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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? bldc.c

?? 無刷電機(jī)驅(qū)動器源代碼。基于無傳感器方案的無刷電機(jī)啟動器。核心是換向角度檢測:即電機(jī)反電勢波形數(shù)據(jù)處理
?? 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.    //

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产在线视频不卡二| 国产欧美一区二区三区在线老狼| 首页国产丝袜综合| 2020国产精品| 色综合网色综合| 欧美精品在线一区二区三区| 国产精品888| 蜜桃视频在线观看一区二区| 一区二区视频在线看| 久久精品在线免费观看| 欧美一区二区私人影院日本| 色综合一个色综合| 国产九色sp调教91| 老色鬼精品视频在线观看播放| 一区二区三区久久| 国产精品女主播在线观看| 日韩欧美中文字幕精品| 欧美日韩电影一区| 一本色道久久综合狠狠躁的推荐| 国产精品中文有码| 男人的j进女人的j一区| 亚洲国产一区二区视频| 综合欧美一区二区三区| 国产亚洲一区二区三区四区| 6080国产精品一区二区| 欧美午夜精品一区| 99久久精品国产麻豆演员表| 国产一区 二区 三区一级| 日本vs亚洲vs韩国一区三区二区 | 蜜臀a∨国产成人精品| 亚洲美女免费视频| 中文字幕一区在线观看视频| 国产清纯白嫩初高生在线观看91 | 日韩三级.com| 综合久久国产九一剧情麻豆| 7777精品伊人久久久大香线蕉的| 日韩激情一二三区| 亚洲va欧美va天堂v国产综合| 裸体歌舞表演一区二区| 春色校园综合激情亚洲| 在线看国产一区| 欧美一区二区三区在线观看| 欧美精品一区二区久久婷婷| 国产精品激情偷乱一区二区∴| 亚洲一区二区四区蜜桃| 精东粉嫩av免费一区二区三区| av日韩在线网站| 欧美日韩黄视频| 久久久久免费观看| 亚洲电影一区二区三区| 国产一区二区伦理片| 色综合久久久久综合体| 精品欧美一区二区久久| 一区二区三区免费看视频| 久久爱www久久做| 日本高清成人免费播放| 日韩精品一区二区三区蜜臀| 国产精品短视频| 蜜桃视频在线观看一区| 色94色欧美sute亚洲线路一ni| 欧美本精品男人aⅴ天堂| 亚洲欧美日韩国产综合在线| 久久精品国产久精国产| 欧美亚洲一区二区三区四区| 欧美—级在线免费片| 日韩精品免费视频人成| 91一区一区三区| 久久伊人蜜桃av一区二区| 五月天欧美精品| 91片黄在线观看| 欧美极品美女视频| 久久精品国产第一区二区三区| 日本乱码高清不卡字幕| 国产精品三级电影| 久久99久国产精品黄毛片色诱| 91精品福利在线| 国产精品素人一区二区| 久久国产夜色精品鲁鲁99| 欧美亚洲综合另类| 17c精品麻豆一区二区免费| 国产精品中文有码| 日韩一区二区高清| 亚洲一二三四久久| www.欧美.com| 国产情人综合久久777777| 免费不卡在线观看| 欧美日韩国产123区| 日韩理论片在线| 北条麻妃国产九九精品视频| 久久蜜桃香蕉精品一区二区三区| 青青草原综合久久大伊人精品| 欧美在线|欧美| 国产精品久久国产精麻豆99网站 | 在线观看亚洲精品视频| 成人欧美一区二区三区黑人麻豆| 国产老妇另类xxxxx| 精品国产乱码91久久久久久网站| 奇米影视一区二区三区| 欧美日韩三级在线| 亚洲妇熟xx妇色黄| 欧美在线短视频| 亚洲国产精品影院| 欧美日韩国产一区二区三区地区| 亚洲制服丝袜在线| 精品污污网站免费看| 亚洲午夜久久久久中文字幕久| 欧美亚洲一区三区| 亚洲香肠在线观看| 欧美巨大另类极品videosbest| 亚洲国产成人porn| 91麻豆精品久久久久蜜臀| 青青草视频一区| 欧美大片日本大片免费观看| 久久99国产精品久久| xvideos.蜜桃一区二区| 福利电影一区二区| 国产精品电影一区二区| 91免费看片在线观看| 亚洲综合久久av| 欧美一区二区在线观看| 狠狠色丁香久久婷婷综合_中| 久久婷婷一区二区三区| 成人免费视频国产在线观看| 中文字幕精品一区二区三区精品| 99久久精品免费看国产| 亚洲一二三四区不卡| 日韩欧美色电影| 国产69精品一区二区亚洲孕妇| 亚洲天堂成人在线观看| 欧美日本韩国一区| 国产真实乱对白精彩久久| 亚洲国产高清aⅴ视频| 欧美在线观看18| 久久99精品久久久久久动态图| 欧美激情自拍偷拍| 色偷偷久久人人79超碰人人澡| 亚洲图片自拍偷拍| 精品国产人成亚洲区| 不卡一区二区中文字幕| 亚洲图片自拍偷拍| 精品免费一区二区三区| 91免费视频观看| 麻豆成人综合网| 国产精品超碰97尤物18| 欧美老女人第四色| 国产东北露脸精品视频| 亚洲综合在线第一页| 欧美大片免费久久精品三p| 99久久免费视频.com| 日本视频中文字幕一区二区三区| 久久久精品天堂| 在线观看网站黄不卡| 免费在线观看一区| 国产精品久久久久久久久快鸭 | 91在线观看污| 免费久久精品视频| 亚洲欧洲色图综合| 91麻豆精品91久久久久同性| 不卡欧美aaaaa| 久久精品国产77777蜜臀| 亚洲欧美欧美一区二区三区| 日韩精品一区二区三区四区| 色哟哟国产精品| 国产精品一区二区果冻传媒| 五月天亚洲婷婷| 亚洲婷婷综合久久一本伊一区| 日韩欧美亚洲另类制服综合在线| 色哦色哦哦色天天综合| 狠狠色狠狠色综合系列| 午夜国产不卡在线观看视频| 中文字幕视频一区| 久久久亚洲综合| 91精品国产综合久久久久久久久久 | 欧美在线你懂的| 丁香婷婷综合网| 青青草国产精品97视觉盛宴| 亚洲欧美另类小说| 久久久久久99久久久精品网站| 777亚洲妇女| 韩国一区二区在线观看| 国产成人精品一区二| 国产精品国模大尺度视频| 精品视频一区二区不卡| 欧美国产日本视频| 奇米777欧美一区二区| 91亚洲精品乱码久久久久久蜜桃| 538prom精品视频线放| 亚洲国产精品影院| 成人黄色av电影| 精品久久久久久久久久久久久久久久久| 国产精品久久久久久久久久免费看| 日本成人在线一区| 欧美日韩视频不卡| 亚洲亚洲精品在线观看| 日本不卡一二三区黄网| 亚洲九九爱视频| 国产精品福利在线播放| 欧美高清一级片在线观看| 久久综合久久综合亚洲| 日韩女优av电影|