Sie sind auf Seite 1von 41

COURSE LABORATORY MANUAL

A. LABORATORY OVERVIEW
Degree: BE Programme: CSE
Semester: 4 Academic Year: 2016-17
Microprocessors and
Laboratory Title: Laboratory Code: 15CSL48
Microcontroller Laboratory
L-T-P-S: 1-0-2-0 Duration of USE: 3 Hrs
Total Contact Hours: 42 Hrs USE Marks: 80
Credits: 2 IA Marks: 20

B. DESCRIPTION
1. PREREQUISITES:
• Microprocessors And ARM Processors(15CS44)
• Basic Electronics (15ELN15)
• Analog and Digital Electronics(15CS32)
• Computer programming laboratory (15CPL16)
• Programming in C and Data Structures (15PCDS13).

2. BASE COURSE:
• Microprocessors and Microcontrollers (15CS44)

3. COURSE OUTCOMES:
At the end of the course, the student will be able to;
1. Apply the programming techniques in designing simple assembly language programs for
solving simple problems by using instruction set of 8086 microprocessor / ARM.
2. Gain hands-on experience in doing experiments on 8086 microprocessor / ARM by using
assembler tool (TASM / MASM) in the laboratory and present the report.
3. Understand the hardware, software tradeoffs involved in the design and interface hardware
devices to x86/ARM family.
4. Assess processors for various kinds of applications.

4. RESOURSES REQUIRED:
• Intel microprocessor based computer with 256MB RAM and 40GB secondary storage
• TASM / MASM assembler
• Interfacing Kits
• 8255 PPI card with FRC connector
• 12V power supply.
COURSE LABORATORY MANUAL
5. RELEVANCE OF THE COURSE:
• Operating Systems (10CS53)
• System Software (10CS52)
• Computer Networks (10CS55)
• Advanced Computer Architecture (10CS74).
6. GENERAL INSTRUCTIONS:
Start Run… cmd
TASM COMMANDS:
C:\ tasm > edit filename.asm ; Write the program and save.
C:\ tasm > tasm filename.asm ; If any errors, correct the same.
C:\ tasm > tlink filename.obj
C:\ tasm > debug filename.exe ; debugger command prompt
C:\ tasm > afdebug filename.exe ; afdebug command prompt
C:\ tasm > iopm filename.exe portnumber ; For Interfacing kits
After the debugger command prompt the
following commands are used; a – assemble
d – dump (to view the contents of
the data memory) g – go (to
execute the entire program at a
time)

u – unassemble
t – trace (to execute the
program in single step) r –
register (to see the
contents of the register) q
– quit
? – to view all the options
After the afdebug command prompt the following commands are
used;
F1 – for single step
execution of the program G
– for the execution of entire
program at a time Quit – to
exit from the afdebug screen
Alt+Enter – to
maximize/minimize the
screen.
8086 PRACTICE PROGRAMS:
8086 assembly language program to add two numbers –
Illustration of MOV/ADD/ADC instructions.
.MODEL SMALL
.STACK 100
.DATA
ALP to add two numbers which are read from the keyboard.
.model small
.data
msg1 db 13,10,'Enter the first number (digit) from the keyboard:$' msg2
db 13,10,'Enter the second number (digit) from the keyboard:$' msg3 db
13,10,13,10,'The sum of the two entered numbers (digits) is:$'

num1 db ?
num2 db ?
sum db ?
.code
start: mov ax,@data
mov ds,ax ; Initializes the DS.
mov dx, offset msg1 ; Displays the message1.
mov ah, 09h
int 21h
mov ah, 01h ; Allows the user to enter
int 21h ; a key from the keyboard.
sub al,30h ; To get the number in decimal.
mov num1, al
mov dx, offset msg2 ; Displays the message2.
mov ah, 09h
int 21h
mov ah, 01h ; Allows the user to enter
int 21h ; a key from the keyboard.
sub al,30h ; To get the number in decimal.
mov num2, al

mov al, num1 Get the first number in


AL.
add al, num2
Add the second number
mov sum, al to AL.

Save the result of


addition.
mov dx, offset msg3 ; Displays the message3.
mov ah,09h
int 21h
mov al, sum ; To display the sum.
mov ah, 00h ; Clear AH.
Aam ; Convert to BCD.
add ax, 3030H ; Convert to ASCII.
mov bx, ax ; Save the result.
mov dl, bh ; Load MSD.
mov ah, 02h ; To display first digit (MSD).
int 21h
mov dl, bl ; Load LSD.
mov ah, 02h ; To display second digit (LSD).
int 21h
mov ah,4ch ; Terminates the program.
int 21h
end start
Try these:
1. Write an 8086 ALP to subtract two numbers.
2. Write an 8086 ALP to add two
i. 8bit numbers, and
ii. 16 bit numbers.

7. CONTENTS:
Expt Blooms
Title of the Experiments CO
No. Level
CO1,2,3,
1 Design and develop an assembly language program to search a key element “X” in a L3 4
list of ‘n’ 16-bit numbers. Adopt Binary search algorithm in your program
for searching.
CO1,2,3,
2 Design and develop an assembly program to sort a given set of ‘n’ 16-bit L3 4
numbers in ascending order. Adopt Bubble Sort algorithm to sort given
elements.
CO1,2,3,
3 Develop an assembly language program to reverse a given string and L3 4
verify whether it is a palindrome or not. Display the appropriate message.
CO1,2,3,
4 Develop an assembly language program to compute nCr using recursive L3 4
procedure. Assume that ‘n’ and ‘r’ are non-negative integers.
CO1,2,3,
5 Design and develop an assembly language program to read the current time and L3 4
Date from the system and display it in the standard format on the screen.
6 To write and simulate ARM assembly language programs for data L3 CO1,2,3,4
transfer, arithmetic and logical operations.
7 To write and simulate C Programs for ARM microprocessor in KEIL L3 CO1,2,3,4
8 a. Design and develop an assembly program to demonstrate BCD Up-Down L4 CO1,2,3,4
Counter on the Logic Controller Interface.
b. Design and develop an assembly program to read the status of two 8-bit
inputs (X & Y) from the Logic Controller Interface and display X*Y.
9 Design and develop an assembly program to display messages “FIRE” and L3 CO1,2,3,4
“HELP” alternately with flickering effects on a 7-segment display
interface for a suitable period of time. Ensure a flashing rate that makes it
easy to read both the messages (Examiner does not specify these delay
values nor is it necessary for the student to compute these values).
10 Design and develop an assembly program to drive a Stepper Motor L4 CO1,2,3,4
interface and rotate the motor in specified direction (clockwise or counter-
clockwise) by N steps (Direction and N are specified by the examiner).
Introduce suitable delay between successive steps. (Any arbitrary value
for the delay may be assumed by the student).
11 Design and develop an assembly language program to L4 CO1,2,3,4
a. Generate the Sine Wave using DAC interface (The output of the DAC
is to be displayed on the CRO).
b. Generate a Half Rectified Sine waveform using the DAC interface.
(The output of the DAC is to be displayed on the CRO).
12 To interface LCD with ARM microprocessor. Write and execute L3 CO1,2,3,4
programs in C language for displaying text messages and numbers on
LCD.
13 To interface Stepper motor with ARM microprocessor. Write a program L3 CO1,2,3,4
to rotate motor in half step and full step mode.
14 Open ended experiment – 1 L4 -
Interfacing of temperature sensor with ARM freedom board (or any other
ARM microprocessor board) and display temperature on LCD
15 Open ended experiment – 2 L4 -
To design ARM cortex based automatic number plate recognition system
16 Open ended experiment – 3 L4 -
To design ARM based power saving system

