Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1567552
  • 博文数量: 354
  • 博客积分: 8137
  • 博客等级: 中将
  • 技术积分: 5137
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-26 15:40
文章分类

全部博文(354)

文章存档

2010年(300)

2009年(54)

分类: 嵌入式

2010-07-17 15:08:46

/************
步进电机测试程序
步进电机型号:MP28GA步进电机
驱动芯片:ULN2003

连接方式:P10~P13分别接ABCD
Author:Kevin Chin
Date:2010/07/17
Email:kevinchin@qq.com
************/

#include <reg52.h>
#define MotorPort P1
//unsigned char FMove[4] = {0xf1, 0xf2, 0xf4, 0xf8};        //单四拍节 A、B、C、D驱动

//unsigned char FMove[4] = {0xf3, 0xf6, 0xfc, 0xf9};            //双四拍节 AB、BC、CD、DA驱动


//单双8拍节 A、AB、B、BC、C、CD、D、DA驱动

unsigned char FMove[8] = {0xf1, 0xf3, 0xf2, 0xf6, 0xf4, 0xf9, 0xf8};

void mDelay(unsigned int i)     //延时约0.5ms

{
    for(; i > 0; i--)
    {
        unsigned char j = 244;
        while(--j);
    }
}

void main(void)
{
    char *p, i, count;

    p = FMove;
    count = sizeof(FMove);

    while(1)
    {
        for(i = 0; i < count; i++)
        {
            MotorPort = *(p + i);

            mDelay(5);
        }

    }
}


文件:motor.zip
大小:7KB
下载:下载
阅读(1578) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~