micro controller lab mannual-09

38
7.1.1 Title of the experiment: Arithmetic operations. 7.1.2 Aim or objectives of the experiment: To implement Addition, Subtraction, Multiplication & division of 8- bit signed & unsigned numbers. 7.1.3 List of equipment required to conduct the experiment with their specifications: SDA 51/31 kits, 5v power supply 7.1.4 Theoretical background for the experiment/validation of the experiment: Architecture & Instruction set of 8051. 7.1.5 Formula required, nature of graph, if any: Not applicable. 7.1.6 Step by step procedure to carry out the experiment: Algorithm 1) Addition, subtraction, Multiplication, Division - Enter any two signed & unsigned numbers. - Carry out Addition, Subtraction, Multiplication & division of signed & Unsigned 8-bit numbers using appropriate instructions. - Store & Display the result. Code is entered according to above algorithm. The assembly programs are compiled. Results are validated by providing required inputs. 7.1.7 Table of observations: 1. Addition Before execution After execution A = 10 h A=30 R0 = 20h 2.subtraction Before execution After execution A = 20 h A=10 R0 = 10h 3. multiplication Before execution After execution A = 10 h A=00 B = 20h B=02 4. division Before execution After execution 1

Upload: praveenkj04

Post on 18-Nov-2014

149 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Micro Controller Lab Mannual-09

7.1.1 Title of the experiment: Arithmetic operations.7.1.2 Aim or objectives of the experiment: To implement Addition, Subtraction,

Multiplication & division of 8-bit signed & unsigned numbers.7.1.3 List of equipment required to conduct the experiment with their

specifications: SDA 51/31 kits, 5v power supply7.1.4 Theoretical background for the experiment/validation of the experiment: Architecture & Instruction set of 8051.7.1.5 Formula required, nature of graph, if any: Not applicable.7.1.6 Step by step procedure to carry out the experiment:

Algorithm1) Addition, subtraction, Multiplication, Division- Enter any two signed & unsigned numbers.- Carry out Addition, Subtraction, Multiplication & division of signed & Unsigned 8-bit numbers using appropriate instructions.- Store & Display the result.

Code is entered according to above algorithm. The assembly programs are compiled. Results are validated by providing required inputs.

7.1.7 Table of observations: 1. AdditionBefore execution After executionA = 10 h A=30R0 = 20h2.subtractionBefore execution After executionA = 20 h A=10R0 = 10h3. multiplicationBefore execution After executionA = 10 h A=00B = 20h B=024. divisionBefore execution After executionA = 20 h A=02B = 10h B=00

7.1.8 Specimen calculations: Not applicable7.1.9 Plotting of the graph: Not applicable7.1.10 Discussion of result & conclusion: Student will learn arithmetic instructions involving signed & unsigned numbers. The student will learn how to handle the signed numbers.

1

Page 2: Micro Controller Lab Mannual-09

7.2.1 Title of the experiment: Finding square & cube of a number.7.2.2 Aim or objectives of the experiment:

Write an 8051 ALP to find the square & cube of a given number7.2.3 List of equipment required to conduct the experiment with their

specifications: SDA 51/31 kits, 5v power supply 7.24 Theoretical background for the experiment/validation of the experiment:

Architecture & Instruction set of 8051.7.2.4 Formula required, nature of graph, if any: Not applicable.7.2.5 Step by step procedure to carry out the experiment:

Algorithm1) Square of a number

- Enter a number- Copy a number in another register- Multiply a number with its copy

2) Cube of a number- Enter a number- Copy a number in another register- Multiply a number with its copy

Instruction code is entered according to above algorithm. The assembly programs are compiled & linked. Results are validated by providing required inputs.

7.2.6 Table of observation: 1. SquareBefore execution After executionA = 02 h A=04 2.CubeBefore execution After executionA = 02 h A=08

7.2.7 Specimen calculations: Not applicable7.2 .8 Plotting of the graph: Not applicable7.2.10 Discussion of result & conclusion: Student will learn arithmetic instructions

2

Page 3: Micro Controller Lab Mannual-09

7.3.1 Title of the experiment: Data transfer programs.7.3.2 Aim or objectives of the experiment: Write an 8051 ALP to transfer a block of data from source to destination.7.3.2 List of equipment required to conduct the experiment with their

specifications: SDA 51/31 kits, 5v power supply7.3.4 Theoretical background for the experiment/validation of the experiment: Architecture & Instruction set of 8051.7.3.5 Formula required, nature of graph, if any: Not applicable.7.3.6 Step by step procedure to carry out the experiment:

