ImageVerifierCode 换一换
格式:DOCX , 页数:37 ,大小:27.24KB ,
资源ID:6202384      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/6202384.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(很详细的dspic逆变svpwm程序.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

很详细的dspic逆变svpwm程序.docx

1、很详细的dspic逆变svpwm程序F:dspicCE003_Sinusoidal_BLDC_010908CE003_Sinusoidal_BLDCsourceSinusoidalBLDC v1.1.c/* SOFTWARE LICENSE AGREEMENT:* Microchip Technology Incorporated (Microchip) retains all ownership and* intellectual property rights in the code accompanying this message and in all* derivatives her

2、eto. You may use this code, and any derivatives created by* any person or entity by or on your behalf, exclusively with Microchips* proprietary products. Your acceptance and/or use of this code constitutes* agreement to the terms and conditions of this notice.* CODE ACCOMPANYING THIS MESSAGE IS SUPP

3、LIED BY MICROCHIP AS IS. NO* WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED* TO, IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A* PARTICULAR PURPOSE APPLY TO THIS CODE, ITS INTERACTION WITH MICROCHIPS* PRODUCTS, COMBINATION WITH ANY OTHER PROD

4、UCTS, OR USE IN ANY APPLICATION.* YOU ACKNOWLEDGE AND AGREE THAT, IN NO EVENT, SHALL MICROCHIP BE LIABLE, WHETHER* IN CONTRACT, WARRANTY, TORT (INCLUDING NEGLIGENCE OR BREACH OF STATUTORY DUTY),* STRICT LIABILITY, INDEMNITY, CONTRIBUTION, OR OTHERWISE, FOR ANY INDIRECT, SPECIAL,* PUNITIVE, EXEMPLARY

5、, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, FOR COST OR EXPENSE OF* ANY KIND WHATSOEVER RELATED TO THE CODE, HOWSOEVER CAUSED, EVEN IF MICROCHIP HAS BEEN* ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT* ALLOWABLE BY LAW, MICROCHIPS TOTAL LIABILITY ON ALL CLAIMS IN A

6、NY WAY RELATED TO* THIS CODE, SHALL NOT EXCEED THE PRICE YOU PAID DIRECTLY TO MICROCHIP SPECIFICALLY TO* HAVE THIS CODE DEVELOPED.* You agree that you are solely responsible for testing the code and* determining its suitability. Microchip has no obligation to modify, test,* certify, or support the c

7、ode.* REVISION HISTORY:*/-/ File: sinusoidalBLDC v1.1.c/ Written By: Jorge Zambada, Microchip Technology/ The following files should be included in the MPLAB project:/ sinusoidalBLDC v1.1.c - Main source code file/ SVM.c - Space Vector Modulation file/ SVM.h/ p30f4012.gld - Linker script file/-/ Rev

8、ision History/ July/5/2005 - first version/-#include p30f4012.h#include svm.h/-Device Configuration-_FOSC(CSW_FSCM_OFF & XT_PLL16);_FWDT(WDT_OFF);_FBORPOR(PBOR_ON & BORV_20 & PWRT_64 & MCLR_EN);/-/ Hurst Motor Terminals | MC LV PICDEM Board Connection/ -|-/ Ground Phase -|- G/ Phase Red -|- M1/ Phas

9、e Black -|- M2/ Phase White -|- M3/ Hall White -|- HA/ Hall Brown -|- HB/ Hall Green -|- HCtypedef signed int SFRAC16;#define CLOSED_LOOP / if defined the speed controller will be enabled#define PHASE_ADVANCE / for extended speed ranges this should be defined#define FCY 20000000 / xtal = 5Mhz; PLLx1

10、6 - 20 MIPS#define FPWM 20000 / 20 kHz, so that no audible noise is present.#define _10MILLISEC 10 / Used as a timeout with no hall effect sensors/ transitions and Forcing steps according to the/ actual position of the motor#define _100MILLISEC 100 / after this time has elapsed, the motor is/ consid

11、er stalled and its stopped1F:dspicCE003_Sinusoidal_BLDC_010908CE003_Sinusoidal_BLDCsourceSinusoidalBLDC v1.1.c#define _1000MILLISEC 1000/ These Phase values represent the base Phase value of the sinewave for each/ one of the sectors (each sector is a translation of the hall effect sensors/ reading#d

12、efine PHASE_ZERO 57344#define PHASE_ONE (PHASE_ZERO + 65536/6) % 65536)#define PHASE_TWO (PHASE_ONE + 65536/6) % 65536)#define PHASE_THREE (PHASE_TWO + 65536/6) % 65536)#define PHASE_FOUR (PHASE_THREE + 65536/6) % 65536)#define PHASE_FIVE (PHASE_FOUR + 65536/6) % 65536)#define MAX_PH_ADV_DEG 40 / Th

13、is value represents the maximum allowed phase/ advance in electrical degrees. Set a value from/ 0 to 60. This value will be used to calculate/ phase advance only if PHASE_ADVANCE is defined/ This is the calculation from the required phase advance to the actual/ value to be multiplied by the speed of

14、 the motor. So, if PHASE_ADVANCE is/ enabled, a certain amount of shit angle will be added to the generated/ sine wave, up to a maximum of the specified value on MAX_PH_ADV_DEG. This/ maximum phase shift will be present when the MeasuredSpeed variable is a/ fractional 1.0 (for CW) or -1.0 (for CCW).

15、#define MAX_PH_ADV (int)(float)MAX_PH_ADV_DEG / 360.0) * 65536.0)#define HALLA 1 / Connected to RB3#define HALLB 2 / Connected to RB4#define HALLC 4 / Connected to RB5#define CW 0 / Counter Clock Wise direction#define CCW 1 / Clock Wise direction#define SWITCH_S2 (!PORTCbits.RC14) / Push button S2/

16、Period Calculation/ Period = (TMRClock * 60) / (RPM * Motor_Poles)/ For example/ Motor_Poles = 10/ RPM = 6000 (Max Speed)/ Period = (20,000,000 / 64) * 60) / (6000 * 10) = 312.5/ RPM = 60 (Min Speed)/ Period = (20,000,000 / 64) * 60) / (60 * 10) = 31250#define MINPERIOD 313 / For 6000 max rpm and 10

