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

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

?? pmsm.c

?? Source Code for Sensorless FOC for PMSM with PFC for dsPIC30F6010A
?? C
?? 第 1 頁 / 共 2 頁
字號:
 /**********************************************************************
 *                                                                     *
 *                        Software License Agreement                   *
 *                                                                     *
 *    The software supplied herewith by Microchip Technology           *
 *    Incorporated (the "Company") for its dsPIC controller            *
 *    is intended and supplied to you, the Company's customer,         *
 *    for use solely and exclusively on Microchip dsPIC                *
 *    products. The software is owned by the Company and/or its        *
 *    supplier, 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 IN AN "AS IS" CONDITION.  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. THE     *
 *    COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL,  *
 *    INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.  *
 *                                                                     *
  **********************************************************************/

 /**********************************************************************
 *                                                                     * 
 *    Author: John Theys/Dave Ross/Jorge Zambada                       * 
 *                                                                     *
 *    Filename:       PMSM.c                                           *
 *    Date:           04/27/07                                         *
 *    File Version:   1.00                                             *
 *                                                                     *
 *    Tools used: MPLAB GL  -> 7.52.0.0                                *
 *                                                                     *
 *    Linker File:    p30f6010a.gld                                     *
 *                                                                     *
 *                                                                     *
 ***********************************************************************
 *10/31/03  2.00    Released    Motor runs fine, still some loose ends
 *
 *12/19/03  2.01    Cleaned up structure, created UserParms.h for all 
 *                  user defines.
 *
 *02/12/04	3.00	-Removed unnecessary files from project.
 					-Changed iRPM to int to correct floating point calc
 * 					problems.
 *					-CalcVel() and velocity control loop only execute
 *					after number of loop periods specified by
 *					iIrpPerCalc.
 *					-Added iDispLoopCount variable to schedule 
 *					execution of display and button routines
 *					-trig.s file changed to use program space for 
 *					storage of sine data.
 *					-Added DiagnosticsOutput() function that uses 
 *					output compare channels to output control variable
 *					information.
 *					-Added TORQUE_MODE definition to bypass velocity
 *					control loop.
 *					-Turned off SATDW bit in curmodel.s file.  The
 *					automatic saturation feature prevents slip
 *					angle calculation from wrapping properly.
 *04/27/07  4.00    -PMSM functionality added. Speed and Position Estimation
 *                  is used to control PMSM motors. ACIM is not supported.
 *
 ************************************************************************
 *      Code Description
 *  
 *  This file demonstrates Vector Control of a 3 phase PMSM using the
 *  dsPIC30F.  SVM is used as the modulation strategy. Currents are measured
 *  to estimate position and speed of PMSM Motors
 **********************************************************************/

/************** GLOBAL DEFINITIONS ***********/




