Saturday, April 7, 2012

Different types of SIGNALING Schemes using MATLAB

clc
clear all
close all
n=input('enter the number of bits')
m=mod(randperm(n),2)            %binary data
t=['the binary data is      ',num2str(m)]
c=input('enter your choice 1.unipolar nrz 2.polar nrz 3.unipolar rz 4.manchester')
switch c
    case 1
for i=1:1:n
s((i-1)*100+1:i*100)=m(i)
end
    case 2
        for i=1:1:n
            if m(i)==1
                m(i)=1
            else
                m(i)=-1
            end
        end
        for i=1:1:n
s((i-1)*100+1:i*100)=m(i)
        end
    case 3
        for i=1:1:n
    s(1+100*(i-1):50*((2*i)-1))=m(i)
    s(1+50*((2*i)-1):100*i)=0
        end
    case 4
        for i=1:1:n
            if m(i)==1
                m(i)=1
            else
                m(i)=-1
            end
        end
        for i=1:1:n
    s(1+100*(i-1):50*((2*i)-1))=m(i)
    s(1+50*((2*i)-1):100*i)=-m(i)
        end
    otherwise
disp('invalid choice')
end
plot(s)
gtext(t)
switch c
    case 1
        gtext('unipolar nrz signaling')
    case 2
        gtext('polar nrz signaling')
    case 3
        gtext('unipolar rz signaling')
    otherwise
        gtaxt('manchester signaling')
end

Thursday, April 5, 2012

Frequency Shift Keying using MATLAB




clc
clear all
close all
m=input('enter the binary sequency')
l=length(m)
t=[0.01:0.01:l]
for i=1:1:l
a((i-1)*100+1:i*100)=m(i)
end
% the fsk can be written as sum of two asks having different frequencies  
% generating the ASK Signal for the inputed sequence with high frequency
f1=a.*(sin(2*pi*5*t))
f2=not(a).*sin(2*pi*t)
fsk=f1+f2
figure(1)
plot(f1)
title('ASk signal')
figure(2)
plot(f2)
title('ask signal')
figure(3)
plot(fsk)
title('frequency shift keying signal')
figure(4)
hold on
plot(f1,'black')
plot(f2,'red')
helg=legend('high frequency signal','low frequency signal')
hold off

YOU MAY LIKE1. Amplitude Shift keying              
2. Phase Shift Keying                  
3. Hybrid Shift Keying                  

Sunday, April 1, 2012

Division of two numbers using 8086 in assembly language

assume cs:code,ds:data
data segment
org 2000h
num1 dw 8345h
num2 dw 2346h
rem dw 2d dup(0h)
quo dw 2d dup(0h)
data ends
code segment
start:mov ax,data
mov ds,ax
mov ax,num1
idiv num2
mov quo,ax
mov rem,dx
mov ah,4ch
int 21h
code ends
end start

Finding the product of two numbers using 8086 program in assembly language

assume cs:code,ds:data
data segment
org 2000h
num1 dw 1234h
num2 dw 2345h
product dw 2d dup(0h)
data ends
code segment
start:mov ax,data
mov ds,ax
mov ax,num1
mul num2
mov product,ax
mov product+2,dx
mov ah,4ch
int 21h
code ends
end start

assume is the preprocessor directive . and we are using two segment registers one is code segment and second is the data segment register.
data segment contains the all initialization s like the starting address of the program. and the variables used and the data type of those variables. product dw 2d dup(0h) specifies the processor to load the variable memory location with the zeros.
next code segment contains the executable code which performs the desired action. the result of the multiplication is stored in the ax register automatically. mov ax,data loads the startin address of the data segment in the ax register. mov ds,ax set thememory location as the variable ds. load the  number one into the ax register. and then directly multiply the content of the ax with num2. the result is stored in the ax register. then move the result into the variable product. at the endint 21h is the interrupt to the processor.

finding the sum of two numbers using 8086 in assembly language

assume cs:code,ds:data
data segment
org 2000h
num1 dw 1234h
num2 dw 2345h
sum db 2d dup(0h)
carry db 1d dup(0h)
data ends
code segment
start:mov ax,data
mov ds,ax
mov ax,num1
mov bx,num2
add al,bl
daa
mov sum,al
mov al,ah
adc al,bh
daa
mov sum+1,al
mov bl,0h
adc bl,0h
mov carry,bl
mov ah,4ch
int 21h
code ends
end start


Assembly language program to find the sum of numbers in a given series using 8086

assume cs:code,ds:data
data segment
org 2000h
series dw 1234h,2345h,0abcdh,103fh,5555h
sum dw 00h
carry dw 00h
data ends
code segment
start:mov ax,data
mov ds,ax
mov ax,00h
mov bx,00h
mov cx,05h
mov si,2000h
go:add ax,[si]
adc bx,00h
inc si
inc si
dec cx
jnz go
mov sum,ax
mov carry,bx
mov ah,4ch
int 21h
code ends
end start