1) Block move Algorithm

- Enter array size & elements of array.- Transfer the array elements using loop structure- Store the exchanged array contents- Display both input & output array’s

Instruction code is entered according to above algorithm. The assembly program is compiled & executed. Input & output array’s are validated by providing required inputs.2) Block Exchange

Algorithm- Enter array size & elements of array.- Transfer the array elements using loop structure- Store the exchanged array contents- Display both input & output array’s

Instruction code is entered according to above algorithm. The assembly program is compiled & executed. Input & output array’s are validated by providing required inputs.

7.3.7 Table of observation: 1. Block moveGive the input block (eg 4 bytes) of data in one memory location 30h & transfer this block of data to memory location 40h

Before execution After executionInput memory output memory Input memory output memory30- 01 40-XX 30- 01 40-0131-02 41-XX 31-02 41-0232-03 42-XX 32-03 42-0333-04 43-XX 33-04 43-04

2. Block Exchange Give the input block (e.g 4 bytes) of data in one memory location 30h & exchange the data in the memory location with the content of the memory location 40h.

Before execution After executionInput memory output memory Input memory output memory30- 01 40-05 30- 05 40-01

3

Page 4: Micro Controller Lab Mannual-09

31-02 41-06 31-06 41-0232-03 42-07 32-07 42-0333-04 43-08 33-08 43-04

7.3.8 Specimen calculations: Not applicable7.3 .9 Plotting of the graph: Not applicable7.3 .10 Discussion of result & conclusion: Student will learn the instructions Regarding data transfer like exchange, move from memory to registers & vice versa.

4

Page 5: Micro Controller Lab Mannual-09

7.4.1 Title of the experiment: Counters7.4.2 Aim or objectives of the experiment:

Write an 8051 ALP for up/down counter ( HEX & BCD).7.4.3 List of equipment required to conduct the experiment with their

specifications: SDA 51/31 kits, 5v power supply 7.4.4 Theoretical background for the experiment/validation of the experiment: Architecture & Instruction set of 8051.7.4.5 Formula required, nature of graph, if any: Not applicable.7.4.6 Step by step procedure to carry out the experiment:

Algorithm- Take a starting count in a register.- Increment/decrement the count & display on the LCD using inbuilt

display routine with small delay between the counts.- For BCD counter after increment/decrement convert the data to BCD &

display. Instruction code is entered according to above algorithm. The assembly programs are compiled. Results are validated by providing required inputs

7.4.7 Table of observation:

1. Hex up counter 2. Hex down counter00 FF01 FE02 .... ....FF 00

3. BCD up counter 4. BCD down counter00 9901 9802 .... ....99 00

7.4.8 Specimen calculations: Not applicable7.4.9 Plotting of the graph: Not applicable7.4.10 Discussion of result & conclusion: Student will learn to use

INC ,DEC & Decimal adjust instructions.

5

Page 6: Micro Controller Lab Mannual-09

7.5.1 Title of the experiment: Array sorting.7.5.2 Aim or objectives of the experiment:

Write an 8051 ALP to find the largest/smallest of an array.Write an 8051 ALP to sort the array in ascending/descending order.

7.5.3 List of equipment required to conduct the experiment with their specifications: SDA 51/31 kits, 5v power supply

7.5.4 Theoretical background for the experiment/validation of the experiment: Architecture & Instruction set of 8051. 7.5.5 Formula required, nature of graph, if any: Not applicable.7.5.6 Step by step procedure to carry out the experiment:

Algorithm1. Largest & Smallest

- Use the algorithm as of sorting program to find the largest & smallest of an array

2. Algorithm to sort the array in the ascending/descending order.- Enter the array length and array elements.- Every number is compared with the next number if first number is

greater/smaller than second one, then exchange is made. Increment the exchange counter.

- If exchange counter is zero (No exchanges) then terminate the loop.- The step-2 is repeated up to (length of the array –1) times.- Display the sorted array.

Instruction code is entered according to above algorithm. The assembly programs are compiled. Results are validated by providing required inputs.

7.5.7 Table of observation: 1. Largest & Smallest

Before executionE100 - 08E101 - 02E102 - 04E103 - 03

Largest number = 08Smallest number = 022. Ascending / descending orderBefore execution After execution

08 0101 0202 0304 0403 08

