Saturday, April 14, 2012

String overlaping program using 8086

ASSUME  CS:CODE, DS:DATA, ES:data
DATA    SEGMeNT
        ORG 8000H
STRING1 DB  'balarama krishna'
string2 db 'rachumallu'
data ends
CODE    SEGMeNT
START:  MOV AX, DATA
        MOV DS, AX
        MOV ES, AX
        lea SI, string1
        lea DI, string2
        MOV CX, 10
        add si, 8d
        CLD
        REP MOVSB
        mov ah, 4ch
        int 21h
CODE    ENDS
        END START

1.
2.

Friday, April 13, 2012

String transfer in reverse direction using 8086

ASSUME  CS:CODE, DS:DATA, ES:data
DATA    SEGMeNT
        ORG 8000H
STRING1 DB  'balaram'
LENGTH_STRING1 EQU $-STRING1
data ends
EXTRA SEGMENT
ORG 9000H
STRING2 DB 50D DUP(0H)
EXTRA ENDS
CODE    SEGMENT
START:  MOV AX, DATA
        MOV DS, AX
        MOV AX, EXTRA
        MOV ES, AX
        lea SI, string1
        lea DI, string2
        MOV CX, LENGTH_STRING1
        add di, LENGTH_STRING1-1
        CLD
go:     MOVSB
        dec di
        dec di
        dec cx
        jnz go
        mov ah, 4ch
        int 21h
CODE    ENDS
        END START

String transefer in forward direction using 8086

ASSUME  CS:CODE, DS:DATA, ES:EXTRA
DATA    SEGMeNT
        ORG 8000H
STRING1 DB  'AKASH'
LENGTH_STRING1 EQU $-STRING1
data ends
EXTRA SEGMENT
ORG 9000H
STRING2 DB 50D DUP(0H)
EXTRA ENDS
CODE    SEGMENT
START:  MOV AX, DATA
        MOV DS, AX
        MOV AX, EXTRA
        MOV ES, AX
        lea SI, string1
        lea DI, string2
        MOV CX, LENGTH_STRING1
        CLD
        REP MOVSB
        MOV AH, 4CH
        INT 21H
CODE    ENDS
        END START



you need enter the address of extra segment as ES:9000h in dump window by pressing ctrl+g to view output

Sorting numbers in ascending oreder (signed) using 8086 in assembly language

assume cs:code,ds:data
data segment
org 2000h
series db 81h,82h,93h,95h,10h,56h,33h,99h,13h,44h
count dw 10d
data ends
code segment
start:mov ax,data
mov ds,ax
mov dx,count
dec dx
go:mov cx,dx
lea si,series
nxt_byte:mov al,[si]
cmp al,[si+1]
jl next
xchg al,[si+1]
xchg al,[si]
next:inc si
loop nxt_byte
dec dx
jnz go
mov ah,4ch
int 21h
code ends
end start

Companding of signal using MULAW in MATLAB

