Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
13Activity
0 of .
Results for:
No results containing your search query
P. 1
MIcro contoller projects

MIcro contoller projects

Ratings: (0)|Views: 927|Likes:
Published by Regan
This file contains three mini projects from 89c series micro controller.
This file contains three mini projects from 89c series micro controller.

More info:

Published by: Regan on Mar 21, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

06/13/2012

pdf

text

original

 
1.Driving Stepper
 
M1 is a stepper taken from an old disk drive. There are five pins, i.e., common, coil 1, 2, 3 and 4.Resistance measured between common pin and each coil is about 75 Ohms. Driving current for eachcoil is then needed about 60mA at +5V supply. A darlington transistor array, ULN2003 is used toincrease driving capacity of the 2051 chip. Each output provides 500mA max at 50V. P1.4 to P1.7,four output pins are connected to the input of the ULN2003 as shown in the circuit. Four 4.7k resistors help the 2051 to provide more sourcing current from the +5V supply. The serial port isoptional for your exercises. Many have provided useful technical, and application of using stepper,see the links below.
stepper.c
 stepper.c stepper.hex I have changed a 10ms time base with a simple TF0 polling instead of using interrupt.The program is just to send the stepper's energizing pattern to the P1 every 10ms. Flag1 isused for intertask communication./** STEPPER.C* sweeping stepper's rotor cw and cww 400 steps* Copyright (c) 1999 by W.Sirichote*/
 
#include c:\mc51\8051io.h /* include i/o header file */#include c:\mc51\8051reg.hregister unsigned char j,flag1,temp;register unsigned int cw_n,ccw_n;unsigned char step[8]={0x80,0xc0,0x40,0x60,0x20,0x30,0x10,0x90}#define n 400/* flag1 mask byte0x01 run cw()0x02 run ccw()*/main(){flag1=0;serinit(9600);disable(); /* no need timer interrupt */cw_n = n; /* initial step number for cw */flag1 |=0x01; /* initial enable cw() */while(1){{tick_wait(); /* wait for 10ms elapsed */energize(); /* round-robin execution the following tasks every 10ms */cw();ccw();}}}cw(){if((flag1&0x01)!=0){cw_n--; /* decrement cw step number */if (cw_n !=0) j++; /* if not zero increment index j */else{flag1&=~0x01; /* disable cw() execution */ccw_n = n; /* reload step number to ccw counter */flag1 |=0x02; /* enable cww() execution */
 
}}}ccw(){if((flag1&0x02)!=0){ccw_n--; /* decremnent ccw step number */if (ccw_n !=0) j--; /* if not zero decrement index j */else{flag1&=~0x02; /* disable ccw() execution */cw_n = n; /* reload step number to cw counter */flag1 |=0x01; /* enable cw() execution */}}}tick_wait(){ /* cputick was replaced by simpler ASM code 10ms wait */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 */}energize(){P1 = step[(j&0x07)]; /* only step 0-7 needed */}
Exercises
 
change the speed showing the rotation becomes faster or slower than 10ms timedelay.
with an additional serial port, write an initializing function that receives asciicommand from terminal to set the number of step for cw and ccw, say.
while energizing the stepper coils, write a function that read ascii character fromterminal on the fly to decrease or increase rotating speed, say.
Stepper Links
 

Activity (13)

You've already reviewed this. Edit your review.
1 hundred reads
A.K.VADIVEL liked this
black jack liked this
UTKAL.45 liked this
Hamada ElMasry liked this
Hamada ElMasry liked this
Hardik liked this
Cliff Durand liked this
vithin liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->