8. REFERENCE:
1. Muhammad Ali Mazidi, Janice GillispieMazidi, Danny Causey, The
x86 PC Assembly Language Design and Interfacing, 5th Edition,
Pearson, 2013.
2. ARM System-on-Chip Architecture, Steve Furber, Second Edition,
Pearson, 2015.
3. ARM System Developer’s Guide, Designing and Optimizing
Software, Andrew N. Sloss,Dominic Symes, Chris W wight,
Elsevier, 2014.

-
C. EVALUATION SCHEME
For 2015, scheme (Module): Below a model scheme is presented. Faculty
may define their own scheme and write.
1. Record writing: 4 Marks
(Each experiment will be evaluated for 5 marks and average of
all the experiments will be taken)

COURSE LABORATORY MANUAL


2. Laboratory Activities: 4 Marks
(Based on the involvement of the student in the regular
laboratory sessions)
3. Laboratory IA tests: 2 (Writeup) + 8 (Conduction) + 2 (Viva) = 12
Marks
(IA tests shall follow in the succeeding week of theory IA.
Minimum 2 IAs are mandatory. For the final IA test marks,
average of the best of 2 IA test marks obtained shall be
considered and converted to maximum of 12)
4. Overall Lab Internal Assessment (IA Marks) = 8 (Record) + 2
(Writeup) + 8 (Conduction) + 2 (Viva) = 20 Marks
5. USE: 80 Marks.
-
D1. ARTICULATION MATRIX
Mapping of CO to PO
POs
COs 1 2 3 4 5 6 7 8 9 10 11 12
1. Apply the programming techniques in
designing simple assembly language
programs for solving simple problems by 2 2 - 2 2 - 1 1 2 1 - 1
using instruction set of 8086
microprocessor/ ARM.
2. Gain hands-on experience in doing
experiments on 8086 microprocessor/
ARM by using assembler tool 2 2 - 2 2 - 1 1 2 1 - 1
(TASM/MASM) in the laboratory and
present the report.
3. Understand the hardware, software
tradeoffs involved in the design and 2 2 - 2 2 - 1 1 2 1 - 1
interface hardware devices to x86/ARM
family.
4 Assess processors for various kinds of 3 3 3 3 2 1 1 1 2 2 2 2
applications.
Note: Mappings in the Tables D1 (above) and D2 (below) are done by entering in the corresponding cell the
Correllation Levels in terms of numbers. For Slight (Low): 1, Moderate (Medium): 2, Substantial (High): 3 and for no
correllation: “ - ”.
D2. ARTICULATION MATRIX CO v/s PSO
Mapping of CO to PSO
PSOs
COs 1 2 3
1. Apply the programming techniques in designing simple assembly
language programs for solving simple problems by using instruction 1 2 2
set of 8086 microprocessor/ ARM.
2. Gain hands-on experience in doing experiments on 8086
microprocessor/ ARM by using assembler tool (TASM/MASM) in 1 2 2
the laboratory and present the report.
3. Understand the hardware, software tradeoffs involved in the
1 2 2
design and interface hardware devices to x86/ARM family.
4 Assess processors for various kinds of applications. 2 2 2

n
E. EXPERIMENTS

1. EXPERIMENT NO:1
2. TITLE: BINARY SEARCH
3. LEARNING OBJECTIVES:
• To learn the implementation of binary search algorithm using
assembly language instructions.
4. AIM:
• To design and implement binary search algorithm using assembly
language instructions.
5. MATERIAL / EQUIPMENT REQUIRED:
• Intel CPU based computer
• MASM/TASM Assembler.
6. THEORY / HYPOTHESIS:
• A] Binary search is a well-known method for searching for an item
in a sorted array. In the beginning the search range is the whole
array. Then the search key is compared with the middle element of
the range. If they are equal, the wanted item has been found. If the
key is smaller, the same procedure is applied recursively to the left
half of the search range, otherwise to the right half as follows-

• If the key is found in the list, it is stored in a memory location, called


loc. The index of the key is stored in the next memory location. If
the key is not found the memory location reserved is empty.

7. PROGRAMME:
.MODEL SMALL
.DATA
ARR DW 0111H, 0112H,
0113H, 0114H, 0115H LEN
DW ($-ARR)/2
KEY EQU 0112H
MSG1 DB "KEY IS
FOUND AT POSITION: "
POS DB ? ,13,10,"$"
MSG2 DB 'KEY NOT FOUND!!!!!!!!!!!!!. $'

.CODE
START: MOV AX, @DATA
n

MOV DX, LEN ; LEN = 05.


MOV CX, KEY

AGAIN: CMP BX, DX


JA NOTFOUND
MOV AX, BX
ADD AX, DX ; Lenght of ARR is stored in AX.
SHR AX, 1 ; Logical right shift, AX = AX / 2.
MOV SI, AX ; Length of ARR is divided by 2,
ADD SI, SI ; doubled, and the number at that position is
CMP CX, ARR[SI] ; compared with KEY.
JNC BIG
DEC AX ; If the KEY is smaller than the number compared.
MOV DX, AX
JMP AGAIN

BIG: JE FOUND
INC AX ; If the KEY is greater than the number compared.
MOV BX, AX
JMP AGAIN

FOUND: ADD AL, 01


ADD AL, '0' ; Add 30 before displaying.
MOV POS, AL
LEA DX, MSG1 ; KEY found.
JMP DISP

NOTFOUND:LEA DX, MSG2 ; KEY not found.

DISP: MOV AH, 09H ; DOS interrupt to display message.


INT 21H
MOV AH, 4CH ; Terminate.
INT 21H
END START

8. BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION:NA


9. OBSERVATION TABLE / LOOKUP TABLE / TRUTH TABLE:

10. FORMULA / CALCULATIONS: NA

11. GRAPHS / OUTPUTS:

KEY IS FOUND AT POSITION:______

KEY NOT FOUND!!!!!!!!!!!!!.

n
12. RESULTS & CONCLUSIONS:
• -
• -
• -
13. LEARNING OUTCOMES:
• The binary search technique can be implemented in assembly language to search a
key element efficiently.
14. APPLICATION AREAS:
• Database applications
• To search a file in specified directory
15. REMARKS:
• -
• -
• -
-
1. EXPERIMENT NO: 2
2. TITLE: BUBBLE SORT
3. LEARNING OBJECTIVES:
• To learn the implementation of Bubble sort in assembly level language
4. AIM:
• To sort a given set of ‘n’ numbers in ascending and descending orders using
the Bubble Sort algorithm
5. MATERIAL / EQUIPMENT REQUIRED:
• Intel CPU based computer
• MASM/TASM Assembler.
6. THEORY / HYPOTHESIS:
• This program sorts a given unsorted list of numbers, using the Bubble Sort algorithm. The
unsorted list is initially stored in a series of memory locations called arr. After the program
execution, the same arr contains the sorted list. The sorting in ascending or descending
order is selected by the user during run-time. The algorithm of bubble sort is as follows-

nc bubblesort( var a as array


) for i from 1 to N
for j from 0 to N - 1
if a[j] > a[j + 1]
swap( a[j], a[j + 1] )
end func

PROGRAMME:
.MODEL SMALL
.DATA
NUMS DW
0FFFFh,0AAAAh,5555h,6666h,4444h,1111h,0cccch,3
333h LEN EQU ($-NUMS)/2