17、 poles motor#define MAXPERIOD 31250 / For 60 min rpm and 10 poles motor/ Use this MACRO when using floats to initialize signed 16-bit fractional/ variables#define SFloat_To_SFrac16(Float_Value) (Float_Value 0.0) ? (SFRAC16)(32768 * (Float_Value) - 0.5) : (SFRAC16)(32767 * (Float_Value) + 0.5)void In

18、itADC10(void); / Initialization of ADC used for Speed Commandvoid InitMCPWM(void); / Initialization for PWM at 20kHz, Center aligned,/ Complementary mode with 1 us of deadtimevoid InitTMR1(void); / Initialization for TIMER1 used for speed control/ and motor stalled protectionvoid InitTMR3(void); / I

19、nitialization for TIMER3 used as a timebase/ for the two input capture channelsvoid InitUserInt(void); / This function initializes all ports/ (inputs and outputs) for the applicationvoid InitICandCN(void); / Initializes input captures and change notification,/ used for the hall sensor inputsvoid Run

20、Motor(void); / This function initializes all variables/ and interrupts used for starting and running/ the motorvoid StopMotor(void); / This function clears all flags, and stops anything/ related to motor control, and also disables PWMsvoid SpeedControl(void); / This function contains all ASM and C o

21、perations/ for doing the PID Control loop for the speedvoid ForceCommutation(void); / When motor is to slow to generate interrupts/ on halls, this function forces a commutationvoid ChargeBootstraps(void); / At the begining of the motor operation, the/ bootstrap caps are charged with this function/ C

22、onstants used for properly energizing the motor depending on the/ rotors positionint PhaseValues6 _attribute_(far,section(.const,r)=PHASE_ZERO, PHASE_ONE, PHASE_TWO, PHASE_THREE, PHASE_FOUR, PHASE_FIVE;/ In the sinewave generation algorithm we need an offset to be added to the/ pointer when energizi

23、ng the motor in CCW. This is done to compensate an2F:dspicCE003_Sinusoidal_BLDC_010908CE003_Sinusoidal_BLDCsourceSinusoidalBLDC v1.1.c/ asymetry of the sinewaveint PhaseOffset = 4100;/ Flags used for the applicationstructunsigned MotorRunning :1; / This bit is 1 if motor runningunsigned unused :15;F

24、lags;unsigned int Phase; / This variable is incremented by the PWM interrupt/ in order to generate a proper sinewave. Its value/ is incremented by a value of PhaseInc, which/ represents the frequency of the generated sinewavesigned int PhaseInc; / Delta increments of the Phase variable, calculated/

25、in the TIMER1 interrupt (each 1 ms) and used in/ the PWM interrupt (each 50 us)signed int PhaseAdvance; / Used for extending motor speed range. This value/ is added directly to the parameters passed to the/ SVM function (the sine wave generation subroutine)unsigned int HallValue; / This variable hol

26、ds the hall sensor input readingsunsigned int Sector; / This variables holds present sector value, which is/ the rotor positionunsigned int LastSector; / This variable holds the last sector value. This/ is critical to filter slow slew rate on the Hall/ effect sensors hardwareunsigned int MotorStalle

27、dCounter = 0; / This variable gets incremented each/ 1 ms, and is cleared everytime a new/ sector is detected. Used for/ ForceCommutation and MotorStalled/ protection functions/ This array translates the hall state value read from the digital I/O to the/ proper sector. Hall values of 0 or 7 represen

28、t illegal values and therefore/ return -1.char SectorTable = -1,4,2,3,0,5,1,-1;unsigned char Current_Direction; / Current mechanical motor direction of/ rotation Calculated in halls interruptsunsigned char Required_Direction; / Required mechanical motor direction of/ rotation, will have the same sig

29、n as the/ ControlOutput variable from the Speed/ Controller/ Variables containing the Period of half an electrical cycle, which is an/ interrupt each edge of one of the hall sensor inputunsigned int PastCapture, ActualCapture, Period;/ Used as a temporal variable to perform a fractional divide operation in/ assemblySFRAC16 _MINPERIOD = MINPERIOD - 1;SFRAC16 MeasuredSpeed, RefSpeed; / Actual and Desired speeds for the PID/ controller, that will generate the errorSFRAC16 ControlOutput = 0; / Controller output, used as a voltage output,/ use its sig

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1