ESD_5
ESD_5
SYSTEMS PRACTICE
LAB - 5
(12/02/2025)
DC Motor Control with
Systick Timer
S Dhanush
EC23B1035
1
Objective :
To control a passing signal with a specific time interval to control the speed and
direction of the DC motor using SysTick timer.
Theory :
A DC motor is an electromechanical converter that transforms electrical energy into
mechanical energy through the phenomenon of electromagnetism. It works due to the
interaction of a magnetic field and a conductor carrying current, producing a force that
leads to rotation. The DC motor converts the direct current into mechanical energy. It
consists of a stator that is generally a permanent magnet and the central rotating part
which is the armature coil. As the current flows through the armature windings it
magnetizes the rotor. These fields interact with the stators permanent magnetic field
and generate torque.
DC motors work on Faraday’s Law of Electromagnetic Induction and Lorentz Force Law:
-> When current flows through a coil in a magnetic field, a force is exerted on the coil,
causing it to rotate.
2
DC Motor Control :
DC Motor Interface :
3
Practice Exercise :
1.SW1 on -> clockwise -> 50 %
Calculations :
Case 1:- Reload value = Desired time delay / 12.5 nsec =5∗10−3 / 12.5 ∗10−9 =400000
Case 2:- Reload value = Desired time delay / 12.5 nsec =7.5∗10−3 / 12.5*10−9=600000
Case 3:- Reload value = Desired time delay / 12.5 nsec =9∗10−3 / 12.5 ∗10−9 = 720000
Case 4:- Reload value = Desired time delay / 12.5 nsec =10∗10−3 / 12.5 ∗10−9=800000
CODE :
#include "tm4c123gh6pm.h"
#include "PLL.h"
#include <stdint.h>
SYSCTL_RCGC2_R |= 0x01;
GPIO_PORTA_DIR_R |= 0x88;
4
void PortF_Init(void){ volatile unsigned long delay;
// only PF0 and PF3 needs to be unlocked, other bits can't be locked
void SysInit(void)
NVIC_ST_CTRL_R = 0;
5
}
int main(void){
//int i;
PLL_Init(); // 80 MHz
SysInit();
PortA_Init();
PortF_Init();
while(1)
Switch=GPIO_PORTF_DATA_R&0x11;
switch(Switch)
case 0x01:
GPIO_PORTA_DATA_R |= (0x08);
break;
case 0x10:
GPIO_PORTA_DATA_R |= (0x80);
6
break;
case 0x00:
GPIO_PORTA_DATA_R |= (0x08);
break;
default:
break; } } }
Output :
7
Inference : The output waveform displays the PWM signal
corresponding to clockwise and anticlockwise rotations and motor off in the
DC motor. To achieve this configuration, we configure the Systick Timer
with specific reload value to ensure accurate rotation of the DC motor.
Reload value = Desired time delay / 12.5 nsec =5∗10−3 / 12.5 ∗10−9 =400000
Which will give the duty cycle of 50% and rotates the DC motor in
clockwise direction.
8
Which will give the duty cycle of 75% and rotates the DC motor in
anticlockwise direction.
Reload value = Desired time delay / 12.5 nsec =9∗10−3 / 12.5 ∗10−9 = 720000
Which will give the duty cycle of 90% and rotates the DC motor in
clockwise direction when both the switches SW1 and SW2 are kept on.
Reload value = Desired time delay / 12.5 nsec =10∗10−3 / 12.5 ∗10−9=800000
Which will turn off the DC motor when both the switches are turned off.