.CODE
START: MOV AX , @DATA ; Initialize the Data Segment.
MOV DS, AX
MOV CL, LEN-1 ; Number of passes.
NXTPAS: MOV CH, CL ; Number of comparisions.
LEA SI,NUMS

NXTCMP: MOV AX, [SI]


CMP AX, [SI+2]
JC NOXCHG ; For descending order use JNC noxchg.
XCHG AX, [SI+2]
MOV [SI], AX

NOXCHG: INC SI ; To point next element in the array.


INC SI
DEC CH
JNZ NXTCMP

DEC CL ; Counter for the next pass.


JNZ NXTPAS

INT 3
END START

8. BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION:NA


9. Observation Table / Lookup Table / Truth Table:NA
10. FORMULA / CALCULATIONS:NA
11. GRAPHS / OUTPUTS:
The given unsorted array is:
0FFFFh,0AAAAh,5555h,6666h,4444h,1111h,0cccch,3333h Obtained
sorted array is:

12. RESULTS & CONCLUSIONS:

13. LEARNING OUTCOMES :


• The Bubble Sort technique can be implemented in assembly
language to sort a given array efficiently

14. APPLICATION AREAS:


• Data base applications.
• Routing table updater.-
15. REMARKS:
• -
• -
• -

-
1. EXPERIMENT NO:3
2. TITLE: PALINDROME
3. LEARNING OBJECTIVES:
• To learn the implementation of checking string palindrome condition in
assembly language
4. AIM:
• To reverse a given string and check whether it is a palindrome.
5. MATERIAL / EQUIPMENT REQUIRED:
• Intel CPU based computer
• MASM/TASM Assembler.
6. THEORY / HYPOTHESIS:
• PALINDROME CHECK: This program waits till it receives a string of
characters from the standard input device(keyboard),terminated by the
carriage return, and stores the string in an array called str. The
reversed string is stored in another array called rev_str. The two
strings are compared character wise; for checking whether the original
string is palindrome. Necessary messages are displayed using DOS
function calls.

7. PROCEDURE / PROGRAMME / ACTIVITY:


.MODEL SMALL
.DATA
STR1 DB "PANNAP"
LEN EQU ($-STR1)
STR2 DB 50 DUP(0)
MSG1 DB "THE GIVEN STRING IS
PALINDROME!$" MSG2 DB "THE GIVEN
STRING IS NOT PALINDROME!$"

.CODE
START: MOV AX, @DATA ; Initialization of DS & ES.
MOV DS, AX
MOV ES, AX

MOV SI, OFFSET STR1 ; Given string pointing to SI.


MOV DI, OFFSET STR2 ; Reversed string pointing to DI.
MOV CX, LEN ; Initialize counter.
ADD SI, LEN-1 ; Last element of the string,

UP: MOV AL, [SI] ; pointing to SI.


MOV [DI], AL ; Copy the last element of the given string,
DEC SI ; to the first position of reversed string.
INC DI
LOOP UP ; loop until CX is zero.
s
MOV SI, OFFSET STR1 ; Given string pointing to SI. e
MOV DI, OFFSET STR2 ; Reversed string pointing to DI.
MOV CX, LEN ; Initialize counter. s
CLD ; Clear Direction Flag. t
REPE CMPSB ; Compare two strings. r
JNE DOWN i
n
MOV DX, OFFSET MSG1 g
JMP STOP
DOWN: MOV DX, OFFSET MSG2 i
STOP: MOV AH, 09H s
INT 21H :
It
MOV AH, 4CH ; Terminate. is
INT 21H a
END START pa
lin
8. BLOCK / CIRCUIT / MODEL DIAGRAM dr
/ REACTION EQUATION: 9. o
OBSERVATION TABLE / LOOKUP TABLE m
/ TRUTH TABLE: e.
10. FORMULA / CALCULATIONS: 12.
11. GRAPHS / OUTPUTS: RESULTS
(i) &
Fo CONCLUS
r IONS:
th For
e the
stri stri
ng ng
: '__
M __
AL __
A __
Y __
AL __
A __
M __
Re _'
ve the
rs rev
e ers
stri ed
ng stri
is: ng
It is not a palindrome. is:
(ii) For __
the __
stri __
ng: __
MA __
LA __
YA __
LA __.
MM Th
Re ere
ver for
e it is _________________
13. LEARNING OUTCOMES :
• Any input string from the keyboard can be checked for
palindrome condition efficiently in
assembly language
14. APPLICATION AREAS:
• String checking
15. REMARKS:

-
• -
• -

1. EXPERIMENT NO: 4
2. TITLE: NCR CALCULATION
3. LEARNING OBJECTIVES:
• To learn the assembly language
implementation of computation of nCr. 4.
AIM:
• To compute nCr using recursive procedure. Assume that
n and r are non-negative numbers. 5. MATERIAL /
EQUIPMENT REQUIRED:
• Intel CPU based computer
• MASM/TASM Assembler.
6. THEORY / HYPOTHESIS:
• The ncr program computes nCr(no. of combinations of n, taken r at a time),using
recursive procedure where n and r are stored in wordwide memory locations.
Recursive definition for nCr:
Case1: If r=0 OR r=n, then nCr = 1
Case2: If r=1 OR r=n-1, then nCr = n
Case3: Other cases, nCr = (n-1)Cr + (n-
1)C(r-1) 7. PROCEDURE / PROGRAMME / ACTIVITY:

.MODEL SMALL
.DATA
n dw 4h
r dw 2h
ncr dw 0
.CODE
start: MOV AX, @DATA
MOV DS,AX
MOV AX,n
MOV BX,r call
encr MOV
AX,ncr MOV
AH,4CH INT
21H
encr proc near
CMP AL,BL
JE case1
CMP BL,0
JE case1
CMP BL,1
JE case21
DEC AL
CMP BL,AL
JE case22
PUSH AX
PUSH BX
CALL
ENCR POP
BX POP AX
DEC BL
PUSH AX
PUSH BX
CALL
ENCR POP
BX POP AX
RET
case1: INC NCR
RET
case22: INC NCR
case21: ADD NCR,Ax
RET
encr endp
END START

8. BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION:


9. OBSERVATION TABLE / LOOKUP TABLE / TRUTH TABLE:
(i) r=8, n=8
ds:0000 08 00 08 00 01 00 (ii)
r=0, n=6
ds:0000 06 00 00 00 01 00
(iii) r=n-1
ds:0000 09 00 08 00 09 00
(iv) n=9, r=1
ds:0000 09 00 01 00 09 00
(v) n=FFFF r=3
ds:0000 FF FF 03 00 00 00
(vi) n=5, r=3
ds:0000 05 00 03 00 0A 00

10. FORMULA / CALCULATIONS:

5c3 = __________________ = 0AH= 10


9c4 = __________________ = __H= ___

11. GRAPHS / OUTPUTS:


• The ncr vlaues
when, n=r is ____
r=0 is_____
r=n-1 is ____
r=1 is_____
ncr is ____
12. RESULTS & CONCLUSIONS:

13. LEARNING OUTCOMES :


• Thus the ncr can be calculated more efficiently using assembly language program.
14. APPLICATION AREAS:
• Solving mathematical problems in MP.
15. REMARKS:
• -
• -
• -

