{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Chapter 5: Digital instrument Basics" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 5.1: high_and_low_output_voltages.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// to find the high and low output voltage values\n", "// example 5-1 in page 120\n", "clc;\n", "//Given data\n", "Vcc=5;// DC source in volts\n", "Io=1e-3;// output current= 1mA \n", "R1=1e+3;//R1=1K-ohm\n", "Vi=0;//lowest input voltage\n", "Vd=0.7;// silicon-diode drop in volts\n", "//calculation\n", "printf('High output voltage=%d V\n',Vcc-(Io*R1));\n", "printf('low output voltage=%.1f V\n',Vi+Vd);\n", "//result\n", "//High output voltage=4 V\n", "//low output voltage=0.7 V" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 5.2: collector_and_base_voltage.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// To find the collector and base voltages\n", "// example 5-2 in page 121\n", "clc;\n", "// Given data\n", "R1=15e+3; R2=27e+3; Rc1=2.7e+3; R11=R1; R21=R2; //resistance values in Ohm where R11=R1' and R21=R2'\n", "Vc2=0.2;// collector voltage of on transistor in volt\n", "Vce=Vc2;//collector-emitter saturation voltage in volt\n", "Vbb=-5;//dc power supply in volt\n", "Vcc=5;//dc power supply in volt\n", "//calculations\n", "Vr1r2=Vc2-Vbb;//voltage across Ri and R2 in volt\n", "Vr1=(R1/(R1+R2))*Vr1r2;// voltage across R1 resistor in volt\n", "Vb1=Vc2-Vr1;// base voltage\n", "printf('Vb1=%.1f V\n',Vb1);\n", "//with Q1 off\n", "Vrc1=(Rc1/(Rc1+R11+R21))*(Vcc-Vbb);\n", "Vc1=Vcc-Vrc1;// collector voltage in volt\n", "printf('Vc1=%.1f V',Vc1);\n", "//result\n", "//Vb1=-1.657143 V\n", "//Vc1=4.395973 V " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 5.3: supply_current_required.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//example 5-3 in page 124\n", "clc;\n", "// Given data\n", "// 3(1/2) digit display\n", "If1=20e-3;//forward current per segment of led=20 mA\n", "If2=300e-6;//forward current per segment of lcd\n", "//calculations\n", "for n=1:2\n", " if n==1\n", " I=If1;\n", " else I=If2;\n", " end\n", " It=3*7*I+2*I;// each digit has 7 segments and there are three digits with a half digit that has 2 segments\n", " printf('case %d,\n Total current=%.0f mA\n',n,It*1000);\n", "end\n", "//result\n", "// case 1,\n", "//Total current=0.460000 A\n", "//case 2,\n", "//Total current=0.006900 A\n", " " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 5.4: out_put_frequency.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// to find the out put frequency in fig 5-10\n", "// example 5-4 in page 130\n", "clc;\n", "//Given data\n", "To=1e-6;//oscillator time period=1 micro-second\n", "N=16;// modulus number of the counter = 16\n", "n=3;// number of counters\n", "//calculations\n", "T=To*(N^n);//out put time period\n", "printf('output frequency=%d hertz',1/T);//output frequency\n", "//result\n", "//output frequency=244 hertz " ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 5.5: number_of_clock_pulses_counted.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "//To find the number of pulses counted\n", "//example5-5 in page 131\n", "clc;\n", "//data given\n", "Vr=1.25;//peak voltage of ramp in volts\n", "tr=125e-3;//time period of the ramp=1.25 ms\n", "T=1/(1e+6);// frequency =1 Mhz and time period of the clock pulses is 1/f\n", "for Vi=0.75:(0.9-0.75):0.9,// analog input voltages for which clock pulses has to b found\n", " t1=(tr/Vr)*Vi;//time period of the comparator high out put\n", " N=t1/T;// pulses counted\n", " printf('number of pulses counted for Vi=%.2f V are %d\n',Vi,N/100);\n", "end\n", "//result\n", "//number of pulses counted for Vi=0.750000 V are 750\n", "//number of pulses counted for Vi=0.900000 V are 900" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 5.6: number_of_output_bits_required.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// example 5-6 in page 133\n", "clc;\n", "//Given data\n", "//error should be less thsn 1%\n", "// for less than 1% error count>=100\n", "n=6;\n", "N=0;\n", "while(N<100)\n", "N=(2^n)-1;//count value\n", "if(N<100)\n", "n=n+1;//increment n and check weather N has exceeded 100\n", "end\n", "end\n", "printf('for less 1percent error,use n=%d\n',n);\n", "//end\n", "// for less 1percent error,use n=7" ] } , { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 5.7: output_voltage_of_DAC.sce" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "// example 5-7 in page 135\n", "clc;\n", "//Given data\n", "D=8; C=0; B=2; A=0; //corresponding analog input voltages for the digital input 1-0-1-0\n", "Vi=10;//input voltage in volts\n", "//calculation\n", "Vo=(D+C+B+A)*Vi/16;// output voltage\n", "printf('out put voltage=%.2f V',Vo);\n", "//result\n", "//out put voltage=6.25 V " ] } ], "metadata": { "kernelspec": { "display_name": "Scilab", "language": "scilab", "name": "scilab" }, "language_info": { "file_extension": ".sce", "help_links": [ { "text": "MetaKernel Magics", "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md" } ], "mimetype": "text/x-octave", "name": "scilab", "version": "0.7.1" } }, "nbformat": 4, "nbformat_minor": 0 }