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

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

?? bldc.c

?? luminary芯片直流無刷電機控制程序
?? 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一区二区三区免费野_久草精品视频
成人国产精品视频| 欧美一区二区日韩| 亚洲一区二区三区在线看| 欧美日韩国产片| 美女视频黄频大全不卡视频在线播放| 日韩视频在线你懂得| 国产综合色精品一区二区三区| 国产欧美一区二区三区鸳鸯浴| 白白色亚洲国产精品| 亚洲一区二区综合| 欧美一级久久久久久久大片| 国产麻豆视频一区二区| 亚洲视频免费在线| 欧美丰满美乳xxx高潮www| 国产一区二区三区四区五区入口| 国产精品久久毛片av大全日韩| 欧美亚洲动漫制服丝袜| 乱中年女人伦av一区二区| 亚洲国产精品激情在线观看| 在线免费视频一区二区| 久久精品国产成人一区二区三区| 欧美国产激情一区二区三区蜜月| 在线观看免费一区| 精品一区免费av| 亚洲男同性恋视频| 欧美老年两性高潮| 风间由美一区二区三区在线观看| 亚洲与欧洲av电影| 久久品道一品道久久精品| 色悠久久久久综合欧美99| 麻豆国产精品一区二区三区| 一区在线中文字幕| 欧美日韩五月天| 国产99精品国产| 午夜国产精品影院在线观看| 国产视频视频一区| 欧美精品123区| 不卡的av网站| 青椒成人免费视频| 亚洲免费视频中文字幕| 精品少妇一区二区三区在线播放 | 91亚洲精品久久久蜜桃| 免费观看日韩电影| 国产精品二区一区二区aⅴ污介绍| 欧美精品在线观看播放| 不卡av在线免费观看| 免费视频一区二区| 一区二区三区色| 久久亚洲精精品中文字幕早川悠里 | 欧美精品成人一区二区三区四区| 国产精品99久久久久久有的能看| 亚洲午夜免费电影| 国产三级精品视频| 91精品在线免费| 91免费版在线| 国产在线国偷精品免费看| 无码av免费一区二区三区试看| 国产欧美日韩在线视频| 69堂国产成人免费视频| 91最新地址在线播放| 国产乱人伦精品一区二区在线观看 | 一区二区三区中文字幕在线观看| 精品国产一区二区三区av性色| 欧美无乱码久久久免费午夜一区| 成人精品亚洲人成在线| 国内久久精品视频| 日韩影院免费视频| 亚洲精品免费播放| 国产精品免费视频网站| 久久伊人中文字幕| 日韩亚洲国产中文字幕欧美| 欧美性猛交一区二区三区精品 | 成人午夜激情影院| 九九久久精品视频| 五月天久久比比资源色| 亚洲欧美视频在线观看视频| 国产喷白浆一区二区三区| 日韩欧美黄色影院| 欧美一三区三区四区免费在线看 | 久久成人综合网| 亚洲电影在线免费观看| 亚洲男人的天堂一区二区| 日本一区二区成人| 国产欧美精品一区二区色综合| 日韩欧美高清一区| 欧美一区二区视频在线观看| 欧美日韩亚洲国产综合| 欧美中文字幕一区二区三区| 99re视频精品| 91在线国内视频| 波多野结衣视频一区| 成人高清av在线| 成人妖精视频yjsp地址| 成人免费观看av| 成人晚上爱看视频| 成人少妇影院yyyy| 高清视频一区二区| 成人三级伦理片| av在线不卡免费看| 91天堂素人约啪| 91蜜桃传媒精品久久久一区二区| av在线一区二区三区| 91美女蜜桃在线| 在线欧美日韩精品| 欧美午夜电影网| 在线播放一区二区三区| 91麻豆精品国产91久久久久| 欧美一级欧美一级在线播放| 欧美一区午夜精品| 精品国产人成亚洲区| 亚洲精品一区二区三区在线观看| 欧美va亚洲va| 国产日韩欧美精品在线| 国产精品美女久久久久久久| 17c精品麻豆一区二区免费| 亚洲免费在线播放| 亚洲电影视频在线| 免费人成网站在线观看欧美高清| 九九久久精品视频| 成人免费毛片片v| 色偷偷88欧美精品久久久| 日本道在线观看一区二区| 9191国产精品| 欧美精品一区视频| 欧美激情在线观看视频免费| 亚洲人亚洲人成电影网站色| 夜夜夜精品看看| 日韩综合一区二区| 九九**精品视频免费播放| 国产精品自拍一区| 99久久精品久久久久久清纯| 色欧美日韩亚洲| 欧美一区日本一区韩国一区| 久久久久久久久免费| 国产精品伦理在线| 亚洲国产美女搞黄色| 久久国产福利国产秒拍| 成人妖精视频yjsp地址| 在线精品视频一区二区| 日韩午夜激情av| 国产精品私人影院| 亚洲综合在线电影| 蜜臀av性久久久久蜜臀aⅴ| 国产91色综合久久免费分享| 欧洲一区二区三区免费视频| 欧美一区二区三区在线看| 国产亚洲欧美色| 亚洲精品欧美激情| 麻豆成人av在线| www.爱久久.com| 欧美精品自拍偷拍| 国产亚洲制服色| 亚洲一二三区视频在线观看| 狠狠色2019综合网| 欧美专区日韩专区| 久久午夜电影网| 亚洲精品视频在线观看网站| 久久成人久久爱| 日本韩国一区二区| 精品久久久久久久久久久久包黑料| 国产精品视频看| 青青草91视频| 91视频com| 久久婷婷一区二区三区| 亚洲一区二区av电影| 国产一二三精品| 欧美日本视频在线| 亚洲国产精品成人综合色在线婷婷| 亚洲一区av在线| 成人午夜视频福利| 日韩你懂的在线播放| 亚洲欧美日韩精品久久久久| 美女视频一区二区| 在线免费观看成人短视频| 久久久蜜臀国产一区二区| 亚洲电影在线播放| 99精品1区2区| 精品国产凹凸成av人导航| 一区二区日韩av| 国产精品亚洲人在线观看| 91 com成人网| 亚洲男帅同性gay1069| 国产剧情一区在线| 欧美高清hd18日本| 亚洲色图欧美在线| 国产成人综合在线| 88在线观看91蜜桃国自产| 亚洲天堂免费看| 国产精品99久久久久久久女警| 6080亚洲精品一区二区| 一区在线中文字幕| 国产电影精品久久禁18| 日韩一区二区在线看片| 亚洲综合激情网| www.色精品| 国产精品人成在线观看免费 | 韩国三级中文字幕hd久久精品| 欧美午夜精品一区二区三区| 国产精品不卡在线| 国产精品99久久不卡二区|