summaryrefslogtreecommitdiff
path: root/3554/CH17/EX17.4/Ex17_4.sce
diff options
context:
space:
mode:
authorprashantsinalkar2017-10-10 12:27:19 +0530
committerprashantsinalkar2017-10-10 12:27:19 +0530
commit7f60ea012dd2524dae921a2a35adbf7ef21f2bb6 (patch)
treedbb9e3ddb5fc829e7c5c7e6be99b2c4ba356132c /3554/CH17/EX17.4/Ex17_4.sce
parentb1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (diff)
downloadScilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.gz
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.tar.bz2
Scilab-TBC-Uploads-7f60ea012dd2524dae921a2a35adbf7ef21f2bb6.zip
initial commit / add all books
Diffstat (limited to '3554/CH17/EX17.4/Ex17_4.sce')
-rw-r--r--3554/CH17/EX17.4/Ex17_4.sce22
1 files changed, 22 insertions, 0 deletions
diff --git a/3554/CH17/EX17.4/Ex17_4.sce b/3554/CH17/EX17.4/Ex17_4.sce
new file mode 100644
index 000000000..db85b5236
--- /dev/null
+++ b/3554/CH17/EX17.4/Ex17_4.sce
@@ -0,0 +1,22 @@
+// Exa 17.4
+
+clc;
+clear all;
+
+// Given data
+Vref=5;//Reference voltage(V)
+R=5;// k Ohms
+
+// Solution
+
+disp("From fig. 17.18(c) , for a 4-bit D/A converter I=Vref/R* (D3+D2*2^-1+D1*2^-2+D0*^-3)");
+//16-input combinations are as follows
+Ip={[0 0 0 0];[0 0 0 1];[0 0 1 0];[0 0 1 1];[0 1 0 0];[0 1 0 1];[0 1 1 0];[0 1 1 1];[1 0 0 0];[1 0 0 1];
+[1 0 1 0];[1 0 1 1];[1 1 0 0];[1 1 0 1];[1 1 1 0];[1 1 1 1]};//[D3 D2 D1 D0 bits]
+
+disp(" Input Bits Output Current(mA) percent Fraction of maximum ");
+for i=1:16
+Iout(i)=Vref/R * (Ip(i,1)+Ip(i,2)*2^-1+Ip(i,3)*2^-2+Ip(i,4)*2^-3);
+
+printf(' %d %d %d %d %.3f %.3f \n',Ip(i,1),Ip(i,2),Ip(i,3),Ip(i,4),Iout(i),(Iout(i)/1.875)*100);//1.875(mA) is the highest output current
+end