Exp3 02
Exp3 02
Exp3 02
1.AIM
To understand and implement the capacitive touch sensor using the programming
and with the help of the 8051- development kit.
2.INTRODUCTION
3.TTP223B SENSOR:
The TTP223B is a Digital touchpad detector IC that offers 1 touch key. The
touching detection IC is designed for replacing traditional direct button keys with
diverse pad sizes. This device uses your body as part of the circuit.
When you touch the sensor pad, the capacitance of the circuit is changed
and is detected. That detected change in capacitance results in the output
changing states When a finger touches the corresponding position, the module
output high, if not touched for 12 seconds, switch to low-power mode.
SPECIFICATION:
This is three pin sensor. You provide power, ground, and monitor the
output.
SIG – Output (If it detects touch, this will be HIGH otherwise LOW)
VCC – 2v to 5.5v
GND – Ground
CODE:
#include<reg51.h>
#define lcd P3
sbit TOUCH=P1^0;
void lcd_init();
void delay();
void main()
lcd_init();
while(1) {
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
if(TOUCH) {
cmd(0xc0);
lcd_string("Touch Detected");
delay();
} else {
cmd(0xc0);
lcd_string(" ");
void lcd_init()
cmd(0x38);
cmd(0x0e);
cmd(0x06);
cmd(0x01);
cmd(0x80);
{
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
lcd=a;
rs=0;
rw=0;
en=1;
delay();
en=0;
lcd=b;
rs=1;
rw=0;
en=1;
delay();
en=0;
while(*s) {
dat(*s++);
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
void delay()
unsigned int i;
for(i=0;i<20000;i++);
OUTPUT:
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
1.AIM:
2.INTRODUCTION:
Interfacing 8051 with DC motor requires a motor driver. There are various
types of driver ICs among which L293D is typically used for interfacing DC
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
motor with 8051. L293 is an IC with 16 pins which are represented in the figure
below.
Figure 4 Motor Driver IC L293D used for Interfacing DC motor with 8051
This L293 IC is having ratings of 600mA per channel and DC supply voltage
in the range of 4.5V to 36V. These ICs can be protected from inductive spikes by
connecting higher speed clamp diodes internally. This 16 pin L293D IC can be used
for controlling the direction of two DC motors. The IC L293D works based on the
H-bridge concept. The voltage can be made to flow in either direction using this
circuit (H-bridge) such that by changing the voltage direction the motor direction
can be changed.
H-BRIDGE CIRCUIT
The name “H-Bridge” comes from the shape of the switching circuit, which
controls the motion of the motor. It is also known as “Full Bridge”. This circuit
has four switching elements. We can make H-bridges with the help of transistors,
MOSFETs, etc. It will be cheap but they will increase the size of the design and
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
the circuit board, which is mostly not preferable, so we can use a small 16-pin IC
for this purpose.
As we can see in the figure, there are four switching elements named:
When these switches are turned on in pairs, the motor changes its direction
accordingly. If we switch on “High side left” and “Low side right”, then the
motor will rotate in a forward direction as current from the power supply flows
through the motor coil and goes to ground through the switch on the low side
(right). This is shown in the figure below.
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
Similarly, when we switch on the low side (left) and the high side (right),
the current flows in the opposite direction and the motor rotates in the opposite
direction. This is the basic working of H-Bridge. We can also make a small truth
table according to the switching of H-Bridge explained above.
Switch. The L293D motor driver IC used to control the DC motor movement in
both directions. It has an in-built H-bridge motor drive.
CODE:
#include <reg52.h>
#include <intrins.h>
int i,j;
void Timer_init()
TL0 = PWM_Period;
PWM_Out_Pin = !PWM_Out_Pin;
if(PWM_Out_Pin)
TL0 = ON_Period;
else
TL0 = OFF_Period;
/* Calculate ON & OFF period from PWM period & duty cycle */
/* Initially Motor Speed & Duty cycle is zero and in either direction */
void Motor_Init()
Speed = 0;
M1_Pin1 = 1;
M1_Pin2 = 0;
Set_DutyCycle_To(Speed);
int main()
Timer_init();
Motor_Init();
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
while(1)
if(Speed_Inc == 1)
Speed += 10;
Set_DutyCycle_To(Speed);
while(Speed_Inc == 1);
delay(200);
if(Speed_Dec == 1)
if(Speed > 0)
Speed -= 10;
Set_DutyCycle_To(Speed);
while(Speed_Dec == 1);
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
delay(200);
if(Change_Dir == 1)
M1_Pin1 = !M1_Pin1;
M1_Pin2 = !M1_Pin2;
while(Change_Dir == 1);
delay(200);
} } }
OUTPUT:
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
1.AIM:
2.INTRODUCTION:
3.PARAMETERS:
Step Angle − The step angle is the angle in which the rotor moves when
one pulse is applied as an input of the stator. This parameter is used to
determine the positioning of a stepper motor.
Steps per Revolution − This is the number of step angles required for a
complete revolution. So the formula is 360° /Step Angle.
Steps per Second − This parameter is used to measure a number of steps
covered in each second.
RPM − The RPM is the Revolution Per Minute. It measures the frequency
of rotation. By this parameter, we can measure the number of rotations in
one minute.
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
The relation between RPM, steps per revolution, and steps per second is
like below:
Steps per Second = rpm x steps per revolution / 60
The following table is showing the sequence of input states in different windings.
2.Full Drive Mode − In this mode, two coils are energized at the same
time. This mode produces more torque. Here the power consumption is also high.
The following table is showing the sequence of input states in different windings.
3.Half Drive Mode − In this mode, one and two coils are energized
alternately. At first, one coil is energized then two coils are energized. This is
basically a combination of wave and full drive mode. It increases the angular
rotation of the motor
The following table is showing the sequence of input states in different windings .
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
CIRCUIT DESCRIPTION:
In the circuit, Port P2 is defined as output port to provide the input sequence
for the stepper motor. Four transistors are used as switches to drive the motor.
The motor leads are not directly interfaced with the microcontroller pins because
stepper motor requires 60mA current while has the maximum current rating of
50mA. So the transistors switches are used to transfer signals from the
microcontroller to the stepper wires.
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
The sequence of signals mentioned in the tables above rotates the motor in
clockwise direction. Reversing these input sequences would rotate the motor in
counter clockwise direction.
CODE:
#include<reg51.h>
sfr stepper=0xA0;
int i;
for(i=0;i<count;i++);
void main()
while(1)
stepper=0x01;
delay(350);
stepper=0x02;
delay(350);
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
stepper=0x04;
delay(350);
stepper=0x08;
delay(350);
#include<reg51.h>
sfr stepper=0xA0;
int i;
for(i=0;i<count;i++);
void main()
while(1)
{
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
stepper=0x01;
delay(300);
stepper=0x03;
delay(300);
stepper=0x02;
delay(300);
stepper=0x06;
delay(300);
stepper=0x04;
delay(300);
stepper=0x0C;
delay(300);
stepper=0x08;
delay(300);
stepper=0x09;
delay(300);
}
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
OUTPUT:
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
1.AIM
To understand and implement LM35 and LDR in the 8051-development
kit with the help of programming.
2.INTRODUCTION:
Figure 9 LM35
variety of functions and resistance. For instance, when the LDR is in darkness,
then it can be used to turn ON a light or to turn OFF a light when it is in the light.
A typical light dependent resistor has a resistance in the darkness of 1MOhm, and
in the brightness a resistance of a couple of Kohm
Figure 10 LDR
ADC0804:
To make this LM35 we will read the temperature sensor value on ADC0804
and will convert the surrounding temperature to voltage. It further converts the
voltage to Celsius, and prints the temperature on the LCD screen.
consumes less power, provides output in multiple formats and are smaller
in size. ADC0804 we need to interfaced with microcontrollers as we do not have
in built in analog to digital converter with Microcontroller AT89S52.
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
Figure 11 ADC0804
Make WR (write) pin high (1) after some delay small delay. This low to high
impulse at WR pin starts your conversion.
Now check the INTR (interrupt) pin if it is high (1) conversion is running if it is
low (0) the conversion is over.
Make RD=low (0) and after some time high (1). This will bring the converted
value to the 8 data output pins of ADC 0804.
CODE:
/* main program */
void main()
{
P1=0xFF; //make Port 1 as input port
INTR_ADC=1; //make INTR pin as input
READ_ADC=1; //set RD pin HIGH
WRITE_ADC=1; //set WR pin LOW
LCD_Init();
lcd_DisplayString(" MICRODIGISOFT ");
lcd_Line_posnY();
lcd_DisplayString("LM35 - ADC0804 ");
delay_ms(1000);
lcd_Clear();
while(1)
{
WRITE_ADC=0; //send LOW to HIGH pulse on WR pin
delay_ms(1);
WRITE_ADC=1;
while(INTR_ADC==1); //wait for End of Conversion
READ_ADC=0; //make RD = 0 to read the data from ADC0804
ADC_VALUE=P1; //copy ADC data
// convert_display(ADC_VALUE); //function call to convert ADC data into
temperature and display it on 16*2 lcd display
C = ADC_VALUE*1.95; // // Read analog voltage and convert it to degree
Celsius
if (C > 99)
Tempr[0] = 1 + 48; // Put 1 (of hundred)
else
Tempr[0] = ' '; // Put space
Tempr[1] = (C / 10) % 10 + 48;
Tempr[2] = C % 10 + 48;
Tempr[5] = 223; // Put degree symbol ( 째 )
lcd_DisplayString("TEMPERATURE");
lcd_Line_posnY();
lcd_DisplayString(Tempr);
EX.NO:3 INTERFACING SENSORS AND ACTUATORS USING 8051 DEVELOPMENT
13.09.23 KIT
}
}
OUTPUT:
CONCLUSION: