Beruflich Dokumente
Kultur Dokumente
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 each
coil is then needed about 60mA at +5V supply. A darlington transistor array, ULN2003 is used to
increase 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 is
optional 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 is
used for intertask communication.
/*
* STEPPER.C
* sweeping stepper's rotor cw and cww 400 steps
* Copyright (c) 1999 by W.Sirichote
*/
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 */
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 */
}
}
energize(){
Exercises
• change the speed showing the rotation becomes faster or slower than 10ms time
delay.
• with an additional serial port, write an initializing function that receives ascii
command 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 from
terminal on the fly to decrease or increase rotating speed, say.
Stepper Links
• Jones on Stepping Motors Jones provides a tutorial covering the basic of stepping
motors and control systems, including physics of the motor, circuits and software
for motor control.
• Basic Stepper Motor Concepts Understanding electromagnetic principle
underlying the stepper.
• Motorize Your Telescope Mel Bartels describes how to motorize telescope, many
links for amateur astronomy.
Introduction
The Saver V5.0 runs simple clock emulation program, turns a night light on and off with
preset time, say 19:00 to 22:00 everyday. The design features low cost, easy installation,
no battery backup and no EMI. The AT89C2051 uses external oscillator generated by
schmitt trigger gate CD4093, ~680kHz. Reference frequency was derived from 50Hz
main line. Time setting only allows at 18:00 by pressing time set button once. If main line
has failed, functioning LED will blink at high rate . Since there is no battery backup, thus
repressing the button is then needed. The output is capable of driving say, a 25W
incandescent lamp.
Circuit Description
2)External oscillator: A reliable schmitt gate oscillator with R8 and C5 produces clock
approx. 680kHZ. One machine cycle is ~18us.
3)89C2051 circuits: C4, 33uF and R4, 10k forms a reset circuit that need time for riasing
logic at least two machines cycle. S1 is a momentary button for setting time to 18:00 by
pulling P3.0 to logic low. The functioning LED is connected to P3.7. Q2 is a small triac
MAC97A6, and is drived by Q1, PNP transistor sinking through P1.7.
Software
Saver5.hex is HEX file suitable for Easy-Downloader V1.1 for writing the code to the
chip. This file sets time to 18:00 when press S1 once. Time on and off is set to 19:00 to
22:00 everyday. And finally the reference main frequency is 50Hz!!
The original source program SAVER5.C was written in 'C' language. User may change
set time when press S1 and change time on/off. It is a good idea to include peak shaving
period, say 20:00 to 20:30 depending on living area. By placing timeOn3 and timeOff3 in
the function comparetime(), see the source program. To recompile the source file you
need a Micro-C Compiler from Dunfield Development System with tiny memory model
and need some modification of the runtime file by putting external interrupt service
routine that increments cputick variable.
Installation
The Saver may be built-in any kind of lamp fixtures. Figure 2 shows the author's concept
for building-in a 25W lamp fixture.
under preparation
Figure 2: The author's concept lamp fixture with built-in Saver circuit
Although the Saver can operate even wrong connection of L and N to the circuit. The
author suggests to correct AC line connection to L and N of the circuit. After finished
installtion, turn the main switch on, functioning LED will blink at high rate. Let try press
S1 once, the lamp will turn on 1 minute then off. The Saver assumes the current time is
18:00. Then wait for the clock at your home reachs 18:00, press S1 again.
Note that everytime you press S1, the lamp will turn on 1 minute only once. The day after
the lamp will then turn on and off at preset time. Functioning LED will blink at low rate
indicating normal operation.
If high blink rate is noticed when return home, power failed should happen, no problem
just wait again 18:00 then press S1. If the LED is not blinked, someone may turn main
switch off, turn it back on again and wait for 18:00.
The Saver was not designed for turning such energy saving lamps on and off. They
mostly use internal high frequency inverter. I have been tested with one from National, it
works!! But I am not guarantee for your energy saving lamp. I would be grateful if you
could test and let me know the result.
Components Listing