亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
久久麻豆一区二区| 日本不卡不码高清免费观看| 蜜臂av日日欢夜夜爽一区| 成人中文字幕在线| 久久亚洲一级片| 免费在线看成人av| 欧美视频精品在线观看| 亚洲图片欧美激情| 国产久卡久卡久卡久卡视频精品| 亚洲欧洲精品一区二区三区| 精品一区二区三区在线视频| 欧美日韩亚洲国产综合| 一区二区视频在线| 欧美亚洲综合另类| 一区二区三区**美女毛片| 成人午夜激情在线| 中文字幕不卡三区| 色综合久久99| 亚洲美女区一区| 欧美日韩综合不卡| 看电视剧不卡顿的网站| 91精品国产免费| 国产精品综合二区| 久久精品视频一区| 色婷婷精品大在线视频| 调教+趴+乳夹+国产+精品| 4438x成人网最大色成网站| 在线播放国产精品二区一二区四区| 精品成人佐山爱一区二区| 精品午夜久久福利影院| 国产精品久久久久影视| 色偷偷久久一区二区三区| 亚洲综合激情网| 精品美女被调教视频大全网站| 黄一区二区三区| 亚洲精品免费视频| 日韩精品一区二区三区蜜臀| 成人精品一区二区三区四区| 亚洲一级不卡视频| 久久久青草青青国产亚洲免观| 91在线看国产| 国产精品456露脸| 天天做天天摸天天爽国产一区| 久久久精品欧美丰满| 欧美午夜电影网| 国产成人一区二区精品非洲| 亚洲在线视频免费观看| 国产三级三级三级精品8ⅰ区| 欧美性欧美巨大黑白大战| 成人福利视频网站| 经典三级视频一区| 免费在线一区观看| 国产精品国模大尺度视频| 日韩免费观看2025年上映的电影| 成人福利在线看| 91在线无精精品入口| jvid福利写真一区二区三区| 极品少妇一区二区| 精品在线视频一区| 奇米综合一区二区三区精品视频| 亚洲一二三专区| 日韩精品免费专区| 久久精品国产色蜜蜜麻豆| 日本成人在线不卡视频| 日韩国产成人精品| 日韩精品电影一区亚洲| 国内精品免费**视频| 极品销魂美女一区二区三区| 国产aⅴ综合色| 成人久久视频在线观看| 一本色道**综合亚洲精品蜜桃冫| 波多野结衣亚洲一区| 91丝袜美女网| 欧美一区二区三区视频免费播放| 日韩视频国产视频| 亚洲精品日日夜夜| 亚洲大片免费看| 国产一区在线不卡| 97久久精品人人做人人爽| 欧美日韩一级黄| 久久久天堂av| 综合色天天鬼久久鬼色| 无码av免费一区二区三区试看 | 欧美日韩国产高清一区| 精品日韩99亚洲| 一区二区三区四区激情| 久久99深爱久久99精品| 国产乱码精品一区二区三区五月婷| 五月天国产精品| 久久精品国产在热久久| 色激情天天射综合网| 欧美高清在线精品一区| 亚洲国产视频在线| 国产成人午夜片在线观看高清观看| 欧美色图片你懂的| 亚洲欧洲色图综合| 粉嫩久久99精品久久久久久夜| 在线视频欧美精品| 亚洲女人****多毛耸耸8| 国产一区二区三区在线观看免费视频| 97精品超碰一区二区三区| 国产亚洲制服色| 国产成人av一区| 国产亚洲欧美激情| 国产精品资源在线| 久久精品欧美一区二区三区不卡| 麻豆国产91在线播放| 欧美一区二区三区四区五区| 午夜在线电影亚洲一区| 91在线免费播放| 亚洲视频一区在线| www.成人网.com| 亚洲综合丝袜美腿| 欧美放荡的少妇| 男人的天堂亚洲一区| 欧美成人女星排名| 国产黄色91视频| 国产欧美视频一区二区| 国产呦精品一区二区三区网站| 精品福利一区二区三区免费视频| 国内久久婷婷综合| 亚洲人成影院在线观看| 欧美日韩在线三区| 国产高清不卡二三区| 一区二区三区精品在线观看| 欧美片在线播放| 国产精品18久久久久久久网站| 亚洲色欲色欲www在线观看| 欧美日韩一区二区在线观看| 蜜桃一区二区三区四区| 国产精品欧美一区二区三区| 91久久精品国产91性色tv| 免费人成在线不卡| 久久综合久久鬼色| 欧美三级韩国三级日本一级| 国产剧情一区二区三区| 亚洲狠狠爱一区二区三区| 精品国精品自拍自在线| 在线一区二区三区四区五区| 国产乱码字幕精品高清av| 亚洲最新视频在线播放| 久久久亚洲精品一区二区三区| 在线免费不卡电影| 波多野结衣视频一区| 久久精品国产成人一区二区三区 | 一本大道久久a久久精二百| 天天av天天翘天天综合网| 亚洲欧洲综合另类| 国产亚洲一二三区| 91精品国产欧美日韩| 色综合夜色一区| 欧美在线播放高清精品| 欧美在线不卡视频| aa级大片欧美| thepron国产精品| 国产成人在线色| 国产成人在线观看| 日韩成人一区二区三区在线观看| 中文字幕成人av| 欧美一级日韩一级| 欧美男人的天堂一二区| 91精品国产一区二区三区蜜臀| 99精品视频中文字幕| 成人av在线电影| 色美美综合视频| 欧美日韩高清不卡| 91精品国产高清一区二区三区| 欧美性猛交xxxxxx富婆| 一本大道久久a久久精二百| 91免费国产在线观看| 国产成a人无v码亚洲福利| 国产综合色在线视频区| 色噜噜狠狠成人中文综合| 欧美人妖巨大在线| 亚洲精品一区二区三区影院| 久久一日本道色综合| 亚洲一二三四久久| 韩国v欧美v亚洲v日本v| 91色在线porny| 欧美精品日韩综合在线| 日韩久久久精品| 亚洲最新视频在线播放| eeuss影院一区二区三区| 制服丝袜日韩国产| 国产欧美一二三区| 久久99精品国产麻豆婷婷| 欧美在线|欧美| 国产精品灌醉下药二区| 免费精品视频在线| 欧美色综合天天久久综合精品| 久久久久久久久久久久电影 | 91老司机福利 在线| 欧美一区二区私人影院日本| 国产精品久久久一本精品| 卡一卡二国产精品| 91精品国产综合久久香蕉的特点| 久久人人超碰精品| 国产福利一区在线观看| 在线不卡中文字幕| 亚洲精品欧美激情|