Lab Manual
Lab Manual
Lab Manual
/%
LIST OF EXPERIMENTS
syllabus
VI SEM - Microcontroller & Embedded System LAB
EXPERIMENT NO 1
AIM: To study development tools/environment for ATMEL/PIC microcontroller programme and
Architecture.
1. Create a New folder on the desktop for saving the contents of the program.
2. Double click on the icon of Keil.
3. Select the device for the target (Select Atmel Select 89C52 Ok No)
4. Go in the project menu and click on µVision Project after this an edit window will appear on
desktop.
5. Write the desired program in the editing window up to end.
6. Right click on source group and select remove start up in project workspace.
7. Go in the file menu and click on save as and save the program with the extinction .asm on
desktop in the new folder.
8. Right click on source group Select add file to group All file Select file .asm
Select Add.
9. Now go in the project menu and click on options for the target “Target1”.
10. Update the frequency value (eg. 11.0592) and click on output and enable the following.
a. ®Create Executable
b. or Ok –Debug info
c. Select Create Hex file
d. Select Browse info
Now click on Ok
11. Go in the project menu and click on built target.
12. Go in the project menu and click on Rebuild target.
13. Go in the project menu and click on Run (or Ctrl +F5).
14. After this Hex file will be created in the New Folder
A microcontroller is a single chip microcomputer with on board program ROM and I/O that can be
programmed for various control functions. Unlike a general purpose computer, which also includes all
of these components, a microcontroller is designed for a very specific task to control a particular
system.
The AT89C52 is a low power, high performance CMOS 8 bit microcomputer with 8K bytes of Flash
Programmable and Erasable Read Only Memory. The on chip flash allows the program memory to be
RST: Resett input: A higgh on this piin for two machine cyclees while the oscillator is running reseets the
device and terminate
t alll activities. This
T is often referred to as
a a power ono reset. Actiivating a powwer on
&'(% '01'
'&%)23%$# %#!#/%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%45567: %
!"#$%&'()##*+,-*./%
reset will cause all values in the register to be lost. Figure A and figure B shows two ways of
connecting the RST pin to the power on reset circuitry.
Positive voltage impulse on RST pin resets the MCU. In order to be detected, this impulse needs to
have duration of at least two operating cycles (this cycle represents the time necessary to execute one
instruction and lasts for 12 oscillator signals).
EA/VPP: External Access Enable; When this pin is connected to the ground, MCU gets program
instructions from external program memory. In case that internal program memory is used (common
case); this pin should be connected to the positive supply pole (VCC). During the loading of program
to internal Flash memory, this pin is at +12V.
ALE/PROG: This pin emits an impulse sequence with a frequency equal to 1/6 of the frequency
generated by the main oscillator. If external memory is used, signal from this pin controls the
additional register for temporary storage of the lower address byte (A0 - A7). This pin also serves as a
control input during the writing of program to MCU.
PSEN: Program Store Enable; This pin is used for reading from external program memory (ROM).
When the AT89C52 is executing code from external program memory, PSEN is activated twice each
machine cycle, except that two PSEN activations are skipped during each access to external data
memory.
XTAL1 and XTAL2: XTAL1 is the Input to the inverting oscillator amplifier and input to the internal
clock operating circuit. XTAL2 is Output from the inverting oscillator amplifier. AT89C52 has an on
chip oscillator but requires an external clock to run it(See Figure. C). Most often quartz crystal is
connected to XTAL1 and XTAL2.The quartz crystal oscillator connected to XTAL pins also needs two
capacitors of 30pf value.
PIC is the name for the Microchip microcontroller (MCU) family, consisting of a microprocessor, I/O
ports, timer(s) and other internal, integrated hardware. The main advantages of using the PIC are low
external part count, a wide range of chip sizes available, nice choice of compilers (assembly, C, Basic,
etc.) good wealth of example/tutorial source code and easy programming. Once bought, the PIC's
program memory is empty, and needs to be programmed with code (usually HEX files) to be usable in
a circuit. For the purpose, a wide range of simple programmer hardware docs and software is
downloadable from the net.
PIC is a family of Harvard architecture microcontrollers made by Microchip Technology, derived from
the PIC1650 originally developed by General Instrument's Microelectronics Division.
A single accumulator (W), the use of which (as source operand) is implied (i.e is not encoded in the opcode)
All RAM locations function as registers as both source and/or destination of math and other functions.
A hardware stack for storing return addresses
A fairly small amount of addressable data space (typically 256 bytes), extended through banking
Data space mapped CPU, port, and peripheral registers
The program counter is also mapped into the data space and writable (this is used to synthesize indirect jumps).
Unlike most other CPUs, there is no distinction between "memory" and "register" space because the
RAM serves the job of both memory and registers, and the RAM is usually just referred to as the
register file or simply as the registers.
Peripheral Features:
Timer0: 8-bit timer/counter with 8-bit prescaler
Timer1: 16-bit timer/counter with prescaler, can be incremented during Sleep via external crystal/clock
Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler
Two Capture, Compare, PWM modules
a. Capture is 16-bit, max. Resolution is 12.5 ns
b. Compare is 16-bit, max. Resolution is 200 ns
c. PWM max. Resolution is 10-bit
Synchronous Serial Port (SSP) with SPI™ (Master mode) and I2C™ (Master/Slave)
Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with 9-bit address detection
Parallel Slave Port (PSP)–8 bits wide with external RD, WR and CS controls (40/44-pin only)
Brown-out detection circuitry for Brown-out Reset (BOR)
Analog Features:
· 4 register banks
· 2 multiple modes, 16 bit timer/counter
· Extensive Boolean processing capabilities.
· 64KB external RAM size.
· 32 bi-directional I/O lines.
3. Explain the operating mode 0 of 8051 serial port?
Ans In this mode serial data enters and exists through RXD, TXD outputs the shift clock. 8-bits are
transmitted or received:8-data bits(LSB first). The baud rate is fixed at 1/12 the oscillator
frequency.
4. Explain the operating mode 2 of 8051 serial port?
Ans In this mode 11 bits are transmitted (through TXD) or received (through (RXD): a start bit(0), 8
data bits( LSB first), a programmable 9th data bit and a stop bit(1). On transmit, the 9th data bit
can be assigned the value 0 or 1. On receive, the 9th data bit go into the RB8 in special function
register SCON, while the stop bit is ignored.
The baud rate is programmable to either 1/32 or 1/64 the oscillator frequency.
5. Explain the mode 3 of 8051 serial port?
Ans In this mode, 11 bits are transmitted (through TXD) or (received (through RXD): a start bit(0),
8 data bits(LSB first), a programmable 9th data bit and a stop
bit(1).It is same as mode 2 except the baud rate. The baud rate in mode 3 is variable.
6. Explain the interrupts of 8051 micro controller?
Ans · External interrupt 0 (IE0) – Highest priority,· Timer interrupt 0 (TF0)
· External interrupt 1 (IE1),· Timer interrupt 1 (TF1)
· Serial port Interrupt,Receive interrupt (RI) – lowest priority
Transmit interrupt (TI)
7. How many bytes of internal RAM and ROM supported by 8051 micro controller?
Ans 128 bytes of internal RAM and 4 bytes of ROM.
8. Define machine cycle of 8051?
Ans 8051 machine cycle consists of 6 states, S1 through S7. One state is made up of 2 clock pulses.
Thus 12 clock period constitute one machine cycle. Two clock periods in a state is termed as
phase 1 and phase 2.
9. What are the special function of port 0 of 8051?
Ans Port 0 is used as a multiplexed low order address/data bus during the external memory access.
When ALE is enabled, the address on port 0 pins are latched and bus is ready to act as a data
bus when ALE is low.
10. What are the alternative function of port 3 of 8051?
Ans Serial data input (P3.0), serial data output (P3.1), external interrupt 0 (P3.2), external interrupt
1 (P3.3), external input for timer 0(P3.4), external input for timer 1 (P3.5), external memory
write pulse (P3.6), external memory read (P3.7) are the alternative functions of port 3.
EXPERIMENT NO 2
AIM: Write an assembly language program to add, subtract, multiply and divide 16 bit data by Atmel
microcontroller.
PROGRAM:
Addition:
ORG 0000H
CLR C ; make CY=0
MOV A, #0E7H ; load the low byte now A=E7H
ADD A, #8DH ; add the low byte now A=74H and CY=1
MOV R6, A ; save the low byte of the sum in R6
MOV A, #3BH ; load the high byte
ADDC A, #3BH ; add with carry (3B+3C+1=78)
MOV R7, A ; save the high byte of the sum
Subtraction:
ORG 3000H
CLR C ; make CY=0
MOV A, #50H ; load the low byte now A= 50H
MOV R1, #30H ; load the byte now R1=30H
SUBB A, R1 ; subtract contents of A and R1
JNC Next
CPL A
INC A
Next: MOV R2, A
SJMP 3000H
Multiply:
ORG 4000H
MOV A, #03H ; move the first no. into acc
MOV B, #02H ; move the second no. into B
MUL AB ; multiply the contents of acc with B
SJMP 4000H
Divide:
ORG 5000H
MOV A, #25H ; move the first no. into acc.
MOV B, #5H ; move the second no. into B
DIV AB ; divide the contents of acc with B
SJMP 5000H
RESULT: Addition, Subtraction, Multiplication, Division of 16 bit data has been performed
successfully
on the kit.
PRECAUTIONS: Make sure correct power supply is given to the kit/Equipment. Wrong power
supplies
may cause damage to your equipments.
EXPERIMENT NO 3
AIM: Write an assembly language program to generate 10 KHz frequency using interrupts on P1.2.
PROGRAM:
RESULT: Square wave has been generated on P1.2 and displayed on CRO.
PRECAUTIONS: Make sure correct power supply is given to the kit/Equipment. Wrong
power supplies may cause damage to your equipments.
1.Device pins XTAL1 and XTAL2 for the 8051 are used for connections to an external
oscillator or crystal.
Ans. TRUE
2.When the 8051 is reset and the line is HIGH, the program counter points to the
first program instruction in the:
Ans.Internal Code Memory
3.An alternate function of port pin P3.4 in the 8051 is:
Ans.Timer 0
4.Bit-addressable memory locations are:
Ans.20H through 2FH
5.The number of data registers is:
Ans.32
6.The total amount of external code memory that can be interfaced to the 8051 is:\
Ans. 64 K
7.An alternate function of port pin P3.0 (RXD) in the 8051 is:
Ans.Serial Port Input
8.MOV A, @ R1 will:
Ans.copy the contents of memory whose address is in R1 to the accumulator
9.The start-conversion on the ADC0804 is done by using the:
Ans.SC
10.The number of data registers is:
Ans.32
EXPERIMENT NO 4
APPARATUS: NV5001 Microcontroller development Board, MC-04 Kit, power cord and
connecting leads.
LCALL DELAY_1S
LCALL DELAY_1S
------------------------------------------------------------------------------------------------------------------------
MOV A, #082H
LCALL COMMAND
MOV A, #"T"
LCALL DISPLAY
MOV A, #"e"
LCALL DISPLAY
MOV A, #"c"
LCALL DISPLAY
MOV A, #"h"
LCALL DISPLAY
MOV A, #"n"
LCALL DISPLAY
MOV A, #"o"
LCALL DISPLAY
MOV A, #"l"
LCALL DISPLAY
MOV A, #"o"
LCALL DISPLAY
MOV A, #"g"
LCALL DISPLAY
MOV A, #"i"
LCALL DISPLAY
MOV A, #"e"
LCALL DISPLAY
MOV A, #"s"
LCALL DISPLAY
---------------------------------------------------------------------------------------------------------------------
LCALL DELAY_1S
LCALL DELAY_1S
LCALL DELAY_1S
LJMP START
---------------------------------------------------------------------------------------------------------------------
DELAY_1S:
MOV R2, #11
LOOP3: MOV R3, #98
LOOP2: MOV R4, #106
LOOP1: NOP
NOP
NOP
NOP
NOP
NOP
DJNZ R4, LOOP1
DJNZ R3, LOOP2
DJNZ R2, LOOP3
RET
-----------------------------------------------------------------------------------------------------------------------
LCDINIT: MOV A, #38H
LCALL COMMAND
MOV A, #0CH
LCALL COMMAND
MOV A, #01H
LCALL COMMAND
MOV A, #06H
LCALL COMMAND
RET
-----------------------------------------------------------------------------------------------------------------------
COMMAND:
ACALL READY
MOV P0, A
CLR RS_LCD
CLR RW_LCD
SETB E_LCD
CLR E_LCD
RET
-----------------------------------------------------------------------------------------------------------------------
DISPLAY:
ACALL READY
MOV P0, A
SETB RS_LCD
CLR RW_LCD
SETB E_LCD
CLR E_LCD
RET
-----------------------------------------------------------------------------------------------------------------------
READY: SETB P0.7
CLR RS_LCD
SETB RW_LCD
WAIT: CLR E_LCD
SETB E_LCD
JB P0.7, WAIT
RET
----------------------------------------------------------------------------------------------------------------------
END
PROCEDURE:
10. Turn contrast control potentiometer in LCD interface block to clockwise position (in MC04).
11. Turn Backlight control potentiometer in LCD interface block to anticlockwise position (in
MC04).
12. Switch ‘On’ the power supply.
13. Observe “NVIS’’ is coming on LCD and after some delay “Technologies”.
14. Observe the output waveform between RS pin of LCD (P3.5) and ground, on oscilloscope.
15. Observe the output waveform between R/W pin of LCD (P3.6) and ground, on oscilloscope
16. Observe the output waveform between E pin of LCD (P3.7) and ground, on oscilloscope.
17. Turn contrast control potentiometer and observe the contrast change on LCD.
18. Turn Backlight control potentiometer and observe the change on backlight of LCD.
3. Which I/O port that does not have a dual-purpose role is?
Ans. Port 1
4. The ADC0804 has resolution of?
Ans. 8 Bit
5. A HIGH on which pin resets the 8051 microcontroller?
Ans. RST
6. An alternate function of port pin P3.1 in the 8051 is:
Ans. Serial Port Output
7. An alternate function of port pin P3.0 (RXD) in the 8051 is:
Ans. Serial Port Input
8. Magnetic tape is a
Ans. Direct Access Storage Device
9. Which parts of the computer perform arithmetic calculation
Ans. ALU
10. Vacuum tube based electronic computers are:
Ans. Hoover generation
EXPERIMENT NO 5
APPARATUS: NV5001 Microcontroller development Board, MC-04 Kit, power cord and
connecting leads.
CLR SEG_D
MOV P2, #00H
SETB SEG_D
MOV P2, #01100110B
LCALL DELAY_1S
CLR SEG_D
CLR SEG_B
CLR SEG_A
CLR SEG_C
MOV P2, #00H
LJMP LOOP
----------------------------------------------------------------------------------------------------------------
-----
DELAY_1S: MOV R2, #06
DO3: MOV R3, #10
DHERE1: MOV R4, #10
DAGAIN: NOP
NOP
NOP
NOP
DJNZ R4, DAGAIN
DJNZ R3, DHERE1
DJNZ R2, DO3
RET
----------------------------------------------------------------------------------------------------------------
-----
END
PROCEDURE:
5. Switch ‘Off’ the power supply and remove the programmed controller from programmer
ZIF socket
6. Switch ‘Off’ the programmer switch in Programmer unit (in NV5001).
7. Insert programmed Microcontroller to microcontroller unit ZIF socket.
8. Connect 20 Pin FRC cable to seven segment display Interface block left side
socket/connector (MC04) to Port P2 in NV5001 Trainer.
9. Connect 20 Pin FRC cable to seven segment Interface block right side socket/connector
(MC04) to Port P1 in NV5001 Trainer.
10. Switch ‘On’ the power supply.
11. Observe “1234’’ is coming on seven segment.
12. Observe the status of segment selection pins on tp28, tp29, tp30 & tp31.output waveform
between RS pin of LCD (P3.5) and ground, on oscilloscope.
13. Observe the status of data bits on tp17 to tp24.
It have control register. The device can be programmed by sending control word in
the prescribed format to the control register.
8. What is baud rate?
Ans.The baud rate is the rate at which the serial data are transmitted. Baud rate is
defined as (The time for a bit cell). In some systems one bit cell has one data bit,
then the baud rate and bits/sec are same.
9. What is a port?
Ans.The port is a buffered I/O, which is used to hold the data transmitted from the
microprocessor to I/O devices and vice versa.
10. What is the need for interrupt controller?
Ans. The interrupt controller is employed to expand the interrupt inputs. It can
handle the interrupt request from various devices and allow one by one to the
processor.
EXPERIMENT NO 6
AIM: Study of implementation of stepper motor angle control.
APPARATUS: NV5001 Microcontroller development Board, MC-05 Kit, power cord and
connecting leads.
DESCRIPTION: The experiment has been designed to have a clear understanding of how
motors are interfaced and controlled with microcontroller. The Motor drive module is made
in such a way that student can understand the whole concepts of steeper motor, DC motor
and Servo system. The object is to connect and program a microcontroller to do any
operation with motors. It has input and output terminals for connection of external real
world applications.
PROGRAM: To monitor the status of switch and rotate the stepper motor.
CLR A_ST
CLR B_ST
SETB C_ST
SETB D_ST
END
PROCEDURE:
EXPERIMENT NO 7
APPARATUS: NV5001 Microcontroller development Board, MC-05 Kit, power cord and
connecting leads.
PROGRAM: To monitor the PWM status and control the speed of DC motor in 100% and 25%
duty cycle pulse.
LCALL DELAY_1S
LCALL DELAY_1S
LCALL DELAY_1S
LCALL DELAY_1S
LCALL DELAY_1S
LCALL DELAY_1S
LCALL DELAY_1S
SJMP FIR_ROU
--------------------------------------------------------------------------------------------------------------------
DELAY_1S_2 : MOV R2, #50
DHERE1_1_1 : MOV R3, #100
DHERE1_2 : NOP
DJNZ R3, DHERE1_2
DJNZ R2, DHERE1_1_1
RET
--------------------------------------------------------------------------------------------------------------------
DELAY_1S : MOV R2,#100
DO3_3 : DEC R2
DJNZ R2, DO3_3
RET
----------------------------------------------------------------------------------------------------------------------
END
PROCEDURE:
1. How many bytes of internal RAM and ROM supported by 8051 micro controller?
Ans.128 bytes of internal RAM and 4 bytes of ROM.
2. Define machine cycle of 8051?
Ans.8051 machine cycle consists of 6 states, S1 through S7. One state is made up of 2 clock
pulses. Thus 12 clock period constitute one machine cycle. Two clock periods in a state is
termed as phase 1 and phase 2.
3. What are the special function of port 0 of 8051?
Ans.Port 0 is used as a multiplexed low order address/data bus during the external
memory access. When ALE is enabled, the addresses on port 0 pins are latched and bus is
ready to act as a data bus when ALE is low.
4. What are the alternative function of port 3 of 8051?
Ans.Serial data input (P3.0), serial data output (P3.1), external interrupt 0 (P3.2), external
interrupt 1 (P3.3), external input for timer 0(P3.4), external input for timer 1 (P3.5),
external memory write pulse (P3.6), external memory read (P3.7) are the alternative
functions of port 3.
5. What are the use of scratch pad area of internal RAM of 8051?
Ans.In internal RAM 80 bytes constitutes the scratch pad area. The scratch pad bytes can
be programmed as a general purpose registers.
6. What are the flags supported by 8051 controller? –
Ans. Carry flag · Auxiliary carry flag · Over flow flag · General purpose user flag ·
Register bank select bit one · Register bank select bit zero · Parity flag
7. What is meant by Power-on- Reset in 8051 controller?
Ans.When RESET pin is activated, the 8051 jumps to address location 0000H. This is
called as Power-on-Reset. Reset pin is considered as a sixth interrupt source of 8051.
8. What are the significance of SFRs?
Ans. All the controller registers such as port latches, timer register, peripheral control
register, accumulator, PC and DPTR all are available in SFR region.
9. What are the different group of instructions supported by 8051? ·
Ans.Data Transfer Group · Arithmetic Logical Branching Bit manipulation
10. Write a program to mask the 0th and 7th bit using 8051?
Ans:
MOV A,#data
ANL A,#81
MOV DPTR,#4500
MOVX @DPTR,A
LOOP: SJMP LOOP
EXPERIMENT NO 8
PROGRAM: To monitor the status of position control switch and control the angle of
servo motor.
PROCEDURE:
Ans.The interrupt service register stores all the levels that are currently being serviced.
9. What is the difference between SHLD and LHLD?
Ans.SHLD- Store HL register pair in memory.
This instruction is used to store the contents of H and L register directly in to memory.
LHLD- Load HL register pair from memory. This instruction copies the contents of
memory location given with in the instruction in to the L register and the contents of next
memory location in to the H register.
10. What is the difference between STAX and LDAX?
Ans.STAX rp – Store the contents of Accumulator register (A) in memory location whose
address is specified by BC or DE register pair.
LDAX rp – Load Accumulator register (A) with the contents of memory location whose
address is specified by BC or DE register pair.
EXPERIMENT NO 9 (a)
APPARATUS: NV5001 Microcontroller development Board, MC-03 Kit, power cord and
connecting leads.
INSTALLATION:
If your computer doesn’t have Hyper Terminal software please follow the below procedure.
1. First go to control panel and click Add/Remove Program.
2. Click Windows Setup.
3. Select Hyperterminal then press OK and click Apply.
4. Select Hyperterminal then press OK and click Apply.
5. Computer will ask for Windows CD for installing Hyperterminal.
6. After installing hyperterminal click cursor on
<start> <programs><Accessories><communications> <Hyperterminal> then open it.
7. Click on < Hyperterminal> icon give ABC in name block and click OK.
8. Select Communication port < Direct to COM1>.
9. For Trainer kit select following COM 1 properties :
Bits per second : 9600
Data bits : 8
Parity : None
Stop bits : 1
Flow control : None
PROGRAM: To transfer the message “YES” serially at 9600 baud, 8 bit data and
1stop bit continuously.
ORG 0000H
JMP START
-----------------------------------------------------------------------------------------------------------------
ORG 0200H
START: MOV A, #00H
MOV PSW, #00H
MOV SBUF, #00H
CLR C
SERI_TRANSMIT: MOV P3, #0FFH
MOV TMOD, #20H
MOV TH1, #0FDH
MOV TL1, #0FDH
PROCEDURE:
EXPERIMENT 9 (b)
AIM: Study of Programming and Reception of data through serial port.
APPARATUS: NV5001 Microcontroller development Board, MC-03 Kit, power cord and
connecting leads.
PROGRAM: To receive bytes of data serially and put them in P0. Set the baud rate at 9600,
8- bit data and 1 stop bit.
MOV B, #00H
MOV P0, #00H
MOV P3, #0FFH
LCALL COMMAND
MOV A, #01H
LCALL COMMAND
MOV A, #06H
LCALL COMMAND
RET
--------------------------------------------------------------------------------------------------------------------
COMMAND:
ACALL READY
MOV P0, A
CLR RS_LCD
CLR RW_LCD
SETB E_LCD
CLR E_LCD
RET
--------------------------------------------------------------------------------------------------------------------
DISPLAY:
ACALL READY
MOV P0, A
SETB RS_LCD
CLR RW_LCD
SETB E_LCD
CLR E_LCD
RET
READY: SETB P0.7
CLR RS_LCD
SETB RW_LCD
WAIT: CLR E_LCD
SETB E_LCD
JB P0.7, WAIT
RET
--------------------------------------------------------------------------------------------------------------------
DELAY_1S:
MOV R2, #11
DO3: MOV R3, #98
DHERE1: MOV R4, #106
DAGAIN: NOP
NOP
NOP
NOP
NOP
NOP
DJNZ R4, DAGAIN
DJNZ R3, DHERE1
PROCEDURE:
5. Switch ‘Off’ the power supply and remove the programmed controller from
programmer ZIF socket.
6. Switch ‘Off’ the programmer switch in Programmer unit (in NV5001).
7. Insert programmed microcontroller to microcontroller unit ZIF socket.
8. Connect 20 Pin FRC cable to Serial port Interface block socket/connector (MC03) to
Port P3 in NV5001 Trainer.
9. Connect 20 Pin FRC cable to LCD Interface block left side socket/connector
(MC04) to Port P2 in NV5001 Trainer.
10. Connect 20 Pin FRC cable to LCD Interface block right side socket/connector
(MC04) to Port P0 in NV5001 Trainer.
11. Unplug the serial cable which is connected between programmer unit and PC.
12. Connect serial cable between computer serial port and serial port interface block
female connector (inMC03).
13. Click on < Hyperterminal> icon in your PC and give ABC in name block then click
OK.
14. Select Communication port < Direct to COM1 > ( If you connect cable to COM1).
15. For Module select following COM 1 properties:
Bits per second : 9600
Data bits : 8
Parity : None
Stop bits : 1
Flow control : None
16. Switch ‘On’ the power supply.
17. “Nvis” is displayed on LCD screen.
18. Now press any key from keyboard (Keep cursor on hyper window).The character
you pressed is displayed on LCD. The character is received by microcontroller via
serial cable and displayed on LCD.
19. To see received data connect CRO probe between tp1 & tp3 test point and ground.
20. To see received data connect CRO probe between tp3 & tp4 test point and ground.
EXPERIMENT NO 10
AIM: To study implementation and programming of Pressure measurement.
APPARATUS: NV5001 Microcontroller development Board, MC-15 Kit, power cord and
connecting leads.
DESCRIPTION: Sensor module, MC15 has input and output terminals for connection
of External real world applications. Pressure Sensor and Temperature Sensor Interface
Module MC15 is generally used in the applications such as Monitoring and
Controlling in Industries and many more.
PROGRAM:
*Delay
*Description : This function provide Delay in Mili Sec.
***************************************************************************
/
&'(% '01'&%)23%$# %#!#/%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%456789 %
!"#$%&'()##*+,-*./%
/**************************************************************************
*
* ADC initialization
* Description: This function initializes the LCD module by the following steps:
*1. Select ADC Channel
*2. Set A/D: 10-bit AIN0 @ 12MHz
* Note: This function should be called once before any of the other functions of ADC.
***************************************************************************
/
void ADC_Init()
{
PINSEL0 |= 0x00003000; /* channel
AD1.0*/
AD1CR = 0x01210400; /* Setup A/D: 10-bit AIN0 @ 3MHz
*/
}
/**************************************************************************
*
* ADC Conversion
* Description: This function convert ADC data into ASCII by the following steps:
* 1. Convert each byte into ASCII
* 2. Each Value will be used for LCD Display
* Arguments : 'RADC_Value' is the Value which needs to convert in ASCII.
***************************************************************************
/
void ADC_Convert(unsigned int ADC_Value)
{
unsigned int X,Y,Z; /* Intermidiate Variables
*/
FirstBit=0,SecondBit=0,ThrdBit=0,FourthBit=0;
X = ADC_Value/10;
FirstBit = ADC_Value%10;
FirstBit = 0x30|FirstBit; /* First Byte(LSB)
*/
Y = X/10;
SecondBit = X % 10;
SecondBit = 0x30|SecondBit; /* Second Byte
*/
Z = Y/10;
ThrdBit = Y % 10;
ThrdBit = 0x30|ThrdBit; /* Third Byte */
FourthBit = Z; /* Last Byte(MSB) */
FourthBit=0x30|FourthBit;
}
/**************************************************************************
*
* LCD initialization
* Description : This function initializes the LCD module by the following steps:
* 1. Set 8bit : 2 Line 5x7 Dots (0x38)
* 2. Display On curser Off (0x0C)
* 3. Clear Display (0x01)
*4. Entry Mode (0x06)
* Note: This function should be called once before any of the other functions
**************************************************************************/
void LCD_Init(void)
{
LCD_Cmd(0x38); /* Function Set 8bit : 2 Line 5x7 Dots */
LCD_Cmd(0x0C); /* Display On curser Off */
LCD_Cmd(0x01); /* Clear Display */
RS_Clr; /* RS Pin
Clear */
LCD_Delay(10); /* Delay for
Clock*/
EN_Set; /* Enable Pin
SET */
LCD_Delay(10);
IO1SET = Shifted_Cmd; /* Write Command Value to LCD Data
Pin */
LCD_Delay(20); /* Delay for enable
Clock*/
EN_Clr; /* Enable Pin
Clear */
LCD_Delay(10);
IO1CLR = 0x00FF0000; /* Clear All pins of
LCD */
}
/**************************************************************************
*
* LCD Data
* Description: This function initializes the LCD module by the following steps:
* 1. Set Register select(RS) to High
* 2. Set enable pin high to low
* 3. Send data to LCd data pin
* Note: Here we have selected Port 1 Pin P1.16 to P1.23 as LCD data line
* thats why we need to shift data by 16.
***************************************************************************
/
void LCD_Data(unsigned long Data)
{
RS_Set; /* RS Pin Clear
*/
LCD_Delay(10); /* Delay for
Clock*/
EN_Set; /* Enable Pin SET
*/
LCD_Delay(10);
IO1SET = Data << 16; /* Write Command Value to LCD Data Pin
*/
LCD_Delay(20); /* Delay for enable
Clock*/
EN_Clr; /* Enable Pin Clear
*/
LCD_Delay(10);
IO1CLR = 0x00FF0000; /* Clear All pins of
LCD */
}
/**************************************************************************
*
* LCD Display
* Description : This function initializes the LCD module by the following steps:
* 1. Send Loc from where data needs to write
void ADC_CALL(void)
{
AD1CR |= 0x01000000; /* start of ADC conversion
*/
do{
/**************************************************************************
*
* Main: Initialize and start RTX Kernel
* Description : This function Initialize the LCD,RTC and ADC and RTX Kernal
***************************************************************************
/
int main (void) /* program exec. starts here */
{
float volt[20],dispvolt;
char k[5];int i;
IO1DIR = 0xFFFF0000; /* Define Port pin P1.16 to P1.31 as Output for LCD
*/
LCD_Init(); /* LCD Initialize
*/
ADC_Init(); * ADC Initialize
*/
display_lcd1(0x80," Voltage");
while(1)
{
for(i=0;i<=19;i++)
{
ADC_CALL();
volt[i] = (ADC_Val * 3.3) / 1023.0;
}
dispvolt =
(volt[0]+volt[1]+volt[2]+volt[3]+volt[4]+volt[5]+volt[6]+volt[7]+volt[8]+volt[9]+volt[10]+
volt[11] +volt[12]+volt[13]+volt[14]+volt[15]+volt[16]+volt[17]+volt[18]+volt[19])/20;
sprintf(k,"%f",dispvolt + 0.01);
LCD_Cmd(0xC6);
LCD_Data(k[0]);
LCD_Cmd(0xC7);
LCD_Data(k[1]);
LCD_Cmd(0xC8);
LCD_Data(k[2]);
LCD_Cmd(0xC9);
LCD_Data(k[3]);
LCD_Cmd(0xCA);
LCD_Data(k[4]);
LCD_Cmd(0xCC);
LCD_Data('V');
LCD_Delay(200000);
}
}
/*----------------------------------------------------------------------------
* end of file
*---------------------------------------------------------------------------*/
PROCEDURE:
1. Connect 20 Pin FRC cable between Sensor Module (MC15) & Port of
NV500Xseries Trainer as mentioned in respective programs.
2. Connect LCD Module compatible with NV500X series Trainer LCD Data and
Control Pins to Ports of NV500X series trainers as mentioned in respective programs
(Optional).
3. Make the connection of Sensor Module with NV500X series as given in the
respective program.
4. Observer the voltage that is being displayed on the LCD and note down the readings.
RESULT: Pressure measured and corresponding digital value observed on the LCD.
EXPERIMENT NO 11
APPARATUS: NV5001 Microcontroller development Board, MC-15 Kit, power cord and
connecting leads.
PROGRAM:
/****************************************************************************
** *D
* Description : This function provide Delay in Mili Sec.
*****************************************************************************
*/
void Delay(unsigned int Time)
{
unsigned int i,j;
for(i=0;i<=Time;i++)
for(j=0;j<1275;j++);
}
/****************************************************************************
*
* LCD_Delay
* Description : This function provide Delay in Mili Sec.
*****************************************************************************
*/
void LCD_Delay(unsigned int Time)
{
unsigned int i,j;
for(i=0;i<=Time;i++)
for(j=0;j<1005;j++);
}
/****************************************************************************
***
* ADC initialization
* Description : This function initializes the LCD module by the following steps:
* 1. Select ADC Channel
* 2. Set A/D: 10-bit AIN0 @ 12MHz
* Note: This function should be called once before any of the other functions of ADC.
*****************************************************************************
***/
void ADC_Init()
{
PINSEL0 |= 0x00003000; /* channel
AD1.0*/
AD1CR |= 0x01210400;
}
/****************************************************************************
**
* ADC Conversion
* Description : This function convert ADC data into ASCII by the following steps:*
* 1. Conver each byte into ASCII
* 2. Each Value will be used for LCD Display
* Arguments : 'RADC_Value' is the Value which needs to convert in ASCII.
*****************************************************************************
**/
void ADC_Convert(unsigned int ADC_Value)
{
unsigned int X,Y,Z; /* Intermidiate
Variables */
FirstBit=0,SecondBit=0,ThrdBit=0,FourthBit=0;
X = ADC_Value/10;
FirstBit = ADC_Value%10;
FirstBit = 0x30|FirstBit; /* First Byte
(LSB) */
Y = X/10;
SecondBit = X % 10;
SecondBit = 0x30|SecondBit; /* Second
Byte */
Z = Y/10;
ThrdBit = Y % 10;
ThrdBit = 0x30|ThrdBit; /* Third
Byte */
FourthBit = Z; /* Last
Byte(MSB) */
FourthBit=0x30|FourthBit;
}
/****************************************************************************
*
* LCD initialization
* Description : This function initializes the LCD module by the following steps:
* 1. Set 8bit : 2 Line 5x7 Dots (0x38)
* 2. Display On curser Off (0x0C)
* 3. Clear Display (0x01)
* 4. Entry Mode (0x06)
* Note : This function should be called once before any of the other functions
*****************************************************************************
**/
void LCD_Init(void)
{
LCD_Cmd(0x38); /* Function Set 8bit : 2 Line 5x7
Dots */
LCD_Cmd(0x0C); /* Display On curser
Off */
LCD_Cmd(0x01); /* Clear
Display */
LCD_Cmd(0X06); /* Entry
Mode */
}
/****************************************************************************
** *L
* Description : This function initializes the LCD module by the following steps:
* Note : Here we have selected Pin P1.16 to P1.23 as LCD data line thats why we need to
* shift data by 16.
*****************************************************************************
**/
void LCD_Cmd(unsigned long Cmd)
{
unsigned long Shifted_Cmd;
Shifted_Cmd = Cmd << 16; /* because we have selected P1.16 to P1.23 as LCD data line
*/
// RW_Clr; /* RW Pin Clear
*/
/****************************************************************************
* LCD Data
* Description : This function initializes the LCD module by the following steps:
* 1. Set Register select(RS) to High
* 2. Set enable pin high to low
* 3. Send data to LCd data pin
* Note: Here we have selected Port 1 Pin P1.16 to P1.23 as LCD data line thats why we need to
shift
data by 16.
*****************************************************************************
**/
RS_Set; /* RS Pin
Clear */
LCD_Delay(5); /* Delay for
Clock*/
EN_Set; /* Enable Pin
SET */
LCD_Delay(5);
IO1SET = Data << 16; /* Write Command Value to LCD Data
Pin */
LCD_Delay(10); /* Delay for enable
Clock*/
EN_Clr; /* Enable Pin
Clear */
LCD_Delay(5);
IO1CLR = 0x00FF0000; /* Clear All pins of
LCD */
}
/****************************************************************************
**
* LCD Display
* Description : This function initializes the LCD module by the following steps:
* 1. Send Loc from where data needs to write
* 2. Display string on LCD
*****************************************************************************
*/
/****************************************************************************
**
* Main: Initialize and start RTX Kernel
* Description : This function Initialize the LCD,RTC and ADC and RTX Kernal
*****************************************************************************
*/
int main (void) /* program exec. starts here
*/
{
int i;
float temp[10],
disptemp;IO1DIR = 0xF8FF0000; /* Define Port pin P1.16 to P1.31 as Output for
LCD */
LCD_Init(); /* LCD
Initialize */
ADC_Init(); /* ADC
Initialize*/
LCD_Cmd(0x01); /* Clear
Display */
while(1) /* Loop
Continue*/
{
LCD_Cmd(0x83); /* Set Curser at
'0x83' */
LCD_Data('T'); /* Display ADC Value on
LCD */
LCD_Cmd(0x84);
LCD_Data('e');
LCD_Cmd(0x85);
LCD_Data('m');
LCD_Cmd(0x86);
LCD_Data('p');
LCD_Cmd(0x87);
LCD_Data('e');
LCD_Cmd(0x88);
LCD_Data('r');
LCD_Cmd(0x89);
LCD_Data('a');
LCD_Cmd(0x8A);
LCD_Data('t');
LCD_Cmd(0x8B);
LCD_Data('u');
LCD_Cmd(0x8C);
LCD_Data('r');
LCD_Cmd(0x8D);
LCD_Data('e');
for(i=0;i<=9;i++)
{
ADC_CALL();
temp[i] = ((ADC_Val * 10) /33);
}
disptemp =
(temp[0]+temp[1]+temp[2]+temp[3]+temp[4]+temp[5]+temp[6]+temp[7]+temp[8]+temp[9])/10
;
Delay(10000); /* Delay */
}
}
/*-----------------------------------------------------------------------------------------------------------------
* end of file
*------------------------------------------------------------------------------------------------------------------
-*/
PROCEDURE:
1. Connect 20 Pin FRC cable between Sensor Module (MC15) & Port of NV500Xseries Trainer
as mentioned in respective programs.
2. Connect LCD Module compatible with NV500X series Trainer LCD Data and Control Pins to
Ports of NV500X series trainers as mentioned in respective programs (Optional).
3. Make the connection of Sensor Module with NV500X series as given in the respective
program.
4. Connect +12V DC supply from respective NV500X series trainer.
5. Observer the voltage that is being displayed on the LCD and note down the readings.
7. Interval between the time of submission and completion of the job is called
Ans.Turnaround time.
8. The “turn-around” time of a user job is
Ans. the total time taken to execute the job.
9. Memory utilization factor shall be computed as follows
Ans. memory in use/total memory connected.
10. Program generation activity aims
Ans. at automatic generation of program.
PIC MICROCONTROLLER
EXPERIMENT NO.12
AIM: Study and analysis of interfacing of graphical LCD using PIC Controller.
APPARATUS: NV5002 Trainer, Graphical Display module, Two 20 Pin FRC Cable
THEORY: This module provides an interface to JHD12864J Graphical LCD module of size
128x64 dots Display controller chip is KS0107/8.
PROGRAM:
LIST P=16F877
INCLUDE "P16F877.INC"
ORG 0000H
ORG 0000H
GOTO START
ORG 0004H
RETFIE
ORG 0005H
START: BSF STATUS,RP0
BCF STATUS,RP1
MOVLW 00H
MOVWF TRISC ;PORTC,PORTD AS OUTPUT
MOVWF TRISD
BCF STATUS,RP0
CLRF PIR1
CLRF CCP1CON
; INITIALIZATION OF LCD
CALL WRITE1
CALL DELAY1
MOVLW 0CH ;OUTPUT 0CH ON DATA BUS
MOVWF PORTC
CALL WRITE1
CALL DELAY1
MOVLW 080H ;OUTPUT 80H ON DATA BUS
MOVWF PORTC
CALL WRITE1
BCF PORTD,0
CALL DISPLAY1 ;DISPLAY
CALL DELAY1
MOVLW 0C0H ;OUTPUT 0C0H ON DATA BUS
MOVWF PORTC
CALL WRITE1
MOVLW 10
MOVWF TEMP2
CALL LOP1 ;DISPLAY
SLF1: GOTO SLF1
DECFSZ DLY3,1
GOTO LOOP2
RETURN
DISPLAY2:MOVF REG2,0
MOVWF PORTC
BSF PORTD,1 ; RS high
BSF PORTD,2 ; EN high
CALL DELAY1
BCF PORTD,2 ; EN low
BSF PORTD,0 ; RW HIGH
BCF PORTD,1
BCF PORTD,0 ;R/W LOW
RETURN
DISPLAY1: MOVLW 10
MOVWF TEMP2
MOVLW 0
MOVWF TEMP1
LOP1: CALL CODE2
MOVWF REG2
CALL DISPLAY2
INCF TEMP1,1
DECFSZ TEMP2,1
GOTO LOP1
BCF PORTD,0 ; R/W LOW
RETURN
PROCEDURE:
PIC MICROCONTROLLER
EXPERIMENT NO.13
AIM: To interface PWM based voltage regulator using PIC microcontroller.
APPARATUS: NV5002 Trainer, 2mm Patch Cords 8, Learning Material CD, MC-16.
THEORY: (MC16) PWM based Voltage Regulator for Microcontroller development board
with programmer trainer is an Extension module. The module has been designed to have a
clear understanding of how a PWM is Converted into Voltage .PWM based Voltage Regulator
module enable students and practicing engineers to gain invaluable practical experience of
voltage regulation using Pulse Width Modulation (PWM). The object is to have a clear
understanding of how PWM is generated using microcontroller to use in various applications
like Servo Motor speed control etc. The object is to connect and program a microcontroller to
generate PWM of any duty cycle and convert it into voltage. It has input and output terminals
for connection of external real world applications.
PROGRAM:
Programming Steps:
To generate the PWM of varying duty cycle 0 to100% and than from 100 to 0% continuously.
for(x=0;x<rTime;x++)
for(y=0;y<500;y++);
}
}
void main()
{
unsigned char Counter ;
PROCEDURE:
1. Insert PIC 18F77A Microcontroller in Programmer unit (in NV5002).
2. Connect serial cable between computer serial port and programmer unit serial port
female connector (in NV5002).
3. Switch ‘On’ the programmer switch in programmer unit (in NV5002) and switch ‘On’
the power supply.
4. Program PWM Interface. hex file (Via CD -NV5002/Modules Programs\MC16).
5. Remove the programmed controller from programmer ZIF socket.
6. Insert programmed microcontroller to “PIC Controller” unit ZIF socket.
7. Connect 20 Pin FRC cable to PWM Based Voltage Regulator socket (MC16) to Port
RC in NV5002 Trainer.
8. Press Reset Switch on the NV5002 Trainer.
9. Check the PWM signal on PWM1 and PWM2 using CRO or DSO on MC16.
EXPERIMENT No 13 (b)
PROCEDURE:
PROCEDURE:
1. Burn Hex file into PIC16F877A by following Experiment 1 and insert programmed
Microcontroller to microcontroller unit ZIF socket.
2. Connect 20 Pin FRC cable to PWM Based Voltage Regulator socket (MC16) to Port RC in
NV5002 Trainer.
3. Connect a patch cord from PWM1 to PWM Input socket.
4. Connect a patch cord from Vout to Input socket of Amplifier block.
5. Connect a patch cord between +12V DC Supply (on NV5002) & +12V socket of Amplifier
block (on MC16).
6. Switch ‘On’ the Power Supply (NV5002).
7. Press Reset Switch from NV5002 Trainer.
8. Now take two separate multimeters.
9. Set multimeters to “DC Voltage” Mode.
10. Now connect one multimeter to Vout socket with respect to ground.
11. Connect another multimeter to Output socket of Amplifier bolck with respect to ground.
12. Now observe voltages on Vout and Output of Amplifier Bolck.
13. Now user can vary gain of Amplifier by varying Amplifier potentiometer.
14. Set pot of Amplifier to Unity Gain by rotating it fully clockwise direction and observe voltage.
Both multimeres will display approximately same voltage level.
15. Now set pot of Amplifier to Gain of 2 by rotating it fully counter clockwise direction and
observe voltage. The voltage level of Output terminal of Amplifier is approximately double
of Vout terminal.
16. Follow the same process for PWM2 terminal also.
PIC MICROCONTROLLER
EXPERIMENT NO.14
AIM: Study and interface of IR (RC5 Protocol) and RF Communication using PIC Controller.
APPARATUS: RS-232 Cable, NV500X Trainer (2), MC12 Module (1), MC10 Module (2),
Patch Cords (3), 20 Pin FRC Cable (8)
PROGRAM:
*****************************************************************************
* File Description: IR Module Demo Code
* Steps for Operation:
* Step 1:-
* Swith ON NV5001
* Burn the Program for IR Demo.hex file in 8051/52 MicroController using NV5001.
* Step 2:-
* Connections : Connect 20 Pin FRC cable in following manner:
* NV5001 Port P0 wuth "LCD_Data" Connector of MC10.
* NV5001 Port P1 with "Hex Keypad Interface Block" Connector of MC10.
* NV5001 Port P2 with "LCD_Control" Connector of MC10.
* NV5001 Port P3 with "CN1" of MC12.
* Connection On MC12 Module:
* Connect one patch cord from CN1 - '1' to IR Rx.
* Connect one patch cord from CN1 - '2' to Data In.
* Connect one patch cord from Data Out to IR Tx.
* Step 3:-
* Place MicroController on ZIF Socket and Press Reset Switch.
* Step 4:-
* OutPut: Initially On MC10 LCD "Sent Data: " in first line
* And "Receive Data: 0" in second line display.
* Now, By Using Keypad you can send any character
* which will display on "Send Data : "and the same will be display on "Receive data :".
* For example if you will Send '1' from keypad then On LCD
* Send Data :1
* Recieve Data:1
&'(% '01'&%)23%$# %#!#/%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%4567;+ %
!"#$%&'()##*+,-*./%
***************************************************************************/
/*************************************************************************
* Function Prototypes Definition
**************************************************************************/
void LCD_Init();
void LCD_Busy();
void LCD_Command(unsigned char);
void LCD_Data(unsigned char);
void LCD_WriteS(unsigned char*);
/***************************************************************************
* Pin allocation for LCD
****************************************************************************/
#define LCD_Port P0 /* LCD data pin(D0-D7) to ort P0 */
#define LCD_Flag P0_7 /* LCD Busy Pin*/
#define LCD_rs P2_5 /* LCD RS (Register select) pin */
#define LCD_rw P2_6 /* LCD R/W (Read/ Write) pin*/
#define LCD_en P2_7 /* LCD Enable pin */
/***************************************************************************
* Pin allocation for Keypad
***************************************************************************/
#define ROW1 P1_4
#define ROW2 P1_5
#define ROW3 P1_6
#define ROW4 P1_7
#define COL1 P1_0
#define COL2 P1_1
#define COL3 P1_2
#define COL4 P1_3
/***************************************************************************
* Global variable Declaration
***************************************************************************/
static unsigned char code *LCDArry[]={" Nvis"," Technologies "};
unsigned char KeyVal,Serial_buf[20];
/****************************************************************************
* KeyPad Function Definition
****************************************************************************/
unsigned char Keypad(void)
{
KeyVal = 100;
P1 = 0xFF; // All rows & columns are hi
&'(% '01'&%)23%$# %#!#/%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%4567;8 %
!"#$%&'()##*+,-*./%
while(1)
{
// Row1 Scan
ROW1 = 0;
if(!COL1)
{
delay_msec(50);
if(!COL1)
KeyVal='1';
return KeyVal;
}
if(!COL2)
{
delay_msec(50);
if(!COL2)
KeyVal='2';
return KeyVal;
}
if(!COL3)
{
delay_msec(50);
if(!COL3)
KeyVal='3';
return KeyVal;
}
if(!COL4)
{
delay_msec(50);
if(!COL4)
KeyVal='F';
return KeyVal;
}
ROW1 = 1;
// Row2 Scan
ROW2 = 0;
if(!COL1)
{
delay_msec(50);
if(!COL1)
KeyVal='4';
return KeyVal;
}
if(!COL2)
&'(% '01'&%)23%$# %#!#/%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%4567;9 %
!"#$%&'()##*+,-*./%
{
delay_msec(50);
if(!COL2)
KeyVal='5';
return KeyVal;
}
if(!COL3)
{
delay_msec(50);
if(!COL3)
KeyVal='6';
return KeyVal;
}
if(!COL4)
{
delay_msec(50);
if(!COL4)
KeyVal='E';
return KeyVal;
}
ROW2 = 1;
// Row3 Scan
ROW3 = 0;
if(!COL1)
{
delay_msec(50);
if(!COL1)
KeyVal='7';
return KeyVal;
}
if(!COL2)
{
delay_msec(50);
if(!COL2)
KeyVal='8';
return KeyVal;
}
if(!COL3)
{
delay_msec(50);
if(!COL3)
KeyVal='9';
return KeyVal;
}
if(!COL4)
&'(% '01'&%)23%$# %#!#/%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%4567;: %
!"#$%&'()##*+,-*./%
{
delay_msec(50);
if(!COL4)
KeyVal='D';
return KeyVal;
}
ROW3 = 1;
// Row4 Scan
ROW4 = 0;
if(!COL1)
{
delay_msec(50);
if(!COL1)
KeyVal='0';
return KeyVal;
}
if(!COL2)
{
delay_msec(50);
if(!COL2)
KeyVal='A';
return KeyVal;
}
if(!COL3)
{
delay_msec(50);
if(!COL3)
KeyVal='B';
return KeyVal;
}
if(!COL4)
{
delay_msec(50);
if(!COL4)
KeyVal='C';
return KeyVal;
}
ROW4 = 1;
}
}
/***************************************************************************
* PrintNum Function Definition
* Here, we will display the number on LCD and same number will be send to IR.
***************************************************************************/
void PrintNum(unsigned char printval)
{
&'(% '01'&%)23%$# %#!#/%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%4567;; %
!"#$%&'()##*+,-*./%
case '3':
LCD_Data('3');
delay_msec(50);
putchar('3');
break;
case '4':
LCD_Data('4');
delay_msec(50);
putchar('4');
break;
case '5':
LCD_Data('5');
delay_msec(50);
putchar('5');
break;
case '6':
LCD_Data('6');
delay_msec(50);
putchar('6');
break;
case '7':
LCD_Data('7');
delay_msec(50);
putchar('7');
break;
case '8':
LCD_Data('8');
&'(% '01'&%)23%$# %#!#/%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%4567;- %
!"#$%&'()##*+,-*./%
delay_msec(50);
putchar('8');
break;
case '9':
LCD_Data('9');
delay_msec(50);
putchar('9');
break;
case '0':
LCD_Data('0');
delay_msec(50);
putchar('0');
break;
case 'A':
LCD_Data('A');
delay_msec(50);
putchar('A');
break;
case 'B':
LCD_Data('B');
delay_msec(50);
putchar('B');
break;
case 'C':
LCD_Data('C');
delay_msec(50);
putchar('C');
break;
case 'D':
LCD_Data('D');
delay_msec(50);
putchar('D');
break;
case 'E':
LCD_Data('E');
delay_msec(50);
putchar('E');
break;
case 'F':
LCD_Data('F');
delay_msec(50);
putchar('F');
break;
&'(% '01'&%)23%$# %#!#/%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%4567;< %
!"#$%&'()##*+,-*./%
}
}
/**************************************************************************
* Decode code for pressed Key
**************************************************************************/
void DecodeKey()
{
switch(Serial_buf[0])
{
case '0'-'9':
Serial_buf[0] = Serial_buf[0]|0x30;
break;
case 'A'-'F':
Serial_buf[0] = Serial_buf[0]|0x40;
break;
default :
break;
}
}
/***************************************************************************
* ISR definition for UART
* Here, whatever data we are sending from IR same will be recieved here.
****************************************************************************/
static void ComISR(void) interrupt 4
{
ES = 0; /* disables intr4*/
if(RI) /* RI=Rcv intr flag*/
{
Serial_buf[0]= SBUF;
RI = 0;
}
ES = 1 ;
}
/***************************************************************************
* Main Function Definition
****************************************************************************/
void main(void)
{
LCD_Init(); /* Initialize LCD */
UART_Init(); /* Initialize UART */
P2 = 0x00; /* Clear Port 2 */
LCD_Command(0x01); /* Clear Display */
LCD_Command(0x84); /* Set LCD cursor at (1,4) */
LCD_WriteS(LCDArry[0]); /* Send String Data to LCD */
LCD_Command(0xC0); /* Set LCD cursor at (2,0) */
&'(% '01'&%)23%$# %#!#/%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%4567-> %
!"#$%&'()##*+,-*./%
P2 = 0x00;
Serial_buf[0] = '0';
KeyVal = 100;
EA = 1; /* Enable global Interrupt */
while(1)
{
KeyVal = Keypad(); /* Check if any key pressed */
PrintNum(KeyVal); /* Display and send data if any key pressed
*/
delay_msec(100);
LCD_Command(0xCD); /* Set LCD cursor at (2,13) */
DecodeKey(); /* Decode the pressed Key */
LCD_Data(Serial_buf[0]); /* Send String Data to LCD */
}
}
void LCD_Init()
{
LCD_Command(0x38); /* Function Set 8bit : 2 Line 5x7 Dots
*/
LCD_Command(0x0C); /* Display On curser Off
*/
LCD_Command(0x01); /* Clear Display
*/
LCD_Command(0x06); /* Entry Mode
*/
}
{
LCD_en=0;
LCD_en=1;
}
}
/*************** Write Srting to LCD ***************/
void LCD_WriteS(unsigned char *lcd_string)
{
while (*lcd_string)
{
LCD_Data(*lcd_string++); /* write data to LCD */
}
}
/*************** Write character to LCD ***************/
void LCD_Data(unsigned char ASCII)
{
LCD_Busy();
LCD_Port=ASCII; /* Write data to LCD in ascii value*/
LCD_rs=1;
LCD_rw=0;
LCD_en=1;
LCD_en=0;
}
PROCEDURE:
1. Connect 20 Pin FRC cable form one NV500X trainer (Transmitter) to CN1 of MC12 and other
NV500X trainer (Receiver) to CN2.
2. Connect one patch cord from any one of “1-8 pin” of CN1 (as mentioned in respective program) to
“Data In” and another patch cord from any one of “1-8 pin” of CN2 (as mentioned in respective
program) to “IR Rx”.
3. Connect both MC10 modules as per mentioned in program.
1. PIC is
Ans.RISC Processor and use Harvard Architecture.
2. PIC machine cycle consists of
Ans. 4 cycles.
3. Execute instruction in
Ans.0.2 µs.
4. interrupt sources are available in PIC16 series.
Ans.12
5. Register available in PIC microcontroller are
Ans.Status, Indirect, File select and Working register.
6. Compare Mode can
Ans. drive a pin H or L at a precisely controlled time.
7. Capture Mode permits
Ans.PIC to be used to determine the time of occurrence of an i/p edge.
8. movwf PORTA performs
Ans. move the working register into the file register named PORTA.
9. An imperative statement
Ans.indicates an action to be performed during execution of assembled program.
10. The “blocking factor” of a file is
Ans.the number of logical records in one physical record.