/************* START OF MAIN FUNCTION ***************/
int main ( void )
{
	SMCInit(&smc1);

    SetupPorts();
	InitLCD();
    InitOutputCompare6();                       // Configure and intialize the Output Compare Module
   	SetupControlParameters(); 
	OC6CONbits.OCM = 0b110;                     // Set the Output Compare Module for PWM Mode
    T3CONbits.TON = 1;                          // Start Timer-3 Module

    while(1)
        {
        uGF.Word = 0;                   // clear flags
        
        // init Mode
        uGF.bit.OpenLoop = 1;           // start in openloop
		
		// init LEDs
        pinLED1 = 0;
        pinLED2 = !uGF.bit.OpenLoop;
        pinLED3 = 0;
        pinLED4 = 0;

        // init board
        SetupBoard();
        
        // init user specified parms and stop on error
        if( SetupParm() )
            {
            // Error
            uGF.bit.RunMotor=0;
            return;
            }
        
        // zero out i sums 
        PIParmD.qdSum = 0;
        PIParmQ.qdSum = 0;
        PIParmQref.qdSum = 0;
     
        iMaxLoopCnt = 0;
        
        Wrt_S_LCD("Vector Control  ", 0 , 0);
        Wrt_S_LCD("S4-Run/Stop     ", 0, 1);
                
        // Enable ADC interrupt and begin main loop timing
        IFS0bits.ADIF = 0; 
        IEC0bits.ADIE = 1;
		
        if(!uGF.bit.RunMotor)
            {	            
            // Initialize current offset compensation
            while(!pinButton1)                  //wait here until button 1 is pressed 
                {
                ClrWdt();               

                // Start offset accumulation    //and accumulate current offset while waiting
                MeasCompCurr();

                }
            while(pinButton1);                  //when button 1 is released 
			SetupParm();
            uGF.bit.RunMotor = 1;               //then start motor
            }

        // Run the motor
        uGF.bit.ChangeMode = 1;
        // Enable the driver IC on the motor control PCB
        pinPWMOutputEnable_ = 0;
        
		Wrt_S_LCD("RPM=            ", 0, 0);
		Wrt_S_LCD("S5-Cls. Lp S6-2x", 0, 1);
		
		//Run Motor loop
        while(1)
            {
            ClrWdt();
            
            // Write vector control variables to output compare channels
            // for observation on oscilloscope.
                          
            // The code that updates the LCD display and polls the buttons
            // executes every 50 msec.
            
            if(iDispLoopCnt >= dDispLoopCnt)
            	{
            	//Display RPM
            	Dis_RPM(5,0);
      			// Button 1 starts or stops the motor
                if(pinButton1)  
	                {
                    if( !uGF.bit.Btn1Pressed )
                        uGF.bit.Btn1Pressed  = 1;
                    }
                else
                    {
                    if( uGF.bit.Btn1Pressed )
                        {
                        // Button just released
                        uGF.bit.Btn1Pressed  = 0;
                        // begin stop sequence
                        uGF.bit.RunMotor = 0;
                        pinPWMOutputEnable_ = 1;
                        break;
                        }
                    }
                    
				//while running button 2 will toggle open and closed loop
                if(pinButton2)                  
                    {
                    if( !uGF.bit.Btn2Pressed )
                        uGF.bit.Btn2Pressed  = 1;
                    }
                else
                    {
                    if( uGF.bit.Btn2Pressed )
                        {
                        // Button just released
                        uGF.bit.Btn2Pressed  = 0;
                        uGF.bit.ChangeMode = 1;
                        uGF.bit.OpenLoop = ! uGF.bit.OpenLoop;
                        pinLED2 = !uGF.bit.OpenLoop;
                        }
                    }
				
				//while running button 3 will double/half the speed or torque demand
                if(pinButton3)                      
                    {
                    if( !uGF.bit.Btn3Pressed )
                        uGF.bit.Btn3Pressed  = 1;
                        LATGbits.LATG0 = 0;
                    }
                else
                    {
                    if( uGF.bit.Btn3Pressed )
                        {
                        // Button just released
                        uGF.bit.Btn3Pressed  = 0;
                        uGF.bit.ChangeSpeed = !uGF.bit.ChangeSpeed;
                        pinLED3 = uGF.bit.ChangeSpeed;
                        
                        #ifdef SNAPSHOT
                        uGF.bit.DoSnap = 1;
                        SnapCount = 0;
                        pinLED4 = 1;
                        #endif
                        
                        }
                    }
				
				if( uGF.bit.SnapDone )
                    { 
                                         
                     uGF.bit.SnapDone=0;
                     pinLED4 = 0;          
                        
                    }

                }  // end of display and button polling code              
                
            }   // End of Run Motor loop

        
        } // End of Main loop
        
    // should never get here
    while(1){}
}

//---------------------------------------------------------------------
// Executes one PI itteration for each of the three loops Id,Iq,Speed

