• 方案介紹
  • 附件下載
  • 相關(guān)推薦
申請(qǐng)入駐 產(chǎn)業(yè)圖譜

基于51單片機(jī)的舞蹈機(jī)器人步進(jìn)機(jī)仿真設(shè)計(jì)

2024/09/27
1873
加入交流群
掃碼加入
獲取工程師必備禮包
參與熱點(diǎn)資訊討論

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

共1個(gè)文件

部分程序:

#include "reg51.h"

#include "intrins.H"

//8步式步進(jìn)電機(jī)脈沖序列

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

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

//當(dāng)前各電機(jī)在上述序列中的位置

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

//這個(gè)文件用于記錄舞步信息序列

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

//從上述文件中讀出的當(dāng)前舞步信息

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

unsigned char data_pointer = 0;//指向舞步數(shù)據(jù)的指針

unsigned char time_t = 0;//指定重新讀取一次 speeds 值的計(jì)時(shí)周期

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; //電機(jī)序號(hào)

void SetAllSpeeds(void)? //設(shè)置各電機(jī)的速度,并讓它運(yùn)動(dòng)起來(lái)

{

char delta;? //旋轉(zhuǎn)方向 1:正 -1:反? 0:停

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

{

P2=pin[i]; //發(fā)送鎖存信號(hào)

speed_tickers[i] += speeds[i]; //計(jì)數(shù)值增加 speed[i]越高,增加得越多

if(speed_tickers[i] >= MAX_SPEED_TICKER) //如果計(jì)數(shù)值超過(guò)預(yù)定最大值,就發(fā)送脈沖

{

speed_tickers[i] = 0;

delta = 1;

}

{

speed_tickers[i] = 0;

delta = -1;

}

else delta = 0;

cur_step[i] += delta;

cur_step[i] &= 0x07; //計(jì)算當(dāng)前應(yīng)發(fā)脈沖

P0 = steps[cur_step[i]];

P2 = 0;

}

}

void main()? //程序的入口

{

InitTimer();? //初始化后等中斷

while(1);

}

 

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

相關(guān)推薦

方案定制

去合作
方案開(kāi)發(fā)定制化,2000+方案商即時(shí)響應(yīng)!