Date post: | 13-Nov-2014 |
Category: |
Documents |
Upload: | debraj1061 |
View: | 27 times |
Download: | 8 times |
PROJECT REPORT
ON
Computer Controlled Stepper Motor
Submitted by:
DEBRAJ ADHIKARI
FUTURE INSTITUTE OF ENGINEERING AND
MANAGEMENT SONARPUR STATION ROAD, KOLKATA-700150
UNDER THE GUIDANCE OF
PROF. DIPANKAR BISWAS
DEPARTMENT OF RADIOPHYSICS AND ELECTRONICSUNIVERSITY OF CALCUTTA
92, A.P.C ROAD, KOLKATA-700009
ACKNOWLEDGEMENT
I would like to express my sincere gratitude to Prof. Dipankar Biswas of Department of Radiophysics and Electronics, University College of Science and Technology, University of Calcutta. Without his able guidance and patience, this project would not have been completed.
I would like to convey my sincere thanks to Sanjib Kabi and Tushar Dhabla Das whose unconditional help and valuable suggestions proved fruitful in achieving the ultimate goal.
Date: --------------------------Place: Debraj Adhikari.
UNIVERSITY COLLEGE OF TECHNOLOGYINSTITUTE OF RADIOPHYSICS AND ELECTRONICS
Telephone : (+91)(33) 23509115Telegram : INRAPHEL SISIR MITRA BHAVAN Fax : (+91)(33) 23515828 92, A.P.C Road,E-mail : [email protected] Kolkata-700 009, INDIA.
This is to certify that Mr.Debraj Adhikari, student of Computer Science and Engineering(2004-2008) from Future Institute of Engineering and Management under West Bengal University of Technology(WBUT), has completed his project entitled ‘Computer Controlled Stepper Motor‘ under my guidance and in my laboratory.
I wish him success in life.
------------------------------------ Prof. Dipankar Biswas
CONTENTS
Objective Introduction Apparatus required Circuit diagram Connector diagram Transistor component Motor description Theory C Source code Bibliography
OBJECTIVE
The aim of this project is to drive a stepper motor through port programming in C. The serial printer port is programmed to monitor the control of the stepper motor. The motor can be controlled to rotate clockwise or anticlockwise, to accelerate and decelerate and to oscillate.
INTRODUCTION
A stepper motor is brushless, synchronous electric motor that can divide a full rotation into a large number of steps. The motor's position can be controlled precisely, without any feedback mechanism (see open loop control). Stepper motors are similar to switched reluctance motors , which are very large stepping motors with a reduced pole count, and generally are closed-loop commutated.
Stepper motors operate much differently from normal DC motors, which rotate when voltage is applied to their terminals. Stepper motors, on the other hand, effectively have multiple "toothed" electromagnets (a.k.a. phases) arranged around a central gear-shaped piece of iron. The electromagnets are energized by an external control circuit, such as a microcontroller. To make the motor shaft turn, first one electromagnet is given power, which makes the gear's teeth magnetically attracted to the electromagnet's teeth. When the gear's teeth are thus aligned to the first electromagnet, they are slightly offset from the next electromagnet. So when the next electromagnet is turned on and the first is turned off, the gear rotates slightly to align with the next one, and from there the process is repeated. Each of those slight rotations is called a "step." In that way, the motor can be turned a precise angle.
The stepper motor for this project is a unipolar stepper motor that has two windings per phase, one for each direction of current. Since in this arrangement a magnetic pole can be reversed without switching the direction of current, the commutation circuit can be made very simple
(eg. a single transistor) for each winding. Typically, given a phase, one end of each winding is made common: giving three leads per phase and six leads for a typical two phase motor. Often, these two phase commons are internally joined, so the motor has only five leads.
The C program is written to power each electromagnet in turn. Thus each electromagnets are powered one after another to make a complete rotation. The ‘female D-25’ connector of the printer port is programmed for this purpose. For the motor to function properly a driver circuit has been built.
APPARATUS REQUIRED
SL NO
NAME RATING
1. 4 Phase Stepper Motor TYPE KP39HM2-S07A
1.8 DEG/STEP 0.16A/PHASE
2. Female D-25 Connector
3. BC 547 Transistor
4. Rectifying Diodes
5. Power Supply +5V,1.5A
CIRCUIT DIAGRAM
Connector Port D0
o/p 1
Connector Port D1
o/p 2
Connector Port D2
o/p 3
Connector Port D3
o/p 4
Yellow, Brown, Orange & Black are the motor wires which are connected in sequence to make the motor rotate. The collector pins of the transistors are connected to the motor wires.
The base of the transistors are connected to the connector ports of the D-25 connector.
The emitter pins are grounded.
CONNECTOR DIAGRAM
IBM-PC's Parallel Printer Port had a total of 12 digital outputs and 5 digital inputs accessed via 3 consecutive 8-bit ports in the processor's I/O space.
8 output pins accessed via the DATA Port 5 input pins (one inverted) accessed via the STATUS
Port 4 output pins (three inverted) accessed via the
CONTROL Port The remaining 8 pins are grounded
25-way Female D-Type Connector
TRANSISTOR COMPONENT
BC547 Transistor Diagram
FEATURES · Low current (max. 100 mA) · Low voltage (max. 65 V).
LIMITING VALUES
Symbol
Parameter Conditions Min. Max. Unit
VCBO collector-base voltage open emitter - 50 V VCEO collector-emitter voltage open base - 45 V
VEBO emitter-base voltage open collector - 6 V IC collector current (DC) ICM peak collector current IBM peak base current Ptot total power dissipation Tamb 25 C; Tj junction temperature
MOTOR DESCRIPTION
TYPE KP39HM2-S07A
1.8 DEG/STEP 0.16A/PHASE
In the above figure the stepper motor has five wires namely Yellow, Brown, Orange, Black and Red. To make the motor rotate in a particular direction (clockwise or anticlockwise), the wires are needed to be connected in a sequence.
For Clockwise rotation the sequence is as follows:Yellow, Brown, Orange, Black. For Anti-Clockwise rotation the sequence is as follows:Black, Orange, Brown, Yellow.
The Red wire in both the cases is kept at a positive voltage.
THEORY
A transistor's collector current is proportionally limited by its base current, it can be used as a sort of current-controlled
switch. A relatively small flow of electrons sent through the base of the transistor has the ability to exert control over a much larger flow of electrons through the collector.
Since the motor used for this project is a 4-Phase motor, therefore only 4 of the 8 Data ports of the Female D-Type Connector(D0-D8) is used.
The 4 ports are programmed to output data in the following manner :
D0
D1
D2
D3
Port 1
1 0 0 0
Port 2
0 1 0 0
Port 3
0 0 1 0
Port 4
0 0 0 1
One port gets activated at a time followed by another. This process continues and the motor rotates. The bases of the transistors are connected to the ports (refer to Connection Diagram) which are activated to control a larger flow of current through the collector which are connected to the motor windings (refer to Connection Diagram). This in turn rotates the motor.
The rectifying diodes protect the transistors from excess current. Integrating all the components the driver circuit has been created. The program controls the working of the motor. The speed of the motor can be controlled, it can be made to rotate clockwise or anticlockwise and made to oscillate.
C SOURCE CODE
#include"stdio.h"#include"conio.h"#include"dos.h"
#define PORT 0x378#define CONTROL PORT+2
void main(){ int i=1,choice,start_speed,end_speed,acc_step; int speed=10,oscillate,k,l; char ch,ch1; clrscr(); while(1) { clrscr();
printf("\n1. --> START THE MOTOR");printf("\n2. --> QUIT");printf("\n3. --> ACCELERATR");printf("\n4. --> DECELERATE");printf("\n5. --> OSCILLATE \n\t");
scanf("%d",&choice);
switch(choice){case 1:
printf("\nEnter Speed of Rotation(in millisec):\t");scanf("%d",&speed);
printf("\nRotate Clockwise or Anticlockwise (C/A):\t");
scanf("%s",&ch1);
printf("\n\nPress any key to stop\n");getch();
if(ch1=='c') {
i=1;
while(!kbhit()) {
if(i==1) { outportb(PORT,1); printf("\n%d",i); delay(speed); }
if(i==2) {
outportb(PORT,2);printf("\n%d",i);delay(speed);
}
if(i==3) {
outportb(PORT,4);printf("\n%d",i);delay(speed);
}
if(i==4)
{outportb(PORT,8);printf("\n%d",i);delay(speed);
}
if(i==4) {
i=0; }
i++;
} //end of while(!kbhit())
} //end of if(ch1)
if(ch1=='a') {
i=1;
while(!kbhit()) {
if(i==1) { outportb(PORT,8); printf("\n%d",i); delay(speed);
}
if(i==2) {
outportb(PORT,4);
printf("\n%d",i);delay(speed);
}
if(i==3) {
outportb(PORT,2);printf("\n%d",i);delay(speed);
}
if(i==4) {
outportb(PORT,1);printf("\n%d",i);delay(speed);
}
if(i==4) {
i=0; }
i++;
} //end of while(!kbhit())
} //end of if(ch1)
break;
case 2:
exit(0);
case 3:
printf("\nEnter Start Speed of Rotation(in millisec)(end_speed<start_speed):\t");
scanf("%d",&start_speed);
printf("\nEnter End Speed of Rotation(in millisec) (end_speed<start_speed):\t");
scanf("%d",&end_speed);
printf("\nRotate Clockwise or Anticlockwise (C/A):\t");
scanf("%s",&ch1);
printf("\nEnter Acceleration steps: \t ");scanf("%d",&acc_step);
printf("\nPress any key to stop\n");getch();
if(ch1=='c') {
i=1;
while(!kbhit()) {
if(i==1) { outportb(PORT,1); delay(start_speed);
}
if(i==2) {
outportb(PORT,2);delay(start_speed);
}
if(i==3) {
outportb(PORT,4);delay(start_speed);
}
if(i==4) {
outportb(PORT,8);delay(start_speed);
}
if(end_speed<start_speed) { start_speed-=acc_step; printf("\n%d",start_speed); } else { printf("\nAcceleration Ends"); break; }
if(i==4) {
i=0; }
i++;
} //end of while(!kbhit())
} //end of if(ch1)
if(ch1=='a') {
i=1;
while(!kbhit()) {
if(i==1) { outportb(PORT,8); printf("\n%d",i); delay(speed); }
if(i==2) {
outportb(PORT,4);printf("\n%d",i);delay(speed);
}
if(i==3) {
outportb(PORT,2);printf("\n%d",i);delay(speed);
}
if(i==4) {
outportb(PORT,1);printf("\n%d",i);delay(speed);
}
if(end_speed<start_speed) { start_speed-=acc_step; }
else { printf("\nAcceleration Ends"); break; }
if(i==4) {
i=0; }
i++;
} //end of while(!kbhit())
} //end of if(ch1)
case 4:
printf("\nEnter Start Speed of Rotation(in millisec)(end_speed>start_speed):\t");
scanf("%d",&start_speed);
printf("\nEnter End Speed of Rotation(in millisec) (end_speed>start_speed):\t");
scanf("%d",&end_speed);
printf("\nRotate Clockwise or Anticlockwise (C/A):\t");
scanf("%s",&ch1);
printf("\nEnter Acceleration steps: \t ");scanf("%d",&acc_step);
if(ch1=='c') {
i=1;
while(!kbhit()) {
if(i==1) { outportb(PORT,1); delay(start_speed);
}
if(i==2) {
outportb(PORT,2);delay(start_speed);
}
if(i==3) {
outportb(PORT,4);delay(start_speed);
}
if(i==4) {
outportb(PORT,8);delay(start_speed);
}
if(end_speed>start_speed) { start_speed+=acc_step; }
else { printf("\nAcceleration Ends"); break; }
if(i==4) {
i=0; }
i++;
} //end of while(!kbhit())
} //end of if(ch1)
if(ch1=='a') {
i=1;
while(!kbhit()) {
if(i==1) { outportb(PORT,8); printf("\n%d",i); delay(speed);
}
if(i==2) {
outportb(PORT,4);printf("\n%d",i);delay(speed);
}
if(i==3) {
outportb(PORT,2);printf("\n%d",i);delay(speed);
}
if(i==4) {
outportb(PORT,1);printf("\n%d",i);delay(speed);
}
if(end_speed>start_speed) { start_speed+=acc_step; }
else { printf("\nDeceleration Ends"); break; }
if(i==4) {
i=0; }
i++;
} //end of while(!kbhit())
} //end of if(ch1)
case 5:printf("\nEnter Speed of Rotation(in millisec):\t");scanf("%d",&speed);
printf("\nEnter number of turns to oscillate: \t");scanf("%d",&oscillate);
printf("\nFirst Clockwise or Anticlockwise(C/A):\t");scanf("%s",&ch1);
L1:if(ch1=='a') { i=1; k=0; l=0; for(k=0;k<=oscillate;k++) {
if(i==1) { outportb(PORT,8); printf("\n%d",i); delay(speed);
}
if(i==2) {
outportb(PORT,4);printf("\n%d",i);delay(speed);
}
if(i==3) {
outportb(PORT,2);printf("\n%d",i);delay(speed);
}
if(i==4) {
outportb(PORT,1);printf("\n%d",i);delay(speed);
}
if(i==4) {
i=0; }
i++; }
i=1; for(l=0;l<=oscillate;l++) {
if(i==1) { outportb(PORT,1); printf("\n%d",i); delay(speed);
}
if(i==2) {
outportb(PORT,2);printf("\n%d",i);delay(speed);
}
if(i==3) {
outportb(PORT,4);printf("\n%d",i);delay(speed);
}
if(i==4) {
outportb(PORT,8);printf("\n%d",i);delay(speed);
}
if(i==4) {
i=0; }
i++; }
while(!kbhit()) goto L1;
} //end of if(ch1=='a')
L2: if(ch1=='c') { i=1; k=0; l=0; for(k=0;k<=oscillate;k++) {
if(i==1) { outportb(PORT,1); printf("\n%d",i); delay(speed);
}
if(i==2) {
outportb(PORT,2);printf("\n%d",i);delay(speed);
}
if(i==3) {
outportb(PORT,4);printf("\n%d",i);delay(speed);
}
if(i==4) {
outportb(PORT,8);printf("\n%d",i);
delay(speed); }
if(i==4) {
i=0; }
i++; }
i=1; for(l=0;l<=oscillate;l++) {
if(i==1) { outportb(PORT,8); printf("\n%d",i); delay(speed);
}
if(i==2) {
outportb(PORT,4);printf("\n%d",i);delay(speed);
}
if(i==3) {
outportb(PORT,2);printf("\n%d",i);delay(speed);
}
if(i==4) {
outportb(PORT,1);printf("\n%d",i);delay(speed);
}
if(i==4) {
i=0; }
i++; }
while(!kbhit()) goto L2;
} //end of if(ch1=='c')
} //end of switch
} //end of while(1)
} //end of main()
BIBLIOGRAPHY
www.nationalelectronics.com Fundamentals of Electronics by Rakshit &
Chattopadhyay