clear all
close all
clc
M=input('enter the signal') %enter the signal with time like sin(2*pi*[0:0.01:1]
Mmax=max(M)
Mn=M/Mmax
u=input('enter the u value') %default value is 255
Vn=log(1+u*Mn)/(log(1+u))
 figure(1)
 plot(Mn)
 figure(2)
 plot(Vn)
 figure(3)
plot(Mn,Vn)

ASK Modulation & Demodulation using MATLAB


Amplitude Shift Keying:

Amplitude shift keying (ASK) is a very popular modulation used in control applications. This is due to its simplicity and low implementation costs. ASK modulation has the advantage of allowing the transmitter to idle during the transmission of a bit zero. Therefore this reduces the power consumption. This disadvantage of ASK modulation arises in the presence of an undesired signal. in amplitude shift keying (ASK), as the name specifies the amplitude of the carrier signal is varied between two levels if the ASK scheme is Binary ASK. Sometimes it is more than two levels if the ASK scheme is M-array. All this is done according to the data bit to be transmitted over the noisy channel. The information is assumed to be unipolar binary data. In binary ask bit 1 is transmitted with the carrier of specified amplitude. The bit zero is transmitted with the no carrier during the bit interval. During all the bit intervals amplitude will be changed but frequency will be kept constant. In M-array ask the amplitude levels of the carrier will change between M numbers of values. The main advantage of the ASK is power saving and simplicity in implementation. The ASK wave form can be represented mathematically as s(t)=m(t)*sin(2πfct). where s(t) is the ASK output signal, m(t) is the unipolar binary message signal to be transmitted and fc is the carrier frequency.Amplitude      shift keying (ASK) is a simple and elementary form of digital modulation in which the amplitude of a carrier sinusoid is modified in a discrete manner depending   on   the   value   of   a   modulating   symbol.This is a narrow band modulation scheme and we assume that a large number carrier cycles are sent within a symbol   interval. obvious that the information is embedded only in the peak amplitude of the modulated signal.this is described as a one type of digital amplitude modulation technique. BASK has only one basis function so this can be described as a one  dimensional modulation scheme.this technique is used for telegraph services.on-off keying is not a spectrally not efficeint scheme becuse as the amplitude of the carrier changes abruptly when the data bit changes. for this reason this technique is used for transmission of data at low or moderate data rates.

 Algorithm:

                The binary message to be transmitted is taken and it should be represented in a waveform so we can implement ask. Then generate the carrier it may be either sin or cos. After generating carrier multiply the carrier with the message point by point.
                in demodulation the code checks for the value and if the value matched during the all the bit interval then the value will be returned.

Matlab commands:

1.       K=Length(x)

It finds the length of the array x and returns its length as an integer.

2.       T=[0.01:0.01:k]

This specifies the time interval over which the carrier time period will be decided.

3.       Z=m.*c

This is matlab Command for point by point multiplication. Sometimes it generates errors if the m and c are not of same dimensions.
4.       M((i-1)*100+1:i*100)=a(i)
This applies the value of the message bit i during the specified interval.

5.       p = randperm(n)

Returns a random permutation of the integers 1:n.

6.       mod(1,randperm(n))

this command generates the n number of integers and all these having only two values. For example mod(1,randperm(5)) ans =[0     1     1     1     1]


program:

x=input('binary message signal')%binary message signal
l=length(x)%length of message
t=[0.01:0.01:l]%time scaling
c=cos(2*pi*t)%carrier signal
for i=1:1:l
    m((i-1)*100+1:i*100)=x(i)%loop to convert inputed sequence to pulsewave
end
a=c.*m
figure(1)
plot(m)
title('massage signal')
figure(2)
plot(a)
title('ASK Signal')
%%% ASK Demodulation envelope detection  without noise%%%
for i=1:1:(i*100)
    if a(i)==0
        r(i)=0
    else
        r(i)=1
    end
end
figure(3)
plot(r)
title('recovered signal')


Base band signal generation Using Matlab

a=input('enter the sequence')
k=length(a)
t=[0.01:0.01:k]
for i=1:1:k
    m((i-1)*100+1:i*100)=a(i)
end
plot(m)
xlabel('time')
ylabel('amplitude')
title('base band signal')

Hybrid Shft Keying PSK & FSK using MATLAB

clc
clear all
close all
clf
m=mod(randperm(4),2)  % this generates the 4 random bits which are binary
l=length(m)
t=[0.01:0.01:l]
for i=1:1:l
a((i-1)*100+1:i*100)=m(i)
end
figure(1)
plot(a,'red')
title('message signal')
f1=4
f2=3
c=sin(2*pi*(f1+(a.*f2)).*t+(not(a).*pi)) %carrier which will be transmitted over channel
figure(2)
plot(c,'black')
title('hybrid shift keying combination of FSK PSK')

Tuesday, April 10, 2012

Procedure to work with Topview Simulator to execute programs in microcontroller 89c51/8051

  • Open text editor and type the program(preferred notepad++/notepad) 
  • Save it with an extension “.asm” 
  • Open top view simulator
  • select your device name from drop down list
  • select the memory
  • select the crystal frequency
  • Go to File-----> load file and select the program.asm you saved earlier
  • Compile the program 
  • Go to External memory and then insert the desired data in the memory locations  given as inputs in the program. 
  • Run the simulator and check the output in the memory location which is set as output in the code.

Steps to execute the Programs on 8086

you need TASM, tlink ,td files to assemble link and create object and exe files for your program. after getting these files create a folder in c drive and name it as bin.
here is a link to download all these files  DOWNLOAD
copy these files in this folder
and now open the command prompt and change the directory to this folder bin.
copy the program and paste it in the notepad.
save it in the bin folder with extension .asm
now type tasm followed by the program name with .asm extension
press enter this will show your errors. correct all these errors then proceed to the next step.
now type tlink followed by the program name with extension .obj
press enter
now type the td followed by the program name with extension .exe
then your program appears in different screen.
press F7 key until you reach the starting address of the program. 
now open the dump window.
and press ctrl+g
then a dialog box will appear. enter the starting address of the program which is typed in the program. for ex 2000h.
then press enter. and close the dialog box.
now continue pressing F7. when the program terminates it shows a dialog box. and the result will be seemed in the dump window

Amplitude Shift Keying demodulation Using Multisim




This is the circuit used to Demodulate the ASK modulated signal.

DOWNLOAD     this file
  ASK or Amplitude Shift keying is the digital modulation technique.And it is simpler over other Digital modulation techniques. similar to other digital modulation techniques ASK is also effected by the atmospheric noise and distortion.ASK technique is used to transmit digital data over an optical fiber.in this technique frequency and phase of the carrier remains constant.this technique is also called on-off keying and is used at radio frequencies to transmit Morse code . ASK needs high SNR i.e. high signal to noise ratio to recover the digital data.the band width is also very high for this type of shift keying technique.if we are using only one or zero to transmit digital data then this type of ASK is called BASK i.e. binary amplitude shift keying.the problem associated with ask is it does not have constant envelop this imposes a restrictions on the power amplification of ask signal because power amplification requires linearity but at the same time the demodulation is we can implement demodulation by using simple envelop detector.Amplitude shift  keying (ASK) is  a  simple   and   elementary form   of  digital modulation in which the amplitude of a carrier sinusoid is modified in a discrete manner depending on the value of a modulating   symbol.This is a narrowband modulation scheme and we assume that a large number of carrier   cycles   are   sent   within  a   symbol interval.obvious that the information is embedded only in the peak amplitude of the modulated signal.this is described as a one type of digital amplitude modulation technique. BASK has only one basis function so this can be described as a one dimensional modulation scheme.this technique is used for telegraph services.on-off keying is not a spectrally not efficeint scheme becuse as the amplitude of the carrier changes abruptly when the data bit changes. for this reason this technique is used for transmission of data at low or moderate data rates..the ask demodulation is done in two steps in first step the band limited bit stream is recovered and in second step regeneration if digital bit stream is done.There are so many other Digital modulation techniques like Frequency shift keying, Phase shift keying, M- array shift keying & combination of Shift keying known as hybrid shift keying. in hybrid shift keying we can combine the two or more shift keying. In all these methods ASK is the easy implementable Shift keying process.
The circuit used here is the asynchronous ASK detector. When the signal passes through a rectifier we get positive half wave signal. by using low pass filter we can detect the envelop of the signal.in the circuit first op-amp acts as the amplifier in inverting configuration to amplify the incoming signal. Diode acts as the rectifier which converts the signal to a half wave signal. resistor and the capacitor combinely forms the low pass filter and acts as envelop detector. Second op-amp with the combination of pot, resistor,diode,capacitor forms a comparator. the entire process can be represented with a simple block diagram. 


Sunday, April 8, 2012

Program to sort numbers in descending order using 8086 (signed numbers)

assume cs:code,ds:data
data segment
org 2000h
series db 81h,82h,93h,95h,10h,56h,33h,99h,13h,44h
count dw 10d
data ends
code segment
start:mov ax,data
mov ds,ax
mov dx,count
dec dx
go:mov cx,dx
lea si,series
nxt_byte:mov al,[si]
cmp al,[si+1]
jnl next
xchg al,[si+1]
xchg al,[si]
next:inc si
loop nxt_byte
dec dx
jnz go
mov ah,4ch
int 21h
code ends
end start

Program to sort numbers in ascending order using 8086 (unsigned numbers)

assume cs:code,ds:data
data segment
org 2000h
series db 81h,82h,93h,95h,10h,56h,33h,99h,13h,44h
count dw 10d
data ends
code segment
start:mov ax,data
mov ds,ax
mov dx,count
dec dx
go:mov cx,dx
lea si,series
nxt_byte:mov al,[si]
cmp al,[si+1]
jb next
xchg al,[si+1]
xchg al,[si]
next:inc si
loop nxt_byte
dec dx
jnz go
mov ah,4ch
int 21h
code ends
end start

Program to find the number of numbers having 5th bit as one in a series using 8086

assume cs:code,ds:data
data segment
org 2000h
series db 56h,32h,45h,11h,32h,87h,97h,65h,55h,88h
numcount db 00h
data ends
code segment
start:mov ax,data
mov ds,ax
mov si,2000
mov cx,0ah
go:mov ax,[si]
test ax,10h
jz next
inc numcount
next:inc si
dec cx
jnz go
mov ah,4ch
int 21h
code ends
end start

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


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...