blob: f5403b3ff9db6daefa9c4f25b5eb50b22efe7ba7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
//To find the number of pulses counted
//example5-5 in page 131
clc;
//data given
Vr=1.25;//peak voltage of ramp in volts
tr=125e-3;//time period of the ramp=1.25 ms
T=1/(1e+6);// frequency =1 Mhz and time period of the clock pulses is 1/f
for Vi=0.75:(0.9-0.75):0.9,// analog input voltages for which clock pulses has to b found
t1=(tr/Vr)*Vi;//time period of the comparator high out put
N=t1/T;// pulses counted
printf("number of pulses counted for Vi=%.2f V are %d\n",Vi,N/100);
end
//result
//number of pulses counted for Vi=0.750000 V are 750
//number of pulses counted for Vi=0.900000 V are 900
|