7.5.8 Specimen calculations: Not applicable7.5.9 Plotting of the graph: Not applicable7.5.10 Discussion of result & conclusion: Student will learn different algorithm for sorting operation, which increases the utility of important instructions.

6

Page 7: Micro Controller Lab Mannual-09

7.6.1 Title of the experiment: Boolean & logical instructions.7.6.2 Aim or objectives of the experiment:

1. Write an 8051 ALP to implement the following Boolean function & verify the truth table.2. Write an 8051 ALP to convert binary to its gray equivalent & vice versa.

7.6.3 List of equipment required to conduct the experiment with their specifications: SDA 51/31 kits, 5v power supply

7.6.4 Theoretical background for the experiment/validation of the experiment: Architecture & Instruction set of 8051. 7.6.5 Formula required, nature of graph, if any: Not applicable.7.6.6 Step by step procedure to carry out the experiment:

Algorithm- Use bit addressable locations for the different literals present in the

Boolean equation.- Use appropriate bit level logical operations for implementation.

Binary to Gray- Enter 8-bit of data- Shift the data left by one position.- Perform XOR operation between original data & rotated data.- Shift the result right by one position to get the gray equivalent

Gray to Binary- Enter 8-bit gray number (data)- Shift the data left by one position.- Perform XOR operation between original data & rotated data.- Repeat the steps 2 & 3 seven times get the binary equivalent

Instruction code is entered according to above algorithm. The assembly programs are compiled. Results are validated by providing required inputs.

7.6.7 Table of observation: 1. Binary number = 02 Gray number = 032. Gray number = 03 Binary number = 02

7.6.8 Specimen calculations: Not applicable7.6.9 Plotting of the graph: Not applicable7.6.10 Discussion of result & conclusion: Student will learn different Bit level logical

operations.

7

Page 8: Micro Controller Lab Mannual-09

7.7.1 Title of the experiment: Code conversions7.7.2 Aim or objectives of the experiment: Carry out Code conversion (a) binary to

gray (b) ASCII to hex and vice versa.7.7.3 List of equipment required to conduct the experiment with their

specifications: SDA 51/31 kits, 5v power supply 7.7.4 Theoretical background for the experiment/validation of the experiment: Architecture & Instruction set of 8051.7.7.5 Formula required, nature of graph, if any: Not applicable.7.7.6 Step by step procedure to carry out the experiment:

Algorithm- Enter 8-bit of data- Convert the data according to the given code conversion method

ASCII to HEX- Subtract the given ASCII number by 30- If the number is less than 9 then the number is Hex equivalent of ASCII- If number is greater than 9 subtract 07 to get the result- Store and display both the values.

HEX to ASCII- Compare the number by 09, if carry is generated add 30 to it to get the

ASCII- If no carry from step-1 then add 7 first and again add 30 to get the result.- Store and display both the values.

HEX to Decimal- Enter the number.- Compare the number by 63h; if carry is not generated subtract 63H from

the number repeatedly till the carry is generated to get BCD3. - If carry is generated, compare the number by 0Ah; if carry is not

generated subtract 0Ah from the number repeatedly till the carry is generated BCD2.

- If carry is generated, store that number as the lower BCD1 digit. - Store and display the result on the LCD

Decimal to HEX- Enter the number.- Store number in one of the register.- Unpack the number in to two BCD numbers.- Shift higher BCD number four times right.- Multiply the above number by 0A- Add the lower BCD to the result to get the required HEX equivalent.- Store and display the result on the LCD..

Instruction code is entered according to above algorithm. The assembly programs are compiled. Results are validated by providing required inputs.

7.7.7 Table of observation:

1. HEX to ASCII conversion

Before execution After executionA =08 A=38

8

Page 9: Micro Controller Lab Mannual-09

2. ASCII to HEXBefore execution After executionA = 38 h A= 08

3. HEX to DecimalBefore execution After executionA = FFh A=255

4. Decimal to HEX conversionBefore execution After executionA = 72 h A=48

7.7.8 Specimen calculations: Not applicable7.7.9 Plotting of the graph: Not applicable7.7.10 Discussion of result & conclusion: Student will learn bit manipulations instructions & byte level logical instructions.

9

Page 10: Micro Controller Lab Mannual-09

7.8.1 Title of the experiment: Prime checking.7.8.2 Aim or objectives of the experiment: To check number is prime or not using

CALL & RET instructions7.8.3 List of equipment required to conduct the experiment with their

