0 Bewertungen0% fanden dieses Dokument nützlich (0 Abstimmungen)
4 Ansichten1 Seite
Function [Digital_value] = a2d(Analog_value,Bits,Volts,time_length,Fs) % A2D is an analog to Digital converter % % bits = bit-resolution of a / d % volts = input volt-range of A/D % time_length = time span of input signal % Fs = sampling frequency in Hz % Digital_value = Quantised digitised analog value vpb
Function [Digital_value] = a2d(Analog_value,Bits,Volts,time_length,Fs) % A2D is an analog to Digital converter % % bits = bit-resolution of a / d % volts = input volt-range of A/D % time_length = time span of input signal % Fs = sampling frequency in Hz % Digital_value = Quantised digitised analog value vpb
Function [Digital_value] = a2d(Analog_value,Bits,Volts,time_length,Fs) % A2D is an analog to Digital converter % % bits = bit-resolution of a / d % volts = input volt-range of A/D % time_length = time span of input signal % Fs = sampling frequency in Hz % Digital_value = Quantised digitised analog value vpb
function [Digital_value] = a2d(Analog_value,Bits,Volts,time_length,Fs)
%function [Digital_value] = a2d(analog_value,bits,volts,time_length,Fs) % A2D is an analog to Digital converter % % Analog_value = analog value to digitise % Bits = bit-resolution of A/D % Volts = input volt-range of A/D % time_length = time span of input signal % Fs = sampling frequency in Hz % % Digital_value = Quantised digitised analog value vpb=2*Volts/(2^Bits-1); % Volts per Bit index=find(Analog_value>Volts); if ~isempty(index) Analog_value(index)=Volts; end clear index; index=find(Analog_value<-Volts); if ~isempty(index) Analog_value(index)=-Volts; end Dig=round(Analog_value/vpb)*vpb; % Quantised Analog input samples_per_sec=length(Dig)/time_length; sample_step=samples_per_sec/Fs; if (sample_step<1) error('Cant interpolate'); end Digital_val=zeros(1,length(Dig)); Digital_val(1:sample_step:end)=Dig(1:sample_step:end); for i=1:sample_step:length(Digital_val) Digital_val(i:i-1+sample_step)=Digital_val(i); end Digital_value=Digital_val(1:length(Dig)); % Digitised analog input