You are on page 1of 10

Continuous Assessment Cover Sheet

Faculty of Engineering

Module Details
Module Code EC 2481 Module Title INTRODUCTION TO CONTROLS & ROBOTICS
Program: Name:
Stream: (Civil/Electronics/Mechanical)

Assessment details

Title LAB 03-Servo and Stepper Group assignment YES / NO


motor control If yes, Group No.

Lecturer/ Instructor Date of Performance

Due date Date submitted

Student statement and signature


By this declaration, I/we confirm my/our understanding and acceptance that the work reported in this report is my/our own wor k. I/we also
understand the consequences of engaging in plagiarism or copying others work without proper citation. Any material used in this work (whether
from published sources, the internet or elsewhere) have been fully acknowledged and referenced and are without fabrication or falsification of
data.
[Copying or plagiarism will result in a “0” mark for the continuous assessment and “F” for the module after an investigation on academic
misconduct;

All academic misconduct is considered seriously and defined as dishonest and in direct opposition to the values of a learning community.
Misconduct may result in penalties from failure to exclusion from the campus.
Further help and guidance on how to avoid academic misconduct can be obtained from your academic advisor/tutor]

By this declaration, I confirm my understanding and acceptance that-


• I have adhered to relevant ethical guidelines and procedures in the completion of the assignment.
• I have not allowed another student to have access to or copy from this work. This work has not been
submitted previously.
[The Institute may request an electronic copy of this work for submission to the Plagiarism detection facility (TURNITIN). You must make sure
that an electronic copy of your work is available in these circumstances]

Group Number: Signature


Student ID EN19381664 Full Name Wijerathna W.M.D.U
Student ID Full Name

Student ID Full Name

Student ID Full Name

Student ID Full Name

OFFICE USE ONLY


Specific comments about the work (including overall comments and guidelines for improvement)

Tutor: Signature: Date:

Marks: [ All marks are subject to external moderation and approval of board of examinations]
INTRODUCTION

 The objective of this experiment is to control servo and stepper motors using the
microcontroller.

APPARATUS

 Stepper motor
 Servo motor
 ULN2003A
 PicKit 2 Programmer and PC with Micro C Pro
 DC Power Supply
 Demonstration Board

PART 1: STEPPER MOTOR CONTROL

Procedure

 Construct the circuit shown in Figure2 on the bread board.


 Power up the stepper motor using 5 V line from the power supply, and make a common ground
between demo board and power supply.
 Load the generated hex file to microcontroller.
 Observe the output of stepper motor.
 Processor clock Frequency set as 20 MHz
Discussion

 Observe the operation of the stepper motor and write a program code to change the rotational
direction of the motor.

void go_forward();
void go_backward();

unsigned int i;

void main() {
TRISB = 0x00; //Port B as output

go_forward();
go_backward();
}

void go_forward(){
for(i=0;i<10;i++){ //Repeat 10 rounds
PORTB = 0x01;
delay_ms(200); // slow down change pace a little
PORTB = 0x02;
delay_ms(200); // slow down change pace a little
PORTB = 0x04;
delay_ms(200); // slow down change pace a little
PORTB = 0x08;
delay_ms(200); // slow down change pace a little
}
}

void go_backward(){
for(i=0;i<10;i++){ //Repeat 10 rounds
PORTB = 0x08;
delay_ms(200); // slow down change pace a little
PORTB = 0x04;
delay_ms(200); // slow down change pace a little
PORTB = 0x02;
delay_ms(200); // slow down change pace a little
PORTB = 0x01;
delay_ms(200); // slow down change pace a little
}
}

 Full turn contains with the 4 steps according to below table.

 The above graph indicate the Stepper motor sequence pattern. Reverse this sequence pattern,
then we can change the rotational direction of the motor.
PART 2: SERVO MOTOR CONTROL

Procedure
 Servo Motor Wiring :
 Red – Vcc
 Brown – Ground
 Orange/Yellow – PWM Signal

 Processor clock Frequency set as 0.5 MHz


Discussion

void main() {

TRISC = 0x00; // PORTC as output


PWM1_Init(50); // Frequency= 50Hz

PWM1_Start();
PWM1_Set_Duty(13); // 1ms pulse width for 5% duty cycle
Delay_ms(1500); //slow down change pace
PWM1_stop();

PWM1_Start();
PWM1_Set_Duty(19); //1.5ms pulse width for 7.5% duty cycle
Delay_ms(1500); //slow down change pace
PWM1_stop();
PWM1_Start();
PWM1_Set_Duty(26); //2ms pulse width for 10% duty cycle
Delay_ms(1500); //slow down change pace
PWM1_stop();

PWM1_Start();
PWM1_Set_Duty(19); // 1ms pulse width for 5% duty cycle
Delay_ms(1500); //slow down change pace
PWM1_stop();

 What is the period and frequency of the pulse train needed to be sent to the servo motor to
control its position?

 Period (T) = 20 ms

 Frequency (f) = 50 Hz

 What are the pulse width (time high) value needed to position the motor at the

𝑡
Duty cycle =
𝑇
 -90 degree position
1ms
× 100 = 5%
20ms

~1ms pulse == 5% duty cycle


5
× 255 ≈ 13
100

 0 degree position
1.5ms
× 100 = 7.5%
20ms

~1.5ms pulse == 7.5% duty cycle


7.5
× 255 ≈ 19
100
 +90 degree position
2ms
× 100 = 10%
20ms

~2ms pulse == 10% duty cycle


10
× 255 ≈ 26
100

You might also like