cpubbs论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

LabVIEW+单片机学习套件全套教程资料下载[免费]LabVIEW论坛精华列表贴USB0816数据采集卡《LabVIEW宝典》
LabWindows/CVI论坛精华贴NET0816以太网数据采集卡RC0210远程设备授权系统 关闭关停锁定打开设备 户外分布式数据采集
NET1624低速高精度以太网数据采集卡WIFI0824SD无线WIFI网络数据采集卡脱机运行 SD存储 小尺寸微型 串口采集远程采集 安卓 手持移动采集 纪录仪
查看: 2109|回复: 4

AT89C2051驱动步进电机的电路和源码

[复制链接]
发表于 2004-11-26 01:48:27 | 显示全部楼层 |阅读模式
<>电路如图所示:</P>

<><img src="attachments/dvbbs/2004-11/2004112517489628.gif" border="0" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt=\'Click here to open new window\nCTRL+Mouse wheel to zoom in/out\';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor=\'hand\'; this.alt=\'Click here to open new window\nCTRL+Mouse wheel to zoom in/out\';}" onclick="if(!this.resized) {return true;} else {window.open(\'attachments/dvbbs/2004-11/2004112517489628.gif\');}" onmousewheel="return imgzoom(this);" alt="" /></P>
<>程序

stepper.c
stepper.hex </P>
<P>/*
* STEPPER.C
* sweeping stepper's rotor cw and cww 400 steps
* Copyright (c) 1999 by W.Sirichote
*/ </P>
<P>#include c:\mc51\8051io.h /* include i/o header file */
#include c:\mc51\8051reg.h </P>
<P>register unsigned char j,flag1,temp;
register unsigned int cw_n,ccw_n; </P>
<P>unsigned char step[8]={0x80,0xc0,0x40,0x60,0x20,0x30,0x10,0x90}
#define n 400 </P>
<P>/* flag1 mask byte
0x01 run cw()
0x02 run ccw()
*/ </P>
<P>main() </P>
<P>{
flag1=0;
serinit(9600);
disable(); /* no need timer interrupt */
cw_n = n; /* initial step number for cw */
flag1 |=0x01; /* initial enable cw() */ </P>
<P>while(1){
{
tick_wait(); /* wait for 10ms elapsed */ </P>
<P>energize(); /* round-robin execution the following tasks every 10ms */
cw();
ccw();
}
} </P>
<P>} </P>
<P>cw(){
if((flag1&amp;0x01)!=0)
{
cw_n--; /* decrement cw step number */
if (cw_n !=0)
j++; /* if not zero increment index j */
else
{flag1&amp;=~0x01; /* disable cw() execution */
ccw_n = n; /* reload step number to ccw counter */
flag1 |=0x02; /* enable cww() execution */
}
} </P>
<P>} </P>
<P>ccw(){
if((flag1&amp;0x02)!=0)
{
ccw_n--; /* decremnent ccw step number */
if (ccw_n !=0)
j--; /* if not zero decrement index j */
else
{flag1&amp;=~0x02; /* disable ccw() execution */
cw_n = n; /* reload step number to cw counter */
flag1 |=0x01; /* enable cw() execution */
}
} </P>
<P>} </P>
<P>tick_wait(){ /* cputick was replaced by simpler ASM code 10ms wait */ </P>
<P>asm" JNB TCON.5,*"; /* wait for TF0 set */
asm" CLR TCON.5"; /* clear TF0 for further set */
asm" ORL TH0,#$DC"; /* reload TH0 with $DC, TL0 = 0 */
} </P>
<P>energize(){ </P>
<P>P1 = step[(j&amp;0x07)]; /* only step 0-7 needed */
}</P>
<P>
</P>

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
发表于 2004-12-2 02:04:28 | 显示全部楼层
<>老大,帮我个忙,现在一块步进电机的控制器大概多少钱?</P><>除了控制器  还有什么方法能控制步进电机?</P>
 楼主| 发表于 2004-12-3 01:19:06 | 显示全部楼层
步进电机本来就是靠一个脉冲转一个角度的呀,没有控制器你得加一些脉冲发生器了哦!
 楼主| 发表于 2004-12-6 17:21:12 | 显示全部楼层
步进电机不贵,我昨天看了一下,最小的10块钱,还有15,20,30这样价格的,当然也有更大的就更贵了!
发表于 2004-12-15 01:26:39 | 显示全部楼层
hehe 我指步进电机的控制卡  我查到得都是2000多  我想知道有没有便宜的
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|cpubbs论坛. ( 粤ICP备09171248号 )

GMT+8, 2025-5-3 22:54 , Processed in 0.672172 second(s), 7 queries , Gzip On, File On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表