specifications: SDA 51/31 kits, 5v power supply 7.8.4 Theoretical background for the experiment/validation of the experiment: Architecture & Instruction set of 8051.7.8.5 Formula required, nature of graph, if any: Not applicable.7.8.6 Step by step procedure to carry out the experiment: Algorithm

Enter the size of an array & array elements Fetch the number from the array & call a prime function to check

whether a given number is prime or not.Algorithm to check number is prime or not.

- Initialize the count to 2- Divide the number by count.- If the reminder is zero number is not prime hence store 00 in the

successive memory locations and go to Step-1- If the reminder is not zero increment the count.- If the count value is less than half of the number then go to Step-2- Store the number as prime by storing FF in the successive memory

locations Instruction code is entered according to above algorithm. The assembly programs are compiled. Results are validated.

7.8.7 Table of observation: 1. Input array

Before execution After execution 08 A000 - 0002 A001 - 0004 A002 - 0003 A003 - FF

7.8.8 Specimen calculations: Not applicable7.8.9 Plotting of the graph: Not applicable 7.8.10 Discussion of result & conclusion: Student will learn to use ACALL & RET instructions, by calling subroutines.

10

Page 11: Micro Controller Lab Mannual-09

7.9.1 Title of the experiment: Generation of delay using instructions & timer & Serial communication

7.9.2 Aim or objectives of the experiment: a.) To generate a delay using instructions & timerb.) To perform serial communication

7.9.3 List of equipment required to conduct the experiment with their specifications: SDA 51/31 kits, 5v power supply

7.9.4 Theoretical background for the experiment/validation of the experiment: A serial port sends and receives data one bit at a time over one wire. While it takes

eight times as long to transfer each byte of data this way, only a few wires are required. In fact, two-way (full duplex) communications is possible with only three separate wires – TXD,RXD and GND wire. Once the start bit has been sent, the transmitter sends the actual data bits. Both receiver and the transmitter must agree on the number of data bits, as well as the baud rate. Almost all devices transmit data using either 7 or 8 data bits.RS-232 stands for Recommend Standard number 232 and C is the latest revision of the standard.

7.9.5 Formula required, nature of graph, if any: Not applicable.7.9.6 Step by step procedure to carry out the experiment:

Algorithm Generating a delay using instructions

- Initialize two counters with appropriate count to generate a delay.- Set the LED connected to port 1 or connect the port to CRO.- Decrement the counters till zero by keeping in a loop.- Reset the LED connected to port 1 or connects the port to CRO.

Generating a delay using Timer- Initialize the timer with appropriate count to generate a delay.- Set the LED connected to port 1.1 or connect the port to CRO.- Start the timer and monitor the timer overflow.- Reset the LED connected to port 1.1 or connects the port to CRO

Serial communication Connect the two microcontroller kits through RS232 cable.

Transmitter side - Configure the serial port using SCON and set the baud rate as

9600. Put the character to be transferred in SBUFF register. Receiver side

- Configure the serial port using SCON and set the baud rate as 9600.- Read the character from SBUFF register & display on LCD

Instruction code is entered according to above algorithm. The assembly programs are compiled.

7.9.7 Table of observation: Observe the square waveform on CRO with desired ON & OFF time.

7.9.8 Specimen calculations: Not applicableUse the following equation to calculate the count to be loaded in the count

RegistersTd = (No.of machine cycles x 12) / 11.0592 MHz

7.9.9 Plotting of the graph: Not applicable7.9.10 Discussion of result & conclusion: Student will learn to generate delay using instructions & timer.

11

Page 12: Micro Controller Lab Mannual-09

7.10.1 Title of the experiment: Interfacing DAC7.10.2 Aim or objectives of the experiment: Write a C program to interface DAC to

8051 Kit & generate the square, saw tooth, triangular & sine waves with variable frequency & amplitude.

7.10.3 List of equipment required to conduct the experiment with their specifications: PC’s, 8031 Microcontroller kit, DAC card & CRO.

7.10.4 Theoretical background for the experiment/validation of the experiment: Architecture & Instruction set of 8051.8255 is a programmable peripheral

interface acts as link between processor and I/O devices. Port-A, port-B can be configured as handshake I/O ports using port-c for control signals. Port-A can be configured as Bi-directional.