-
1. EXPERIMENT NO: 5
2. TITLE: DISPLAY THE CURRENT TIME FROM THE SYSTEM
3. LEARNING OBJECTIVES:
• To learn the implementation reading current time from the system and displaying it.
4. AIM:
• To read the current time from the system and display it in the standard format on the screen.
5. MATERIAL / EQUIPMENT REQUIRED:
• Intel CPU based computer
• MASM/TASM Assembler.
6. THEORY / HYPOTHESIS:
• The program for reading system time reads the system time ,using DOS ;function call
number 2CH. The hour, minute and second are returned in CH, CL and DH registers
(in HEX form) respectively, by the DOS function. It is then converted into ASCII for
display purpose. The timing is displayed, approximately at the center of the screen.
7. PROCEDURE / PROGRAMME / ACTIVITY:

.MODEL SMALL
.STACK
.DATA
MSG DB 'THE CURRENT TIME IS: $'

.CODE
START: MOV AX, @DATA ; Initialize DS.
MOV DS, AX

LEA DX, MSG ; Display the MSG.


MOV AH, 09H
INT 21H
MOV AH, 2CH ; DOS function to get the current
INT 21H ; system time.
MOV AL, CH
AAM ; ASCII adjust.
MOV BX, AX
CALL DISP ; Procedure to display.

MOV DL, ':' ; Display the character ':'.


MOV AH, 02H
INT 21H

MOV AL, CL
AAM ; ASCII adjust.
MOV BX, AX
CALL DISP ; Procedure to display.

MOV AH,4CH ; Terminate.


INT 21H

DISP PROC NEAR ; Procedure to display a character


MOV DL, BH ; on the standard output device.
ADD DL, 30H
MOV AH, 02H
INT 21H

MOV DL, BL
ADD DL, 30H
MOV AH, 02H
INT 21H
RET
DISP ENDP
END START

8. BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION:


9. OBSERVATION TABLE / LOOKUP TABLE / TRUTH TABLE:

Current time is: 22:00:10

10. FORMULA / CALCULATIONS:


11. GRAPHS / OUTPUTS:
• Current time is: 02:00:10
12. RESULTS & CONCLUSIONS:
• For system time ______ time obtained in program _________
• For system time ______ time obtained in program _________

13. LEARNING OUTCOMES :


• Thus the system time can be accessed using DOS interrupts and used in
any system application programs
14. APPLICATION AREAS:
• System time related user end applications like calenders, reminders, etc.
15. REMARKS:
• -
• -
• -

1. EXPERIMENT NO: 6
2. TITLE: ARM MICRO PROCESSOR PROGRAMMING IN ASSEMBLY LANGUAGE
3. LEARNING OBJECTIVES:
• To learn the process of writing and simulating ARM assembly language programs for
data transfer, arithmetic and logical operations.
4. AIM:
• To write and simulate ARM assembly language programs for data transfer, arithmetic
and logical operations.
5. MATERIAL / EQUIPMENT REQUIRED:
• PC with windows 7 OS and minimum 1GB RAM
• KEIL-5 MDK-ARM with Legacy support
6. THEORY / HYPOTHESIS:
• The ARM processor is easy to program at the assembly level.
The state of an ARM system is determined by the content of visible registers and memory.
• A user-mode program can see 15 32-bit general purpose registers (R0-R14),
program counter (PC) and CPSR.
• Memory system of ARM is a linear array of bytes addressed from 0 to 232-1.
• ARM instructions are all 32-bit long (except for Thumb mode). There are
232 possible machine instructions. Fortunately, they are structured.
• Features of ARM instruction set-
• Load-store architecture
• 3-address instructions
• Conditional execution of every instruction
• Possible to load/store multiple registers at once
• Possible to combine shift and ALU operations in a single instruction
• Instruction set is of following types:
• Data processing
• Data movement
• Flow control
7. PROCEDURE / PROGRAMME / ACTIVITY:

TTL ADDITION PROGRAM ;Title of the program, should start with TTL
AREA PROG, CODE, READONLY ;store this application PROG in code
memory(EEPROM)and an apllication is always readonly in ARM.
EXPORT MAIN ;exporting MAIN defined in statup.s and link that Main to
current Main this.
ENTRY ;Entry point to body of the program
MAIN ;main function
MOVS R1, #0X21 ;load 21h to RO with effect on status register
MOVS R2, #21 ;load 21D to R1 (equivalent to 15H)
ADD R1, R1, R2 ;R1=R1+R2
HERE B HERE ;stay here/infinite loop
END
---------------------------------------------------------------------------------------------
TTL SUBTRACTION PROGRAM
AREA PROG, CODE, READONLY
EXPORT MAIN
ENTRY
MAIN
MOVS R1, #0X21
MOVS R2,#21
SUBC R1, R1, R2 ;R1=R1-R2 (destination and second operand must be same)
HERE B HERE
END
---------------------------------------------------------------------------------------------------------

TTL MULTIPLICATION PROGRAM


AREA PROG, CODE, READONLY
EXPORT MAIN
ENTRY
MAIN
MOVS R1, #0X21
MOVS R2, #21
MULS R1, R1, R2 ;R1=R1*R2
HERE B HERE
END
----------------------------------------------------------------------------------------------------------
TTL DIVISION PROGRAM AREA
PROG, CODE, READONLY
EXPORT MAIN
ENTRY
MAIN
MOVS R1, #0X21
MOVS R2,#21
UDIV R1, R1, R2 ;R1=R1/R2 (destination and second operand must be same)
HERE B HERE
END
(NOTE: this program will work only in ARM Cortex M3 and M4)

---------------------------------------------------------------------------------------

TTL DATATRANSFER PROGRAM


