Use proteus8.0 to simulate 51 single-chip microcomputer to control stepper motor, and realize simple forward and reverse, acceleration and deceleration control.
ps. This post is only for obtaining black coins. If there is any similarity, please guarantee
the experimental content.
Master the method of joint simulation debugging of KeilC51 software and Protues software;
Master the working principle and control method of stepper motor;
Master different programming methods for stepper motor control.
Circuit Diagram
Experimental experience
This experiment taught me that by changing the parameters of the delay function, the stepper motor can be accelerated or decelerated, and by changing the digital analog of the drive motor, the motor can be reversed. I encountered many difficulties during the process, but I finally completed the task under the guidance of the teacher. These two experiments enabled me to use microcomputers to control other devices more skillfully, and I benefited a lot.
The microcontroller source program is as follows:
#include sbit KEY0=P0^0; sbit KEY1=P0^1; sbit KEY2=P0^2; sbit KEY3=P0^3; sbit KEY4=P0^4; unsigned char a[]={0x01,0x02,0x04,0x08}; unsigned char b[]={0x08,0x04,0x02,0x01}; unsigned char c[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8}; unsigned char i,s=0,f=0; unsigned char k=200; unsigned char l=4; void delay(unsigned int t) { unsigned char j,b; b=t; while(b--) { for (j=0;j<125;j++); } } void key() {P0=0x1f; if(P0!=0x1f) {delay(30); if(P0!=0x1f) {delay(30); if(KEY0==0) {s=1;} if(KEY1==0) {f=1;} if(KEY4==0) {s=0; f=0;} if(KEY2==0) {if(l>1) l--;} if(KEY3==0) {if(l<7) l++;} }} } void speed() {switch(l) {case 7:k=50;P1=c[l];break; case 6:k=100;P1=c[l];break; case 5:k=150;P1=c[l];break; case 4:k=200;P1=c[l];break; case 3:k=250;P1=c[l];break; case 2:k=300;P1=c[l];break; case 1:k=350;P1=c[l];break;} } void main() { while(1) {key(); while(s>0) {speed(); for(i=0;i<4;i++) { P2=b[i]; delay(k); key(); } delay(100); key(); } while(f>0) {speed(); for(i=0;i<4;i++) { P2=a[i]; delay(k); key(); } delay(100); key(); } } }
Previous article:Simple electronic piano source code based on 51 single chip microcomputer
Next article:51 MCU driving LCD1602 programming (C language) very detailed tutorial
Recommended ReadingLatest update time:2024-11-16 12:55
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- Single-chip microcomputer C language programming and simulation
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Principles and Applications of Single Chip Microcomputers and C51 Programming (3rd Edition) (Xie Weicheng, Yang Jiaguo)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- EEWORLD University Hall----Live Replay: Infineon & Intron Explanation- How to Choose a Suitable Automotive MOSFET
- Amway uses LT768 to realize TFT industrial serial port screen solution
- Neopixel Christmas Tree
- Gigabit Network Contactless Connector-SK202 Review Unboxing
- What are the methods of wireless bridge relay transmission?
- Diode selection
- The computer will automatically restart when the LabVIEW program is running
- Master these techniques to easily operate DC-DC circuits!
- TYPEC to HDMI 4K@60HZ docking station CS5265 design reference circuit diagram
- DFT design/digital backend PR/digital backend integration/system software/and other positions, Beijing/Shanghai/Nanjing