The dual DAC interface consists of two Digital-to-Analog converters (DAC-0800). The outputs are converted to voltage using op-amps (MC 1458). The voltage outputs are terminated in a 4-way reliamate connector for external connections. Stable reference voltage for the DAC’s is obtained using a LM 723 regulator. Unipolar or bipolar outputs are selected by either shorting J1 or J3 to J2 and J4 respectively or by isolating the jumpers. The inputs of the DAC are connected to port-A and Port-B. The output from port-A is connected to X-out and port-B is connected to Y-out. The purpose of a digital to analog converter is to convert a binary word to its equivalent analog voltage or current. Interfacing an 8-bit D/A with a microcontroller involves connecting the inputs of the converter to an output port. Using DAC one can produce desired analog voltage (0 to Vref) by out putting equivalent digital word to port-A or port-B.

7.10.5 Formula required, nature of graph, if any: Not applicable.7.10.6 Step by step procedure to carry out the experiment:

Figure-1

Interface the DAC card to the 8051 kit as in figure-1. Connect the power supply connections to DAC and kit as per the

specification. Connect the CRO to the Port A to observe the waveforms. Algorithm

- Initialize the control word register of 8255 with port-A as out port.Square wave- Output ‘FF’ and ‘00’ to port-A with the required amount of delay in

between to generate the square wave.- To generate the rectangular waveform vary the on delay & off delay.Saw tooth wave

12

Page 13: Micro Controller Lab Mannual-09

- Initialize a counter to 00 and increment the counter till it reaches the maximum(FF) value. Out each count of the counter on port A to display a appropriate analog value on the CRO to generate the rising part of the waveform.

- Make counter 00 & repeat the steps to generate the waveform.Triangular wave- Initialize a counter to 00 and increment the counter till it reaches the

maximum value. Out each count of the counter on port a to display a appropriate analog value on the CRO to generate the rising part of the waveform.

- Once it reaches maximum value (FF) decrement the counter and out each value of the counter on CRO to display falling part of the waveform.

Sine wave- Use a equation x = 7F+ 7FsinӨ- For different values of Ө ( in steps of 5 or 10 degrees) calculate the

corresponding value of x.- Store all the values of x in the lookup table.- Read the values from the look up table one by one & out on to the CRO .

Instruction code is entered according to above algorithm. The generated rectangular and square waveforms are observed on the CRO.

7.10.7 Table of observation: Not applicable7.10.8 Specimen calculations: Not applicable7.10.9 Plotting of the graph:

Figure 27.10.10 Discussion of result & conclusion:Student will learn the

Interfacing and application of DAC for waveform generation

13

Page 14: Micro Controller Lab Mannual-09

7.11.1 Title of the experiment: ADC interface.7.11.2 Aim or objectives of the experiment: Interface analog to digital converter and

display the digital equivalent of unknown analog signal. 7.11.3 List of equipment required to conduct the experiment with their specifications: PC’s, 8031 Microcontroller kit and ALS ADC card using DAC.7.11.4 Theoretical background for the experiment/validation of the experiment: Architecture of 8031/51, Instruction set of 8031/51 and Hardware details of ADC The function of an A/D converter is to produce a digital word, which

represents the equivalent magnitude of the unknown analog signal (voltage or current). The DAC is used to convert digital to analog signal. The converted analog signal is compared with unknown analog signal. The comparator sets end of conversion if both are equal. If the end of conversion is active low then data at the input of the DAC represents the digital equivalent of conversion is connected to PCI and end of conversion is connected to PC0 of 8255.

Note: Hardware details of ADC are enclosed.7.11.5 Formula required, nature of graph, if any: Not applicable.7.11.6 Step by step procedure to carry out the experiment:

Figure-3

Interface the ADC card to the 8051 kit through flat cable as in figure-5. Connect the power supply connections to ADC and kit. Give the analog input to the one channel of the ADC Algorithm

- Initialize the control word register of 8255 with port-A as input port to read the digital equivalent & port-C as output port to send the control signals.

- Generate the start of conversion signal on PC7.- Disable the internal latch by sending the low signal on PC6.- Keep monitoring the end of conversion (EOC) signal on PA7 generated

by ADC.- If end of conversion (EOC) signal is high, then enable the internal latch

by sending the high signal on PC6.- Read the converted data from Port A and display on the LCD display of

kit. Instruction code is entered according to above algorithm. Observe the analog equivalent of digital output on the display for different

analog inputs.

14

Page 15: Micro Controller Lab Mannual-09

7.11.7 Table of observation: Analog i/p

voltageDigital equivalent

of analog i/p voltage