REA PROG, CODE, READONLY
EXPORT MAIN
ENTRY
MAIN
MOVS R1, #0X21
MOVS R2,#21
LDR R0, [R1] ; R0 = @ mem[R1]
LDR R3, [R1, #4] ; R3=@ mem[R1+4]
LDR R4, [R1, R2] ;R4 = @ mem[R1+R2]
HERE B HERE
END
------------------------------------------------------------------------------------
TTL LOGICALOPERATION
PROGRAM AREA PROG, CODE,
READONLY EXPORT MAIN
ENTRY
MAIN
MOVS R1, #0X21
MOVS R2,#21
AND R0, R1, R2 @ R0 = R1 and R2
ORR R0, R1, R2 @ R0 = R1 or R2
EOR R0, R1, R2 @ R0 = R1 xor R2
HERE B HERE
END

8. BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION:


9. OBSERVATION TABLE / LOOKUP TABLE / TRUTH TABLE:
• addition: R1 =________ R2=________Result R3=______
• Subtraction:R =________ R=________Result R=______
• Multiplication:R =________ R=________Result R=______
• Logical AND of _________ and________=______
• Logical OR of _________ and________=______
• Logical XOR of _________ and________=______
10. FORMULA / CALCULATIONS:

11. GRAPHS / OUTPUTS:


• -
• -
• -
• -
12. RESULTS & CONCLUSIONS:
• The basic arithmetic and logical operations are implemented in Assembly
language. 13. LEARNING OUTCOMES :
• The ARM processor can be programmed in assembly language which gives good control
over the processor.
14. APPLICATION AREAS:
• -
• -

• -
15. REMARKS:
• -
• -
• -
-
1. EXPERIMENT NO: 7
2. TITLE: ARM MICRO PROCESSOR PROGRAMMING IN 'C' LANGUAGE
3. LEARNING OBJECTIVES:
• To learn the process of writing and simulating C Programs for ARM microprocessor in KEIL
4. AIM:
• To write and simulate C Programs for ARM microprocessor in KEIL
5. MATERIAL / EQUIPMENT REQUIRED:
• PC with windows 7 OS and minimum 1GB RAM
• KEIL-5 MDK-ARM with Legacy support
6. THEORY / HYPOTHESIS:
• ARM microprocessor programming basics in C:
Bitwise or bitlevel operations form the basis of embedded programming. The
interconversion between Hexadecimal and Binary we can start with Bitwise(or bit
level) operations in C. There are bascially 6 types of Bitwise operators. These are :

1. Bitwise OR operator denoted by ‘|‘


2. Bitwise AND operator denoted by ‘&‘
3. Bitwise Complement or Negation Operator denoted by ‘~‘
4. Bitwise Right Shift & Left Shift denoted by ‘>>‘ and ‘<<‘ respectively
5. Bitwise XOR operator denoted by ‘^‘
As we can see using binary number directly is a difficult specially when there are
like 32 bits to handle. Using Hexadecimal instead makes it a bit easier and using
Left shift operator makes it very simple. Here '<<' is called the Left Shift Operator.
Similar to this is ">>" is Right Shift operator.
"(1<<19)" Simply means 'Shift 1 towards the LEFT by 19 Places'. Other bits will
be Zero by default.
The bitwise 1s complement can be done using the Bitwise negation operator
denoted by '~'. The result of this operation is called 1's Complement .
Generally its a not suggested to assign a value directly to Registers since doing so
may change the value of other bits which might be used to contol some other
hardware. Consider an 8 bit Register say REGT_8b is used to Start/Stop 8 different
Timers. Bit 0 (from left) controls Timer 0 , Bit 1 Controls Timer 1 and so on. Writing
a '1' to a bit will Start the timer and a '0' will Stop the Timer.
Now lets say Timers 7,6,5 are started and others are stopped. So the current value of
REGT_8b will be '11100000'. Now assume that we want to Start Timer 2. We can do this in
a manner which doesn't affect the other bits as follows :
REGT_8b = REGT_8b | (1<<2);

ARM (LPC2148) GPIO programming C:


When getting started in embedded programming, GPIO (General Purpose Input Output)
pins are one of the first things played with. Its also quite evident that the blink led program
toggles an LED connected to the pin on the Microcontroller that keeps it blinking. The use
of GPIO is not limited to driving LEDS but can be also used for reading digital signal ,
generating triggers for external components , controlling external devices and what not.

7. PROCEDURE / PROGRAMME / ACTIVITY:

8. BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION:


ARM microprocessor programming basics in C:

#include "lpc17xx.h"
#include "stdio.h" int
main(void)
{
uint16_t a, b;
uint32_t REG,x;
uint8_t REG_8b;
char n1,n2,n3;

/*integer addition operation in


ARM*/ a=0x21;
b=21;
a=a+b;

/*bitwise assign operation in


ARM*/ REG = 0X00100000; // make 19th bit of a register high
REG = (1<<19); // make 19th bit high(alternate method)

/*OR operation in ARM*/


REG = (1<<19)|(1<<12); //19th and 12th bits are set to 1

/*1's complement/negation in
ARM*/ x=0x0FFF000F;
REG = ~(x);

/*AND operation in ARM*/


n1 = 0xF4;
n2 = 0x3A;
n3 = n1&n2;
/*XOR operation in ARM*/
n1 = 0xF4;
n2 = 0x3A;
n3 = n1^n2;

/*working with ARM registers*/


REG_8b = REG_8b | (1<<2); // set bit number 7,6,5 of a register as 1
}
ARM (LPC2148) GPIO programming C:

#include <lpc214x.h>
void delay(void);
int main(void)
{
IO0DIR = 0xFFFFFFFF; // Configure all pins on Port 0 as Output
while(1)
{
IO0SET = 0xFFFFFFFF; // Turn on LEDs
delay();
IO0CLR = 0xFFFFFFFF; // Turn them off
delay();
}
return 0; // normally this wont execute
}

void delay(void)
{
int z,c;
c=0;
for(z=0; z<4000000; z++)
{
c++;
}
}

9. OBSERVATION TABLE / LOOKUP TABLE / TRUTH TABLE:


• Integer addition of _________ and________=______
• Bitwise AND of _________ and________=______
• Bitwise OR of _________ and________=______
• Bitwise XOR of _________ and________=______
• 1'S complement of __________= _____________

10. FORMULA / CALCULATIONS:

11. GRAPHS / OUTPUTS:


• -
• -
• -
• -
12. RESULTS & CONCLUSIONS:
• Basic arithmetic and logical operation on ARM processor are implemented
using C language

14. REMARKS:
the GPIO peripherals of the ARM processor are programmed using c
language 13. LEARNING OUTCOMES :
Basic arithmetic and logical operation on ARM processor can be performed
using C language
• the peripherals of the ARM processor can be efficiently programmed using c
language 14. APPLICATION AREAS:
• -
• -
• -

-
1. EXPERIMENT NO: 8
2. TITLE: A) LOGIC CONTROLLER INTERFACE – BCD UP-DOWN COUNTER
B) LOGIC CONTROLLER INTERFACE – READ TWO 8-BIT INPUTS (X & Y)
AND DISPLAY X*Y
3. LEARNING OBJECTIVES:
• To learn the implementation of BCD up-counter in Logic Controller Interface.
• To learn the implementation of multiplication of two numbers on Logic Controller Interface.

4. AIM:
• To interface Logic Controller Interface kit to the microprocessor and design and
develop an ALP to perform BCD up-down counter.
• To interface Logic Controller Interface kit to the microprocessor and design and
develop an ALP to read the status of two 8-bit input bytes (X and Y) from the LCI,
and display X*Y on it. from the Logic Controller Interface and display X*Y.
5. MATERIAL / EQUIPMENT REQUIRED:
• Intel CPU based computer
• Logic Controller Interface kit
• FRC connector.
• 7-segment LED Interface kit
6. THEORY / HYPOTHESIS:
• BCD up-down counter: The program initiates a BCD up-down counter. The content of
accumulator is incremented from zero in BCD form(with proper time delay between
increments),and displayed in the Logic controller interface card in binary form. When the
display reaches 99, down counter is initiated. When the count is down to 00,the program
gets terminated. The program 2b2 imitates a ring counter. Immediate number 1 is moved to
accumulator, and is rotated right once at a time, with proper delay between rotations, and
displayed in Logic controller; interface card, until any key of the keyboard is pressed.
• The program inputs a byte (X) from the Logic controller card through port-B. Then the
processor is made to enter a wait loop, using a DOS function number 0Bh. During this
waiting period, the second byte (Y) is manually set in the card. After that, when any key
of the keyboard is pressed, processor comes out of the waiting loop and inputs the byte
Y. The two input bytes are multiplied. Low byte of the product is displayed first, and
then after a time delay, the high byte of the product is displayed, though port-A.
7. PROCEDURE / PROGRAMME / ACTIVITY:

LOGIC CONTROLLER INTERFACE - BCD UPDOWN COUNTER.


.MODEL SMALL
.DATA
MSG1 DB 13,10,"LOGIC CONTROLLER INTERFACE – BCD UPDOWN
COUNTER...",13,10,'$'
PA EQU 0CD00H ; Port addresses for ESA Module.
PB EQU 0CD01H
PC EQU 0CD03H
CR EQU 0CD03H
CW DB 82H

.CODE
START: MOV AX, @DATA
MOV DS, AX

LEA DX, MSG1 ; To display MSG1.


