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

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