1V 332V 663V 994V CC5V FF

7.11.8 Specimen calculations: Not applicable7.11.9 Plotting of the graph: Not applicable7.11.10Discussion of result & conclusion: Student will learn to interface ADC to 8051

kit for converting an analog signal to its digital equivalent.

15

Page 16: Micro Controller Lab Mannual-09

7.12.1 Title of the experiment: Simple Calculator7.12.2 Aim or objectives of the experiment: To write a C program to interface 4 digit

seven segment displays & hex keyboard to 8051 kit to operate as simple calculator

7.12.3 List of equipment required to conduct the experiment with their specifications: PC’s, 8031 Microcontroller kit and keypad & display interface card.

7.12.4 Theoretical background for the experiment/validation of the experiment: Architecture & Instruction set of 8086. Hardware design details of Display card And keypad details are enclosed. Many Microprocessor & Micro controller based instruments and machines

need display letters of the alphabet and numbers to give directions or data values to the users. For displaying only numbers and hex decimal letters, simple seven segment displays are used. For a common anode 7-segment display, a low is applied to a segment to turn it on. When a BCD code sent to the inputs of the 7447, it outputs low on the segments required to display the number represented by BCD code.

7.12.5 Formula required, nature of graph, if any: Not applicable.7.12.6 Step by step procedure to carry out the experiment:

Figure-4

a

f b

ge c

d h

Figure-5

16

Page 17: Micro Controller Lab Mannual-09

Interface the Keypad & display card to the 8051 kit with a flat cable as shown in figure-4

Give the power supply connections to the Display & keypad card. Algorithm

- Initialize the control word register of 8255 with port-B, port-c as out port and port A as input port.

- Read the data 1 from the keypad & display on the display.- Read the data 2 from the keypad & display on the display.- Read the operation to be performed on the data.- Perform the operation on data 1 & data2 & display the result on display.Algorithm to display on 7 segment LED- The required 7-segment code corresponding to the display format is

generated according to figure-5- Store the codes of all BCD digits in the memory. Configure port B and

port C as output port - Fetch 7-segment code for the data 1 & display bit-wise through PB0.- Generate clock pulse for each bit to shift the bit right.- Repeat the above steps for data 2 & result.

Instruction code is entered according to above algorithm. The assembly programs are compiled & linked. Observe the display of required digits at the display card.

7.12.7 Table of observation: 7.12.8 Specimen calculations: Not applicable7.12.9 Plotting of the graph: Not applicable7.12.10Discussion of result & conclusion: Student will learn to

interface keypad & display card to 8051 to operate it as a simple calculator.

17

Page 18: Micro Controller Lab Mannual-09

7.13.1 Title of the experiment: LCD & Keypad interface7.13.2 Aim or objectives of the experiment: Write a C program to interface

Alphanumeric LCD panel & hex keyboard to 8051 kit.7.13.3 List of equipment required to conduct the experiment with their

specifications: PC’s, 8031 Microcontroller kit, LCD display and keypad interface card

7.13.4 Theoretical background for the experiment/validation of the experiment: Architecture & Instruction set of 8086. Hardware design details of Display card And keypad details are enclosed. Many Microprocessor & Micro controller based instruments and machines

need display letters of the alphabet and numbers to give directions or data values to the users. For displaying only numbers and hex decimal letters, simple seven segment displays are used. For a common anode 7-segment display, a low is applied to a segment to turn it on. When a BCD code sent to the inputs of the 7447, it outputs low on the segments required to display the number represented by BCD code.

7.13.5 Formula required, nature of graph, if any: Not applicable.7.13.6 Step by step procedure to carry out the experiment:

Figure-6

Interface the Keypad & LCD display card to the 8051 kit with a flat cable. Give the power supply connections to the LCD Display & keypad card. Algorithm

- Initialize the control word register of 8255 with port-B, port-c as out port and port A as input port.

- Read the data from the keypad.- Call a LCD display subroutine to display the characters on the LCD.- Check the display out put.

Instruction code is entered according to above algorithm. The assembly programs are compiled & linked.

18

Page 19: Micro Controller Lab Mannual-09

Observe the display of required digits at the display card.7.13.7 Table of observation: Not applicable7.13.8 Specimen calculations: Not applicable7.13.9 Plotting of the graph: Not applicable7.13.10Discussion of result & conclusion: Student will learn to interface keypad & LCD display to 8051.

19

Page 20: Micro Controller Lab Mannual-09

