Professional Documents
Culture Documents
ES Lab Observation note
ES Lab Observation note
TECHNOLOGY
(Approved by AICTE & Affiliated to Pondicherry University)
Achariyapuram, Villianur, Puducherry-605
Puducherry 110
Reg.No : ______________________
AIM:
To write a C program to measure the voltage from 0 to 5 volts and
displaying the measured value using seven segment displays.
APPARATUS REQUIRED:
1) PIC16F877a kit
2) 5V Adapter
3) RS 232 Cable
SOFTWARE USED:
1) MP Lab IDE Compiler
2) PIC ISP Downloader
3) WINX Talk
PROGRAM:
# include <16f877a.h>
int i=0;
unsigned char arr[10] = {0x3f, 0x06, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x67}
unsigned char x = 0;
x = (arr [x1]/0x80);
i2c_start();
i2c_write(0x40);
i2c_write(arr[x1]/0x80);
i2c_stop();
i2c_start();
i2c_write(0x42);
i2c_write(arr[x2]);
i2c_stop();
void main()
while(1)
set_adc_channel(0);
value =read_adc();
i = ((value *50)/255);
write_reg(i/w,i%10);
}
ALGORITHM:
Step 6: Start the I2C CAN bus and pass the arguments 0x40 in I2C write
bus.
Step 7: The arguments arr[x1]/0x80 is written in I2C write bus and stop the
function.
Step 8: Now again start the bus and write 0x42 and arr[x2] and stop the
function.
Step 9: In the main function setup the ADC port with RA0 as analog and
clock interval.
Step 10: If while condition is true then set the ADC channel as 0 and value
is assigned as read_adc.
Step 11: Initialize the value of i as value *50/255 and pass i/w, i%10 as
arguments in write seg.
RESULT:
AIM:
To design a water pump controller by sensing the low and high level in
the water tank.
APPARATUS REQUIRED:
1) PIC 16F877A kit
2) 5V adapter
3) RS 232 cable
4) ITB 003 module
SOFTWARE USED:
1) MPLAB IDE Compiler
2) PIC ISP Downloader
PROGRAM:
# include<16f877a.h>
#include<stdio.h>
void main()
while(1)
a=input(PIN-D0);
b=input(PIN-D1);
printf(“#n #r %d %d”,a,b);
b=a&b;
printf(“%d”,b);
if(b==0)
output_high(PIN-D4);
output_high(PIN-D6);
output_low(PIN-D7);
else
output_low(PIN-D4);
output_low(PIN-D6);
output_high(PIN-D7);
if(a==0)
output_low(PIN-D6);
}
CONNECTION DIAGRAM:
GND
1
RD1
PC0
RD4
RD6 PC1
RD4 PC2
RD0 PB0
PIC 16F877A
ALGORITHM:
Step 3: Initialize a and b as input which takes the pine D0 and D1.
Step 5: Check for the condition, if b input is zero, then the output is
predicted.
Step 6: If the a input is zero, then the output low is at pin – D6.
1) Compile the above C program using the MPLAB IDE software to create
hex file.
2) Download the hex file using PIC ISP software.
3) Connections are given as per the connection diagram.
4) After executing the program, the low level in the tank is reused and it is
indicated by green signal and high level in water is given the red signal.
5) When water reaches the high level the relay will be cut – off.
RESULT:
Thus the water pump controller by sensing low and high level in water
tank was studied and output was verified.
DIGITAL CLOCK WITH LCD DISPLAY
AIM:
To write a C program to display the real time clock is LCD display.
APPARATUS REQUIRED:
1) PIC 16F877A kit
2) 5V adapter
3) RS 232 cable
4) RTC board
SOFTWARE USED:
1) MPLAB IDE Compiler
2) PIC ISP Downloader
PROGRAM:
#include<16877a.h>
#delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN-c6,rcv=PIN-c7)
#use i2c(master,sda=PIN-c4,scl=PIN-c3)
void set_rtc_time();
void get_rtc_time();
void lcd_init();
unsigned int i;
char rtc[];
char x[]=”TIME”;
output_high(PIN-c0);
output_low(PIN-c1);
output_low(PIN-c2);
for(i=0;x[i]!=’\0’;i++)
{
output_D(x[i]);
output_high(PIN-c2);
delay_us(500);
output_low(PIN-c2);
output_high(PIN-E0);
output_low(PIN-E1);
output_low(PIN-E2);
for(i=0;x[i]!=’\0’;i++)
output_D(x[i]);
output_high(PIN-E2);
delay_us(500);
output_low(PIN_E2);
void main()
lcd_init();
data_display(x);
set_rtc_time();
while(1)
get_rtc_time();
printf(“T:%x:%x:y.x\t”,hour,minute,second);
sprint(rtc,”%0.2x:%0.2x:%0.2x,hour,minute,second);
lcd_cmd(0x10);
data_display(rtc);
while(del=del-1)
output_low(PIN-E0);
output_low(PIN-E1);
delay(500);
output_d(cmd);
delay(500);
output_high(PIN-c2);
delay(500);
output_low(PIN-c2);
}
output_high(PIN-E0);
output_low(PIN-E1);
delay(500);
output_d(dat);
delay(500);
output_high(PIN-E2);
delay(500);
output_low(PIN-E2);
void lcd_init()
for(k=0;k<5;k++)
lcd_cmd(init i[k]);
}
CONNECTION DIAGRAM:
GND BLACK
VCC RED
RC4 YELLOW
RC3 GREEN
ALGORITHM:
Step 4: Pass the arguments as int x1 and int x2 in the function write_reg.
Step 5: Declare char x=0 and x=lar[x1]/0x80 arguments 0x40 in I2C write
bus.
Step 6: The arguments arr[x1]/0x80 is written in I2C write bus and stop the
function.
Step 7: Now again start the bus and write 0x42 and arr[x2] and stop the
function.
Step 8: Call the function data_display by passing arguments char x and the
output high is taken in pin – E0 and low in E1 or E2.
Step 9: Get the values of hour, minute and second and display the values.
Step 10: In the set_rtc_time function, the I2C bus starts and write with 0x00,
0x02, 0x55, 0x15 and 0x05 and stop the operation
Step 11: Call the function led_cmd and make the output pin as low and
high.
RESULT:
Thus the digital clock was studied and the output was verified.
TEMPERATURE MEASUREMENT WITH 7 SEGMENT DISPLAY
AIM:
To write a C program to display temperature value in a 7 segment using
LH35 sensor.
APPARATUS REQUIRED:
1) PIC 16F877A kit
2) 5V adapter
3) RS 232 cable
4) VI sensor 17 module
SOFTWARE USED:
1) MPLAB IDE Compiler
2) PIC ISP Downloader
PROGRAM:
#include<16f877a.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN-c6,rcv=PIN-c7)
#use i2c(master,sda=PIN-c4,scl=PIN-c7)
float value;
while(del)
i2c_start();
i2c_write(0x40);
i2c_write(arr[x1]);
i2c_stop();
i2c_start();
i2c_write(0x42);
i2c_write(arr[x2]);
i2c_stop();
void main()
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL):
while(1)
set_adc_channel(2);
value=read_adc();
value=value;
i=((int)(value));
i=(i*2);
if(i>=99){i=99;}
write_seg(i\10,i%10);
delay(48000);
}
CONNECTION DIAGRAM
GND GND
VCC DVCC
RC4 O/P
ALGORITHM:
Step 2: Initialize the float and unsigned int value and char arr[10].
RESULT:
Thus the temperature measurement was done and the output was verified.
REMOTE CONTROL THROUGH FM LINK
AIM:
To write a C program to establish a remote link between two
microcontroller using RF transmitter, receiver an send the message “abcd” from
the transmitter side to the receiver side.
APPARATUS REQUIRED:
1) PIC 16F877a kit
2) 5V adapter
3) RS 232 cable
SOFTWARE USED:
1) MPLAB IDE Compiler
2) PIC ISP Downloader
PROGRAM:
TRANSMITTER SIDE:
#include<16f877a.h>
#include<stdio.h>
#use delay(clock=20000000)
#use rs232(baud=1200,xmit=PIN-c6,rcv=PIN-c7)
int i;
int j;
void rx()
unsigned int i;
for(i=0;i<5;i++)
receive[i]=getch();
void main()
while(1)
{
for(j=0;j<10000;j++)
printf(“%c”,a);
RECEIVER SIDE:
#include<16f877a.h>
#include<stdio.h>
#use delay(clock=20000000)
#use rs232(baud=1200,xmit=PIN-c6,rcv=PIN-c7)
#use rs232(baud=1200,xmit=PIN-c6,rcv=PIN-c7,stream=GPS)
char x[]=”TIME”;
unsigned int i;
unsigned char a;
while(del--);
output_low(PIN_E0);
output_low(PIN_E1);
delay(500);
output_D(cmd);
delay(500);
output_high(PIN_E2);
delay(500);
output_low(PIN_E2);
}
unsigned char i=0;
for(i=0;w[i]!=’\0’;i++)
{
lcd_cmd(add +i);
lcd_dat(w[i]);
delay(500);
}
}
void print()
{
lcd_disp(arr1,0xc0);
}
void main()
{
lcd_init();
while(1)
{
a=getch();
printf(“%c”,a);
lcd_cmd(0x8d);
lcd_data(a);
}
}
CONNECTION DIAGRAM:
TRANSMITTER SIDE:
VCC RED
GN BLACK
YELLO
PIC RF
1
9
2
8
3
7
4 TxD
6
5
RECEIVER SIDE:
VCC RED
GND BLACK
YELLOW
PIC 16F877A RF
9 1
2
8
3
7
4 RxD
6
5
ALGORITHM:
Step 5: Call the function of delay and check for the condition.
Step 6: In the main check the condition and print the value.
Step 7: For the receiver side delay, lcd_cmd and lcd_dat and lcd_init and
data – 1 and check the condition.
RESULT:
Thus the remote control through FM link was done and output was
obtained.
HOT CHAMBER CONTROLLER TO MAINTAIN THE
TEMPERATURE AT THE SET POINT
AIM:
APPARATUS REQUIRED:
SOFTWARE USED:
#include<16f877a.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN-c6,rcv=PIN-c7)
float value;
unsigned int i=0;
void main()
{
while(1)
{
setup_adc_ports(ALL_Analog);
setup_adc(ADC_CLOCK_INTERNAL);
setup_adc(channel(1));
value=read_adc();
i=(int)(value*0.3);
printf(“%d”\n\r”,i);
if(i>40)
{
output_low(PIN_D0);
printf(“Above”);
else if(i<35)
{
output_high(PIN_D0);
printf(“Below”);
}
}
}
CONNECTION DIAGRAM:
I/P
P O/P
4
P
5
RA1
GN SENSOR
RD ON/OFF
0 CONTROLLER HEATER
PIC 16F877A
GND POWER
RED CABLE
RELAY O/P
ALGORITHM:
RESULT:
Thus the C program for hot chamber to maintain the temperature say at
40˚C was done and the output is verified.
OBSTACLE DETECTOR USING ULTRASONIC
TRANSMITTER - RECEIVER
AIM:
APPARATUS REQUIRED:
SOFTWARE USED:
#include<16f877a.h>
#include<stdlib.h>
#include<sting.h>
#include<stdio.h>
#use delay(clock=20000000)
#use rs232(baud=1200,xmit=PIN-c6,rcv=PIN-c7,stram=GPS)
while(del--)
output_low(PIN-E0);
output_low(PIN-E1);
delay(500);
output_D(cmd);
delay(500);
output_500(PIN-E2);
delay(500);
output_low(PIN-E2);
output_high(PIN-E0);
output_low(PIN-E1);
delay(500);
output_D(dat);
delay(500);
output_high(PIN-E2);
delay(500);
output_low(PIN-E2);
void print()
lcd_disp(arr,0x80);
void get()
do{i}while{get c!=’R’};
a1=((get()-48)*100)&((get()-48)*10)&(get()-48);
void main()
lcd_init();
print();
while(1)
while(1)
get();
lcd_cmd(0xc0);
lcd_con(a1);
}
CONNECTION DIAGRAM:
VCC RED
GND BLACK
YELLOW
PIC 16F877A Ultrasonic
1 sensor module
9
2
8
3
7
4 9 PIN D MATE IN
6 PIC 16F877A
5
ALGORITHM:
Step 4: The corresponding input & the output is taken in the respective pin.
Step 7: Call the lcd_disp function and initialize the value and check for the
condition.
Step 8: Call the lcd_con function and print and get and check for
condition.
RESULT:
Thus the obstacle detection system was designed using ultrasonic sensor
and the C program for that was compiled and executed.
MOISTURE DETECTOR AND SPRINKLER CONTROLLER DESIGN
AIM:
APPARATUS REQUIRED:
SOFTWARE USED:
Relay Output
YELLOW
BLACK
Sprinkler
Controller
RD0
Module
GND
VCC
RA1
PIC 16F877A
BLACK
RED
YELLOW
Moisture
Sensor Module
ALGORITHM:
Step 4: Set up the ADC ports and channel and initialize the value as read
ADC.
RESULT:
AIM:
APPARATUS REQUIRED:
SOFTWARE USED:
#include<16f877a.h>
#include<stdio.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN-c6,rcv=PIN-c7)
#use 12c(master,sda=PIN-c4,scl=PIN-c3)
void main()
setup_adc_ports(ALL_ANALOG);
setup_adc(ADC_clock_internal);
set_rtc_time();
while(1)
{
get_rtc_time();
set_adc_channel(1);
value=read_adc();
i=(int)(value/2);
year=0;
if(minute==0xa0)
{
year=1;
}
if(minute==0x02)
{
year=1;
}
printf(“%d time:%x,%x,%x\n\n”,i,hour,minute,second);
if((year==1)||(i>60)
{
output_high(PIN-D1);
}
else if((year==0)&&(i<60))
{
output_low(PIN-D1);
}
}
ALGORITHM:
PROCEDURE:
1) Compile the above C program using MPLAB LDE software to create hex
file.
2) Download the hex file using PIC ISP software.
3) After executing the program, the low level in the tank is reused and it is
indicated by signal and high level in the water tank is indicated by red
signal when water reached the high level, the relay will be cut-off.
RESULT:
Thus the lamp controller having light sensor and relay was done and
executed successfully.
PC COMMUNICATION
AIM:
To write a C program to display the message in the serial window.
APPARATUS REQUIRED:
1) PIC 16F877 kit
2) 5V adapter
3) RS 232 cable
SOFTWARE USED:
1) Microprocessor lab IDE Compiler
2) PIC ISP Downloader
3) WINX Talk
PROGRAM:
#include<16f877a.h>
#include<stdio.h>
#use delay(clock=20000000)
#use rs232(baud=9600,xmit=PIN-c6,rcv=PIN-c7)
void main()
while(1)
printf(“VI MICROSYSTEM”);
}
ALGORITHM:
PROCEDURE:
RESULT:
Thus the above C program to display the message in serial window was
executed and verified successfully.