MOV AH, 09H
INT 21H
MOV AL, CW
MOV DX, CR
OUT DX, AL

MOV AL, 0 ; Make AL=0 (Used as counter).


UP: MOV DX, PA
OUT DX, AL ; Send the count through PA.
CALL DELAY ; Provide delay to see the count.
CALL KBHIT ; Is any key pressed? if yes, exit.
ADD AL, 1 ; Increment the counter.
DAA ; Make it BCD.
CMP AL, 99H ; Compare with the last count.
JNE UP ; If not equal repeat.

MOV AL, 99H


DOWN: MOV DX, PA
OUT DX, AL ; Send the count through PA.
CALL DELAY ; Provide delay.
CALL KBHIT ; Is any key pressed? if no, continue.
SUB AL, 1 ; Decrement the counter.
DAS ; Make it BCD.
CMP AL, 0 ; Is end?
JNE DOWN ; If no repeat.

EXIT: MOV AH, 4CH ; Terminate.


INT 21H

DELAY PROC ; Procedure for delay.


MOV BX, 11FFH
B2: MOV CX, 0FFFFH
B1: LOOP B1
DEC BX
JNZ B2
RET
DELAY ENDP

KBHIT PROC ; Procedure to get the keyboard status.


PUSH AX
MOV AH, 01H ; If no key is pressed, Zero flag is set.
INT 1H ; If any key is pressed, Zero flag is reset.
JNZ DONE
POP AX
RET
DONE: JMP EXIT
KBHIT ENDP

END START

LOGIC CONTROLLER INTERFACE - READ TWO 8 BIT INPUTS (X & Y)


AND DISPLAY X*Y.
.MODEL SMALL

.DATA
MSG1 DB 13,10,"LOGIC CONTROLLER INTERFACE - READ TWO
8 BIT INPUTS (X & Y) AND DISPLAY X*Y...",13,10,'$'
MSG2 DB 13,10,"Accept the value of X through Interface card
and press any key.$" MSG3 DB 13,10,"Accept the value of Y
through Interface card and press any key.$" MSG4 DB
13,10,"Press any key to observe the value of X*Y.$"
PA EQU 0CD00H ; Port address for ESA Module.
PB EQU 0CD01H
PC EQU 0CD02H
CR EQU 0CD03H
CW DB 82H ; Control Word for ESA Module.
PRINT MACRO MSG ; Macro to write messages.
LEA DX, MSG
MOV AH, 09H
INT 21H
ENDM

.CODE
START:
MOV AX,
@DATA
MOV DS,
AX

PRINT MSG1 ; To display MSG1.


MOV AL, CW
MOV DX, CR
OUT DX, AL

PRINT MSG2 ; To display MSG2.


MOV AH, 8 ; Is any key pressed?
INT 21H
MOV DX, PB
IN AL, DX ; If yes, read data for X.
MOV BL, AL ; Save it in BL register.

PRINT MSG3 ; To display MSG3.


MOV AH, 8 ; Is any key pressed?

INT 21H
MOV DX, PB
IN AL, DX ; If yes, read data for Y.

MUL BL ; Perform X*Y(8-bit * 8-bit = 16-bit)

PUSH AX
PRINT MSG4 ; To display MSG4.
POP AX

MOV DX, PA
OUT DX, AL ; Send lower order byte of product.
CALL DELAY ; Wait.
MOV AL, AH
MOV DX, PA
OUT DX, AL ; Send high order byte of product.

MOV AH, 4CH ; Terminate.


INT 21H

DELAY PROC ; Delay procedure.


MOV BX, 03FFH
B2: MOV CX, 0FFFFH
B1: LOOP B1
DEC BX
JNZ B2
RET
DELAY ENDP

END START
8. BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION: NA
9. OBSERVATION TABLE / LOOKUP TABLE / TRUTH TABLE: NA
10. FORMULA / CALCULATIONS:

11. GRAPHS / OUTPUTS:

• 0 0 0 0 0 0 0 0 (FF H) * 0 0
0 0 0 0 0 0 (02 H) Result:
LSB: 0 0 0 0 0 0 0 0 (FE H)
MSB: 0 0 0 0 0 0 0 0 (01 H)
12. RESULTS & CONCLUSIONS:
• -

13. LEARNING OUTCOMES:


• Any BCD counting sequences from 00-99 can be shown on LEDs of
LCI.
• Two hexadecimal numbers taken from external switches of a Logic
Controller Interface can be multiplied in the microprocessor and
displayed on it.
14. APPLICATION AREAS:
• To represent decimal numbers as packed BCD numbers.
• Implementation of calculators.

15. REMARKS:

-
1. EXPERIMENT NO: 9
2. TITLE: A) 7-SEGMENT DISPLAY INTERFACE – DISPLAY MESSAGES FIRE AND
HELP

3. LEARNING OBJECTIVES:
• To learn the interfacing of 7segment LED display kit to the microprocessor and
display alphanumeric characters on it.
• -
• -
• -
4. AIM:
• To interface 7-Segment LED kit to the microprocessor and design and develop an
ALP to Display messages FIRE and HELP alternatively with flickering effects on a
7-segment display interface for a specified period of time.
• -
5. MATERIAL / EQUIPMENT REQUIRED:
• Intel CPU based computer
• 7-Segment LED Interface kit
• FRC connector.

6. THEORY / HYPOTHESIS:
• The hardware uses four shift register ICs 74164. 74164 is an 8-bit serial in-parallel out shift
register with asynchronous reset and two input pins. It requires 8 clock cycles at “CLK” pin
to shift the serial data from input to 8 parallel outputs. After 8 shifts, the first serial bit will be
in output QH, and only now the data at output is valid. To cascade more 74164 shift
register IC need to connect the last output QH to the input of second shift register.

The output is connected to the cathode of the LEDs in the 7 segment display and thus
common anode displays are used. The anode is connected to +Vcc..The last output of
nd
the first sift register is connected to input of the 2 shift register and the last output o f
nd shift register to input of 3rd and so on. Thus the shift register are serial in parallel
2
out and they are connected to displays, in such a way that output 0A is connected to
display segment ‘a’ and 0B to ‘b’ and so on up to 0H; through 330 ohm resistors.
The shifting of data bit takes place for each clock cycle. 7404 IC used provides
isolation and the interface board gets 5V through port bit.
Pin 1 is used as data pin and pin 2 is used as other input to Vcc. The clock signal is
generated at a port bit which will be connected to the clock of the shift register.
PB0 is used for data bit; and PC0 for clock through which a falling edge has to be sent.

The microprocessor stores the display information in a RAM. Each time a display has to be
updated the microprocessor fetches all bytes one by one from RAM and
outputs corresponding display codes serially that is bit by bit to display.
Hexadecimal code is stores in the RAM. The code conversion from hexa
to 7 segment is done just before the display is updated.
The 7 segment display is used as a numerical indicator on many types of
test equipment. It is an assembly of light emitting diodes which can be
powered individually. There are two important types of 7-segment LED
display.
In a common cathode display, the cathodes of all the LEDs are joined
together and the individual segments are illuminated by HIGH voltages.
In a common anode display, the anodes of all the LEDs are joined
together and the individual segments are illuminated by connecting to a
LOW voltage.

Display code
Since the outputs of shift registers are connected to cathode sides of
displays, low input must be given to segments for making them glow and
high inputs for making them blank. Each display has 8 segments (a, b, c,
d, e, f, g, h) as shown. For displaying any character the corresponding
segment must be given low inputs.