7.14.1 Title of the experiment: Speed control of stepper motor.7.14.2 Aim or objectives of the experiment: To write a C program to interface stepper

motor to 8051 kit.7.14.3 List of equipment required to conduct the experiment with their specifications: PC’s, 8031 Microcontroller kit , stepper motor with driver circuit. 7.14.4 Theoretical background for the experiment: Architecture of 8031, Instruction

set of 8031. Stepper or step motors (SM) have been developed since 1930’s but their expansion began in 1960’s with the advent of digital electronics. The main reason is that Stepper Motors are themselves digital electro-mechanical devices, easy to interface with digital electronics. The microcontrollers have greatly aided the increase in Stepper Motors use, as many computer peripherals contain one or more Stepper Motors.

The main advantages are, Directly compatible with digital control techniques. Open loop control is fairly good with no accumulative positional error or drift. Mechanically simple and rugged with least maintenance.

The required sequences are generated and given to the driver circuit of SM7.14.5 Step by step procedure to carry out the experiment:

8031 8255 Driver SMcard

Figure-7 Interface the stepper Motor interface card to 8051 kit through flat cable as

shown in figure 7. Select the clockwise or anti clockwise directions for stepper motor rotation. Algorithm

- Initialize the control word register of 8255 to configure port C as output port.

- Store the required sequence depending on the angle and direction of rotation in the memory.

- Send the data from memory to port C of 8255. Instruction code is entered according to above algorithm. The direction and step size of SM is observed.

7.14.6 Table of observation: Sequence for clockwise rotation Sequence for clockwise rotation A B C D A B C D0 0 0 1 1 0 0 0 1

0 0 1 0 0 1 0 00 1 0 0 0 0 1 01 0 0 0 0 0 0 1

7.14.7 Specimen calculations: Not applicable7.14.9 Plotting of the graph: Not applicable

20

Page 21: Micro Controller Lab Mannual-09

7.14.10. Discussion of result & conclusion: Student will learn how to control the speed and direction of the stepper motor and also to rotate the stepper motor by a particular angle..

21

Page 22: Micro Controller Lab Mannual-09

7.15.1 Title of the experiment: Elevator Interface7.15.2 Aim or objectives of the experiment: To write a C program to interface an

Elevator to 8051 kit7.15.3 List of equipment required to conduct the experiment with their specifications: PC’s, 8031 Microcontroller kit and ALS ADC card using DAC.7.15.4 Theoretical background for the experiment/validation of the experiment: Architecture of 8031/51, Instruction set of 8031/51 and Hardware details of ADC

An elevator or lift is a transport device used to move goods or people vertically. Because of wheelchair access laws, elevators are often a legal requirement in new buildings with multiple floors. Hydraulic elevators use the principles of hydraulics to pressurize an above ground or in-ground piston to raise and lower the car. Roped Hydraulics use a combination of both ropes and hydraulic power to raise and lower cars. Recent innovations include permanent earth magnet motors, machine room-less rail mounted gearless machines, and microprocessor controls.

7.15.5 Formula required, nature of graph, if any: Not applicable.7.15.6 Step by step procedure to carry out the experiment:

Figure-8

Interface the Elevator card to 8051 kit through flat cable as in figure-8. Connect the power supply connections to Elevator card and kit. Algorithm

- Initialize the control word register of 8255 with port-A as input port & port B as output port.

- read the floor count from port a & out on port B to indicate rise of the lift on LED’s.

7.15.7 Table of observation: Not applicable7.15.8 Specimen calculations: Not applicable7.15.9 Plotting of the graph: Not applicable7.15.10 Discussion of result & conclusion: Student will learn to interface keypad & display card to 8051 to operate it as an elevator.

22

Page 23: Micro Controller Lab Mannual-09

7.16.1 Title of the experiment: Temperature control7.16.2 Aim or objectives of the experiment: To write a C program to control the

temperature using ADC & temperature sensor.7.16.3 List of equipment required to conduct the experiment with their specifications: PC’s, 8031 Microcontroller kit and ALS ADC card using DAC.7.16.4 Theoretical background for the experiment/validation of the experiment: Architecture of 8031/51, Instruction set of 8031/51 and Hardware details of ADC

