-
大小: 4KB文件類(lèi)型: .c金幣: 1下載: 0 次發(fā)布日期: 2021-01-09
- 語(yǔ)言: 其他
- 標(biāo)簽: 51單片機(jī)??步進(jìn)電機(jī)??
資源簡(jiǎn)介
嘗試用51單片機(jī)控制步進(jìn)電機(jī),所能實(shí)現(xiàn)功能包括按鍵控制步進(jìn)電機(jī)加減速及正反轉(zhuǎn)。
代碼片段和文件信息
#include?
/********************************************************************************************************
**?????????????????????????Marcos?define
*********************************************************************************************************/
#define?MotorTabNum?5
unsigned?char?T0_NUM;
sbit?K1?=?P3^5;????????//?啟動(dòng)
sbit?K2?=?P3^4;????????//?反向
sbit?K3?=?P3^3;????????//?加速
sbit?K4?=?P3^2;????????//?減速
sbit?K5?=?P3^1;????????//?往返
sbit?FX??????=?P2^4;?????//?反向
//sbit?MotorEn?=?P2^5;?????//?使能
sbit?CLK?????=?P2^6;?????//?脈沖
int?table[]={0x3f0x060x5b0x4f0x660x6d0x7d0x070x7f0x6f0x40};???????????//????????
unsigned?char?g_MotorSt?=?0;?????//?啟停
unsigned?char?g_MotorDir?=?0;????//?正反
unsigned?char?MotorTab[7]?=?{12?10?8?6?4?2
評(píng)論
共有 條評(píng)論