The one shown above is a common anode display since all anodes are
joined together and go to the positive supply. The cathodes are connected
individually to zero volts. Resistors must be placed in series with each
diode to limit the current through each diode to a safe value. The d.p
represents a decimal point.
The following table shows how to form characters: '0' means that pin is
connected to ground. '1' means that pin is connected to Vcc.
• STRING: HELP

• d.p g f e d c b a

• 1 0 0 0 1 1 0 0 ---- P (8CH)

• 1 1 0 0 0 1 1 1 ---- L (C7H)

• 1 0 0 0 0 1 1 0 ---- E (86H)

• 1 0 0 0 1 0 0 1 ---- H (89H)

74164 is an 8-bit SIPO Shift Register. Instead of a single-serial input, an


AND gate
combines inputs DA and DB to produce the serial input. When clock and

DB inputs are high, output of AND gate which is the actual serial Input for

the shift register is nothing but the input DA which is connected to the

Least Significant Bit of port B (PB0). PCo, Least Significant Bit of port C

has been internally connected to the clock i/p of all 74164 IC’s.

7. PROCEDURE / PROGRAMME / ACTIVITY:


7-SEGMENT DISPLAY INTERFACE - DISPLAY MESSAGES FIRE AND
HELP.
.MODEL SMALL
.DATA
PA EQU 0CD00H ; Port address for ESA Module.
PB EQU 0CD01H
PC EQU 0CD02H
CR EQU 0CD03H
CW DB 80H ; Port-B Out, Port-C Out, Mode 0 I/O.
MSG1 DB 13,10,"7-SEGMENT DISPLAY INTERFACE - DISPLAY
MESSAGES FIRE AND HELP...",'$'
MSG2 DB 13,10,"Press any key to Exit.$"
STR1 DB 8EH, 0F9H, 0AFH, 86H ; F I r E
STR2 DB 89H, 86H, 0C7H, 8CH ; H E L P

.CODE
START: MOV AX, @DATA
MOV DS, AX

LEA DX, MSG1 ; To display MSG1.


MOV AH, 09H
INT 21H
LEA DX, MSG2 ; To display MSG2.
INT 21H

MOV AL, CW
MOV DX, CR
OUT DX, AL
AGAIN: LEA SI, STR1 ; Get base address of STR1(FlrE},
CALL DISP_STR ; to display string on SSD.
CALL DELAY ; Wait.
LEA SI, STR2 ; Get base address of STR2(HELP),
CALL DISP_STR ; to display message on SSD.
CALL DELAY ; Wait

MOV AH, 1 ; Press any key to exit.


INT 16H
JZ AGAIN
MOV AH, 4CH ; Terminate.
INT 21H

DISP_STR PROC ; Procedure to display strings.


DISP_STR PROC ; Procedure to display strings.
MOV CX, 4 ; Total number of characters per string.
NCHAR: MOV BL, 8 ; Total number of bits in SSC.
MOV AL, [SI] ; Get the first SSC.
NXTBIT: ROL AL, 1 ; Bring B7 to B0, i.e., B6B5B4B3B2B1B0B7.
MOV DX, PB
OUT DX, AL ; Send bit (0/1) through PB0.
PUSH AX
MOV AL, 00H ; For Clock.
MOV DX, PC
OUT DX, AL ; Send bit 0 through PC0.
MOV AL, 01H ; Send bit 1 through PC0.
MOV DX, PC
OUT DX, AL
POP AX
DEC BL ; Reduce bits counter.
JNZ NXTBIT ; Is counter =0? If no, repeat.
INC SI ; Update pointer.
LOOP NCHAR ; Repeat till CX=0.
RET
DISP_STR ENDP

DELAY PROC ; Procedure for delay.


MOV BX, 011FFH ; Outer counter.
B2: MOV CX, 0FFFFH ; Inner counter.
B1: LOOP B1 ; Repeat till inner counter = 0.
DEC BX
JNZ B2 ; Repeat till outer counter = 0.
RET
DELAY ENDP
END START
8. BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION: NA
9. OBSERVATION TABLE / LOOKUP TABLE / TRUTH TABLE: NA-
10. FORMULA / CALCULATIONS:
11. GRAPHS / OUTPUTS:

12. RESULTS & CONCLUSIONS:


13. LEARNING OUTCOMES:


• Any alphanumeric character can be displayed on the 7 segment
LED unit.

14. APPLICATION AREAS:


• Character display on a video device
• Moving message displays.

15. REMARKS:

-
1. EXPERIMENT NO: 10
2. TITLE: STEPPER MOTOR INTERFACE – CLOCKWISE OR
COUNTER-CLOCKWISE
3. LEARNING OBJECTIVES:
• To learn the interfacing of Stepper motor to the microprocessor and
to rotate it in a specified.
4. AIM:
• To drive a stepper motor interface to rotate the motor in specified
direction (clockwise or counter-clockwise) by N steps by introducing
suitable delay between successive steps. (Any arbitrary value for the
delay may be assumed by the student).
5. MATERIAL / EQUIPMENT REQUIRED:
• Intel CPU based computer
• Stepper motor driver Interface kit
• FRC connector.
6. THEORY / HYPOTHESIS:
• The ncr program computes nCr(no. of combinations of n, taken r
at a time),using recursive procedure where n and r are stored in
wordwide memory locations.
Recursive definition for nCr:
Case1: If r=0 OR r=n, then nCr = 1
Case2: If r=1 OR r=n-1, then nCr = n
Case3: Other cases, nCr = (n-1)Cr + (n-1)C(r-1)
• In a permanent magnet stepper motor, the rotor is a permanent
magnet and stator is electromagnet. The rotor positions itself is such
that its poles lock with corresponding opposite poles of the stator.
Stepper motor control is a very popular application of
microprocessor system, in industrial process- control area, since stepper
motor is capable of accepting pulses directly from the microprocessor,
and rotates accordingly. F or clockwise direction of rotation, the voltage
application sequence for the coils is 3,2,1,0.

The stepper motor showing full-step operation is shown below.


A) 45-degrees (B) 135-degrees (C) 225-degrees (D) 315-degrees

For anticlockwise, the sequence is 0,1,2,3. So actually, only 4 bits


are needed, but since registers are 8 bit-wide, we repeat the same
value i n the lower nibble of AL register. We load AL with
10001000B.When the processor execute OUT and ROR AL,1
repeatedly(with proper delay),appropriate voltage sequence for
Clockwise rotation is fed to the stepper-motor.
AL =

The ’step angle’, as given by the manufacturer is 1.8˚

7. PROCEDURE / PROGRAMME / ACTIVITY:


STEPPER MOTOR INTERFACE - CLOCKWISE OR COUNTER-
CLOCKWISE.

.MODEL SMALL
.STACK
.DATA
PA EQU 0cd00H ; Port address in ESA Module.
PB EQU 0cd01H
PC EQU 0cd02H
CR EQU 0cd03H
CW EQU 80H ; Port-A Out, Mode 0, I/O.
COUNT DB 200 ; 200 steps.
MSG DB 13,10,"STEPPER MOTOR INTERFACE - CLOCKWISE OR COUNTER-
CLOCKWISE...$"

.CODE
START: MOV AX, @DATA
MOV DS, AX
LEA DX, MSG ; To write MSG.
MOV AH, 09H
INT 21H

MOV DX, CR
MOV AL, CW
OUT DX, AL

MOV DX, PA
MOV AL, 88H ; AL = 10001000B. 88, 44, 22, 11 for Clockwise.
MOV CX, 00H
MOV CL, COUNT

