You are looking at the HTML representation of the XML format.
HTML is good for debugging, but is unsuitable for application use.
Specify the format parameter to change the output format.
To see the non HTML representation of the XML format, set format=xml.
See the complete documentation, or API help for more information.
<?xml version="1.0"?>
<api>
  <query-continue>
    <allpages gapcontinue="Reference_List" />
  </query-continue>
  <query>
    <pages>
      <page pageid="2600" ns="0" title="Real electronics">
        <revisions>
          <rev contentformat="text/x-wiki" contentmodel="wikitext" xml:space="preserve">[[Category:20.309]]
[[Category:Electronics]]
{{Template:20.309}}

Real electronics sometimes behave significantly different than the idealized models presented in lecture.

==Real power supplies==

[[Image:Real_Voltage_Source.png|thumb|600px|center]]

===Limits of ideal elements: more realistic model of a battery===

Recall the ideal ''i-v'' curves for our four elements, referring to Table 1 in the [[Electronics_Primer#Ideal lumped circuit elements|Electronics Primer]].

Let’s model a battery as an ideal voltage source connected to no other elements except ideal wires (Fig. 14). 

What is the current flowing through this circuit? The resistance of the wires is zero, implying that the current is infinite! Therefore this model, and the associated horizontal ''i-v'' curve, is not realistic.

{| class=&quot;figuretable&quot;
|- valign=&quot;bottom&quot;
|[[Image:309_epd_battery-as-simple-v-source.png|thumb|300 px|'''Figure 14: Model for ideal battery.''']]
|[[Image:309_epd_battery-model-port.png|thumb|300 px|'''Figure 15: More realistic battery model with access port.''']]
|}

Instead, let’s model the battery as having an internal resistance, &lt;math&gt;R_{BATT}&lt;/math&gt; (Fig. 15). To investigate the ''i-v'' curve, we’ll view the output port formed by nodes A and B. 

When the port is not connected to anything, resistance is infinite and current is zero. There is no load on the battery, and thus the output voltage at node A must be the full &lt;math&gt;V_{BATT}&lt;/math&gt;. This useful quantity is our by now familiar open circuit voltage, &lt;math&gt;V_{oc}&lt;/math&gt;.

Next, let’s attach a voltmeter to the port with an associated resistance &lt;math&gt;R_m&lt;/math&gt;. 

[[Image:309_epd_battery-model-voltmeter.png|thumb|center|300px|'''Figure 16: More realistic battery model with voltmeter attached.''']]

When we assume that &lt;math&gt;R_m = 0&lt;/math&gt;, &lt;math&gt;v_A&lt;/math&gt; is shorted to ground. Thus, the current ''i'' is at its maximum, namely the short circuit current:

&lt;math&gt;I_{sc} = \frac{V_{BATT}}{R_{BATT}}&lt;/math&gt;.

These two quantities define two points on our new, more realistic, ''i-v'' curve! Presumably a line connects them, but let’s prove it by solving this simple circuit. We’ll practice our systematic approach once again. 

The only unknown node voltage is &lt;math&gt;v_A&lt;/math&gt;. The other nodes are either ground or &lt;math&gt;V_{BATT}&lt;/math&gt; by definition of a perfect conductor. Hence we want to solve KCL at &lt;math&gt;V_{BATT}&lt;/math&gt;, substituting in the relevant &lt;math&gt;v=iR&lt;/math&gt; constitutive relations:

&lt;math&gt;i1 + i2 = 0 = \frac{9-v_A}{R_{BATT}} + \frac{0-v_A}{R_m} = 0&lt;/math&gt;  

and substituting for &lt;math&gt;R_m&lt;/math&gt; using &lt;math&gt;I = \frac{v_A}{R_m}&lt;/math&gt;

to simplify to &lt;math&gt;v_A = 9-I * R_{BATT}&lt;/math&gt;, 

indeed the equation of a line. 

[[Image:309_epd_battery-model-plot.jpg|thumb|center|400px|'''Figure 17: More realistic battery model: IV plot.''']]

From the model diagram, we see that a real battery only sources a full 9V when no load is applied. As current increases, supplied voltage decreases linearly, with negative slope equalling internal resistance. Here is just one simple example of how we can learn about a system by perturbing it -- whether theoretically or experimentally. In this case we found the function relating voltage and current by imagining putting a load on the battery. Note that the equation we found is ultimately ''not'' dependent on the resistance of this added load &lt;math&gt;R_m&lt;/math&gt;.

==Real voltage and current measurement devices==

An ideal voltage meter will allow no current to flow through it, but in practice, current can actually flow. A model of an ideal voltage meter includes a circuit element that records the voltage difference between its terminals in series with an infinitely large resistor. In practice, for example in the digital multi-meter (DMM) used in the lab, this series resistor is finite in size, typically on the order of 1 M&amp;Omega;, and is called the input impedance of the meter. Therefore, if the Thevenin Equivalent resistance of the circuit being measured is also on the order of 1 M&amp;Omega; then the in-practice model of the DMM must be employed in order to determine the actual output voltage of the circuit if the DMM were not connected. This is generally the desired voltage. An example will demonstrate the difference in behavior between the DMM and the ideal voltmeter.

==Real electronic breadboards==

At each tie point on the breadboard the connection between the wire or circuit element lead and the internal conductor of the breadboard is not perfect. The imperfection appears as both a parasitic resistance and a parasitic capacitance in series with the circuit element on the breadboard. The resistance can be on the order of 1 &amp;Omega; while the capacitance can be on the order of a few pF. Thus if the circuit design incorporates capacitance on this order or if the voltage drop caused by a parasitic 1 &amp;Omega; resistor is relevant, then either these non-idealities must be taken into account or the electronic breadboard must be abandoned in favor of another approach.

Breadboards are most commonly constructed on an anodized metal backboard. The anodization layer is very thin so if a wire or lead is long enough to contact the backboard then it can penetrate that layer and short to the backboard, which may be at ground or at some unknown floating potential.

On the back of the breadboard there are screws holding the banana terminals in place. On new breadboards these are held away from the work surface by rubber or plastic feet on the backboard. On our breadboards these feet have often long since parted company with the backboard. It is wise to cover the screws with a couple layers of electrical tape.

==Real capacitors==

Real capacitors include a small but sometimes relevant resistance in parallel with the ideal model of a capacitor. This resistance will be specified on the datasheet for the capacitor.

Electrolytic capacitors are generally polarized and cannot support large reverse currents. They should only be used for DC voltages with small AC fluctuations. If they are installed in reverse polarity then at best they will function poorly and start to stink as the rubber cap melts. At worst, they will fail catastrophically and &quot;You'll shoot your eye out&quot; with the metal can that used to contain a capacitor.&lt;ref&gt;For more information on why this is a bad thing, please watch [http://www.imdb.com/title/tt0085334/ ''A Christmas Story.'']&lt;/ref&gt; The negative terminal of the electrolytic capacitor will most often be marked by a thick minus sign (-) or a thick line running the length of the capacitor. Another variation is shown in the image below. Note in the top, axial, electrolytic capacitor the arrows indicate the direction of voltage ''drop''.

[[Image:Capacitors_electrolytic.jpg|300px|thumb|center|'''Typical electrolytic can-type capacitors''' This is generally the only type of electrolytic capacitor found in the 309 lab.]]

==Real op-amps==

[[Image:Real_Electronics_Op-amp_Model.png|thumb|center|600px|A model of an op-amp highlighting its behavior in practice.]]

Amplifiers using op-amps unfortunately do not follow the golden rules to the letter. The open-loop gain is not infinite. Therefore the difference between the input voltages is not zero and the current into or out of the inputs is not zero. A realistic model of an op-amp must incorporate a specification for the input offset voltage ''V&lt;sub&gt;OS&lt;/sub&gt;'', an internal voltage that adds to whatever voltage is externally applied to the input terminals V- and V+. The model also incorporates a bias current ''I&lt;sub&gt;B&lt;/sub&gt;'' for each input. These are close in real op-amps so the average is specified on the datasheet. However they are not perfectly matched and the difference is specified as the input offset current ''I&lt;sub&gt;OS&lt;/sub&gt;''. All of these non-idealities have the net effect of causing a non-zero voltage, sometimes large, at the output in a negative feedback implementation even when the input is zero. Luckily there are corrective actions available.

Most op-amps provide balance terminals to adjust the output voltage. On the LF411 these are pins 1 and 5. A voltage divider is connected across these terminals with the voltage divider output connected to the negative power terminal, pin 4. The correct divider resistances are not know ahead of time so this balancing act is usually done with a potentiometer, or ''pot''. The pot pins 1 and 3 (the first and last pins) are connected to op-amp pins 1 and 5, while pot pin 2 (the center pin) is connected to op-amp pin 4. It so happens that pots are rather noisy. So once the best balance is achieved with the pot, it can be disconnected and the resistances between pins 1 and 2 and between pins 2 and 3 may be measured. Then the voltage divider can be reconstructed using (high-precision if needed) fixed resistors.

==References==
&lt;references/&gt;

{{Template:20.309 bottom}}</rev>
        </revisions>
      </page>
      <page pageid="8549" ns="0" title="Recording, displaying and saving images in MATLAB">
        <revisions>
          <rev contentformat="text/x-wiki" contentmodel="wikitext" xml:space="preserve">&lt;figure id=&quot;fig:UsefulImageAcquisition&quot;&gt;
[[Image:UsefulImageAcquisiton.png|thumb|right|&lt;caption&gt;The UsefulImageAquisition window can be used to (hopefully) easily control the camera settings. To run it, type &quot;&lt;tt&gt;foo = UsefulImageAcquisition;
foo.Initialize&lt;/tt&gt;&quot; into the MATLAB console window.&lt;/caption&gt;]]
&lt;/figure&gt;

&lt;ol&gt;
&lt;li&gt; Run the &lt;tt&gt;UsefulAcquisition&lt;/tt&gt; tool
 &lt;ul&gt; &lt;li&gt; Launch MATLAB and in the command window type: &lt;/li&gt;
&lt;pre&gt;foo = UsefulImageAcquisition; 
foo.Initialize &lt;/pre&gt;
 &lt;li&gt; The Image Acquisition window (&lt;xr id=&quot;fig:UsefulImageAcquisition&quot; /&gt;) will open with the controls for the camera.&lt;/li&gt;
 &lt;li&gt; The &quot;Manta_G-032B&quot; CCD and &quot;Manta G-040&quot; CMOS cameras are configured to produce 12-bit, monochrome images. In this mode, the intensity of each pixel in the image will be represented by 12 binary digits, allowing a range of values from 0-4095.&lt;/li&gt;
 &lt;li&gt; In the Image Acquisition window set &quot;Frame Rate&quot; to 20. This will cause the camera to take 20 complete images per second (this will only be relevant when recording movies in Assignments 4 and 5 of the lab).&lt;/li&gt;
 &lt;li&gt; Click the &quot;Start Preview&quot; button. The live image from the camera should appear in the Preview pane.&lt;/li&gt;
 &lt;li&gt; If this does not produce a live image, use an appropriate expletive, and ask an instructor to figure out what the heck went wrong.&lt;/li&gt;
 &lt;li&gt; Change the &quot;Exposure&quot; setting to produce a good image. The value sets the exposure time for each frame in microseconds. &lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt; Recording an image 
&lt;ul&gt;&lt;li&gt; In the Image Acquisition window, set &quot;Number of Frames&quot; to 1. This setting controls how many images MATLAB will record each time you press the &quot;Acquire&quot; button.&lt;/li&gt;
&lt;li&gt; When you are happy with the image displayed by the live preview, press &quot;Acquire&quot;. The live preview will stop.&lt;/li&gt;
&lt;li&gt; The image is now stored in the &lt;tt&gt;foo.ImageData&lt;/tt&gt; variable, which will update each time you acquire a new image. To copy the data into a new variable, choose a descriptive name for your image like 'microruler10x' and save it to your workspace by typing the following into the MATLAB command window:&lt;/li&gt;
&lt;pre&gt;microruler10x = foo.ImageData;&lt;/pre&gt;
&lt;li&gt; Next, in the MATLAB command window type &lt;/li&gt;
&lt;pre&gt;whos microruler10x &lt;/pre&gt;
&lt;li&gt; This command will display relevant information about the new variable you’ve created. You should see that the image is represented as a 544x728 matrix of 16-bit integers.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt; Displaying the image
&lt;ul&gt;&lt;li&gt; You can display images using a variety of commands in MATLAB. In the optics bootcamp we used the &lt;tt&gt;imagesc&lt;/tt&gt; command which scales the image intensity (the brightest pixel is white, the darkest is black). In some cases, like when you have very dim images, this command can be misleading. It’s better to use the un-scaled &lt;tt&gt;imshow&lt;/tt&gt; command for quantitative measurements. &lt;/li&gt;
&lt;li&gt; When the 12-bit numbers from the camera get transferred to the computer, they are converted to 16-bit numbers. 16-bit numbers can represent a range of values from 0-65535, while your 12-bit image only contains values from 0-4095. This leaves a considerable portion of the number range unoccupied. Consequently, if you type &lt;tt&gt;imshow( microruler10x )&lt;/tt&gt;, you will see an image that looks almost completely black (try it!). &lt;/li&gt;
&lt;li&gt; One way to make this work is to rescale your image to 16 bits: &lt;tt&gt; imshow( 65535/4095 * microruler10x )&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt; An even better way to work with images in MATLAB is to convert them to [http://en.wikipedia.org/wiki/Double-precision_floating-point_format double precision floating point format] straightaway. Double precision floating point numbers can represent an extremely wide range of values with high precision. Convert the image to a double and rescale it using the following command:&lt;/li&gt;
&lt;pre&gt;microruler10x = double( microruler10x ) / 4095; &lt;/pre&gt;
&lt;li&gt; This conversion has made your image into a double with a range of intensities from 0-1, with 1 being full intensity and 0 completely dark. Now try: &lt;/li&gt;
&lt;pre&gt;whos microruler10x
imshow( microruler10x ) &lt;/pre&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt; Saving your image 
&lt;ul&gt;&lt;li&gt;Save images in a .mat format so that you can easily reload them into Matlab for later use. &lt;/li&gt;
&lt;pre&gt;
save microrulerImages     % saves entire workspace to filename 'microrulerImages.mat'
save microrulerImages image1 image2     %saves only variables image1 and image2 to filename 'microrulerImages.mat'&lt;/pre&gt;
&lt;li&gt; To reload your data the next time you open matlab, navigate to the folder where you saved your workspace, type &lt;/li&gt;
&lt;pre&gt;load microrulerImages &lt;/pre&gt;
&lt;li&gt; If you want to save individual images as a .PNG (a good format for use in your report or other programs), the command might look something like: &lt;/li&gt;
&lt;pre&gt;imwrite( im2uint16( microruler10x ), 'microruler10x.png', 'png' );&lt;/pre&gt;
&lt;li&gt; Note that you can also use the File&amp;rarr;Save As menu after displaying an image or figure. This is useful if you want to save additions to your images (like data cursors). However, we recommend always saving the raw data as .mat files so that you are able to re-process your images later. 
&lt;/ul&gt;&lt;/li&gt;
&lt;/ol&gt;</rev>
        </revisions>
      </page>
    </pages>
  </query>
</api>