Saturday, 16 August 2014

High Temperature Alarm using NI MYDAQ

Present days detection of high temperature is important in industrial applications and also in some of the daily home applications .For knowing temperature and give an alarm for high temperature of  water, welding purposes, furnaces etc. So here I present a high temperature alarm circuit using LM 35.
Let us first discuss on LM35 which I used in this application
 LM35  whose output voltage is varied linearly with repect to temperature, but inversely proportional to the temperature.
Detectable range:-55 deg.C to 150 deg.C.  

Apparatus:
1) LM35 temperature sensor.
2) NI MY DAQ.
3) connecting wires.
Circuit which is interfaced with NI MYDAQ:
Step:1
Here +15 is connected to +VCC of LM35 and, AGND of DAQ to ground and output terminal to AI +1 and AI-1 to ground





Step:2
First calibrate output voltage to the detected temperature using multiplier and adder.

Output displaying temperature:
Step:3
Using comparator set a reference value:
Example: reference is 40
Temperature is 30. Then led is off (Boolean).
Here I used green one. But it would be better if we use red for danger.
Output when reference is more than detected temperature:
Output of  buzzer when reference is more than detected temperature.
  
Step4:
Output when reference is less than detected temperature:
Example: if reference value is 20
Detected temperature is 30
If we observe here led is glowing.i.e., representing more temperature.


Output of buzzer when reference is less than detected temperature:
If any queries, post a comment as well as you can contact me at kamalmohan.m1994@gmail.com

Monday, 11 August 2014

AMPLITUDE MODULATION USING MULTIPLIERS AND SYNCHRNOUS DEMODULATION USING PHASE AND FREQUENCY OFFSET ERRORS

Task1:                                                                                                                                                                            
  Consider a single tone modulating signal m(t)= cos10^3*pi*t , and  carrier signal c(t) =cos10^4*pi*t     
      Given that  Am=1,fm=500,Ac=1,fc=5000   µ=Am/Ac =1
A.M signal in time domain description is

            
In the time domain  
   Sam(t)= cos(2 π*5000*t)+1/2[cos2 π *(4500)*t]+1/2[cos2 π*(5500)*t]
In the frequency domain
                S(f)=1/2[δ (f-5000)+ δ (f+5000)]+ 1/4 [δ (f-5500)+ δ (f+5500)]
                                                                 +  1/4 [δ (f-4500)+ δ (f+4500)]

MULTITONE SIGNLAS:
Task2:
        Let us consider a multi tone modulating signal
                                  m(t) = 2cos1000p t -sin1500p +1.5cos2000p
For the given multi tone signal Am1=2,Am2=-1,Am3=1.5 &Ac=1 for carrier signal which is used in task 1 .  
Now A.m signal in time domain & frequency domain  as shown below
In time domain
                           S(t)= cos ( 10000pt)+[cos(2 *p*4500 *t)+ cos(2 *p*5500*t) ]
                                -1/2[sin(2*p*250* t)+ sin(2*p*1250* t)]
                            +3/4[cos(2 *p*4000 *t)+ cos(2 *p*6000*t)]
