summaryrefslogtreecommitdiff
path: root/3682/CH10/EX10.5/Ex10_5.sce
blob: 13f5389b9209e956acabd761b9f62e015bf6a929 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Exa 10.5

clc;
clear;

// Given data

// A 16bit dual slope ADC is specified
Va = 4.129; // Input analog Voltage 
Vr= 8; // Maximum integrator output voltage(Reference Voltage)
n=16; // 16 bit counter

// Solution

disp("Referring to Eqn 10.7 on page no. 365 we get,")
// Va = Vr*(N/2^n);
N = round(Va * 2^n / Vr); // Digital count
printf(' The digital count N = %d for which the binary equivalent = \n',N);

// code to convert decimal to binary weuivalent
Nbin = [0000000000000000];
while (N > 0 & n > 0)
    if (modulo(N,2)== 0)
        Nbin(n)=0;
    else
        Nbin(n)=1;
end
n=n-1;
N=int(N/2);
end
disp((Nbin)');