Unit5 Ece MC4TH Sem
Unit5 Ece MC4TH Sem
[BEC405A]
MODULE 5
I/O Port Interfacing &
Programming:
Jayaprasad K M
Assistant Professor,
ECE Department, Coorg Institute of Technology
What do you learn in MODULE 5?
I/O Programming in 8051 C,
LCD interfacing,
DC motor control
3
8051 Programming Model
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Stepper motor interfacing
The most common stepper motors
have four stator windings that are
paired with a centre tapped common.
23
Stepper motor interfacing
24
Stepper motor interfacing
25
Stepper motor interfacing
26
Stepper motor interfacing
27
Stepper motor interfacing
28
Stepper motor interfacing
29
Stepper motor interfacing
#include <reg51.h> for(i=0; i<50;i++)
void MSDelay (unsigned int); {
P0 =0x33; //AntiClockwise Rotation
void main( ) MSDelay (100);
{ P0 =0x99;
for(i=0; i<50;i++) MSDelay (100);
{ P0 =0xCC;
P0 =0x66; //Clockwise Rotation MSDelay (100);
MSDelay (100); P0 =0x66;
P0 =0xCC; MSDelay (100);
MSDelay (100); }
P0 =0x99;
MSDelay (100); }
P0 =0x33; void MSDelay (unsigned int value)
MSDelay (100); {
} unsigned int x, y;
for (x=0;x<600;x++)
for (y=0;y< value; y++);
Return(0); 30
}
31
DC MOTOR INTERFACING AND PWM
Unidirection Control
32
DC MOTOR INTERFACING AND PWM
Unidirection Control
33
DC MOTOR INTERFACING AND PWM
Unidirection Control
34
DC MOTOR INTERFACING AND PWM
Unidirectional Control
35
DC MOTOR INTERFACING AND PWM
Bidirectional Control
36
DC MOTOR INTERFACING AND PWM
PWM
The speed of the motor depends on three factors:
(a) load, voltage, and (c) current.
For a given fixed load we can maintain a steady speed by using method called pulse
width modulation (PWM). By changing (modulating)
By changing (modulating) the width of the pulse applied to the DC motor we
can increase or decrease the amount of power provided to the motor, thereby
increasing or decreasing the motor speed.
Notice that, although the voltage has a fixed amplitude, it has a variable duty
cycle. That means the wider the pulse, the higher the speed.
37
DC MOTOR INTERFACING AND PWM
PWM
38
DC MOTOR INTERFACING AND PWM
DC motor control and PWM using C
39
DC MOTOR INTERFACING AND PWM
DC motor control and PWM using C
40
DC MOTOR INTERFACING AND PWM
DC motor control and PWM using C
41
42
DIGITAL TO ANALOG [DAC]
This section will show how to interface a DAC to the 8051.
Then we demonstrate how to generate a sine wave on the scope using the DAC.
The vast majority of integrated circuit DACs, including the MCI408 (DAC0808) used in
this section, use the R/2R method since it can achieve a much higher degree of precision.
The first criterion for judging a DAC is its resolution, which is a function of the number of
binary inputs.
The common ones are 8, 10, and 12 bits. The number of data bit inputs decides the
resolution of the DAC since the number of analog output levels is equal to 2^n, where n
is the number of data bit inputs.
Therefore, an 8-input DAC such as the DAC0808 provides 256 discrete voltage (or
current) levels of output. 43
44
DIGITAL TO ANALOG [DAC]
45
DIGITAL TO ANALOG [DAC]
46
DIGITAL TO ANALOG [DAC]
47
DIGITAL TO ANALOG [DAC]
48
DIGITAL TO ANALOG [DAC]
49
DIGITAL TO ANALOG [DAC]
50
DIGITAL TO ANALOG [DAC]
51
DIGITAL TO ANALOG [DAC]
52
DIGITAL TO ANALOG [DAC]
53