In the frequency domain
S(f)=1/2[δ (f-5000)+ δ (f+5000)]+ 1/2 [δ (f-5500)+ δ (f+5500)+ δ (f-4500)+ δ +4500)]
-1/4 [δ (f-5750)+ δ (f+5750)+ δ (f-4250)+ δ(f+4250)                                                          + 3/8[δ (f-6000)+ δ (f+6000)+ δ (f-4000)+ δ (f+4000)]
 
 

 
TASK-3:
 
DEMODULATED SIGNAL:
 
 
 

 
 
 
 
PHASE DEVIATION ERRORS:        Φ=45˚,90˚,135˚
 

 
 
FREQUENCY DEVIATION ERROS: Df = 500hz,1000hz,1500hz
 

 
 
DEMODULATION WITH PHASE AND FREQUENCY ERRORS:
 

MAT LAB program:
clc;
clear all;
close all;
fc=6000;% carrier frequency
fs=50000;%sampling frequency
f=500;%tone modulation
Am=1;
Ac=1;
t=0:1/fs:((4/f)-(1/fs));
 
%Task-1--------------Modulating wave-----------------
     
M=Am.*cos(2*pi*f*t);
m1=2*cos(2*pi*500*t)-1*sin(2*pi*750*t)+1.5*cos(2*pi*1000*t);
figure(1);
subplot(3,2,1);plot(t,M,'linewidth',2);
plot(t,M);
axis([0 0.008 -1.5 1.5])
xlabel('Time (sec)');
ylabel('Amplitude');
title(['Message Signal']);
grid on;
f_M=abs((fft(M,1024)));
f_M=[f_M(514:1024) f_M(1:513)];
f=(-511*fs/1024):(fs/1024):(512*fs/1024);
subplot(3,2,2);
plot(f,f_M);
xlabel('Frequency in Hz');
ylabel('Amplitude');
title('Spectrum of Message Signal');
%----------MULTITONE SIGNAL---------%
figure(6);
subplot(3,2,1);plot(t,m1,'linewidth',2);
plot(t,m1);
axis([0 0.008 -1.5 1.5])
xlabel('Time (sec)');
ylabel('Amplitude');
title(['multitone Signal']);
grid on;
f_m1=abs((fft(m1,1024)));
f_m1=[f_m1(514:1024) f_m1(1:513)];
f=(-511*fs/1024):(fs/1024):(512*fs/1024);
subplot(3,2,2);
plot(f,f_m1);
xlabel('Frequency in Hz');
ylabel('Amplitude');
title('Spectrum of multitone Signal');
 
%---------------------------carrier wave----------------------
 
C=Ac*cos(2*pi*fc*t);
subplot(3,2,3);
plot(t,C);
xlabel('Time (sec)');
ylabel('Amplitude');
title(['Carrier Signal']);
%grid on;
f_C=abs((fft(C,1024)));
f_C=[f_C(514:1024) f_C(1:513)];
f=(-511*fs/1024):(fs/1024):(512*fs/1024);
subplot(3,2,4);
plot(f,f_C);
xlabel('Frequen;cy in Hz');
ylabel('Amplitude');
title('Spectrum of Carrier Signal');
%-------------------------------modulated wave---------------------
sam=Ac*(1+M).*cos(2*pi*fc*t);
subplot(3,2,5);
plot(t,sam);
xlabel('Time (sec)');
ylabel('Amplitude');
title('Amplitude Modulated Signal');
grid on;
f_sam=abs((fft(sam,1024)));
f_sam=[f_sam(514:1024) f_sam(1:513)];
f=(-511*fs/1024):(fs/1024):(512*fs/1024);
subplot(3,2,6);
plot(f,f_sam);
xlabel('Frequency in Hz');
ylabel('Amplitude');
title('Spectrum of Amplitude Modulated Signal');
 
 
%----------------------Demodulation signal--------------------------
 
XC1=Ac*cos(2*pi*fc*t);
demod=XC1.*sam;
figure(2);
subplot(2,2,1);
plot(t,demod,'r','linewidth',2)
xlabel('time');
ylabel('Amplitude');
title(' Amplitude demodulated Signal1');
f_demod=abs((fft(demod,1024)));
f_demod=[f_demod(514:1024) f_demod(1:513)];
f=(-511*fs/1024):(fs/1024):(512*fs/1024);
subplot(2,2,2);
plot(f,f_demod,'r','linewidth',2)
xlabel('Frequency in Hz');
ylabel('Amplitude');
title('Spectrum of Demodulated Signal1');
 
F=1000;s=15000;
x1=demod;
[b,a] = butter(3,F*2/s,'low');
y1 = filtfilt(b,a,x1);
subplot(2,2,3)
plot(t,y1,'r','linewidth',2)
title('Demodulated Signal1');
xlabel('Time');
ylabel('amplitude');
 
 
%----------------------1st phase deviation--------------
 
XC1=Ac*cos((2*pi*fc*t)+45);
demod1=XC1.*sam;
figure(3);
subplot(3,2,1);
plot(t,demod1);plot(t,demod1,'y','linewidth',2)
xlabel('time');
ylabel('Amplitude');
title('demodulated Signal1 with 45deg');
f_demod1=abs((fft(demod1,1024)));
f_demod1=[f_demod1(514:1024) f_demod1(1:513)];
f=(-511*fs/1024):(fs/1024):(512*fs/1024);
subplot(3,2,2);
plot(f,f_demod1,'y','linewidth',2)
xlabel('Frequency in Hz');
ylabel('Amplitude');
title('Spectrum of Demodulated Signal1 with 45deg');
 
 
%----------------------2nd phase deviation--------------
 
XC2=Ac*cos((2*pi*fc*t)+90);
demod2=XC2.*sam;
subplot(3,2,3);
plot(t,demod2,'y','linewidth',2)
xlabel('time');
ylabel('Amplitude');
title(' demodulated Signal2 with 90deg');
f_demod2=abs((fft(demod1,1024)));
f_demod2=[f_demod2(514:1024) f_demod2(1:513)];
f=(-511*fs/1024):(fs/1024):(512*fs/1024);
subplot(3,2,4);
plot(f,f_demod2,'y','linewidth',2)
xlabel('Frequency in Hz');
ylabel('Amplitude');
title('Spectrum of demodulated Signal2 with 90deg');
 
 
%----------------------3rd phase deviation--------------
 
XC3=Ac*cos((2*pi*fc*t)+120);
demod3=XC3.*sam;
subplot(3,2,5);
plot(t,demod3,'y','linewidth',2)
xlabel('time');
ylabel('Amplitude');
title(' demodulated Signal3 with 120deg');
f_demod3=abs((fft(demod1,1024)));
f_demod3=[f_demod3(514:1024) f_demod3(1:513)];
f=(-511*fs/1024):(fs/1024):(512*fs/1024);
subplot(3,2,6);
plot(f,f_demod3,'y','linewidth',2)
xlabel('Frequency in Hz');
ylabel('Amplitude');
title('Spectrum of demodulated Signal3 with 120deg');
 
%----------------------1st frequency deviation--------------
 
XC4=Ac*cos(2*pi*(fc+500)*t);
demod4=XC4.*sam;
figure(4);
subplot(3,2,1);
plot(t,demod4);
xlabel('time');
ylabel('Amplitude');
title(' Amplitude demodulated Signal4freq deviation 500hz');
f_demod4=abs((fft(demod4,1024)));
f_demod4=[f_demod4(514:1024) f_demod4(1:513)];
f=(-511*fs/1024):(fs/1024):(512*fs/1024);
subplot(3,2,2);
plot(f,f_demod4);
xlabel('Frequency in Hz');
ylabel('Amplitude');
title('Spectrum of demodulated Signal4 of freq deviation 500hz');
 
%----------------------2nd frequency deviation--------------
 
XC5=Ac*cos(2*pi*(fc+1000)*t);
demod5=XC5.*sam;
subplot(3,2,3);
plot(t,demod5);
xlabel('time');
ylabel('Amplitude');
title(' Amplitude demodulated Signal5 freq deviation 1000hz');
f_demod5=abs((fft(demod5,1024)));
f_demod5=[f_demod5(514:1024) f_demod5(1:513)];
f=(-511*fs/1024):(fs/1024):(512*fs/1024);
subplot(3,2,4);
plot(f,f_demod5);
xlabel('Frequency in Hz');
ylabel('Amplitude');
title('Spectrum of demodulated Signal5 freq deviation 1000hz');
 
 
 
%----------------------3rd frequency deviation--------------
XC6=Ac*cos(2*pi*(fc+1500)*t);
demod6=XC6.*sam;
subplot(3,2,5);
plot(t,demod6);
xlabel('time');
ylabel('Amplitude');
title(' Amplitude demodulated Signal6 freq deviation 1500hz');
f_demod6=abs((fft(demod6,1024)));
f_demod6=[f_demod6(514:1024) f_demod6(1:513)];
f=(-511*fs/1024):(fs/1024):(512*fs/1024);
subplot(3,2,6);
plot(f,f_demod6);
xlabel('Frequency in Hz');
ylabel('Amplitude');
title('Spectrum of demodulated Signal6 freq deviation 1500hz');
 
 
%-----------------1st phase error demodulation using filter-------------
F=1000;s=15000;
x1=demod1;
[b,a] = butter(3,F*2/s,'low');
y1 = filtfilt(b,a,x1);
figure(5);
subplot(3,2,1)
plot(t,y1)
title('Demodulated Signal1 with phase deviaton 45degrees');
xlabel('Time');
ylabel('amplitude');
 
%-----------------2nd phase error demodulation using filter-------------
 
x2=demod2;
[b,a] = butter(3,F*2/s,'low');
y2 = filtfilt(b,a,x2);
subplot(3,2,2)
plot(t,y2)
title('Demodulated Signal2 with phase deviaton 90degrees');
xlabel('Time'); ylabel('amplitude');
%-----------------3rd phase error demodulation using filter-------------
 
x3=demod3;
[b,a] = butter(3,F*2/s,'low');
y3 = filtfilt(b,a,x3);
subplot(3,2,3)
plot(t,y3)
title('Demodulated Signal3 with phase deviaton 120degrees');
xlabel('Time'); ylabel('amplitude');
 
%---------------frequency error demodulation using filter-------
x6=demod6;
axis([0 0.005 -1 1])
[b,a] = butter(3,F*2/s,'low');
y6 = filtfilt(b,a,x6);
subplot(3,2,6);
plot(t,y6);
title('Demodulated Signal1 with freq deviation 500hz');
xlabel('Time'); ylabel('amplitude');
 
x5=demod5;
[b,a] = butter(3,F*2/s,'low');
y5 = filtfilt(b,a,x6);
subplot(3,2,5);
plot(t,y5);
title('Demodulated Signal with freq deviation 1000hz');
xlabel('Time'); ylabel('amplitude');
 
x4=demod4;
[b,a] = butter(3,F*2/s,'low');
y4 = filtfilt(b,a,x4);
subplot(3,2,4);
plot(t,y4);
title('Demodulated Signal with freq deviation 1500hz');
xlabel('Time'); ylabel('amplitude');

Tuesday, 5 August 2014

MATLAB code for DSB-SC modulation

fc=167000;
fm=fc/100;
fs=100*fc;
t=0:1/fs:4/fm;
xc=cos(2*pi*fc*t);
xm1=2*cos(1000*pi*t)-sin(1500*pi*t);
xm2=1.5*cos(2000*pi*t);
xm=xm1+xm2;
figure(1)
subplot(3,1,1),plot(t,xm1);
title('mesaage signal 1');
xlabel('time (sec)');
ylabel('amplitude');
subplot(3,1,2),plot(t,xm2);
title('message signal 2');
xlabel('time (sec)');
ylabel('amplitude');
subplot(3,1,3),plot(t,xm);
title('total message signal');
xlabel('time (sec)');
ylabel('amplitude')
% DSB-SC MODULATION
z1= xm.*xc;
figure(2)
subplot(2,1,1),plot(t,z1);
title('DSB-SC MODULATION IN TIME DAOMAIN');
xlabel('time (sec)');
ylabel('amplitude');
l1=length(z1);
f=linspace(-fs/2,fs/2,l1);
Z1=fftshift(fft(z1,l1)/l1);
subplot(2,1,2),plot(f,abs(Z1));
title('DSB SC MODULATION IN FREQUENCY DOMAIN');
xlabel('frequency(hz)');
ylabel('amplitude');
demodulation
s1=z1.*xc;
S1=fftshift(fft(s1,length(s1))/length(s1));
figure(3)
plot(f,abs(S1));
title(' demodulated signal IN FREQUENCY DOMAIN before filtring');
xlabel('frequency(hz)');
ylabel('amplitude');

For information about DSB-SC modulation:
http://en.wikipedia.org/wiki/Double-sideband_suppressed-carrier_transmission