Assembly language program to find the number of ones in a given number using 8086

assume cs:code,ds:data
data segment
org 2000h
num dw 4567h
onecount db 01d dup(0h)
data ends
code segment
start:mov ax,data
mov ds,ax
mov cx,16d
mov ax,num
go:ror ax,01
jnc next
inc onecount
next:dec cx
jnz go
mov ah,4ch
int 21h
code ends
end start

Assembly language program to find maximum and minimum number in a series using 8086

assume cs:code,ds:data
data segment
org 2000h
series db 12h,11h,09h,05h,23h,99h,86h
count dw 07h
max db 00h
min db 00h
data ends
code segment
start:mov ax,data
mov ds,ax
mov cx,count
lea si,series
mov al,[si]
mov bl,al
go:inc si
cmp [si],al
jl min_val
mov al,[si]
jmp nxtp
min_val:cmp [si],bl
jg nxtp
mov bl,[si]
nxtp:loop go
mov max,al
mov min,bl
mov ah,4ch
int 21h
code ends
end start

Assembly language program to convert binary number to BCD using 8086 using procedures

ASSUME  CS:CODE, DS:DATA, SS:STACK1
DATA    SEGMENT
SERIES  DB 74H,29H,4AH,3BH
BCD_OUT DW 04H DUP(0H)
BCD     EQU 04H
DATA    ENDS
STACK1 SEGMENT
BALARAM DW 40H DUP(0H)
TOP_STACK LABEL WORD
STACK1 ENDS
CODE SEGMENT
START:  MOV AX, DATA
        MOV DS, AX
        MOV AX, STACK1
        MOV SS, AX
        LEA SI, SERIES
        LEA DI, BCD_OUT
        LEA SP, TOP_STACK
        MOV CH, BCD
        CALL BIN_BCD
        MOV AH, 4CH
        INT 21H
BIN_BCD PROC NEAR
PUSHF
PUSH AX
PUSH BX
PUSH CX
NXT_VALUE: MOV AL, [SI]
           MOV AH, 0H
           MOV CL, 64H
           DIV CL
           MOV BH, AL
           MOV AL, AH
           MOV AH, 0H
           MOV CL, 0AH
           DIV CL
           MOV CL, 04H
           ROR AL, CL
           MOV BL, AH
           ADD BL, AL
           MOV [DI], AX
           INC SI
           ADD DI, 02
           DEC CH
           JNZ NXT_VALUE
           POP CX
           POP BX
           POP AX
           POPF
           RET
           BIN_BCD ENDP
           CODE ENDS
           END START


Friday, March 30, 2012

Display string on scrren in assembly language using 8086


assume cs:code,ds:data
data segment
org 2000h
msg db "MICROPROCESSORLAB",0DH,0AH,"$"
data ends

code segment
start:
mov ax,data
mov ds,ax
lea dx,msg
mov ah,09h
int 21h
mov ah,4ch
int 21h
code ends
end start

Thursday, March 29, 2012

Find the string for polindrome or not using 8086 program in assembly language


assume cs:code,ds:data,es:data
data segment
org 2000h
msg1 db "enter your string",0dh,0ah,"$"
msg2 db "It is palindrom",0dh,0ah,"$"
msg3 db "It is not palindrom",0dh,0ah,"$"
msg4 db "Do you wish to continue y/n",0dh,0ah,"$"
org 4000h
strg1 db 50h dup(0h)
        org 6000h
strg2 db 50h dup(0h)
data ends

code segment
start:
mov ax,data
mov ds,ax
mov es,ax
lea si,strg1
lea di,strg2
mov bx,0h
lea dx,msg1
mov ah,09h
int 21h
next_char:
mov ah,01h
        int 21h
cmp al,0dh
je rev_string
inc bx
stosb
jmp next_char
rev_string:
mov cx,bx
dec di
nxt_byte:
mov al,[di]
mov [si],al
inc si
dec di
loop nxt_byte
lea si,strg1
lea di,strg2
mov cx,bx
cld
rep cmpsb
je palin
lea dx,msg3
mov ah,09h
int 21h
jmp next
palin:
lea dx,msg2
mov ah,09h
int 21h
next:
lea dx,msg4
mov ah,09h
int 21h
mov ah,01h
int 21h
cmp al,'y'
je start
cmp al,'n'
je terminate
        jmp next
terminate:
mov ah,4ch
int 21h
code ends
end start


DC motor control with Pulse Width Modulation Part 1

DC Motor intro DC motor is a device which converts electrical energy into kinetic energy. It converts the DC power into movement. The typica...