AGAIN: OUT DX, AL


CALL DELAY
ROR AL, 1
LOOP AGAIN

MOV AH,4CH ; Terminate.


INT 21H
DELAY PROC ; Procedure for delay.
PUSH CX
PUSH BX
MOV BX, 2FFFH
D1: MOV CX,0FFFFH
D2: LOOP D2
DEC BX
JNZ D1
POP BX
POP CX
RET
DELAY ENDP

END START
8. BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION: NA
9. OBSERVATION TABLE / LOOKUP TABLE / TRUTH TABLE: NA
10. FORMULA / CALCULATIONS:
Number of step required for 90 degree rotation = 90/1.8 =
Number of step required for 90 degree rotation = 360/1.8 =
11. GRAPHS / OUTPUTS:
• Stepper motor runs in counter-clockwise direction, for 200 steps and then stops.
• Stepper motor runs in clockwise direction, for 200 steps and then stops.

12. RESULTS & CONCLUSIONS:


Number of steps taken by the stepper motor to rotate
i) 90degree= ______
ii) 360 degree= _____
13 LEARNING OUTCOMES :
• The stepper motor can be interfaced to the microprocessor and can be controlled.

14. APPLICATION AREAS:


• Industrial automation, Robotics.
15. REMARKS:

-
1. EXPERIMENT NO: 11
2. TITLE: A) DAC INTERFACE – SINE WAVE
B) DAC INTERFACE – HALF RECTIFIED SINE WAVE
3. LEARNING OBJECTIVES:
• To learn the generation of sinusoidal wave forms using microprocessors.
• To learn the generation of Half rectified sine waveforms using microprocessors.
4. AIM:
• To generate the Sine Wave using the DAC interface (The output of the DAC is to be
displayed on the CRO)
• To generate a Half rectified sine wave-form using the DAC interface (The output of
the DAC is to be displayed on the CRO).
5. MATERIAL / EQUIPMENT REQUIRED:
• Intel CPU based computer
• DAC Interface kit
• FRC connector.

6. THEORY / HYPOTHESIS:
• A) The dual DAC interface can be used to generate different interesting waveforms using
the microprocessor. The reference voltage needed for the DAC is obtained from an on-
board voltage regulator uA723/uA741. The voltage generated by this regulator is about 8V.
The outputs from the DAC vary between 0 to 5V corresponding to the values between 00H
to FFH. The digital inputs to DAC are provided through the ports of 8255, and the analog
outputs from the DAC are given to operational amplifiers which acts as current to voltage
converters. Refer to the schematics of DAC given in the above Figure.
The Port A and Port B of 8255 PPI are used as output ports. The outputs from the
OpAmp are connected to Xout and Yout, from which the waveforms are observed
on a CRO. Port A is used to control Xout and Port B is used to control Yout.
The value of digital output (from MP, through Port A) is stored in the array called
table. The value for each element of the table is calculated using the formula,
Table = 127 + 127sinθ.
• The value of digital output for every 6˚ rise (up to 180˚ electrical)is stored in the table. For
the next 180˚, the element values of table are simply inverted by NOT instruction, with negligible error. The addition of the
constant 127 (Amplitude of sine wave here) in the formula has a convenience because if we calculate the table values by just
127sinθ, we get negative values (for θ between 180˚ to 360˚), which is more complicated for table formation here in ALP. The
above formula has ensured that negative elements are not in table array. The value 127 corresponds the reference line (i.e. X-
axis).
• B) This program is much similar sine wave generation except that the second loop instructions out only the reference line
digital output(i.e. 127d)for 31 times. So analog output will be confined to only to the reference line during 180˚ to 360˚,
producing a half rectified sine wave on the CRO.
This program outputs 8-bit digital value to the Digital-to-Analog converter(i.e. DAC).The digital output is varied
according to sine wave function, for every 6˚(electrical), only during 0˚ to 180˚.For 180˚ to 360˚ ,the digital
output corresponds to only the reference line(i.e. 127d). So we can observe a half rectified sine wave at the output of DAC,
using a CRO(Digital data = 127 + 127sinθ). The digital data is stored in the array called table.

7. PROCEDURE / PROGRAMME / ACTIVITY:


DAC INTERFACE - SINE WAVE.

.MODEL SMALL
.STACK
.DATA
PA EQU 0CD00H ; Port address in ESA Module.
PB EQU 0CD01H
PC EQU 0CD02H
CR EQU 0CD03H
CW EQU 80H ; Port-A Out.
VALUES DB 127, 140, 153, 166, 178, 190, 201, 212
DB 221, 229, 236, 243, 247, 251, 253, 254
DB 253, 251, 247, 243, 236, 229, 221
DB 212, 201, 190, 178, 166, 153, 140, 127
MSG DB 13,10,"DAC INTERFACE - SINE WAVE...$"

.CODE
START: MOV AX, @DATA
MOV DS, AX

LEA DX, MSG ; To write MSG.


MOV AH, 09H
INT 21H
MOV DX, CR
MOV AL, CW
OUT DX, AL

MOV DX, PA
NC: LEA SI, VALUES
MOV CX, 31D
NA1:MOV AL, [SI]
OUT DX, AL
nINC SI
LOOP NA1
LEA SI, VALUES
MOV CX, 31D
NA2:MOV AL, [SI]
NOT AL
OUT DX, AL
INC SI
LOOP NA2
JMP NC

MOV AH, 4CH ; Terminate


INT 21H

END START

DAC INTERFACE - HALF-RECTIFIED SINE WAVE.

.MODEL SMALL
.STACK
.DATA
PA EQU 0CD00H ; Port address in ESA Module.
PB EQU 0CD01H
PC EQU 0CD02H
CR EQU 0CD03H
CW EQU 80H ; Port-A Out.
VALUES DB 127, 140, 153, 166, 178, 190, 201, 212
DB 221, 229, 236, 243, 247, 251, 253,
254 DB 253, 251, 247, 243, 236, 229, 221
DB 212, 201, 190, 178, 166, 153, 140, 127
MSG DB 13,10,"DAC INTERFACE – HALF-RECTIFIED SINE WAVE...$"

.CODE
START: MOV AX, @DATA
MOV DS, AX
LEA DX, MSG ; To write MSG. MOV AH, 09H

INT 21H
MOV DX, CR
MOV AL, CW
OUT DX, AL

MOV DX, PA
NC: LEA SI, VALUES
MOV CX, 31D
NA: MOV AL, [SI]
OUT DX, AL
INC SI
LOOP NA
COURSE LABORATORY MANUAL

MOV CX, 31D


MOV AL, 127D
RL: OUT DX, AL
LOOP RL
JMP NC

MOV AH, 4CH ; Terminate


INT 21H
END START

8. BLOCK / CIRCUIT / MODEL DIAGRAM / REACTION EQUATION: NA


9. OBSERVATION TABLE / LOOKUP TABLE / TRUTH TABLE: NA
10. FORMULA / CALCULATIONS: NA
11. GRAPHS / OUTPUTS:

DAC Value = 127 + 127sinθ


12. RESULTS & CONCLUSIONS: NA
13. LEARNING OUTCOMES:

• The sinusoidal waveform can be generated by the microprocessor by giving suitable values to the DAC.

14. APPLICATION AREAS:


• Microprocessor controlled sine wave inverters, modulations.
• Test wave form generation for hardware debugging.

15. REMARKS:

Das könnte Ihnen auch gefallen