Control Method of 28BYJ48 Stepper Motor

Publisher:caoda143Latest update time:2016-01-18 Source: eefocusKeywords:28BYJ48 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
  I got a 28BYJ48 stepper motor not long ago, but I didn't have any information. I searched online and found some information, but I didn't succeed in following the program experiments introduced online. Later, according to the principle part of the information, I tried to write a program myself, and after many experiments and debugging, I finally succeeded.

  Haha, quite a harvest!!!

  A stepper motor is an actuator that converts electrical pulses into angular displacement. In simple terms: when the stepper driver receives a pulse signal, it drives the stepper motor to rotate a fixed angle (i.e., step angle) in the set direction. We can control the angular displacement by controlling the number of pulses to achieve accurate positioning; at the same time, we can control the speed and acceleration of the motor by controlling the pulse frequency to achieve speed regulation.

  The 28BYJ48 stepper motor is a four-phase eight-beat motor with a voltage of DC5V~DC12V. When a series of continuous control pulses are applied to the stepper motor in a certain order, it can rotate continuously. Each pulse signal changes the power-on state of one or two phases of the stepper motor winding once, which corresponds to the rotor rotating a certain angle. When the change of the power-on state completes a cycle, the rotor rotates one tooth pitch. The four-phase stepper motor can operate in different power-on modes. Common power-on modes include single (single-phase winding power-on) four-beat (ABCDA...), double (two-phase winding power-on) four-beat (AB-BC-CD-DA-AB...), and four-phase eight-beat (A-AB-B-BC-C-CD-D-DA-A...). This example is implemented using the four-phase eight-beat drive mode.

  The following is the C language control program I wrote to achieve the effect of the 28BYJ48 stepper motor rotating five circles forward and then five circles reverse:

//************************************************************************************
//*  Title:  Stepper motor forward and reverse demonstration program                                               *
//*  File:  Stepper motor forward and reverse demonstration.C                                                 *
//*  Date:  2011-3-13                                                            *
//*  Environment:  Use the homemade microcontroller minimum system board to test passed                                     *
//************************************************************************************
//*  Description:  28BYJ-48 stepper motor forward and reverse control                                           *
//*  Motor use ports: P1.0, P1.1, P1.2, P1.3                                        *
//*  Single and double eight-beat working mode: A-AB-B-BC-C-CD-D-DA                                       *
//********************************************************************************

#include
#include

//*************************Forward rotation phase sequence table*****************************
unsigned char code FFW[8]={0x08,0x0c,0x04,0x06,0x02,0x03,0x01,0x09};

//**********************Reverse rotation phase sequence table***************************** 

unsigned char code REV[8]={0x09,0x01,0x03,0x02,0x06,0x04,0x0c,0x08};

//***********************Delay subroutine******************************** 

void delay(unsigned int t)
                         
  unsigned int k;
  while(t--)
  {
    for(k=0; k<125; k++)
    {}
  }
}

 

//*************************Stepper motor forward ******************************** 

void  motor_ffw(unsigned int n)
 {
  unsigned char i;
  unsigned int  j;
  for (j=0; j<8*64*n; j++)
   {
     for (i=0; i<8; i++)
       {
         P1 = FFW[ i];
        delay(1);
        }
   }
 }

 

//*********************Stepper motor reverse ********************************** 

void  motor_rev(unsigned int n)
{
   unsigned char i;
 unsigned int  j;
 for (j=0; j<8*64*n; j++)
     {
       for (i=0; i<8; i++)
       {
         P1 = REV[ i];
         delay(1);
       }
     }
 }

 

//*************************Main program************************************
main()
  
  while(1)                     
   
      motor_ffw(5);          //The motor rotates 5 times forward
      delay(1000);
      motor_rev(5);          //The motor rotates 5 times reverse
      delay(1000);

   }
 }

Keywords:28BYJ48 Reference address:Control Method of 28BYJ48 Stepper Motor

Previous article:An interesting explanation of the concept of microcontroller stack
Next article:8 steps to learn microcontrollers

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号