加入星计划,您可以享受以下权益:

  • 创作内容快速变现
  • 行业影响力扩散
  • 作品版权保护
  • 300W+ 专业用户
  • 1.5W+ 优质创作者
  • 5000+ 长期合作伙伴
立即加入

基于51单片机的舞蹈机器人步进机仿真设计

09/27 08:55
581
服务支持:
技术交流群

完成交易后在“购买成功”页面扫码入群,即可与技术大咖们分享疑惑和经验、收获成长和认同、领取优惠和红包等。

虚拟商品不可退

当前内容为数字版权作品,购买后不支持退换且无法转移使用。

加入交流群
扫码加入
获取工程师必备礼包
参与热点资讯讨论
放大
实物图
相关方案
  • 方案介绍
  • 相关文件
  • 相关推荐
  • 电子产业图谱
申请入驻 产业图谱

部分程序:

#include "reg51.h"

#include "intrins.H"

//8步式步进电机脉冲序列

//unsigned char steps[8] = {0x77,0x33,0xbb,0x99,0xdd,0xcc,0xee,0x66};

unsigned char steps[8] = {0x2,0x6,0x4,0xc,0x8,0x9,0x1,0x3};

//当前各电机在上述序列中的位置

unsigned char cur_step[8] = {0,0,0,0,0,0,0,0};

//这个文件用于记录舞步信息序列

char speed_tickers[8] = {0,0,0,0,0,0,0,0};

//从上述文件中读出的当前舞步信息

unsigned char speeds[8] = {0,0,0,0,0,0,0,0};

unsigned char data_pointer = 0;//指向舞步数据的指针

unsigned char time_t = 0;//指定重新读取一次 speeds 值的计时周期

code char dancedata[] = {54,15,12,12,87,95,65,45,-89,-88,-54,-54,54,68,-45,-65,-65,-48,101,121,115,117,19,

-98,-100,-21,-114,-101,-24,-98,95,102,102,100,130,30,10,-90,-120,87,102,103,105,109,104,-30,-102,-104,-106,110,100,

54,15,12,12,87,95,65,45,-89,-88,-54,-54,-98,95,102,102,100,130,30,10,-90,-120,87,102-114,-101,-24,-98,95,102,102,

100,130,30,10,-90,-120,87,102,102,100,130,30,10,-90,-120,87,102,103,105,54,15,12,12,87,95,65,45,-89,-88,-54,

-98,-100,-21,-114,-101,-24,-98,95,102,102,100,130,30,10,-90,-120,87,102,103,105,12,87,95,65,45,-89,-88,-54,

-98,-100,-21,-114,-101,-24,-98,95,102,102,100,130,30,10,-90,-120,87,102,103,105,109,104,-30,-102,-104,-106,110,

100,130,30,10,-90,-120,87,102,102,100,130,30,10,-90,-120,87,-120,87,102,103,105,109,104,-30,-102,-104,-106,110,

54,15,12,12,87,95,65,45,-89,-88,-54,-54,-98,95,102,102,100,130,30,10,-90,-120,87,102-114,-101,-24,-98,95,102,102,

54,15,12,12,87,95,65,45,-89,-88,-54,-54,-98,95,102,102,100,130,30,10,-90,-120,87,102-114,-101,-24,-98,95,102,102,

54,15,12,12,87,95,65,45,-89,-88,-54,-54,-98,95,102,102,100,130,30,10,-90,-120,87,102-114,-101,-24,-98,95,102,102,

54,15,12,12,87,95,65,45,-89,-88,-54,-54,-98,95,102,102,100,130,30,10,-90,-120,87,102-114,-101,-24,-98,95,102,102,

-98,-100,-21,-114,-101,-24,-98,95,102,102,100,130,30,10,-90,-120,87,102,103,105,12,87,95,65,45,-89,-88,-54,

-98,-100,-21,-114,-101,-24,-98,95,102,102,100,130,30,10,-90,-120,87,102,103,105,12,87,95,65,45,-89,-88,-54,

-98,-100,-21,-114,-101,-24,-98,95,102,102,100,130,30,10,-90,-120,87,102,103,105,12,87,95,65,45,-89,-88,-54,

};

code char pin[8] = {1,2,4,8,16,32,64,128};

char MAX_SPEED_TICKER = 120;

unsigned char i; //电机序号

void SetAllSpeeds(void)  //设置各电机的速度,并让它运动起来

{

char delta;  //旋转方向 1:正 -1:反  0:停

for(i=0;i<8;i++)

{

P2=pin[i]; //发送锁存信号

speed_tickers[i] += speeds[i]; //计数值增加 speed[i]越高,增加得越多

if(speed_tickers[i] >= MAX_SPEED_TICKER) //如果计数值超过预定最大值,就发送脉冲

{

speed_tickers[i] = 0;

delta = 1;

}

{

speed_tickers[i] = 0;

delta = -1;

}

else delta = 0;

cur_step[i] += delta;

cur_step[i] &= 0x07; //计算当前应发脉冲

P0 = steps[cur_step[i]];

P2 = 0;

}

}

void main()  //程序的入口

{

InitTimer();  //初始化后等中断

while(1);

}

 

  • 有需要资料的可了解一下.docx

相关推荐

电子产业图谱