What is the reason for adding 1 to magnitude of sine when we want to send samples to DAC (12 bit resolution)?
Afficher commentaires plus anciens
I'm not understanding reason for using y=y+1; We know that sin(0) is 0 . But getting 2048 as first sample.
What is the reason for adding 1 to Y?
Y = Y + 1;
This is the code written to generate sine wave for DAC input .
clear all;
close all;
clc; % Clear The Previous Points
Ns = 128; % Set The Number of Sample Points
RES = 12; % Set The DAC Resolution
OFFSET = 0; % Set An Offset Value For The DAC Output
%------------[ Calculate The Sample Points ]-------------
T = 0:((2*pi/(Ns-1))):(2*pi);
Y = sin(T);
Y = Y + 1;
Y = Y*((2^RES-1)-2*OFFSET)/(2+OFFSET);
Y = round(Y);
plot(T, Y);
grid
%--------------[ Print The Sample Points ]---------------
fprintf('%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, \n', Y);
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur MATLAB dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!