Experimental report and source code of simulating 51 single-chip microcomputer to control stepper motor using proteus8.0

Publisher:EtherealGraceLatest update time:2019-10-23 Source: 51heiKeywords:proteus8 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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();

                }

        }

        }


Keywords:proteus8 Reference address:Experimental report and source code of simulating 51 single-chip microcomputer to control stepper motor using proteus8.0

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

Experimental report and source code of simulating 51 single-chip microcomputer to control stepper motor using proteus8.0
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
[Microcontroller]
Experimental report and source code of simulating 51 single-chip microcomputer to control stepper motor using proteus8.0
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号