void DoControl( void )
{
short i;
short TempAng;

    // Assume ADC channel 0 has raw A/D value in signed fractional form from
    // speed pot (AN7).
    
	ReadSignedADC0( &ReadADCParm );
	
    if( uGF.bit.OpenLoop )
        {
        // OPENLOOP:  force rotating angle,Vd,Vq

        if( uGF.bit.ChangeMode )
            {
            // just changed to openloop
            uGF.bit.ChangeMode = 0;
            // synchronize angles

            // VqRef & VdRef not used
            CtrlParm.qVqRef = 0;
            CtrlParm.qVdRef = 0;
			uGF.bit.DoSnap = 1;
			Startup_Lock = 0;
			Startup_Ramp = 0;
			// Initialize SMC
			smc1.Valpha = 0;
			smc1.Ealpha = 0;
			smc1.EalphaFinal = 0;
			smc1.Zalpha = 0;
			smc1.EstIalpha = 0;
			smc1.Vbeta = 0;
			smc1.Ebeta = 0;
			smc1.EbetaFinal = 0;
			smc1.Zbeta = 0;
			smc1.EstIbeta = 0;
			smc1.Ialpha = 0;
			smc1.IalphaError = 0;
			smc1.Ibeta = 0;
			smc1.IbetaError = 0;
			smc1.Theta = 0;
			smc1.Omega = 0;

            }

		CtrlParm.qVelRef = ADCBUF3/2; // Initial Torque Reference

        #ifdef	SNAPSHOT
		// Log data in the snapshot buffers
       	if( uGF.bit.DoSnap )
        {
	     SnapBuf1[SnapCount] = SNAP1;
	     SnapBuf2[SnapCount] = SNAP2;  
	     SnapBuf3[SnapCount] = SNAP3;   
	     SnapCount++;    
         if(SnapCount == SNAPSIZE)
            {
				SnapCount = 0;
            }
         }
       	#endif

        if(AccumThetaCnt == 0)
	    {
			CalcVel();
            PIParmQref.qInMeas = smc1.Omega;
		}

        CtrlParm.qVqRef    = CtrlParm.qVelRef;
       	
        // PI control for Q
        PIParmQ.qInMeas = ParkParm.qIq;
        PIParmQ.qInRef  = CtrlParm.qVqRef;
        CalcPI(&PIParmQ);
        ParkParm.qVq    = PIParmQ.qOut;       

        // PI control for D
        PIParmD.qInMeas = ParkParm.qId;
        PIParmD.qInRef  = CtrlParm.qVdRef;
        CalcPI(&PIParmD);
        ParkParm.qVd    = PIParmD.qOut;
    }

    else
        // Closed Loop Vector Control
        {

		if(uGF.bit.ChangeSpeed)
		{
		    CtrlParm.qVelRef = ReadADCParm.qADValue/3;
		}
		else
		{
		    CtrlParm.qVelRef = ReadADCParm.qADValue/6;
		}

        if( uGF.bit.ChangeMode )
        {
            // just changed from openloop
            uGF.bit.ChangeMode = 0;
			PIParmQref.qdSum = (long)CtrlParm.qVqRef << 13;
			Startup_Lock = 0;
			Startup_Ramp = 0;
	    }               
                
        // Check to see if new velocity information is available by comparing
        // the number of interrupts per velocity calculation against the
        // number of velocity count samples taken.  If new velocity info
        // is available, calculate the new velocity value and execute
        // the speed control loop.

        if(AccumThetaCnt == 0)
        	{
	        // Calculate velocity from acumulated encoder counts
        	CalcVel();
        	// Execute the velocity control loop
			PIParmQref.qInMeas = smc1.Omega;
        	PIParmQref.qInRef  = CtrlParm.qVelRef;
        	CalcPI(&PIParmQref);
        	CtrlParm.qVqRef = PIParmQref.qOut;
           	}
       
        #ifdef	SNAPSHOT
		if(SnapShotDelayCnt++ == SnapShotDelay)
		{

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美性大战久久久久久久蜜臀| 欧美一二三在线| 日韩av中文字幕一区二区三区| 久久久久久久久久美女| 欧美日韩一区二区三区不卡 | 亚洲欧美色一区| 2020日本不卡一区二区视频| 欧美色网一区二区| 不卡的av电影| 国产盗摄女厕一区二区三区| 日日摸夜夜添夜夜添精品视频 | 亚洲永久精品国产| 国产欧美一区二区在线| 日韩免费观看高清完整版| 欧洲精品在线观看| 成人美女在线观看| 国产乱码精品一区二区三区av | 色综合天天在线| 国产成人日日夜夜| 精品一区二区三区免费毛片爱| 天天综合色天天综合色h| 亚洲自拍都市欧美小说| 亚洲男人天堂av网| **网站欧美大片在线观看| 欧美国产日韩亚洲一区| 精品福利一区二区三区免费视频| 7777精品伊人久久久大香线蕉完整版| 日本高清免费不卡视频| 91小视频在线观看| 99精品欧美一区二区三区小说| 国产精品一区免费在线观看| 国产又粗又猛又爽又黄91精品| 精品一区二区在线看| 蜜桃久久av一区| 日韩国产精品久久久| 天天射综合影视| 蜜桃视频一区二区三区在线观看| 青青草97国产精品免费观看无弹窗版| 亚洲成av人片一区二区| 午夜精品福利一区二区三区av| 亚洲chinese男男1069| 亚洲成人久久影院| 全部av―极品视觉盛宴亚洲| 日本三级亚洲精品| 国产综合久久久久久鬼色| 精品无人码麻豆乱码1区2区 | 精品国产伦一区二区三区观看方式| 日韩欧美中文一区二区| 日韩精品专区在线影院重磅| 日韩精品在线看片z| 久久综合999| 欧美激情在线观看视频免费| 国产精品伦一区| 亚洲免费看黄网站| 日韩国产精品久久| 国产毛片一区二区| 99精品视频在线免费观看| 91成人国产精品| 7777精品伊人久久久大香线蕉完整版 | 亚洲五月六月丁香激情| 日本91福利区| 成人小视频免费观看| 一本色道a无线码一区v| 欧美肥妇bbw| 国产午夜精品一区二区三区四区| 国产精品久久免费看| 亚洲午夜电影在线| 国产一区二区三区免费播放| 成人免费毛片高清视频| 欧美日韩欧美一区二区| 久久亚洲欧美国产精品乐播| 亚洲欧美日韩国产一区二区三区 | 91精品蜜臀在线一区尤物| 久久夜色精品国产噜噜av| 亚洲天堂免费看| 免费日本视频一区| av高清不卡在线| 日韩欧美成人午夜| 中文字幕在线不卡一区二区三区| 亚洲图片欧美一区| 粉嫩高潮美女一区二区三区| 精品视频999| 中文成人av在线| 奇米精品一区二区三区四区| 成人晚上爱看视频| 日韩午夜av一区| 亚洲精品视频免费看| 国产一区二区0| 欧美日韩国产乱码电影| 国产精品欧美一级免费| 天天操天天色综合| 不卡av在线免费观看| 欧美成人三级电影在线| 一个色综合av| 成人免费视频caoporn| 日韩欧美一卡二卡| 亚洲国产aⅴ天堂久久| 99久久免费国产| 精品国产1区2区3区| 三级一区在线视频先锋 | 亚洲综合一区二区三区| 国产精品资源在线| 欧美一区二区播放| 夜夜嗨av一区二区三区四季av| 成人在线综合网| 精品少妇一区二区三区日产乱码 | 精彩视频一区二区三区| 欧美吻胸吃奶大尺度电影 | 五月婷婷欧美视频| 色综合久久久久久久久久久| 久久久久久久久久美女| 蜜桃久久精品一区二区| 欧美人动与zoxxxx乱| 亚洲精品ww久久久久久p站| 高清beeg欧美| 久久久99久久精品欧美| 国产在线视频一区二区三区| 欧美精品 国产精品| 亚洲综合在线视频| 色综合久久久久| 国产精品二三区| 成人午夜电影网站| 国产精品网曝门| 成人av电影在线观看| 久久精品一区二区三区不卡牛牛| 激情综合色播激情啊| 精品动漫一区二区三区在线观看 | 欧美在线观看一区| 一区二区三区四区在线免费观看| 91在线观看成人| 曰韩精品一区二区| 在线观看成人小视频| 亚洲国产中文字幕| 欧美日韩一区小说| 日本视频在线一区| 欧美va亚洲va香蕉在线| 激情综合五月天| 国产午夜一区二区三区| 粉嫩一区二区三区性色av| 国产精品卡一卡二| www.久久久久久久久| 亚洲精品国产无天堂网2021| 欧美在线高清视频| 偷拍日韩校园综合在线| 日韩三级伦理片妻子的秘密按摩| 精品一区二区三区在线视频| 久久精品这里都是精品| 成人精品gif动图一区| 亚洲三级小视频| 欧美性大战久久久久久久蜜臀 | 免播放器亚洲一区| 精品乱人伦小说| 岛国av在线一区| 亚洲日本在线观看| 欧美日韩视频在线观看一区二区三区| 丝袜美腿亚洲综合| 久久综合中文字幕| av电影在线观看一区| 亚洲h精品动漫在线观看| 精品久久久久久久久久久院品网| 国产河南妇女毛片精品久久久| 亚洲视频免费观看| 在线电影国产精品| 国产乱人伦精品一区二区在线观看| 国产精品二区一区二区aⅴ污介绍| 色婷婷久久99综合精品jk白丝| 日精品一区二区| 国产亚洲一区二区三区在线观看| 色综合亚洲欧洲| 久久成人久久爱| 亚洲日本va午夜在线影院| 91精品在线观看入口| 成人影视亚洲图片在线| 婷婷中文字幕综合| 国产精品情趣视频| 日韩午夜三级在线| 91美女福利视频| 蜜桃久久精品一区二区| 中文字幕亚洲区| 日韩精品一区二区三区蜜臀 | 欧美成人高清电影在线| av一二三不卡影片| 青青青爽久久午夜综合久久午夜 | 久久99国产精品尤物| 中文字幕一区二区三区乱码在线| 这里只有精品免费| 91在线云播放| 久久99久久精品| 亚洲精品一二三| 国产午夜精品久久| 欧美一区二区三区在线| 91美女在线看| 国产盗摄精品一区二区三区在线| 首页国产欧美日韩丝袜| 亚洲柠檬福利资源导航| 久久久久久久久99精品| 91精品麻豆日日躁夜夜躁| 色婷婷久久久久swag精品| 国产ts人妖一区二区| 精品一区二区三区在线播放 |