Motor Control

  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Motor Control as PDF for free.

More details

  • Words: 1,805
  • Pages: 36
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 ELECTRONICS UNIVERSITY 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: Adhikari.

Debraj

UNIVERSITY COLLEGE OF TECHNOLOGY INSTITUTE OF RADIOPHYSICS AND ELECTRONICS Telephone : (+91)(33) 23509115 Telegram : INRAPHEL BHAVAN Fax : (+91)(33) 23515828 A.P.C Road, E-mail : [email protected] 009, INDIA.

SISIR MITRA 92, Kolkata-700

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 1.

NAME 4 Phase Stepper Motor

RATING TYPE KP39HM2-S07A 1.8 0.16A/PHASE

2. 3. 4. 5.

Female D-25 Connector BC 547 Transistor Rectifying Diodes Power Supply

DEG/STEP

+5V,1.5A

CIRCUIT DIAGRAM

Connector D0 Connector D1 Connector D2 Connector D3

Port

o/p 1

Port

o/p 2

Port

o/p 3

Port

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 Symb ol

Parameter

VCBO VCEO VEBO IC

collector-base voltage collector-emitter voltage emitter-base voltage collector current (DC)

Conditions open emitter open base open collector

Min. -

Max. Unit 50 45 6

V V V

ICM IBM Ptot Tj

peak collector current peak base current total power dissipation junction temperature

Tamb ≤ 25 °C;

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 :

Port 1 Port 2 Port 3 Port 4

D 0 1

D 1 0

D 2 0

D 3 0

0

1

0

0

0

0

1

0

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. printf("\n2. printf("\n3. printf("\n4. printf("\n5.

--> --> --> --> -->

START THE MOTOR"); QUIT"); ACCELERATR"); DECELERATE"); OSCILLATE \n\t");

scanf("%d",&choice); switch(choice) { case 1: printf("\nEnter Speed of Rotation(in millisec):\t"); scanf("%d",&speed); printf("\nRotate (C/A):\t"); scanf("%s",&ch1);

Clockwise

or

Anticlockwise

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++; } } break;

case 2:

//end of while(!kbhit()) //end of if(ch1)

exit(0); case 3: printf("\nEnter Start Speed millisec)(end_speed<start_speed):\t"); scanf("%d",&start_speed);

of

Rotation(in

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 millisec)(end_speed>start_speed):\t"); scanf("%d",&start_speed);

of

Rotation(in

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 •

Related Documents

Control Motor
November 2019 43
Motor Control
October 2019 40
Control De Motor Encoder
December 2019 26