Temperature measurement is of great importance in industry as most of the processes are temperature dependent. A number of devices & schemes have been used over the years, for the measurement of the temperature. Typical sensors include devices like thermocouples, thermostats, RTD’s & semiconductor sensors. This interface uses semiconductor sensor AD590 to monitor the temperature of the water bath. The AD590 is Basically PTAT (Proportional to Absolute Temperature) current regulator. It generates a current output of 1uA above absolute zero temperature that is -273 o C. Thus at 0 oC the current output will be 272 uA & at 25 oC it will be 298uA. And at 100 oC it will be 373uA. This current flows through a 1K resistor there by producing 273 mV at 0 oC., 298 mV at 25o oC & 373 mV at 100 oC. This interface consists of two parts – ADC & temperature controlling.

7.16.5 Formula required, nature of graph, if any: Not applicable.7.16.6 Step by step procedure to carry out the experiment:

Figure-9

Interface the ADC & temperature control kit to 8051 kit through flat cable as in figure-9.

Connect the power supply connections to Elevator card and kit. Algorithm

- Get temperature value from the memory location F000.- Configure the ports according to the specifications.- Select the channel 0 to give the sensor output.- Start the ADC by sending the start of conversion pulse.- Keep monitoring the EOC signal- After EOC read the data from the ADC.- Get temperature values corresponding to the ADC output from the

lookup table in to R5- Convert temperature value in to BCD- Display the temperature value in to the data field.- Compare the current temperature with the set of temperature.

23

Page 24: Micro Controller Lab Mannual-09

- Until the current temperature = set temperature relay will be on.- Once it exceeds relay will be turned off.

Instruction code is entered according to above algorithm. Observe the analog equivalent of digital output on the display for different

analog inputs.7.16.7 Table of observation: Not applicable7.16.8 Specimen calculations: Not applicable7.16.9 Plotting of the graph: Not applicable7.16.10 Discussion of result & conclusion: Student will learn to interface temperature sensor to 8051, to monitor & control the same.

24

Page 25: Micro Controller Lab Mannual-09

7.17.1 Title of the experiment: Stepper motor control using hyper terminal7.17.2 Aim or objectives of the experiment: Write a C program to control the stepper

motor using serial port (using hyper terminal) R key on terminal controls run command, C clockwise , A anticlockwise

S stops the motor.

7.17.3 List of equipment required to conduct the experiment with their specifications: PC’s, 8031 Microcontroller kit, ALS ADC card using DAC.7.17.4 Theoretical background for the experiment/validation of the experiment:

Stepper or step motors (SM) have been developed since 1930’s but their expansion began in 1960’s with the advent of digital electronics. The main reason is that Stepper Motors are themselves digital electro-mechanical devices, easy to interface with digital electronics. The microcontrollers have greatly aided the increase in Stepper Motors use, as many computer peripherals contain one or more Stepper Motors.

The main advantages are, Directly compatible with digital control techniques. Open loop control is fairly good with no accumulative positional error or drift. Mechanically simple and rugged with least maintenance.

The required sequences are generated and given to the driver circuit of SM

7.17.5 Formula required, nature of graph, if any: Not applicable.7.17.6 Step by step procedure to carry out the experiment:

Figure-10

Interface the stepper Motor interface card to 8051 kit through flat cable as shown in figure 10.

Select the clockwise or anti clockwise directions for stepper motor rotation. Algorithm

- Initialize the control word register of 8255 to configure port C as output port.

- Store the required sequence depending on the angle and direction of rotation in the memory.

- Send the data from memory to port C of 8255. Instruction code is entered according to above algorithm. The direction and step size of SM is observed.

7.17.7 Table of observation: Not applicable7.16.8 Specimen calculations: Not applicable7.16.9 Plotting of the graph: Not applicable7.16.10 Discussion of result & conclusion: Student will learn the interfacing of temperature sensor & controlling.

25

Page 26: Micro Controller Lab Mannual-09

Appendixa. Course details i. Subject Code : 06ES42

ii. Ttle of the laboratory : Micro controller iii. Teaching scheme : Three hours lab/week. iv. Examination scheme : Exam marks-100, IA Marks –25

b. Conversionsc. Conventionsd. Standard Datae. Reference

" The 8051 Microcontroller Architecture, Programming & Applications "

by ' Kenneth J. Ayala’, Penram International, 1996

" The 8051 Microcontroller and Embedded systems ", by ' Muhammad

Ali Mazidi and Janice Gillispie Mazidi’, Pearson Education, 2003

Note: In case of laboratories like Computer programming, Machine drawing, etc any steps mentioned above can be omitted if found irrelevant and additional steps may be added.

END

26