Wednesday, June 20, 2012

Amplitude Modulation using matlab

Amplitude Modulation Matlab Program
fs=400;
fo=5;
fc=25;
num_periods=40;
samp_period=(fs/fo);
totalsamp=samp_period*num_periods;
n=[0:totalsamp-1];
t=(n/fs);
m=sin(2*pi*fo*t);
N=totalsamp;
M=abs(fft(m,N))/totalsamp;
M=fftshift(M);
F=[-N/2:(N/2)-1];
Ac=1;
Ka=0;
DCoffset=1;
s=Ac*(DCoffset+Ka*m).*cos(2*pi*fc*t);
S=abs(fft(s,N))/totalsamp;
S=fftshift(S);
close all;
F2=figure;
subplot(3,1,1);
plot(t,s,t,(DCoffset+Ka*m),'--'),grid;
Maxtime=5*samp_period/fs;
xlabel('time(ms)');
subplot(3,1,2);
plot(F,M)
xlabel('frequency(khz)');
subplot(3,1,3);
plot(F,s)



 You may like Digital Modulation Techniques now you are at analog modulation
0. Frequency Modulation                     
1. Amplitude shift keying                     
2. Frequency shift keying                     
3. Phase shift keying                             
4. Hybrid Shift Keying                          

Friday, June 15, 2012

Frequency Modulation Using Matlab

clear;
close all;

%PARAMETERS
fc=200;            % carrier frequency in hertz
t0=0.15;            %time range in seconds
Df=50;            %frequency deviation constant in hertz/volt

ts=0.0005;                  % sampling interval
t=[0:ts:t0];                % time vector

%MESSAGE SIGNAL
m=[2*ones(1,t0/(3*ts)),-3*ones(1,t0/(3*ts)),ones(1,t0/(3*ts)+1)];
figure(1)
hold on
plot(m,'black');
title('Message signal');
xlabel('time');
ylabel('signal value');
set(1,'PaperPositionMode','auto');
%FM SIGNAL
fi=fc+Df*m;
s=cos(2*pi*fi.*t);
plot(s,'red');
title('FM signal');
xlabel('time');
ylabel('signal value');
hleg=legend('message signal','FM signal')



You may like Digital Modulation Techniques now you are at analog modulation
0. Amplitude Modulation         AM
1. Amplitude shift keying        ASK
2. Frequency shift keying        FSK
3. Phase shift keying                PSK

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.

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