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----------------//
//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 ……………………
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
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- During the Mid-Autumn Festival, engineers will not work overtime!
- Different types of pin headers
- How to select peripheral components of DC-DC boost regulator
- Example interpretation of 51 single chip microcomputer complete learning and application
- FM33LG0xx FL Library Examples & Keil Pack
- How do zstack routers and terminal nodes share a common set of programs?
- The efficiency has little to do with IC.
- Display technologies for IoT devices
- [Sipeed LicheeRV 86 Panel Review] 13- Review Summary
- Do I need to remove 1, 2, 3, and 4 from this comment? It seems more detailed, but is it not standard or good?