Initial debugging results and learning experience of single-chip microcomputer controlled brushless motor

Publisher:LeishanLatest update time:2019-11-27 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

I have been tuning the brushless motor for more than a day. The brushless ESC I used should have been made with 32, but I don't know the principle. So I used the more familiar 51 single-chip tablet to debug it. The information I searched was quite simple, but the actual operation was not that easy. There was no usable program on the Internet, especially 51, because basically brushless ones are used in drones with four or six axes. So today I posted my program to share with you, hoping to save you time to learn and get started quickly. The function implemented by this program is to first increase the throttle, then reduce the throttle, and finally fully open the throttle after the brushless motor is powered on for the first time. Note, note, note, note, be sure not to use a brushless motor with a propeller for the experiment, it is dangerous, it will run at full speed after turning on, I open it at full speed to use the duct, so full speed, without
 

further ado, the program
51 single-chip source program is as follows:

/**********************************************************************************/


          //-----------------DC motor PWM speed regulation experimental program----------------//


//Test MCU: STC89C52


//Crystal: 11.0592M (external)


//Reset mode: internal reset

                    

//Debugging environment: KEIL3


//Hardware test environment: Use "Qingxiang Electronics" MCU development board to test


//Program function: PWM, also known as pulse width modulation, refers to changing the high level while keeping the frequency of the periodic pulse signal unchanged.

//

// And the ratio of low level, that is, changing the duty cycle. PWM is used in lighting dimming and DC motor speed regulation

//

// It has a wide range of applications. The program uses timer 0 interrupt to simulate PWM timing, S2 and S3 are two independent buttons 

//

//Keys control the motor speed. To make the demonstration results clear, PWM output

//

// To the entire P1 interface, the brightness change can be seen through the LED light on the board.

//

/********************************************************************************/        


#include


typedef unsigned char uint8;

typedef unsigned int uint16;


sbit down = P3^0;

sbit up = P3^1;


uint8 t = 0;

uint8 PWM_T = 0; //Duty cycle control variable

uint8 pwm_init_ready;

void delay_1ms(uint16 t)

{

        uint16 x,y;

        for(x=t;x>0;x--)

                for(y=120;y>0;y--);

}



          

/****************************************************

                  Main Program

********************************************************/

void main(void)      

{


        TMOD = 0x02; //Timer 0, working mode 2, 8-bit timing mode

        TH0=(65536-20000)/256;// 11.0592, 46080, 50000

        TL0=(65536-20000)%256;//46080???,?50000*11.0592/12

        TR0=1; //Start the timer

        ET0=1; //Enable timer 0 interrupt

        EA=1; //Enable general interrupt

        P1=0xff; //Initialize P1, output port


                PWM_T=19;

                delay_1ms(1000);

    PWM_T=11;

         while(1)              

         { // delay_1ms(3000);

                         PWM_T=48;         

    /* if(!up)

                  {

                                if(PWM_T<200)

                                        {

                                          PWM_T++;

                                        }

                                        while(!up);

                                delay_1ms(10);

                  }

                 if(!down)

                         {

                                if(PWM_T>0)

                                        {

                                          PWM_T--;

                                        }

                                while(!down);

                                delay_1ms(10);

                        }*/


        

         }      

}

timer0() interrupt 1  

{         

         t++; //Add 1 every time the timer overflows

         TH0=(65536-20000)/256;// 11.0592, 46080, 50000

   TL0=(65536-20000)%256;//46080???,?50000*11.0592/12

         if(t==200) //PWM cycle 100 units

                 {

                          t=0; //Set t=0 to start a new PWM cycle

                          P1=0xff; //output port

                 }

         

         if(t==PWM_T) //Switch the output to high level according to the current duty cycle

……………………



Reference address:Initial debugging results and learning experience of single-chip microcomputer controlled brushless motor

Previous article:Complete design of electronic password lock based on single chip microcomputer
Next article:Simulation Design of Eight-way Answering Machine Based on 51 Single-chip Microcomputer

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号