tag:blogger.com,1999:blog-59221200830834558392024-02-19T00:58:14.821-08:00Mechanical Engineering.mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comBlogger61125tag:blogger.com,1999:blog-5922120083083455839.post-88166255046667611672014-10-20T00:46:00.007-07:002022-09-07T08:38:20.384-07:00Crankshaft Manufacturing Process<div align="justify">
</div>
<div align="justify">
<b><br /> Crankshaft Manufacturing Process</b></div><div align="justify"><b> </b></div><div align="justify"><b>Introduction</b> </div>
<div align="justify">
The crankshaft is located in the engine of a vehicle and converts the force created by the engine's pistons moving up and down into a force that moves the wheels in a circular motion so the car can go forward. Located inside the car's engine, it is connected to all the pistons in the engine and to the flywheel. To understand this shaft, it is important to understand how the pistons and the flywheel work.</div><div align="justify"> </div><div align="justify"><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: center;"> </div>
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='326' height='266' src='https://www.blogger.com/video.g?token=AD6v5dxM0Gsg_GGpCrdnN_ogpoAM-aZ_aWYS-FHwImG_m7Hq1bbHDubmHDDy-p1E0aPSTxGGyeOorz8qVf9S5SxfRA' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div>
<br />
A car engine produces motion by creating explosions inside it. The pistons, which are attached to the crankshaft in an engine, are moved up by the explosions inside the cylinders. As the shaft turns, it pushes those pistons back down, so that the next explosion can push it up again and start the cycle over again. The pistons are connected to the crankshaft to ensure it moves with them and keeps their movements regulated. </div>
<div align="justify">
As there are few methods of manufacturing a crankshaft, this report explains how BILLET CRANKSHAFTS are manufactured.<br />
<br />
<br /></div>
<div align="justify">
<b>FORCES IMPOSED ON A CRANKSHAFT</b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
The obvious source of forces applied to a crankshaft is the product of combustion chamber pressure acting on the top of the piston. High-performance, normally-aspirated Spark-ignition (SI) engines can have combustion pressures in the 100-bar neighbourhood (1450 psi), while contemporary high-performance Compression-Ignition (CI) engines can see combustion pressures in excess of 200 bar (2900 psi). A pressure of 100 bar acting on a 4.00 inch diameter piston will produce a force of 18,221 pounds. A pressure of 200 bar acting on a 4.00 inch diameter piston produces a force of 36,442 pounds. That level of force exerted onto a crankshaft rod journal produces substantial bending and torsional moments and the resulting tensile, compressive and shear stresses. </div>
<div align="justify">
However, there is another major source of forces imposed on a crankshaft, namely <a href="http://www.epi-eng.com/piston_engine_technology/piston_motion_basics.htm#accel">PistonAcceleration</a>. The combined weight of the piston, ring package, wristpin, retainers, the connecting rod small end and a small amount of oil are being continuously accelerated from rest to very high velocity and back to rest twice each crankshaft revolution. Since the force it takes to accelerate an object is proportional to the weight of the object times the acceleration (as long as the mass of the object is constant), many of the significant forces exerted on those reciprocating components, as well as on the connecting rod beam and big-end, crankshaft, crankshaft, bearings, and engine block are directly related to piston acceleration. </div>
<div align="justify">
So due to these many forces acting on this single component it makes one of the main force bearing components in an engine, making its’ production process very important and the need to be precise and accurate. </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<h5 align="justify">
</h5>
<h5 align="justify">
</h5>
<h5 align="justify">
CRANKSHAFT MATERIALS</h5>
<h5 align="justify">
</h5>
<div align="justify">
<div class="separator" style="clear: both; text-align: center;"><br /></div>
The steel alloys typically used in high strength crankshafts have been selected for what each designer perceives as the most desirable combination of properties. <b>The table below </b>shows the nominal chemistries of the crankshaft alloys discussed here. </div>
<div align="justify">
Medium-carbon steel alloys are composed of predominantly the element iron, and contain a small percentage of carbon (0.25% to 0.45%, described as ‘25 to 45 points’ of carbon), along with combinations of several alloying elements, the mix of which has been carefully designed in order to produce specific qualities in the target alloy, including hardenability, nitridability, surface and core hardness, ultimate tensile strength, yield strength, endurance limit (fatigue strength), ductility, impact resistance, corrosion resistance, and temper-embrittlement resistance. The alloying elements typically used in these carbon steels are manganese, chromium, molybdenum, nickel, silicon, cobalt, vanadium, and sometimes aluminium and titanium. Each of those elements adds specific properties in a given material. The carbon content is the main determinant of the ultimate strength and hardness to which such an alloy can be heat treated. </div>
<div align="justify">
<b>Chemistry of crankshaft Alloys</b> </div>
<div align="justify">
<b>Nominal Percentages of Alloying Elements</b></div>
<div align="justify">
<br /></div>
<iframe border="0" frameborder="0" height="60" marginwidth="0" scrolling="no" src="//rcm-na.amazon-adsystem.com/e/cm?o=1&p=26&l=ur1&category=automotive&banner=0W3P18V56AB627JPPE02&f=ifr&linkID=5a582391ab479f4e9e255df20a3306c3&t=ishan07-20&tracking_id=ishan07-20" style="border: none;" width="468"></iframe>
<br />
<div align="justify">
<table border="1" cellpadding="0" cellspacing="0"> <tbody>
<tr> <td valign="top" width="79"><h4>
<b><span style="color: blue;">Material</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">AMS</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">C</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">Mn</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">Cr</span></b></h4>
</td> <td valign="top" width="66"><h4>
<b><span style="color: blue;">Ni</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">Mo</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">Si</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">V</span></b></h4>
</td></tr>
<tr> <td valign="top" width="79"><h4>
<b><span style="color: blue;">4340</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">6414</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.40</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.75</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.82</span></b></h4>
</td> <td valign="top" width="66"><h4>
<b><span style="color: blue;">1.85</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.25</span></b></h4>
</td> <td valign="top" width="65"><b><span style="color: blue;"></span></b><br /></td> <td valign="top" width="65"><b><span style="color: blue;"></span></b><br /></td></tr>
<tr> <td valign="top" width="79"><h4>
<b><span style="color: blue;">EN-30B</span></b></h4>
</td> <td valign="top" width="65"><b><span style="color: blue;"></span></b><br /></td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.30</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.55</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">1.20</span></b></h4>
</td> <td valign="top" width="66"><h4>
<b><span style="color: blue;">4.15</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.30</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.22</span></b></h4>
</td> <td valign="top" width="65"><b><span style="color: blue;"></span></b><br /></td></tr>
<tr> <td valign="top" width="79"><h4>
<b><span style="color: blue;">4330-M</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">6427</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.30</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.85</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.90</span></b></h4>
</td> <td valign="top" width="66"><h4>
<b><span style="color: blue;">1.80</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.45</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.30</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.07</span></b></h4>
</td></tr>
<tr> <td valign="top" width="79"><h4>
<b><span style="color: blue;">32-CrMoV-13</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">6481</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.34</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.55</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">3.00</span></b></h4>
</td> <td valign="top" width="66"><h4>
<b><span style="color: blue;"><0.30</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.90</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.25</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.28</span></b></h4>
</td></tr>
<tr> <td valign="top" width="79"><h4>
<b><span style="color: blue;">300-M</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">6419</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.43</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.75</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.82</span></b></h4>
</td> <td valign="top" width="66"><h4>
<b><span style="color: blue;">1.85</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.40</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">1.70</span></b></h4>
</td> <td valign="top" width="65"><h4>
<b><span style="color: blue;">0.07</span></b></h4>
</td></tr>
</tbody></table>
</div>
<h5 align="justify">
</h5>
<div align="justify">
Key: C = Carbon Mn = Manganese Cr = Chromium Ni = Nickel </div>
<div align="justify">
Mo = Molybdenum Si = Silicon V = Vanadium AMS = Aircraft Material spec number </div>
<h5 align="justify">
CRANKSHAFT MANUFACTURING PROCESSES</h5>
<div align="justify">
<b></b> </div>
<div align="justify">
Crankshafts at the upper end of the motorsport spectrum are manufactured from billet. Billet crankshafts are fully machined from a round bar ("billet") of the selected material (<b>Figure 1</b>). This method of manufacture provides extreme flexibility of design and allows rapid alterations to a design in search of optimal performance characteristics. In addition to the fully-machined surfaces, the billet process makes it much easier to locate the counterweights and journal webs exactly where the designer wants them to be. This process involves demanding machining operations, especially with regard to counterweight shaping and undercutting, rifle-drilling main and rod journals, and drilling lubrication passages. The availability of multi-axis, high-speed, high precision CNC machining equipment has made the carved-from-billet method quite cost-effective, and, together with exacting 3D-CAD and FEA design methodologies, has enabled the manufacture of extremely precise crankshafts which often require very little in the way of subsequent massaging for balance purposes. </div>
<div align="justify">
<a href="http://lh4.ggpht.com/-Z6SlzbeTPjg/VES9faw2-OI/AAAAAAAAGSY/0GjFGk19QcQ/s1600-h/image%25255B5%25255D.png"><img alt="image" border="0" height="464" src="https://lh6.ggpht.com/-j8JjpgRIjgE/VES9iHxF8oI/AAAAAAAAGSg/rQSbpCLrOaw/image_thumb%25255B3%25255D.png?imgmax=800" style="border-bottom: 0px; border-color: currentcolor; border-left: 0px; border-right: 0px; border-style: none; border-top: 0px; border-width: 0px; display: inline;" title="image" width="599" /></a> </div>
<div align="justify">
</div>
<h3 align="justify">
Manufacturing Process ofBillet Crankshafts Explained</h3>
<div align="justify">
Great care must be observed in the manufacture of the crankshaft since it is the most important part of the engine. While machining, the shaft must be properly supported between centres and special precautions should be taken to avoid springing. The journals and the crank pins are ground to exact size after turning. After this, the crankshaft is balanced. Large shafts of low speed engines are balanced statically. Crankshafts of high speed engines are balanced dynamically on special balancing machines. Most crankshafts are ground at the journals and crankpins. In some cases, grinding is followed by hand lapping with emery cloth.<br />
Crankshaft used in high production automotive engines may be either billet, forged or cast. </div>
<div align="justify">
High strength steels are carefully refined so as to remove as many of the undesirable impurities as possible (sulphur, phosphorous, calcium, etc.) and to more tightly constrain the tolerances, which define the allowable variations in the percentage of alloying elements. The highest quality steels are usually specified and ordered by reference to their AMS number (Aircraft Material Specification). These specs tightly constrain the chemistry, and the required purity can often only be achieved by melting in a vacuum, then re-melting in a vacuum to further refine the metal. Typical vacuum-processing methods are <b>VIM</b> and <b>VAR</b>. </div>
<div align="justify">
</div>
<h4 align="justify">
What is VIM?</h4>
<div align="justify">
<b></b> </div>
<div align="justify">
Vacuum Induction Melting (VIM) is a process for producing very high purity steels by melting the materials by induction heating inside a high-vacuum chamber. </div>
<div align="justify">
</div>
<h4 align="justify">
What is VAR?</h4>
<div align="justify">
<b></b> </div>
<div align="justify">
Vacuum Arc re-melting (VAR) is a refining process in which steels are re-melted inside a vacuum chamber to reduce the amount of dissolved gasses in the metal. Heating is by means of an electric arc between a consumable electrode and the ingot. </div>
<div align="justify">
There are other ultra-high-strength steels that are not carbon steels. These steels, known as "maraging" steels, are refined so as to remove as much of the carbon as possible, and develop their extreme strength and fatigue properties as a by-product of the crystalline structures resulting from the large amounts of nickel (15% and up) and cobalt (6% and up) they contain. These steels can achieve extreme levels of strength and maintain excellent levels of impact resistance. Maraging alloys are not currently (2008) used for racing crankshafts but they have been used in certain extreme application connecting rods. </div>
<div align="justify">
In the high performance crankshaft world, the nickel-chrome-moly alloy SAE-4340 (AMS-6414) has been a favourite in both forged and billet applications. It is used because of its very high strength and fatigue properties, coupled with good ductility and impact resistance at high strengths. SAE-4340 contains a nominal 40 points of carbon and is often described as <i>"the standard to which other ultra-high strength alloys are compared"</i>. </div>
<div align="justify">
Basic Steps of Manufacturing a Billet Crankshaft </div>
<ol>
<li> <div align="justify">
· Cutting to length and centering</div>
</li>
<li> <div align="justify">
· Turning</div>
</li>
<li> <div align="justify">
· Turnbroaching</div>
</li>
<li> <div align="justify">
· Turn-turnbroaching</div>
</li>
<li> <div align="justify">
· Internal milling</div>
</li>
<li> <div align="justify">
· High speed external milling</div>
</li>
<li> <div align="justify">
· Oil hole drilling</div>
</li>
<li> <div align="justify">
· Roller burnishing</div>
</li>
<li> <div align="justify">
· End machining</div>
</li>
</ol>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b>Manufacturing Process Explained Graphically</b> </div>
<div align="justify">
<b>1) Shaping on the lathe – This process shaves the journals leaving a margin of finishing</b> </div>
<div align="justify">
<a href="http://lh5.ggpht.com/-tXyK58roDmI/VES9i7-xpxI/AAAAAAAAGSo/qNDwoUjowYs/s1600-h/image%25255B9%25255D.png"><img alt="image" border="0" height="186" src="https://lh3.ggpht.com/-3_OmWRA8YfE/VES9kN9KyeI/AAAAAAAAGSw/mqQ3d4TDB0Y/image_thumb%25255B5%25255D.png?imgmax=800" style="border-bottom: 0px; border-color: currentcolor; border-left: 0px; border-right: 0px; border-style: none; border-top: 0px; border-width: 0px; display: inline;" title="image" width="526" /></a> </div>
<div align="justify">
<b>2) Process to mill the pin - This process shaves the weight part coarsely, and shaves the pins leaving a margin of finishing.</b> </div>
<div align="justify">
<a href="http://lh4.ggpht.com/-0iQugdvFqxo/VES9k2w4zPI/AAAAAAAAGS4/RKVN-OCPo64/s1600-h/image%25255B13%25255D.png"><img alt="image" border="0" height="192" src="https://lh5.ggpht.com/-Tg_58U4kmno/VES9l3yVDLI/AAAAAAAAGTA/WVNn7CsKUaI/image_thumb%25255B7%25255D.png?imgmax=800" style="border-bottom: 0px; border-color: currentcolor; border-left: 0px; border-right: 0px; border-style: none; border-top: 0px; border-width: 0px; display: inline;" title="image" width="543" /></a> </div>
<div align="justify">
<b>3) The process to mill the weight - In order to make it the form of a crank shaft, the outside portion of weight and superfluous portion are shaved.</b> </div>
<div align="justify">
</div>
<div align="justify">
</div>
<div align="justify">
<a href="http://lh4.ggpht.com/-dRYifjGSCz0/VES9msXpX5I/AAAAAAAAGTI/JrSSIP6gbBQ/s1600-h/image%25255B17%25255D.png"><img alt="image" border="0" height="196" src="https://lh3.ggpht.com/-WOpnk-Xsdy0/VES9n7tznoI/AAAAAAAAGTQ/B1vApqQh5pY/image_thumb%25255B9%25255D.png?imgmax=800" style="border-bottom: 0px; border-color: currentcolor; border-left: 0px; border-right: 0px; border-style: none; border-top: 0px; border-width: 0px; display: inline;" title="image" width="557" /></a> </div>
<div align="justify">
<b>4) Conditioning quality and shot peening - Internal stress is removed, the structure is stabilized and hardness is set to HRC 28-32.</b> </div>
<div align="justify">
<a href="http://lh5.ggpht.com/-jSiCBa6Mhvk/VES9omk6owI/AAAAAAAAGTY/yZ33dcyssSI/s1600-h/image%25255B21%25255D.png"><img alt="image" border="0" height="199" src="https://lh5.ggpht.com/-SPH-hwgemcM/VES9pjQmzLI/AAAAAAAAGTg/OEBvJF0Volg/image_thumb%25255B11%25255D.png?imgmax=800" style="border-bottom: 0px; border-color: currentcolor; border-left: 0px; border-right: 0px; border-style: none; border-top: 0px; border-width: 0px; display: inline;" title="image" width="572" /></a> </div>
<div align="justify">
<b>5) Shaping on the lathe for the 2<sup>nd</sup> time - This process shaved the journals leaving a margin of polishing.</b> </div>
<div align="justify">
<a href="http://lh6.ggpht.com/-xMl1x6JQAww/VES9qe5Q1FI/AAAAAAAAGTo/e88K4bu8xsU/s1600-h/image%25255B26%25255D.png"><img alt="image" border="0" height="210" src="https://lh4.ggpht.com/-DUKEW_5S9uY/VES9rS3m_hI/AAAAAAAAGTw/QnjNNQDsKuU/image_thumb%25255B14%25255D.png?imgmax=800" style="border-bottom: 0px; border-color: currentcolor; border-left: 0px; border-right: 0px; border-style: none; border-top: 0px; border-width: 0px; display: inline;" title="image" width="584" /></a> </div>
<div align="justify">
<b>6) Process to mill the pin - This process shaved the pins leaving a margin of polishing</b> </div>
<div align="justify">
<a href="http://lh5.ggpht.com/-4Ru9lumdYhQ/VES9sDZwI5I/AAAAAAAAGT4/ZoOic4XD1mY/s1600-h/image%25255B31%25255D.png"><img alt="image" border="0" height="215" src="https://lh6.ggpht.com/-_SC5GKEFhhQ/VES9tOYVPmI/AAAAAAAAGUA/ISrJvuViiy0/image_thumb%25255B17%25255D.png?imgmax=800" style="border-bottom: 0px; border-color: currentcolor; border-left: 0px; border-right: 0px; border-style: none; border-top: 0px; border-width: 0px; display: inline;" title="image" width="598" /></a> </div>
<div align="justify">
<b>7) The oil hole, the key slot, and the bolt hole processing - This process made the oil holes, the key slots, the pulley bolt holes, and the flywheel bolt holes.</b> </div>
<div align="justify">
</div>
<div align="justify">
<a href="http://lh6.ggpht.com/-_lBdkc8Iopk/VES9uOR1TyI/AAAAAAAAGUI/u7QetREoeTs/s1600-h/image%25255B36%25255D.png"><img alt="image" border="0" height="219" src="https://lh3.ggpht.com/-_LrdD_PFVJ4/VES9vJhyaFI/AAAAAAAAGUQ/J2Lbomn4vnw/image_thumb%25255B20%25255D.png?imgmax=800" style="border-bottom: 0px; border-color: currentcolor; border-left: 0px; border-right: 0px; border-style: none; border-top: 0px; border-width: 0px; display: inline;" title="image" width="609" /></a></div>
<b></b> <br />
<div align="justify">
<b> 8) The pin and the journal polishing process - This process polished the journals and the crank pins.</b></div>
<div align="justify">
<a href="http://lh3.ggpht.com/-dn0t4WMBtmM/VES9wGXa34I/AAAAAAAAGUY/nW8zrJOvmrU/s1600-h/image%25255B40%25255D.png"><img alt="image" border="0" height="216" src="https://lh6.ggpht.com/-xzNM33yjBxI/VES9xAOhGaI/AAAAAAAAGUg/807GFBDAL9Q/image_thumb%25255B22%25255D.png?imgmax=800" style="border-bottom: 0px; border-color: currentcolor; border-left: 0px; border-right: 0px; border-style: none; border-top: 0px; border-width: 0px; display: inline;" title="image" width="621" /></a> </div>
<div align="justify">
<b>9) The dynamic balance adjustment process - In order to suppress oscillating of a crank as much as possible, the balance of a crank simple substance is measured and balance processing is performed.</b> </div>
<div align="justify">
<b>10) The pin and the journal wrapping process - This process is to improve the degree of true circle and surface roughness in order to gain smooth rotation and reduction of friction.</b> </div>
<div align="justify">
<b>11) The surface treatment process - Surface strength, durability of friction, and fatigue strength of the surface are improving. The surface becomes black by the surface treatment.<br />(There is effect which helps early fitting.)</b></div>
<div align="justify">
<b>12) The final wrapping, bend correction, and inspection process - After the last wrapping, the bend which causes vibration is corrected. It is inspected after bend correction.</b> </div>
<div align="justify">
<b></b> </div>
<h2 align="justify">
Quality Consideration</h2>
<h5 align="justify">
</h5>
<div align="justify">
The difference between cast iron and nodular cast iron is the shape of the graphite particles in the iron. Cast iron is not just iron, pure iron is too soft to be used as a crankshaft. In regular cast iron, the graphite particles are flakes. In nodular cast iron, they are spherical nodules. This gives the cast iron more strength and flexibility. </div>
<div align="justify">
To make billet crankshafts, a much larger bar of steel is forged into a cylinder shape as large as the total diameter of the finished crank, then it is machined to the final shape. As you can imagine that is a lot more machining and final cost reflects this. </div>
<div align="justify">
<a href="http://lh5.ggpht.com/-_Hn53GiCSw4/VES9yMKMJgI/AAAAAAAAGUo/jydjtxm_3Gk/s1600-h/image%25255B45%25255D.png"><img alt="image" border="0" height="455" src="https://lh3.ggpht.com/-xDJL4SELMk8/VES9zRVBsGI/AAAAAAAAGUw/WSlPlfWL0OE/image_thumb%25255B25%25255D.png?imgmax=800" style="border-bottom: 0px; border-color: currentcolor; border-left: 0px; border-right: 0px; border-style: none; border-top: 0px; border-width: 0px; display: inline;" title="image" width="591" /></a> </div>
<div align="justify">
Cast crank on the left and Billet crank on the right </div>
<div align="justify">
One thing to think about is that depending on the alloy used, a cast steel crank can be almost as strong as a forged crank. </div>
<div align="justify">
There is a theory that while forging aligns the crystals of the steel, all the bending that is needed to make the final shape breaks some of those. Versus the billet, that while it doesn’t use as much pressure as forging and doesn’t produce as tight of a grain, it isn’t disrupted by bending. Instead it is machined to the final shape. </div>
<div align="justify">
<b>Tooling Required</b> </div>
<div align="justify">
To produce a crankshaft there are few main tools required: </div>
<div align="justify">
1) Lathe machine – this machine is mainly used when manufacturing billet crankshafts as it requires heavy machining. </div>
<div align="justify">
2) Shaper – to shape, oil lubrication paths </div>
<div align="justify">
3) Precision Drills - to create hole to make sure oil goes through the crankshaft to keep it lubricated, so to cool. </div>
<div align="justify">
4) Milling machine – a part of machining process to finalise/shape the crankshaft. </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b>Possible Defects in Manufacturing</b></div>
<div align="justify">
<br /></div>
<div align="justify">
<table border="0" cellpadding="0" cellspacing="0"> <tbody>
<tr> <td><h3>
<b><span style="color: blue;">Defect</span></b></h3>
</td> <td><h3>
<b><span style="color: blue;">Causes</span></b></h3>
</td></tr>
<tr> <td valign="top"><h5>
<span style="color: blue;">Errors occurred by worn lathe machines</span></h5>
</td> <td valign="top"><h5>
<span style="color: blue;">· Journals or other parts could differ in size from each other and could cause the crankshaft produce a imbalance cycle.</span></h5>
</td></tr>
<tr> <td valign="top"><h5>
<span style="color: blue;">A defected billet</span></h5>
</td> <td valign="top"><h5>
<span style="color: blue;">· The final product together will fail in an engine due to lack of strength.</span></h5>
</td></tr>
<tr> <td valign="top"><h5>
<span style="color: blue;">Human error</span></h5>
</td> <td valign="top"><h5>
<span style="color: blue;">· Product failure</span></h5>
</td></tr>
<tr> <td valign="top"><h5>
<span style="color: blue;">Too much allowance</span></h5>
</td> <td valign="top"><h5>
<span style="color: blue;">· Fittings won’t fit or will run with high friction producing more wear, tear and heat.</span><a href="https://www.blogger.com/null" name="_GoBack"></a></h5>
</td></tr>
</tbody></table>
</div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
<b>Conclusion</b> </div>
<div align="justify">
<b></b> </div>
<div align="justify">
From all of the above we can conclude that for a better finish and accuracy billet crankshafts are the best, while forged crankshafts can be used for heavy duty purposes. Cast crankshafts are suitable for day today use. </div>
<div align="justify">
Though billet crankshafts take time and money to be manufactured they are the most effective crankshafts out in the engineering field. Not to count out the accuracy, precision, ability to customize counter weights without mouldings and most importantly the whole crankshaft is one whole product.</div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-47119630909063763122014-10-20T00:01:00.001-07:002019-09-16T21:48:31.909-07:00Manufacturing process of Ductile Pipes by the process of Casting<h4>
</h4>
<h4>
Manufacturing process of Ductile Pipes by the process of Casting</h4>
<a href="http://lh4.ggpht.com/-XxX2dsjOJ84/VESy2N4DLxI/AAAAAAAAGPQ/HJ_1veCkSn4/s1600-h/image%25255B7%25255D.png"><img alt="image" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9CCo9b_e9HVnynePqulZuFWkHKscNf2E6Uh5QBpobwN4EA43RVZtg088Lu_fcWpZ29eYlwWbkzpHY5anYXMg2p5SxRTTsX5JwRBueP2OdC5yThGNehg3BiIEAvti1kOw5LMMKsx66Zms/?imgmax=800" height="231" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="image" width="447"></a><br />
<h4>
Introduction</h4>
<iframe src="//rcm-na.amazon-adsystem.com/e/cm?o=1&p=12&l=ur1&category=3dprint&banner=07DX77RXAPBWNNBR1WR2&f=ifr&linkID=74cb7fcc27de95b67b17ec0ebca145cd&t=ishan07-20&tracking_id=ishan07-20" width="300" height="250" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>
<div align="justify">
The term Ductile refers to the ability of a metal to undergo deformation before failure or the ability to be stretched in to wires. Ductile pipes are used heavily in the world today and are key components in the water supply infrastructure. </div>
<div align="justify">
The underground pipes that transport cities drinking water and the sewer pipes that take away the household waste are casted from ductile iron because it is more flexible than the ordinary gray ironunder pressure so, it will bend before it breaks. Different types of ductile iron water pipes photo(2012) is shown below as an example. </div>
<div align="justify">
<a href="http://lh6.ggpht.com/-8BC6PU9Lf28/VESy4glTTII/AAAAAAAAGPg/V2o5YoldlgQ/s1600-h/image%25255B17%25255D.png"><img alt="image" border="0" src="https://lh3.ggpht.com/-AXisKGemHys/VESy6hJ05CI/AAAAAAAAGPo/cg3iW8hU6L4/image_thumb%25255B11%25255D.png?imgmax=800" height="212" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="596"></a> </div>
<div align="justify">
Since ductile iron pipes are mostly fitted underground, they have to be manufactured in such a way to withstand pressure and overcome </div>
<div align="justify">
</div>
<div align="justify">
corrosion etc. Therefore, these pipes are manufactured using quality standards and have gone various types of tests before finally launching the product in to the market. </div>
<div align="justify">
In this report, you will get a brief idea about the manufacturing process of Ductile Iron Pipes that utilizes the process “casting” for its manufacture. You will also get an idea about the materials used for the pipes, the machines involved, the tools required, quality considerations andpossible defects that arise during product’s manufacture. </div>
<div align="justify">
</div>
<h4>
What is ductile iron?</h4>
<div align="justify">
Ductility refers to the ability of a metal to deform before breaking or can be simply stated as the ability of a component to be stretched in to wires. Ductile iron basically consists of various materials that can be produced to have a wide range of properties. Adding a small amount of magnesium or cerium to gray iron before casting produces a distinctly different microstructure and set of mechanical properties. </div>
<div align="justify">
Instead of forming flakes, graphite still forms as sphere like particles or nodules and the resulting alloy is called <u>nodular</u> or <u>ductile iron. </u>The image below is shown to get a close view of the graphite form inductile iron. </div>
<div align="center">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEir-cPU1fRSuqEYABG2Mo45kyxZrEVDq7IlDjElAs156vlw1g-hEDPOCeUmpZZfqk4VdGx7UJBLMYu5XxtIJCNCSn0wY-QmAqaS4Yv3ilvkKFKklpx1ggu2BRbGAL6Pc5byad_3S3WdgPE/s1600-h/image%25255B21%25255D.png"><img alt="image" border="0" src="https://lh3.ggpht.com/-vezUUECdEWo/VESy8fohGCI/AAAAAAAAGP4/GAALUBi8LF4/image_thumb%25255B13%25255D.png?imgmax=800" height="285" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: block; float: none; margin-left: auto; margin-right: auto;" title="image" width="311"></a>Photomicrograph Showing Graphite Form in Ductile Iron </div>
<iframe src="//rcm-na.amazon-adsystem.com/e/cm?o=1&p=13&l=ur1&category=software&banner=19B9W0V74Z9KV3E29MR2&f=ifr&linkID=5d3515759817baf608cd699ea612f2d4&t=ishan07-20&tracking_id=ishan07-20" width="468" height="60" scrolling="no" border="0" marginwidth="0" style="border:none;" frameborder="0"></iframe>
The manufacture of iron pipes in the UK has undergone 3 major changes in the last century and these are summarized below (UK water industry, 2006). <br />
Grey cast iron (vertically cast) -> 1920s <br />
Grey cast iron (spun) 1920s – 1960s <br />
Ductile cast iron (spun) –> 1960s <br />
<br />
<h4>
Why choose ductile iron pipes?</h4>
Ductile iron is a development of an earlier cast iron pipe that has superseded due to its many advantages as follows, <br />
<ul>
<li>· Ductile iron has excellent mechanical properties under the influence of forces, such as high resistance to tensile stresses and high impacts.</li>
<li>· Above and below ground applications.</li>
<li>· Conservation of energy and low pumping costs.</li>
<li>· Extensive size ranges.</li>
<li>· Assured long term reliability and single rated system. </li>
<li>· Installations and testing are easy.</li>
<li>· Tolerates ground movement.</li>
<li>· Different pressure capabilities and high safety factor.</li>
<li>· Gives constant performance in hydraulics flow.</li>
<li>· Corrosion is less.</li>
<li>· Surge resistance.</li>
</ul>
<b>Following information shows the typical properties of ductile iron pipe. (Electro steel castings ltd, 2012).</b> <br />
Properties of Ductile Iron Pipe <br />
Tensile strength (min): 420 MPa <br />
Elongation (min) at break 10 % <br />
Coefficient of thermal expansion 11x10-6 per oC <br />
Modulus of elasticity 1.7x1010 kg/m2 <br />
Hardness (max): 230 BHN <br />
Density: 7050 kg/m3 <br />
Bending/Beam strength Over 200 MPa (appx). <br />
Factor of safety against bursting is 8 to 10. <br />
<br />
<h4>
Reasons why we have chosen ductile iron instead of gray iron</h4>
<br />
<u></u> <table border="0" cellpadding="0"> <tbody>
<tr> <td><b><span style="color: #8000ff;">Advantages</span></b></td> <td><b><span style="color: #8000ff;">Disadvantages</span></b></td></tr>
<tr> <td valign="top"><span style="color: #8000ff;">· Greater ductility than grey iron</span> <br />
<span style="color: #8000ff;">· Greater impact resistance than grey iron</span> <br />
<span style="color: #8000ff;">· Greater strength than grey iron</span> <br />
<span style="color: #8000ff;">· Lighter and easier to lay than grey iron</span> <br />
<span style="color: #8000ff;">· Simplicity of joints</span> <br />
<span style="color: #8000ff;">· Joints can accommodate some angular deflection</span> <br />
<span style="color: #8000ff;">· Low pumping cost due to larger nominal inside diameter</span><br />
<br />
<br />
<br />
<br />
<br />
</td> <td valign="top"><span style="color: #8000ff;">· Similar rate of corrosion to grey iron and steel</span> <br />
<span style="color: #8000ff;">· Prone to external and internal corrosion</span> <br />
<span style="color: #8000ff;">· Internal and external protection systems required</span> <br />
<span style="color: #8000ff;">· Limited number of protection systems available in U.S.</span> <br />
<span style="color: #8000ff;">· Polyethylene wrappings can be damaged</span><br />
<br />
<br />
<br />
</td></tr>
</tbody></table>
<br />
(Pure technologies, 2014) <br />
<u></u> <br />
<h4>
Materials used for manufacturing process</h4>
<ul>
<li> Recycled iron.</li>
<li> Magnesium.</li>
<li> Coke.</li>
<li> Cement (mortar).</li>
<li> Water based paint.</li>
<li> Zinc and aluminum alloy and blue epoxy (for coatings).</li>
<li></li>
</ul>
<h4>
Machines used for manufacturing process</h4>
<b>1. Blast furnace.</b> <br />
<div align="justify">
Blast furnaces are typically in the form of towers in appearance. Furnaces of this type are used in steel making processes, and it is ideal for mixing charcoals and iron ore together. The extreme heat in the furnace makes it easy for both of the substances to melt in to an integrated liquid metal. </div>
<div align="justify">
Blast furnaces are used for the process of iron smelting. Since heat is created by the furnace, it is possible for the iron to produce iron oxide. The blast of air contained within the furnace helps to intensify the amount of heat produced. </div>
<div align="justify">
Blast furnaces are typically equipped with drawers at the base that makes collection of slag. Secure doors are mounted on to the front of the furnace, making it easier for the raw materials to be inserted in to the furnace by a conveyor belt or a trough. A blast furnace is shown with its major components in the image (2010). </div>
<div align="center">
<a href="http://lh6.ggpht.com/-rd-F0ldjgaw/VESy9MJNWGI/AAAAAAAAGQA/ntlUCcG64tA/s1600-h/image%25255B26%25255D.png"><img alt="image" border="0" src="https://lh6.ggpht.com/-Wg9RdLXIi1E/VESy-Z9M3jI/AAAAAAAAGQI/kx5cY7YuHYU/image_thumb%25255B16%25255D.png?imgmax=800" height="341" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="596"></a> </div>
<div align="center">
Blast furnace image (2010) </div>
<b>2. Centrifugal casting machine.</b> <br />
<div align="justify">
Metal casting can be simply stated as the process, which solid materials are heated to become molten by a furnace such as a blast furnace and are poured in to a mold cavity that contains a desired shape. When it cools down after a period of time, the molten solidifies and can be removed from a casting machine. </div>
<div align="justify">
Centrifugal casting process uses inertia forces caused by rotation or spinning to distribute the molten metal in to the mold cavity. Centrifugal castings are typically three types, </div>
<div align="justify">
· Centrifuging casting. </div>
<div align="justify">
· Semi centrifugal casting. </div>
<div align="justify">
· True centrifugal casting. </div>
<div align="justify">
We use true centrifugal casting in manufacturing ductile iron pipes. Ahorizontal true centrifugal casting machine is shown in the image (2009). </div>
<a href="http://lh5.ggpht.com/-mQENZMHwlvc/VESy_jgGJ7I/AAAAAAAAGQQ/vSs_dBi0t9s/s1600-h/image%25255B32%25255D.png"><img alt="image" border="0" src="https://lh4.ggpht.com/-Yml1kwa_BLE/VESzAv3Np4I/AAAAAAAAGQY/beGDv8rZG74/image_thumb%25255B20%25255D.png?imgmax=800" height="363" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="593"></a> <br />
<div align="center">
Image (2009) </div>
There are advantages of casting. And few of them are as follows, <br />
<ul>
<li> It is possible to cast any material.</li>
<li>Complex geometries can be produced easily, internally and externally.</li>
<li> Very large parts can be produced.</li>
<li> Material wastage is less.</li>
<li> Casted parts have same properties in all directions.</li>
</ul>
<b>3. Annealing furnace.</b> <br />
<div align="justify">
Annealing is simply a heat treatment process. Annealing furnaces are used to change the internal structure of metals such as to remove coarseness of grain of pipes making it harder and flexible. An annealing furnace is shown below in the image (2011-2012). </div>
<a href="http://lh6.ggpht.com/-n-qa7noLu20/VESzCs_DxDI/AAAAAAAAGQg/_0tC0BCK0B0/s1600-h/image%25255B38%25255D.png"><img alt="image" border="0" src="https://lh5.ggpht.com/-mgV_D8H2vug/VESzEyXJm5I/AAAAAAAAGQo/MKpJ3MJlleo/image_thumb%25255B24%25255D.png?imgmax=800" height="374" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="604"></a> <br />
<h4>
Designing Process</h4>
<div align="justify">
Few years ago, the designing process of iron pipes were all drawn by engineers by hand and all the calculations have been done manually. This wastime consuming. With the development of new technologies and software such as AutoCAD, the designing process have been made so easy as engineers and designers could easily design pipes for the needs of the consumers saving a lot of time. Due to this advance technological breakthroughs, custom made pipes and fittings are possible and could be designed and manufactured within a short period of time. Various pipe companies use different software. </div>
<div align="justify">
Designing tools are as follows (Saint-Gobain Pam UK, 2014), </div>
<div align="justify">
</div>
<h4>
Pipespec software</h4>
<div align="justify">
PipeSpecdesign software is a support tool to assist engineers in the design and specification of pipeline schemes. The software features five analytical tools that can be utilized throughout the planning and design stages of the project: </div>
<ul>
<li> <div align="justify">
· Hydraulics - Full Pipe.</div>
</li>
<li> <div align="justify">
· Hydraulics - Part-full Pipe.</div>
</li>
<li> <div align="justify">
· Embedment.</div>
</li>
<li> <div align="justify">
· Anchorage.</div>
</li>
<li> <div align="justify">
· Installation Cost.</div>
</li>
<li> <div align="justify">
</div>
</li>
</ul>
<h4>
PAMCAD Design software</h4>
To assist engineers in the creation and modification of a pipework design, a complete database of water pipeline products is available. The software enables accurate drawings to be produced quickly and easily by calling up pipeline components and arranging them on screen. PAMCAD is compatible with the latest version of AutoCAD. PAMCAD features a floating menu for easy, efficient pipework design. <br />
Benefits: <br />
<ul>
<li>· Enables pipe runs to be drawn quickly and easily.</li>
<li>· Make-up pipe facility.</li>
<li>· Use of standard products to minimize cost and lead time.</li>
<li>· Automatically allows joint gaps.</li>
<li>· Bill of materials function gives a clear list of products used.</li>
</ul>
<a href="http://lh6.ggpht.com/-crPh4rLjFkc/VESzGKhR2WI/AAAAAAAAGQw/q28iHLYBB3I/s1600-h/image%25255B42%25255D.png"><img alt="image" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgULqe9leNkmURDrXJsm0fpv68qa0SnzesiIgnyM45Dd41kSNOHnudGTnpjuKOVSZEjanAPxjDGqF-iY6yd3lyHbrfTBegp_oPElMLe5QmGxJ7CZB8ls83qlb_w3thTkDaoIV7bBmqelHQ/?imgmax=800" height="263" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="577"></a> <br />
<h4 align="justify">
Diameters and lengths for ductile iron pipes</h4>
<div align="justify">
<br /></div>
<div align="justify">
Ductile iron pipes are usually manufactured at a length of 6 meters.Diameters for ductile iron pipes range from 60mm to 2m or 3m. But these values differ according to countries and factory to factory. The image (2013-2015) shows pipes of various diameters but at same length, that is 6m. </div>
<div align="justify">
</div>
<h4>
Manufacturing Process </h4>
<div align="justify">
Ductile iron is made from 90% of the recycled iron where production begins in backyards of pipe factories. Old cars are put in to a shredder that chews them up to bits and pieces, and the shredded metal is analyzed by its chemical composition and sorted accordingly. It discards the plastics and sells aluminum and copper but keeps the iron and steel for manufacturing purposes. The factory also gets scrap steel from demolished buildings and other sources.<b></b> </div>
<div align="justify">
A crane operator uses an industrial magnet to gather precise amount of steel and iron. See image (2011) </div>
<a href="http://lh4.ggpht.com/-8OVqBZu8uK0/VESzIxGwlOI/AAAAAAAAGRA/93YKoP307Oo/s1600-h/image%25255B46%25255D.png"><img alt="image" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOEn9anq0TiKTM8z_doiRivoZtOBqYcIahajImadxPHdsHoXNnPR-zSKTbIbpa0rfNFCebKLggCvAOv1stttcP_734Dq-7XqiOIwdB-4RbItEMRqS8ODqpvAcW06NGQZ3v2nvclzqjqPQ/?imgmax=800" height="292" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="383"></a> <br />
<div align="justify">
Image showing a magnetic crane carrying shredded metal (2011) </div>
<div align="justify">
The shredded metals then go in to a blast furnace with coke, a form of coal at 1,500 shown by the image (2004-2010). The iron and steel liquefy while impurities are carried away. <b></b> </div>
<a href="http://lh3.ggpht.com/-i7wOM5-8kS8/VESzLP-irUI/AAAAAAAAGRQ/wtWDu9Q4jQo/s1600-h/image%25255B51%25255D.png"><img alt="image" border="0" src="https://lh6.ggpht.com/-dWe8V8towS8/VESzMyJC1HI/AAAAAAAAGRY/8_lAVNtLUIo/image_thumb%25255B31%25255D.png?imgmax=800" height="529" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="391"></a> <br />
<div align="justify">
Image (2004-2010) </div>
<div align="justify">
Workers then add magnesium to the low-sulfur base iron under closely controlled conditions.When magnesium is added to the molten iron, the graphite forms in spheres rather than in flakes (Saint-Gobain pam UK,2012).Change in metal is characterized by the free graphite in ductile iron being deposited in spheroidal or nodular form instead of flake form as in gray iron. </div>
<div align="justify">
With the free graphite in nodular form, the continuity of the metal matrix is at a maximum.The formation of a far stronger, tougher ductile material greatly exceeds gray iron in strength, in ductility, and in impact characteristics. This turns the metal from ordinary gray iron in to stronger and flexible ductile iron. </div>
<div align="justify">
The molten iron then travels down a trough in to a spinning mold of a centrifugal casting machine where centripetal force spreads the iron against the mold walls as shown in image below </div>
<a href="http://lh4.ggpht.com/-w7urOfLKfr4/VESzN4ggdcI/AAAAAAAAGRg/fBDR5i40UoU/s1600-h/image%25255B56%25255D.png"><img alt="image" border="0" src="https://lh3.ggpht.com/-nIOBEk9XMyo/VESzP8KXJCI/AAAAAAAAGRo/5kk0yqgxD_Q/image_thumb%25255B34%25255D.png?imgmax=800" height="323" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="597"></a> <br />
<div align="justify">
A cooling system cools the walls and the iron solidifies within seconds. Then the extractor pulls out an iron pipe mold to the standard industry length, which is 6m. The image below shows the solidification process </div>
<div align="justify">
<a href="http://lh5.ggpht.com/-EWsYACUIm5U/VESzRI1gCLI/AAAAAAAAGRw/HzxXjyY81iU/s1600-h/image%25255B60%25255D.png"><img alt="image" border="0" src="https://lh4.ggpht.com/-KjAZ54XkbHk/VESzStMVwBI/AAAAAAAAGR4/U6RLCrYTqRA/image_thumb%25255B36%25255D.png?imgmax=800" height="212" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="602"></a> </div>
<div align="justify">
Before each casting, workers insert a round form of a core in one end of the pipe mold. The molten iron fills the void between the core and the mold forming a flared edge called a “bell”. The core then seals off that end of the mold preventing molten iron from flying out during the casting. </div>
<div align="justify">
When it’s time to connect the pipe, installers will fit the bell of one pipe over the other. Then a rubber gas seals the links together. The casting machine can make pipes of various diameters by changing the mold inside the centrifugal casting machine. </div>
<div align="justify">
After the pipe is extracted, the inspectors weigh it and measure the wall thickness just to make sure that everything meets specifications accordingly. </div>
<div align="justify">
Then the core is removed from the bell end and since it’s made from sand and plastic resin, the core will disintegrate simply. </div>
<div align="justify">
<i><u>Regardless of the size, pipes can be made in different diameters and the casting process is always the same for these pipes</u></i>. It takes less time to manufacture smaller pipes as they harden faster because of the smaller surface area. </div>
<div align="justify">
A freshly casted pipe is around 850 and it cools down quickly after leaving the mold. Such rapid cooling makes the iron brittle so the pipes go directly in to a gas filled annealing furnace that reheats to about 950 . This alters the internal structure making it strong and flexible. Acooling pathgraph (2009) is shown to get an idea of the temperature change with time as the full annealing process of ductile iron is similar to this full anneal curve. </div>
<div align="justify">
<a href="http://lh3.ggpht.com/-f4MqHzM_FUo/VESzTktgOdI/AAAAAAAAGSA/d0c_fx0owxc/s1600-h/image%25255B65%25255D.png"><img alt="image" border="0" src="https://lh5.ggpht.com/-nlmPUVGoZDw/VESzU1d1lKI/AAAAAAAAGSI/4bD7eD1PqLg/image_thumb%25255B39%25255D.png?imgmax=800" height="479" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="565"></a> </div>
<div align="justify">
Cooling path graph (2009) </div>
<div align="justify">
The pipe then runs through a cooling chamber that showers it with cold water. Ductile iron is somewhat resistant to internal corrosion, but for the sewer water it is less aggressive to corrosion. A variety of internal linings are available to reduce or eliminate corrosion, such as, Cement mortar and Polyurethane (PUR). Where cement mortar is more common in manufacturing ductile iron pipes. </div>
<div align="justify">
To prevent the iron from corroding inside of the pipe, cement is sprayed called cement mortarbuilding up a lining of 1/8 of an inch thick. Then the pipe is spun for a few seconds to smooth out the cement. This seals the surface enabling the cement to cure over the next 24 hours and it also provides some extra rust protection. </div>
<div align="justify">
The entire pipe is painted inside and the outside. For external coating, polyethylene, zinc or bituminous coating is applied. </div>
<div align="justify">
Finally a robot paints a stripe around the straight end of each pipe. This is a depth guideline so the installation crews know when they insert the straight end of one pipe as far as it can go in to the bell end of another. </div>
<h4>
Quality considerations and standards</h4>
Quality of products is essential for a business if it is to succeed. From detailed metallurgical analysis of the molten metal to tight control of coating and lining applications, procedures have been developed to ensure consistent high quality of each individual pipe and fitting (Saint-Gobain pam UK,2012). <br />
Iron pipes have been prepared to coincide with the publication of two new European standards covering ductile iron pipes, fittings, accessories and their joints for water pipelines (BS EN 545: 1994) and sewerage pipelines (BS EN 598: 1994), which supersede the former British Standard for such products BS 4772:1988. <br />
Every pipe is pressure tested according to British standard BS EN 545/ BS EN 598 (BSI 2006). <br />
<h4>
Comparison of European Standards with BS 4772 (Water Industry,2006)</h4>
Quality control <br />
ü Dimensional checks. (BS EN 545, BS EN 598) <br />
ü Tensile property determinations. (BS EN 545, BS EN 598, BS 4772*) <br />
ü Hydrostatic pressure tests. (BS EN 545, BS EN 598, BS 4772*) <br />
ü Zinc coating mass determinations. (BS EN 545, BS EN 598, BS 4772*) <br />
ü Paint coating thickness checks. (BS EN 545, BS EN 598) <br />
ü Cement mortar lining thickness checks. (BS EN 545 BS EN 598 BS 4772*) <br />
ü Cement mortar lining compressive strength checks. (BS EN 545, BS EN 598) <br />
During production, each ladle of ductile iron is checked for exact content of magnesium and other elements with a computer controlled optical emission spectrometer. <br />
The “quality-is-key” principle applies to every stage of the manufacturing process and includes(Saint-Gobain pam UK, 2012): <br />
● Validation of suppliers and/or their materials. <br />
● Continuous assessment of quality systems. <br />
● On-going monitoring of product quality. <br />
● Technical support prior to and after sales. <br />
● On-time delivery of products and supporting information. <br />
<br />
<h4>
Possible defects</h4>
<ul>
<li> <div align="justify">
v When carrying away impurities in the blast furnace, some impurities can be left in the molten that proceeds to the centrifugal casting machine.</div>
</li>
<li> <div align="justify">
v When the mold rotates about the axis the molten iron can fly outside of the machine although the core is attached to the bell end of the pipe due to cracks and holes.</div>
</li>
<li> <div align="justify">
v There can be systematic errors when measuring the length and diameters of the pipes and when the pipes are detected by inspection, they are sent back for remanufacturing, which increases the costs.</div>
</li>
<li> <div align="justify">
v When anti corrosive fluids are sprayed on the pipe there might be spots that have been missed or scratches on the surface can cause oxidization. </div>
</li>
<li> <div align="justify">
v Defects in blast furnaces and centrifugal cast iron machines such as holes, cracks etc.</div>
</li>
</ul>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-41515111844677811412014-09-02T23:38:00.002-07:002014-09-02T23:38:46.868-07:00Surface Finish Characterisation<iframe width="600" height="600" src="https://docs.google.com/document/d/187kGv588e3C6AhzLl_DwR-Li3mjCGfmZI6B6IT-fKwY/pub?embedded=true"></iframe>mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-33963616409224568382014-09-02T23:31:00.001-07:002014-09-02T23:35:09.350-07:00Manufacturing cost estimation
<iframe width="650" height="600" src="https://docs.google.com/document/d/19e_7tit0KGJk8IDr-T_Kzqn7kGxCQhDEswY4U3Xbbhw/pub?embedded=true"></iframe>mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-16648582544996901592014-09-02T21:24:00.001-07:002014-09-02T21:24:01.684-07:00Manufacturing process of Plastic ball<p align="justify"> </p> <p>INTRODUCTION <p>I’m going to explain about the complete proses of making plastic ball. In this case mainly Injection molding is used. Gas-injection molding has been developed to save material, shorten cycle times and to improve the surface aspects of thick-walled injection-molded parts. Engineers has done a considerable amount of research to investigate this process’ practical applications. This technical report describes the process and its effect on materials. Special design considerations and processing recommendations are given. <p>TYPE OF PLASTIC BALLS <p><a href="http://lh3.ggpht.com/-a7WlgkKkxiQ/VAaWpfijscI/AAAAAAAAGG4/Xv-MTMcESkU/s1600-h/image%25255B5%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="203" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr_to1VPYOlQRUQu_FI5gB3E4U7EveHRKR2gpJ-hG06nNiiY0GHhqjT82PHvOlMv76GhCns-o7_UC_fBrcYKo5CaO3u6Xyzc9jr9hYjDGpOaTn5aAuVcifhdvfnUGp8wriM8ZxtKBi-8w/?imgmax=800" width="244" border="0"></a> <p><a href="http://lh3.ggpht.com/-pXDnJn4J5fI/VAaWu8NJvyI/AAAAAAAAGHI/3CC2Q2OprnQ/s1600-h/image%25255B8%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="177" alt="image" src="http://lh6.ggpht.com/-TNBrE4KQae8/VAaWxyjwFTI/AAAAAAAAGHQ/JqYii2813ys/image_thumb%25255B2%25255D.png?imgmax=800" width="244" border="0"></a> <p><b>General Principles</b> <p>When plastic ball is made Gas-injection moulding uses a standard injection-mouldingmachine, extended with equipment to inject gas (normally Nitrogen) parallel or in series with the injection of the melt (Fig. 1).Gas injection can take place through the same nozzle as the melt (machine nozzle), or via one or more special gas injection needles located at the runner or where there are material concentrations (thicker walls).Special machine nozzle designs are needed to ensure reliability. <p>The gas-injection-moulding process starts with injection of plastic into the cavity (Fig. 2).When the cavity is 50 to 95% full (depending on the shape of the part – see Fig. 3), the barrel is closed by a “shut-off” and gas injection starts. It can be controlled by pressure or by volume. The gas expands in the cavity, pushing the plastic in front of it until the cavity is filled. Then the gas-pressure is reduced by withdrawing the injection nozzle from the spruce, so that the gas can escape. In some designs the gas may be allowed to escape from the cavity via the injection needle, so that the machine can recover the gas for re-use. If the gas is injected through the same nozzle as the melt, a second injection of plastic is made to seal the hole inthe part (Fig. 2). <p><a href="http://lh4.ggpht.com/-oAXs-Dm9Z5s/VAaW1GlhtiI/AAAAAAAAGHY/6lvQH2xJydQ/s1600-h/image%25255B13%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="407" alt="image" src="http://lh6.ggpht.com/-YXl7yrKr2jU/VAaW2k8pLVI/AAAAAAAAGHg/ypby3wdWKog/image_thumb%25255B5%25255D.png?imgmax=800" width="612" border="0"></a> <p><a href="http://lh3.ggpht.com/-MxIBYIHFgfU/VAaW5Dlwh4I/AAAAAAAAGHo/wrhgpmzacHg/s1600-h/image%25255B18%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="581" alt="image" src="http://lh6.ggpht.com/-45Sr1kfocRo/VAaW7XSKoJI/AAAAAAAAGHw/E0v3yzgTML4/image_thumb%25255B8%25255D.png?imgmax=800" width="602" border="0"></a> <p><a href="http://lh3.ggpht.com/-p0V1V_nOOzU/VAaW8j6yeVI/AAAAAAAAGH0/G6rD6LX-C8A/s1600-h/image%25255B23%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="348" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZ2TqLrUqj_rg-1y7WkhHUyHmUg_p_kNUtWRCyNXg9qE9pXAoeZU_ELGHZaSITonNT0tbU3YzQYPi0H73FKUROGHmqx9zbORlOIXq3pGVPwWxmG3b8-xLeK6Nxks9Itryy0hNlbFLyIpA/?imgmax=800" width="614" border="0"></a> <p><a href="http://lh4.ggpht.com/--4-LG2m9nQ0/VAaXBBQZjdI/AAAAAAAAGII/X1qolpjXX8w/s1600-h/image%25255B28%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="707" alt="image" src="http://lh6.ggpht.com/-3RDcim6glnw/VAaXC9YUegI/AAAAAAAAGIQ/7YEIbFJvP4M/image_thumb%25255B14%25255D.png?imgmax=800" width="610" border="0"></a> <p> <p><b>Processing</b> <p><b>Gas pressure</b> <p>There are two important considerations relating to gas pressure: <p>• The time when gas injection should start (delay time) <p>• The gas pressure profile. <p>The delay time depends on the thickness of the layer frozen to the cavity wall. If the delay is too short, the gas can blow away too much material which is still liquid, leaving insufficient wall thickness. This, in addition to low melt viscosity, allows the gas to break through the melt front1 <p>(Fig. 4). The same phenomenon can be noted if the gas pressure is not closely controlled. The lower the resistance offered by the melt to the gas bubble, the more difficult it is to control the gas pressure. This resistance is a function of the cross-sectional area of the gas channel, the thickness of the melt front, and the melt viscosity. Too short a delay time may lead to turbulence in the gas and the melt; this can spoil the part’s surface appearance. The best results are obtained if, in addition to determining the correct delay time, the gas-pressure profile advances the flow front at a constant speed, so as to avoid flow marks on the surface. The melt front resistance decreases with time, because the amount of material being pushed forward by the gas is getting less. For this reason the gas pressure should be reduced as the operation proceeds, in order to keep a constant flow-front velocity. Fig. 5 illustrates this principle; <p>However, the diagram must be adjusted according to the needs of each specific application. When the cavity is completely filled, gas pressure can be increased again to obtain optimum crystallizationstructure, better surface appearance, better packing and fewer sink marks. <p>Gas pressure also makes for faster crystallizationtime, because it keeps the surface of the part pressed against thecavity surface, so that better cooling is obtained.Typical pressures for gas injection are 100 to 500 bars, depending on the application. To avoid turbulence during melt injection, the gas pressure level should be less than half the melt pressure in the runner. <p><b>Mould temperature</b> <p>Mould temperature has a direct influence of the wall thickness profile of the part. It affects the speed of crystallization, that is to say, the rate at which the frozen skin is built up. Accurate temperature control in all parts of the mould should help to build up the desired wall thickness profile. In general, the mould temperatures recommended by DuPont for normal injection moulding of the various resins should be observed. <p>1 Terminology: <p>The melt front is the melted plastic between the gas front and the flow front. The flow front is the cavity side of the melt front. The gas front is the contact surface between the gas and the melt front (see Fig. 2). <p><a href="http://lh5.ggpht.com/-UbHFLhjukB8/VAaXFN1qaZI/AAAAAAAAGIY/YR855xpqoQU/s1600-h/image%25255B33%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="570" alt="image" src="http://lh5.ggpht.com/-nSEI6g1CB3A/VAaXHv8UepI/AAAAAAAAGIg/n5NYv1IbLng/image_thumb%25255B17%25255D.png?imgmax=800" width="584" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8s5rMX9bbxdDgdv0Ero5MMNnncphDHMKwAO3dQYsgVOQ76LUwY7VturPsjuFTMaJyiLP9u434-2JELdEP6tahYrhYwJNtEOdiMMH0_Bw8EvLR1Kxwjt9eYj4gWZ_lgDBQc9vED4nbN-E/s1600-h/image%25255B37%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="306" alt="image" src="http://lh5.ggpht.com/-zqr9j6MGwRU/VAaXLtXMBaI/AAAAAAAAGIw/lunsCuRuZt8/image_thumb%25255B19%25255D.png?imgmax=800" width="599" border="0"></a> <p><b>Melt viscosity</b> <p>Melt viscosity affects parts in two important ways <p>• Size of the gas cavity <p>• Reproducibility <p>Higher melt viscosity produces thicker walls, narrower andshorter gas channels with more remaining material at the end, and allows high reproducibility. Lower melt viscosities produce longer gas channels with a larger cross-sectional area, but usually with less uniform wall thicknesses (Fig. 6). Because low melt viscosity reduces the pressure-drop between the gas front and the flow front, there is a danger of unequal melt fronts with less reproducibility, especially where there are more than one melt fronts. Decreasing melt viscosity has another negative influence on the process: melt strength decreases with lower melt viscosity, so that the gas can break through the melt front more readily. Plastics with a stable viscosity over the processing <p>Temperature range will give the best results. Processing parameters of crystalline materials must therefore be set more carefully than those of amorphous materials. <p><b>Processing parameters</b> <p>The influence of processing parameters on the gas injection process is shown in Fig. 7. <p><b>Process simulation</b> <p>The complexity of gas-injection moulding requires process simulation to predict processing parameters and optimum part design if development time is to be reduced. Process simulation software has been developed to simulate mould filling, including a phase where a second componentthe gas – is injected. Results to date from use of this software, compared with data obtained experimentally; show that some basic assumptions still need to be improved. <p><a href="http://lh4.ggpht.com/-oCRD06z4bsQ/VAaXNnCXz3I/AAAAAAAAGI4/g4qmCfLWUTU/s1600-h/image%25255B41%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="608" alt="image" src="http://lh5.ggpht.com/-aLLqJLib8w8/VAaXPhpQeOI/AAAAAAAAGJA/lfh1-wXZOH0/image_thumb%25255B21%25255D.png?imgmax=800" width="536" border="0"></a> <p><a href="http://lh6.ggpht.com/--aPWAUu1mqo/VAaXTJhrvaI/AAAAAAAAGJI/lP3ODtN_kh4/s1600-h/image%25255B46%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="174" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEih-hJLgnJnbVKdxX7NChtXKtNb60fyI8M5HfC6wt1rnap57qLMCJITLi7etp8BSyQfBLvXElgoxDQ-kLZ8oRwMUyrJa2n7V1N0425Bc0sO-Px9WMmxyfRvvdag9AHdTS2RVgxQZ3l8eW0/?imgmax=800" width="549" border="0"></a> <p><a href="http://lh5.ggpht.com/-YptgBeB1SVE/VAaXWZ9VNLI/AAAAAAAAGJY/P5cc5UIA8Ig/s1600-h/image%25255B50%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="281" alt="image" src="http://lh4.ggpht.com/-wf-aJ7x6Nvs/VAaXX57WP6I/AAAAAAAAGJg/N6sDKT8mCDU/image_thumb%25255B26%25255D.png?imgmax=800" width="562" border="0"></a> <p><b>Design</b> <p>When making a best ball, it has to be a best method. The best designs for gas-injection moulding are parts in which the gas flow is in one direction only. Not around corners or bends. Usually; special rules apply to parts designed for the gas injection-moulding process. The basic rule is that the gas always pushes the plastic away at the locations with the best flow conditions – that is to say, where resistance to the melt front is lowest. For this reason, gas channels will tend to appear in sections with large cross-sectional area and/or higher melt temperatures. This is illustrated in Fig. 8. The upper part of the illustration shows a design with a sharp corner and melts accumulation; the lower part shows an improved design with rounded corners. <p>The gas in the cavity fulfils two main functions:<a name="_GoBack"></a> <p>• To produce a hollow cavity, weight reduction being themain objective. <p>• To provide constant pressure throughout the part in order to <p>Compensate for volume shrinkage after the cavity has been filled; the main objective is to avoid sink marks, thus obtaining a smooth surface. For thin parts with a relatively large cross section, such as handles, weight saving is the main reason for using gas injection. Gas channels tend to be a feature of these designs. For shallow parts with stiffening ribs, the main reason for using gas-injection moulding is the creation of a smooth surface without sink marks. Gas channels are needed for such parts to bring the gas to locations where the volume shrinkage of the material could otherwise cause a sink mark. Since shell structures (e.g. housings) normally do not include sections which can be used as gas channels, channels have to be specially designed. This can be done at corners for the shell or at rib/shell junctions. Fig. 9 shows examples. Ribbed housings with gas channels to avoid sink marks often need to link the ribs in a network by an incorporated <p>gas channel which goes around the geometry of the part. Reducedwarp age is an advantage of this kind of design. The size of the gas channel depends on the volume shrinkage of the material and on the size of the shell. <p>The following considerations are of importance: <p>• the smaller its size compared to total flow length, the sooner the gas pressure has to be activated in order to avoid the gas channels freezing off. This means that the gas channel will try to compensate the volume shrinkage of the flat part, too, by pushing melt into flat, shrinking <p>sections. A cross-section over a part with a gas channel that is too small can give results such as those shown in Fig. 10. Because of lack of melt, gas is pushed into the shell, producing “notches” which are undesirable if the part is to resist high dynamic loads. <p>• the larger the square section of the channel, the longer the activation of the gas pressure can be delayed. However, channels that are too big mean extra weight and a less stable melt-flow front, though they increase the stiffness. As a rule of thumb, gas channels should be designed to be 2 to 3 times bigger than the shell thickness (Fig. 9). <p><a href="http://lh3.ggpht.com/-sCC1B_UGRJs/VAaXZ_i5npI/AAAAAAAAGJo/8qvG37z7Dvs/s1600-h/image%25255B54%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="411" alt="image" src="http://lh4.ggpht.com/-A6GlTS-0KaI/VAaXbUJMimI/AAAAAAAAGJw/51ejISv22Xw/image_thumb%25255B28%25255D.png?imgmax=800" width="540" border="0"></a> <p><a href="http://lh4.ggpht.com/-TFt_lM6sSzg/VAaXc5vGOQI/AAAAAAAAGJ4/dfCgiv51RiY/s1600-h/image%25255B58%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="364" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcRsuRd7__WA3q8s_sg4m3_9WyHwD2SiU-1OleKIBvH_a9nWvAafwMBiBVB4GDpES5Y25lL9QBkyYkiRpEZ1pgQi3TOm3B6faZ3MzwWJc4Mw7YpkJAOcnu3kChZP5hG3cwdE8ZaW5wk4U/?imgmax=800" width="556" border="0"></a> <p><a href="http://lh5.ggpht.com/-zwPJh69XkL4/VAaXf4QPfHI/AAAAAAAAGKI/UAEGxMkCjdQ/s1600-h/image%25255B63%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="393" alt="image" src="http://lh5.ggpht.com/-aOd9qfg5wbU/VAaXhuGIMCI/AAAAAAAAGKQ/XeuNRF1tHco/image_thumb%25255B33%25255D.png?imgmax=800" width="568" border="0"></a> <p>In certain applications – e.g. if the part has an integrated function, such as carrying liquids, or if it has connectors attached to it – the gas channel has to extend over the full length of the part, leaving only a thin skin of plastic at the end. In such cases an overflow has to be provided (Fig. 11).Its size will depend on part design and must be determined by process simulation studies, which should help to diminish the need for practical trials. Inserts are a challenging design problem for gas-injected parts. Inserts have to be properly surrounded by plastic material; the gas channel has to be placed at a certain distance from it. Usually this can be achieved by using a separate gas injection needle placed downstream from the insert (Fig. 11). If the machine nozzle is used for gas injection, more design effort will be needed to ensure thatthe insert remains properly surrounded by plastic. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtxQ2WQtjUx5wNuPhGBRm6D85BFImJzcsCQf06Z6N8Yz47-2a-Z9zymgiRiGzwpbIdqeSM8NB80uV0mJUw7HJE4FSuLGtga9vT7N4vop4upL4RTIIqqMIG9_iSEzMvE1s_W3S7rOpK3TU/s1600-h/image%25255B67%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="490" alt="image" src="http://lh4.ggpht.com/-ofVLfkKRedQ/VAaXlfYUyKI/AAAAAAAAGKg/15AL-FL71pI/image_thumb%25255B35%25255D.png?imgmax=800" width="551" border="0"></a> <p><b>Material Properties</b> <p>For some materials, the mechanical properties of end-use parts produced with the gas-injection-moulding process. Tests were needed because several essential parameters in this process which affect the resin’s mechanical properties areDifferent from standard injection moulding. The tests showed that the modulus of elasticity and tensile strength of glass reinforcedmaterials near gas channels are lower because of reduced shear during processing, so that fibre orientation at these points cannot be optimal. These mechanical properties are reduced by around 10% and in extreme cases by as much as 50% compared with standard values. Fig. 12 compares the structure of a conventional injection mouldedmethod. Whereas the conventional component has a comparatively high degree of orientation of the glass fibresin the round zones and a rather less orientated arrangement in the Centre, the component produced by the internal gas pressure method has a low degree of orientation in the peripheral zone (mould wall). Orientation increases towards <p>the gas channel side, but the Centre of the cross-section is characterized by an area of low orientation. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhidz0RKzt2RWchtXI-knmUyTe5Ckyf-6MpSjyejBvZNdAvqrS-Uxw3lHwtNiirXPU1xGufKJSCnrfYPEEL-XMklY2kc6ps27qetiv5xY10OzcTvyBPWg6WnfqgCwOZ1yeTjtAMMKyzNpI/s1600-h/image%25255B71%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="362" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIU2yWhvJzttpw8VcqjnMm4glWcxQuTec0soEU4ZZE6wGiWtfeEOZ9s6dUfJbwgH8CvXv7RNwG3QLBCzGP54VJvHeWYcQAEHi86V7dCPcb6CYdR1f0yCdC9Ew3ah9xJtAUJ7_gPWpqsfA/?imgmax=800" width="608" border="0"></a> <p><a href="http://lh3.ggpht.com/-3zZSEuuo9g4/VAaXqje6o8I/AAAAAAAAGK4/d0qorgrnWac/s1600-h/image%25255B75%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="206" alt="image" src="http://lh4.ggpht.com/-EbBPabWgF2w/VAaXvV7AKzI/AAAAAAAAGLA/RIKIFjjckDs/image_thumb%25255B39%25255D.png?imgmax=800" width="629" border="0"></a> <p>Fig. 12 : Micro tomographyview of a cross-section of a component: (a) formed by traditional moulding (b) formed by gas injection moulding, made of ZYTEL® 70G30 (PA66 with 30% glass fibre). <p><b>Gate</b> <p>The gate for gas-injection moulding is different from gates for conventional moulding. If gas injection is done via the Machine nozzle, the gate and runner dimensions have to be about twice as big as for conventional moulding. The gate should be positioned so that the melt is injected in awide, even flow along the cavity wall, as in the extrusion process; split flows and confluences, which can lead to unwanted turbulence, should be avoided. <p><a href="http://lh6.ggpht.com/-B1ajPqMnZRU/VAaXwg2BosI/AAAAAAAAGLI/6MXjvCPA-VE/s1600-h/image%25255B79%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="292" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnCC1oB1nwNMt7COyt6GBnnbxEUmk7i_GHsHpuPAMm18GJmzvRcALC-ktbOg-0kUQfhq5lUYEXlky1LtRr8064-HTttNhMgku-I39H1srWcKjOocniho_SSvaxBUksH_7vX6NxYuLH64s/?imgmax=800" width="629" border="0"></a> <p><a href="http://lh5.ggpht.com/-T5fuu5Eo-CE/VAaXz3x3JcI/AAAAAAAAGLY/bVY1FnuV8k4/s1600-h/image%25255B83%25255D.png"><img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="403" alt="image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgy7PK7CYYd5NoDb35PXII_WroJ_5_iH0VzsQ_S7rbLtbgK98pH3VQ2c-vkcRuG-eFys6PvZsEyznxLQor_NLgH_1HKkgOmWc9uRqi8bjWGN4E46ozaqb-fLzw3Ug09L3kn0OfE_Fe_Bf0/?imgmax=800" width="636" border="0"></a> <p><b>Machine equipment</b> <p>For the gas-injection-moulding process special equipment is needed to provide the moulding machine with the desired gas volume and pressure at the right time. The principle of a gas-injection unit is shown in Fig.1. The nitrogen is supplied from a conventional pressure vessel into a compressor. The pressure profile is controlled by a special electronic device via the compressor unit. <p><b>Nozzle</b> <p>The gas is injected via a special nozzle. Some types of nozzle are designed to recover the gas after the cycle via the gas injection equipment. High reliability in production is a vital requirement for such nozzles. The polymer to be processed is of major importance for the <p>Nozzle design. In general, gas can be injected in two ways: <p>• Via the machine nozzle (Fig.14) <p>• Via one or more special needle(s) direct into the runner(s) or into the part (Fig. 13). <p>When gas is injected through the machine nozzle, the pressure in the nozzle is allowed to build up and then the gas valve at the tip of the nozzle is opened. In general a “Shot Off” is used to close the machine nozzle at a given time, so no melt can flow back from the cavity into the barrel. Using special needles has certain advantages. The gas cavity can be created just where it is wanted in the part. There can be several (independent) gas cavities in one part, created <p>With several needles. (The hole left by a gas injection needle is less than 1 mm in diameter). <p>The most effective way to place needles is in sections where the melt stays liquid longest. <p><b>Aspects of gas-injection moulding</b> <p><b>Benefits:</b> <p><b></b> <p><i>Processing</i> <p>• lower clamping force <p>• greater flow length <p>• lower pressure drop <p>• substitute hot runner <p>• simpler, cheaper mould <p>Design <p>• lower part weight (reduction up to 40%) <p>• fewer sink marks <p>• less warp age <p>• less shrinkage across direction of flow <p>• higher torque resistance <p>• more design freedom with non-uniform wall thicknesses <p><b>Limitations:</b> <p><b></b> <p><i>Processing</i> <p>• extra equipment <p>• special nozzle design/gas-injection needles <p><i>Design</i> <p>• wall thickness only roughly predictable, but reproducible <p>• cross section of gas channels less than 15 to 20 mm <p>• increased shrinkage in the direction of gas channel flow <i>Material</i> <p>• Material properties usually lower than in equivalent parts made by conventional injection moulding <p>• Surface quality depends on material <p>. mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-71237591925735099172014-09-01T04:14:00.001-07:002014-09-01T04:14:57.874-07:00Understanding various types of Stepper Motors And Controlling it through Parallel Port<p><b><u></u></b> <p><b><u></u></b> <p><b><u></u></b> <p><b><u></u></b> <p><b><u></u></b> <p><b><u></u></b> <p><b><u></u></b> <p><b><u></u></b> <p> <h1>Content</h1> <p>1. Theory<u> 3</u> <p>2. Stepper Motor<u> </u>3 <p>i. Definition<u> </u>3 <p>ii. Characteristics<u> </u>3 <p>iii. Working<u> </u>4 <p>iv. Stepping Modes<u> 6</u> <p>b. Parallel Port<u> 8</u> <p>3. The Circuit<u> 11</u> <p>4. Programming<u> 14</u> <p>a. The Accessing I/O Ports under NT/2000/XP<u> </u>14 <p>b. The Program code in VB<u> </u>15 <p>c. I/O Port Access in Turbo C, Borland C/C++<u> </u>19 <p>d. The Program Code in Unix environment In C<u> </u>19 <p><b><u>AIM</u></b> :- To understand and run a stepper motor through PC’s parallel port Interface. <p> <p> <p> <p><b><u>THEORY</u></b> <ol> <li>STEPPER MOTOR <li>PARALLEL PORT </li></ol> <p><b><u>1. STEPPER MOTOR</u></b> <p><b><u></u></b> <p>In Theory, a Stepper motor is a marvel in simplicity. It has no brushes, or contacts. Basically it's a synchronous motor with the magnetic field electronically switched to rotate the armature magnet around. <p><b>Definition</b> <p>A stepper motor is basically an electromechanical device which converts electrical pulses into discrete mechanical movements. The shaft or spindle of a stepper motor rotates in discrete step increments when electrical command pulses are applied to it in the proper sequence. The motors rotation has several direct relationships to these applied input pulses. The sequence of the applied pulses is directly related to the direction of motor shafts rotation. The speed of the motor shafts rotation is directly related to the frequency of the input pulses and the length of rotation is directly related to the number of input pulses applied. <p><b>Characteristics:</b> <p>• <b>Holding Torque</b> - Steppers have very good low speed and holding torque. Steppers are usually rated in terms of their holding force (oz/in) and can even hold a position (to a lesser degree) without power applied, using magnetic 'detent' torque. <p>• <b>Open loop positioning</b> - Perhaps the most valuable and interesting feature of a stepper is the ability to position the shaft in fine predictable increments, without need to query the motor as to its position. Steppers can run 'open-loop' without the need for any kind of encoder to determine the shaft position. Closed loop systems- systems that feed back position information, are known as servo systems. Compared to servos, steppers are very easy to control; the position of the shaft is guaranteed as long as the torque of the motor is sufficient for the load, under all its operating conditions. <p>• <b>Load Independent</b> - The rotation speed of a stepper is independent of load, provided it has sufficient torque to overcome slipping. The higher rpm a stepper motor is driven, the more torque it needs, so all steppers eventually poop out at some rpm and start slipping. Slipping is usually a disaster for steppers, because the position of the shaft becomes unknown. For this reason, software usually keeps the stepping rate within a maximum top rate. In applications where a known RPM is needed under a varying load, steppers can be very handy. <p><b>Working:</b></p> <p> <table cellspacing="0" cellpadding="0"> <tbody> <tr> <td width="180"></td></tr> <tr> <td></td> <td><a href="http://lh5.ggpht.com/-3GK3FmT4dLo/VARUccs79AI/AAAAAAAAF-Q/XOhmCLBlKec/s1600-h/clip_image001%25255B4%25255D.gif"><img title="clip_image001" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="285" alt="clip_image001" src="http://lh6.ggpht.com/-r5kxma6VpSQ/VARUdjtDp9I/AAAAAAAAF-Y/3is9nwetsaw/clip_image001_thumb%25255B1%25255D.gif?imgmax=800" width="319" border="0"></a></td></tr></tbody></table></p> <p><b>Figure 1.</b> <b>Diagram that shows the position of the six-pole rotor and four-pole stator of a typical stepper motor</b></p> <p><br>The stepper motor uses the theory of operation for magnets to make the motor shaft turn a precise distance when a pulse of electricity is provided. You learned previously that like poles of a magnet repel and unlike poles attract. Figure 1 shows a typical cross-sectional view of the rotor and stator of a stepper motor. From this diagram you can see that the stator (stationary winding) has four poles, and the rotor has six poles (three complete magnets). The rotor will require 12 pulses of electricity to move the 12 steps to make one complete revolution. Another way to say this is that the rotor will move precisely 30° for each pulse of electricity that the motor receives. The number of degrees the rotor will turn when a pulse of electricity is delivered to the motor can be calculated by dividing the number of degrees in one revolution of the shaft (360°) by the number of poles (north and south) in the rotor. In this stepper motor 360° is divided by 12 to get 30°.</p> <p> <p>When no power is applied to the motor, the residual magnetism in the rotor magnets will cause the rotor to <i>detent</i> or align one set of its magnetic poles with the magnetic poles of one of the stator magnets. This means that the rotor will have 12 possible detent positions. When the rotor is in a detent position, it will have enough magnetic force to keep the shaft from moving to the next position. This is what makes the rotor feel like it is <i>clicking </i>from one position to the next as you rotate the rotor by hand with no power applied. <p>When power is applied, it is directed to only one of the stator pairs of windings, which will cause that winding pair to become a magnet. One of the coils for the pair will become the north pole, and the other will become the south pole. When this occurs, the stator coil that is the north pole will attract the closest rotor tooth that has the opposite polarity, and the stator coil that is the south pole will attract the closest rotor tooth that has the opposite polarity. When current is flowing through these poles, the rotor will now have a much stronger attraction to the stator winding, and the increased torque is called<br><i>holding torque.</i> <p>By changing the current flow to the next stator winding, the magnetic field will be changed 90°. The rotor will only move 30° before its magnetic fields will again align with the change in the stator field. The magnetic field in the stator is continually changed as the rotor moves through the 12 steps to move a total of 360°. Figure 2 shows the position of the rotor changing as the current supplied to the stator changes. <p><i></i> <table cellspacing="0" cellpadding="0"> <tbody> <tr> <td width="149"></td></tr> <tr> <td></td> <td><a href="http://lh4.ggpht.com/-1OdA2xiOU7o/VARUey18PQI/AAAAAAAAF-g/sLZzjzzO8Cw/s1600-h/clip_image002%25255B4%25255D.gif"><img title="clip_image002" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="356" alt="clip_image002" src="http://lh5.ggpht.com/-IgvX6F5CXaU/VARUgFAMRyI/AAAAAAAAF-o/za5QbHQ0Cl0/clip_image002_thumb%25255B1%25255D.gif?imgmax=800" width="384" border="0"></a></td></tr></tbody></table> <p><b>FIGURE 2 Movement of the stepper motor rotor as current is pulsed to the stator. (a) Current is applied to the top and bottom windings, so the top winding is north, (b) Current is applied to left and right windings, so the left winding is north, (c) Current is applied to the top and bottom windings, so the bottom winding is north, (d) Current is applied to the left and right windings so the right winding is north.</b> <p><i></i> <p>In Fig. 2a you can see that when current is applied to the top and bottom stator windings, they will become a magnet with the top part of the winding being the north pole, and the bottom part of the winding being the south pole. You should notice that this will cause the rotor to move a small amount so that one of its south poles is aligned with the north stator pole (at the top), and the opposite end of the rotor pole, which is the north pole, will align with the south pole of the stator (at the bottom). A line is placed on the south-pole piece that is located at the 12 o'clock position in Fig. 2a so that you can follow its movement as current is moved from one stator winding to the next. In Fig. 2b current has been turned off to the top and bottom windings, and current is now applied to the stator windings shown at the right and left sides of the motor. When this occurs, the stator winding at the 3 o'clock position will have the polarity for the south pole of the stator magnet, and the winding at the 9 o'clock position will have the north-pole polarity. In this condition, the next rotor pole that will be able to align with the stator magnets is the next pole in the clockwise position to the previous pole. This means that the rotor will only need to rotate 30° in the clockwise position for this set of poles to align itself so that it attracts the stator poles. <p>In Fig. 2c you can see that the top and bottom stator windings are again energized, but this time the top winding is the south pole of the magnetic field and the bottom winding is the north pole. This change in magnetic field will cause the rotor to again move 30° in the clockwise position until its poles will align with the top and bottom stator poles. You should notice that the original rotor pole that was at the 12 o'clock position when the motor first started has now moved three steps in the clockwise position. <p>In Fig. 2d you can see that the two side stator windings are again energized, but this time the winding at the 3 o'clock position is the north pole. This change in polarity will cause the rotor to move another 30° in the clockwise direction. You should notice that the rotor has moved four steps of 30° each, which means the rotor has moved a total of 120° from its original position. This can be verified by the position of the rotor pole that has the line on it, which is now pointing at the stator winding that is located in the 3 o'clock position. <p><b>Types of Stepper Motors:</b> <p>Stepper Motors come in a variety of sizes, and strengths, from tiny floppy disk motors, to huge machinery steppers rated over 1000 oz in. Three basic types of stepper motors include <b>the permanent magnet motor, the variable re-luctance motor, and the hybrid motor,</b> which is a combination of the previous two. <p><b>Stepping Modes</b> <p><b></b> <p>The following are the most common drive modes. <p>• Wave Drive (1 phase on) <p>• Full Step Drive (2 phases on) <p>• Half Step Drive (1 & 2 phases on) <p>• Microstepping (Continuously varying motor currents) <p><a href="http://lh3.ggpht.com/-_EV_M9Rquzo/VARUhZSFsWI/AAAAAAAAF-w/J2RBWxb-Ym4/s1600-h/clip_image004%25255B4%25255D.jpg"><img title="clip_image004" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="315" alt="clip_image004" hspace="12" src="http://lh3.ggpht.com/-MrNZP6WhLAI/VARUik3wCeI/AAAAAAAAF-4/-ad7xEKbaTM/clip_image004_thumb%25255B1%25255D.jpg?imgmax=800" width="179" border="0"></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm47pfzB4UFAPbD5auYbwq3fzGQguq0EIzZGH2P8luCEaJj6BnAtbHZx9S2oo7Uc2-u_PCTpdaQjDa5SngAeC_R2SiaJjgOafdnZZx6slk49Jd2zqdwzMxqWO-1TCPEXY0FTEA2VRTD1k/s1600-h/clip_image009%25255B4%25255D.gif"><img title="clip_image009" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="75" alt="clip_image009" hspace="12" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3kzQmrnRmFrHXK-B1_2yxXbxkPu01X_cDnRO6yO_vdAXFGu27iNzm8zC6DMichR_ho-m4wrqIojbiMmfaGv5L7enscaiMwKepmbzI-jRVYbGU4Gd49HmDnWaeBSzcx4-cjGU8p0c6toc/?imgmax=800" width="316" border="0"></a> <p>For the following discussions please refer to the figure 9. <p>In Wave Drive only one winding is energized at any given time. The stator is energized according to the sequence A -> B -> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY5g9MJiuTM4dtgdTZQN4YbZFaS95tEQSLXMIhJW-G6ipmF_C7BEnvRgf26eW9vh7bT_WoUowbwBjkrLeTtX3bRWS8lylQCQvajojgKRqM8rvIL8VUdtsqswFpEgC2Lhzy5nhuNmwxK2w/s1600-h/clip_image006%25255B3%25255D.gif"><img title="clip_image006" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="20" alt="clip_image006" src="http://lh5.ggpht.com/-5u3yo16m1VE/VARUm0jl4FI/AAAAAAAAF_Y/zYXhC-ZBFWk/clip_image006_thumb.gif?imgmax=800" width="17" border="0"></a> -> <a href="http://lh3.ggpht.com/-om6zIw7kvN4/VARUoOUC-CI/AAAAAAAAF_g/Bek9jZz4vJs/s1600-h/clip_image008%25255B3%25255D.gif"><img title="clip_image008" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="20" alt="clip_image008" src="http://lh3.ggpht.com/-a88R_KwLxys/VARUpN4WBNI/AAAAAAAAF_o/FWTkp2gawCI/clip_image008_thumb.gif?imgmax=800" width="17" border="0"></a> and the rotor steps from position 8 -> 2 ->4 -> 6. For unipolar and bipolar wound motors with the same winding parameters this excitation mode would result in the same mechanical position. The disadvantage of this drive mode is that in the unipolar wound motor you are only using 25% and in the bipolar motor only 50% of the total motor winding at any given time. This means that you are not getting the maximum torque output from the motor. <p>In Full Step Drive you are energizing two phases at any given time. The stator is energized according to the sequence <a href="http://lh3.ggpht.com/-zPo7qkZkSzs/VARUp58nrMI/AAAAAAAAF_w/EjL671ck4kQ/s1600-h/clip_image011%25255B3%25255D.jpg"><img title="clip_image011" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="23" alt="clip_image011" src="http://lh5.ggpht.com/-OC7X_32VOKM/VARUq8xNkaI/AAAAAAAAF_4/8U85LNaorzU/clip_image011_thumb.jpg?imgmax=800" width="141" border="0"></a> <a href="http://lh6.ggpht.com/-N1sb41QBlbs/VARUrxsGhWI/AAAAAAAAGAA/nGC_NRFPNB4/s1600-h/clip_image013%25255B3%25255D.jpg"><img title="clip_image013" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="22" alt="clip_image013" src="http://lh4.ggpht.com/-DVPydpMkXGU/VARUtRGeflI/AAAAAAAAGAI/VnTMP3UY4JU/clip_image013_thumb.jpg?imgmax=800" width="31" border="0"></a> and the rotor steps from position 1 ->3 ->5-> 7 . Full step mode results in the same angular movement as 1 phase on drive but the mechanical position is offset by one half of a full step. The torque output of the unipolar wound motor is lower than the bipolar motor (for motors with the same winding parameters) since the unipolar motor uses only 50% of the available winding while the bipolar motor uses the entire winding. <p><a href="http://lh6.ggpht.com/-ogJMVBz5Mwg/VARUuIB5uiI/AAAAAAAAGAQ/sp3eO4slkK4/s1600-h/clip_image015%25255B3%25255D.jpg"><img title="clip_image015" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="19" alt="clip_image015" hspace="12" src="http://lh4.ggpht.com/-7RAu23lhbBA/VARUu77YVrI/AAAAAAAAGAY/6Cj-gaXE524/clip_image015_thumb.jpg?imgmax=800" width="142" border="0"></a>Half Step Drive combines both wave and full step (1&2 phases on) drive modes. Every second step only one phase is energized and during the other steps one phase on each stator. The stator is energized according to the sequence <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcT8i8OJ4ZCUBhZpdtwYrgl4OM6ZU67-clh4vE5fhfBPUUIHK2ytywAOaDcnoBo0wSehoM-LZ3zFGJWQDx03TRH8ddlhQ6YaxU3S7QNG00xffaFNFk89uxFmCOoCMkfOoqb8GNXtf_OgQ/s1600-h/clip_image017%25255B3%25255D.jpg"><img title="clip_image017" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="21" alt="clip_image017" hspace="12" src="http://lh5.ggpht.com/-vou4AjkGxB4/VARUwpzi7pI/AAAAAAAAGAo/R4CDQ4D-S6g/clip_image017_thumb.jpg?imgmax=800" width="172" border="0"></a>and the rotor steps from position 1 ->2 -> 3-> 4 ->5 -> 6 -> 7 -> 8. This results in angular movements that are half of those in 1- or 2-phases-on drive modes. Half stepping can reduce a phenomena referred to as resonance which can be experienced in 1- or 2- phases-on drive modes. <p>The excitation sequences for the above drive modes are summarized in Table 1. <table cellspacing="0" cellpadding="0"> <tbody> <tr> <td width="24"></td></tr> <tr> <td></td> <td><a href="http://lh3.ggpht.com/-0IfC8BNLid0/VARUyP8Gj2I/AAAAAAAAGAw/1CXsA0kIu9E/s1600-h/clip_image019%25255B3%25255D.jpg"><img title="clip_image019" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="82" alt="clip_image019" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhQYUKqQWSOrv57_gnFwSwaLBQLwiSxoVR3Nv1N7wgb6mhUZz54BNp7i27l7fPc_-s91JOq_D4arWGnyKkSxKxHTxhllf5vWLmvhLidhEBCWQnL9hw7JU_TdzcesbWAhdxpLa17vznT77w/?imgmax=800" width="244" border="0"></a></td></tr></tbody></table> <p>In Microstepping Drive the currents in the windings are continuously varying to be able to break up one full step into many smaller discrete steps. <p><b>Shortcut for finding the proper wiring sequence</b> <p>For 5 wires – 1 is common to be plugged at positive supply and rest four to the pulses. For 6 wires – 2 are common to be plugged at positive supply and rest four to the pulses. <p>Connect the center tap(s) to the power source (or current-Limiting resistor.) Connect the remaining 4 wires in any pattern. If it doesn't work, you only need try these 2 swaps... <p>1 2 3 4 - (arbitrary first wiring order) <p>1 2 4 3 - switch end pair <p>1 4 2 3 - switch middle pair <p>You're finished when the motor turns smoothly in either direction. If the motor turns in the opposite direction from desired, reverse the wires so that ABCD would become DCBA. <p><b>Wiring of stepper motor of different number of wires:</b> <p><b></b> <p><b></b> <table cellpadding="0" border="1"> <tbody> <tr> <td width="75"> <table cellspacing="0" cellpadding="0"> <tbody> <tr> <td width="4"></td></tr> <tr> <td></td> <td><a href="http://lh4.ggpht.com/-oP4eqiT8RH0/VARU0JEbu_I/AAAAAAAAGBA/SW5xd0VGzwo/s1600-h/clip_image021%25255B3%25255D.jpg"><img title="clip_image021" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="161" alt="clip_image021" src="http://lh6.ggpht.com/-MGD5-gYDbHs/VARU1KaBL6I/AAAAAAAAGBI/DQcG6GT5SfQ/clip_image021_thumb.jpg?imgmax=800" width="68" border="0"></a></td></tr></tbody></table> <p>4 wires</p></td> <td width="88"> <table cellspacing="0" cellpadding="0"> <tbody> <tr> <td width="1"></td></tr> <tr> <td></td> <td><a href="http://lh4.ggpht.com/-FOFTbdLT2A8/VARU2OMvwAI/AAAAAAAAGBM/Ug1uzNIEjPc/s1600-h/clip_image023%25255B3%25255D.jpg"><img title="clip_image023" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="161" alt="clip_image023" src="http://lh3.ggpht.com/-j-f3lcdZvBU/VARU244DphI/AAAAAAAAGBY/mEfRDoFA1U8/clip_image023_thumb.jpg?imgmax=800" width="79" border="0"></a></td></tr></tbody></table> <p>5 wires</p></td> <td width="92"> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-cq7QUDWls7NhRlZorDiEwvR3CbgjlqDveUwMRZEnv4bDjHt2_CuShFD1L2uWbI9ShGo5DqmeV_B0eJQY6bj3yMOIpZ06Uwkb5c9Ln4UBvcZtSdMmyeLgO6ZZhsk9AtXFHGn4jyQPNos/s1600-h/clip_image025%25255B3%25255D.jpg"><img title="clip_image025" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="161" alt="clip_image025" src="http://lh5.ggpht.com/-KR6eQtz7ik8/VARU5ewzVQI/AAAAAAAAGBo/2q7TfrPVI80/clip_image025_thumb.jpg?imgmax=800" width="84" border="0"></a> <p>6 wires</p></td> <td width="94"> <table cellspacing="0" cellpadding="0"> <tbody> <tr> <td width="4"></td></tr> <tr> <td></td> <td><a href="http://lh3.ggpht.com/-AFm1oJHCtEE/VARU6diJmtI/AAAAAAAAGBw/2yCRh1gxxRQ/s1600-h/clip_image027%25255B3%25255D.jpg"><img title="clip_image027" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="161" alt="clip_image027" src="http://lh4.ggpht.com/-bJhN8wdP6TA/VARU7hnVLuI/AAAAAAAAGB4/s-08Sa51h8c/clip_image027_thumb.jpg?imgmax=800" width="78" border="0"></a></td></tr></tbody></table> <p>8 wires</p></td></tr></tbody></table> <p>Now that we are done with the circuitry for the wiring sequence, and theory of stepper motor, we will build up a circuit through the use of TTL device to get a supply voltage of 12V.this is because, our stepper motor used is a 12V one and the parallel port gives us only 5V. But before that lets discuss how to intract with parallel port. <p><b><u>2. SOME BASICS OF A PARALLEL PORT</u></b> <p><b></b> <p><b>What is a port? </b> <p><a href="http://lh5.ggpht.com/-Q1fjMFPZeh4/VARU8nVWgkI/AAAAAAAAGCA/4Gsc5H-S19M/s1600-h/clip_image028%25255B3%25255D.gif"><img title="clip_image028" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="46" alt="clip_image028" src="http://lh4.ggpht.com/-ustbkHHDvGE/VARU_AFzafI/AAAAAAAAGCI/uKDs5j-6UqE/clip_image028_thumb.gif?imgmax=800" width="240" border="0"></a><br>A port contains a set of signal lines that the CPU sends or receives data with other components. We use ports to communicate via modem, printer, keyboard, mouse etc. In signaling, open signals are "1" and close signals are "0" so it is like binary system. A parallel port sends 8 bits and receives 5 bits at a time. The serial port RS-232 sends only 1 bit at a time but it is multidirectional so it can send 1 bit and receive 1 bit at a time... <p><b>Figure 10. Parallel Port Configuration</b> <p><b></b> <p><b>Parallel</b><b> Port</b><b> - Data Ports: </b> <p>In sending the sequences, you will need the data ports which can be seen in the picture from D0 to D7 . <p><b>Parallel</b><b> Port</b><b> - Status Ports:</b> <p>These ports are made for reading signals. The range is like in data ports which are S0-S7. But S0, S1, S2 are invisible in the connector. And S0 is different; this bit is for timeout flag in EPP (Enhanced Parallel Port) compatible ports. The address of this status port is 0x379 . This will always be refer to "DATA+1" and it can send 5 numeric data from the 10 - 11 - 12 - 13 - 15 th pins. So how can we reach the data ports? It is simple: every parallel port has an address. In Windows 2000, you can see yours by Settings > Control Panel > System > Hardware > Device Manager > Ports (COM & LPT) > Printer Port(LPT1) > Properties = in Resources > Resource Setting and you can see your address for your parallel port. For Ex: Generally it is 0378-037F. This is hexadecimal like in math (mod 16). <u>0x378 belongs to 888 in decimal form</u>. In this way you can look for your com port or game port addresses. Let's enlighten these bits with a printer example: <ul> <li>S0: This bit becomes higher (1) if a timeout operation occurs in EPP mode. <li>S1: Not used (Maybe for decoration :)) <li>S2: Mostly not used but sometime this bit shows the cut condition (PIRQ) of the port <li>S3: If the printer determines an error it becomes lower (0). Which is called nError or nFault <li>S4: It is high (1) when the data inputs are active. Which is called Select <li>S5: It is high(1) when there is no paper in printer. Which is called PaperEnd, PaperEmpty or PError <li>S6: It sends low impact signaling when the printer gets a one byte data. Which is called nAck or nAcknowledge <li>S7: This is the only reversed pin on the connector (see my table in the article) . If the printer is busy and it cannot get any additional data this pin becomes lower. Which is called Busy </li></ul> <p><b>Parallel</b><b> Port</b><b> - Control Ports:</b> <p>This port usually used for outputting but these can be used for inputting. The range is like in data ports C0-C7 but C4, C5, C6, C7 are invisible in connector. And the address for this is 0x37A <ul> <li>C0: This pin is reversed. It sends a command to read D0-D7 on the port. When the computer starts it is high in the connector. Which is called nStrobe <li>C1: This pin is reversed. It sends a command to the printer to feed the next line. It is high in the connector after the machine starts. Which is called Auto LF <li>C2: This pin is for reset the printer and clear the buffer. Which is called nInit, nInitialize <li>C3: This pin is reversed. Sends a high(1) for opening data inputs. It is low after the machine starts. Which is called nSelectIn <li>C4: Opens the cut operation for the printer. Not visible in the connector... <li>C5: Sets the direction control in multidirectional ports. Not visible in the connector... <li>C6: Not used and also Not visible in the connector... <li>C7: Mostly not used but it is used as a C5 in some ports. Not visible in the connector... </li></ul> <p><b>Parallel</b><b> Port</b><b> -Ground Pins:</b> <p>These are (G0 - G7) the pins from 18 to 25 . These are mostly used for completing the circuit. Different pins are required when using all the pins including the inputs. <p>After these we will be using data ports in experiment because there are reversed pins in control and status ports. Here is an explanation for reversed pins: While you are not sending any signals to the data port it is in closed position like "00000000" so the 8 pins have no voltage on it (0 Volt) .If you send decimal "255" (binary "11111111") every pin (D0-D7) has a +5 Volt... On the other hand, if we use control ports, there are reversed pins which are C0, C1 and C3 so while we send nothing to the control port its behaviour is "0100" in binary (decimal "11")... <table cellpadding="0" border="1"> <tbody> <tr> <td width="41%"> <p><b>Signal</b></p></td> <td width="12%"> <p><b>BIT</b></p></td> <td width="12%"> <p><b>PIN</b></p></td> <td width="26%"> <p><b>Direction</b></p></td> <td valign="top" width="2%"> <p><b></b></p></td></tr> <tr> <td width="41%"> <p>-Strobe </p></td> <td> <p>¬C0 </p></td> <td> <p>1</p></td> <td> <p>Output </p></td> <td valign="top" width="2%"> </td></tr> <tr> <td width="41%"> <p>+Data Bit 0</p></td> <td> <p>D0 </p></td> <td> <p>2</p></td> <td> <p>Output </p></td> <td valign="top" width="2%"> </td></tr> <tr> <td width="41%"> <p>+Data Bit 1</p></td> <td> <p>D1 </p></td> <td> <p>3</p></td> <td> <p>Output</p></td> <td valign="top" width="2%"> </td></tr> <tr> <td width="41%"> <p>+Data Bit 2</p></td> <td> <p>D2 </p></td> <td> <p>4</p></td> <td> <p>Output</p></td> <td valign="top" width="2%"> </td></tr> <tr> <td width="41%"> <p>+Data Bit 3</p></td> <td> <p>D3 </p></td> <td> <p>5</p></td> <td> <p>Output</p></td> <td valign="top" width="2%"> </td></tr> <tr> <td width="41%"> <p>+Data Bit 4</p></td> <td> <p>D4 </p></td> <td> <p>6</p></td> <td> <p>Output</p></td> <td valign="top" width="2%"> </td></tr> <tr> <td width="41%"> <p>+Data Bit 5</p></td> <td> <p>D5 </p></td> <td> <p>7</p></td> <td> <p>Output</p></td> <td valign="top" width="2%"> </td></tr> <tr> <td width="41%"> <p>+Data Bit 6</p></td> <td> <p>D6 </p></td> <td> <p>8</p></td> <td> <p>Output</p></td> <td valign="top" width="2%"> </td></tr> <tr> <td width="41%"> <p>+Data Bit 7</p></td> <td> <p>D7 </p></td> <td> <p>9</p></td> <td> <p>Output</p></td> <td valign="top" width="2%"> </td></tr> <tr> <td width="41%"> <p>-Acknowledge </p></td> <td> <p>S6 </p></td> <td> <p>10</p></td> <td> <p>Input</p></td> <td valign="top" width="2%"> </td></tr> <tr> <td width="41%"> <p>+Busy </p></td> <td> <p>¬S7 </p></td> <td> <p>11</p></td> <td> <p>Input</p></td> <td valign="top" width="2%"> </td></tr> <tr> <td width="41%"> <p>+Paper End </p></td> <td> <p>S5</p></td> <td> <p>12</p></td> <td> <p>Input</p></td> <td valign="top" width="2%"> </td></tr> <tr> <td width="41%"> <p>+Select In </p></td> <td> <p>S4</p></td> <td> <p>13</p></td> <td> <p>Input</p></td> <td valign="top" width="2%"> </td></tr> <tr> <td width="41%"> <p>-Auto Feed </p></td> <td> <p>¬C1</p></td> <td> <p>14</p></td> <td> <p>Output</p></td> <td valign="top" width="2%"> </td></tr> <tr> <td width="41%"> <p>-Error </p></td> <td> <p>S3 </p></td> <td> <p>15</p></td> <td> <p>Input</p></td> <td valign="top" width="2%"> </td></tr> <tr> <td width="41%"> <p>-Initialize </p></td> <td> <p>C2 </p></td> <td> <p>16</p></td> <td> <p>Output</p></td> <td valign="top" width="2%"> </td></tr> <tr> <td width="41%"> <p>-Select </p></td> <td> <p>¬C3 </p></td> <td> <p>17</p></td> <td> <p>Output</p></td> <td valign="top" width="2%"> </td></tr> <tr> <td width="41%"> <p>Ground </p></td> <td> <p>- </p></td> <td> <p>18-25 </p></td> <td> <p>Ground</p></td> <td valign="top" width="2%"> </td></tr></tbody></table> <p><b><u></u></b> <p><b><u></u></b> <p><b><u></u></b> <p><b><u></u></b> <p><b><u></u></b> <p><b><u>CIRCUIT</u></b> <p><b>Electricity - Lets get some Zzzzzttt zzzzttt...</b> <p><b></b> <p><b><i>Note- Here the circuit is based on running a stepper motor of 12V (dc), 1.8 DEG/Step, .16A/Phase</i></b> <p>Here, we will build up a circuit through the use of TTL device to get a supply voltage of 12V; this is because, our stepper motor used is a 12V one and the parallel port gives us only 5V. <p>Here I have used IC ULN2803, which is an 8-bit, TTL-input npn Darlington driver with a maximum rating of 50V, 500mA. You can also use high current gain transistor like CMJE 3055T and place diodes to block the back current flow. <table cellspacing="0" cellpadding="0"> <tbody> <tr> <td width="84"></td></tr> <tr> <td></td> <td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJrgUSbZ7j_uNmA4t5g_KHhSWll9WntQqQbHqk_HeWWT81L3bmneJpWjGLiQ-lIYxbNPyWS6DaFLV0S1G4fNojdSKdN5QrjWev3H6OI18X3Y6FwzQ7S3r9ueAT4H3x-hUbNztG2h74UcI/s1600-h/clip_image030%25255B4%25255D.jpg"><img title="clip_image030" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="239" alt="clip_image030" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisp_T_r-YaEh3VbrruUJMwsVNSL7yChXwNvibrXJhuz1qdplA180V7KkmesXTytQvHIpjR-mHw0I_pYSpcIyGeJyhRWDFnYzlJP53oLGKn5wmdefVqqXQgsCNph1dGlgnKDb1C03275fc/?imgmax=800" width="362" border="0"></a></td></tr></tbody></table><br>As Parallel port is very delicate port attached with mother board, any back current or reverse emf can blow your entire parallel port along with motherboard off. To prevent this you need to isolate it through optocouplers. Any optocouplers will serve the purpose and safeguard the computer. Here I have used IC 4N35. <table cellspacing="0" cellpadding="0"> <tbody> <tr> <td width="241"></td></tr> <tr> <td></td> <td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiSd_zlB-VWICG2lGmkzcZ9z7EmiDqKD4cBgAwWpWRhaxieFFgsRYyrODv9f2rCbFzZ-3RJ5Q0zM-AuJcG3DO1WMHp8osWeexvUfr06omMtYZpznkQgKhWcDFriGSUi6QVZcK_7uMdhUqU/s1600-h/clip_image032%25255B4%25255D.jpg"><img title="clip_image032" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="308" alt="clip_image032" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOFHS8lES1Bg0Gyki3p3EhbtYkgfjoC6kuQEXSQsFuYnNmQf9xZPtHzUNBPxGZXD4Ic_rkPNcjUqpMvVWOMsHENWNBG9DDD_K-rRzK6x8OficEEsMKmC_3qXERztYl9zLqe5MxAEBObHg/?imgmax=800" width="169" border="0"></a></td></tr></tbody></table><br><b>Figure 10. 4N35 IC configuration</b> <p><b>Figure 11. IC ULN2803 configuration</b> <p><b></b> <p><b>The Circuit Diagram: </b> <p><b></b> <p>The simplest circuit diagram with no optocouplers is the figure 12: <table cellspacing="0" cellpadding="0"> <tbody> <tr> <td width="24"></td></tr> <tr> <td></td> <td><a href="http://lh3.ggpht.com/-4lUb-JxI00M/VARVD9RP8PI/AAAAAAAAGCw/sOZSEL04oKA/s1600-h/clip_image034%25255B4%25255D.jpg"><img title="clip_image034" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="252" alt="clip_image034" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi45_1Y3tu1VwIfWLd7H6_2Fu7ZKMq1-tdlqCV45gQlfUufmG7jNuQEVcTJYJ0W3B3O6U3U766Otx1wEfNzEwk4LD083EBDMPRGd8KDH_vuNC8gPFCTjfo2hB-s9-BnpBPv4ZcTQiFhzco/?imgmax=800" width="384" border="0"></a></td></tr></tbody></table><br><b>Figure 12. Circuit diagram 1</b> <p><b><u></u></b> <p><b><u></u></b> <p><b><u></u></b> <p><b><u>Enhancing the circuit.</u></b> <p><b><u></u></b> <p>You can add optocouplers for safety of your motherboard. As nobody wants to blow the motherboard through reverse emf sent back or if IC internals get short circuited. <p>All you need to do is connect the dataport inputs to Anode of IC 4N35 or any optocouplers. Make cathode ground by grounding to any of the ports ground pin. <p>On the other side, connect the emiiter to to IC and give 5V to the collector. <p>This will act as a switch between your circuit and parallel port safeguarding it from any damage. <p><b>And…</b> <table cellspacing="0" cellpadding="0"> <tbody> <tr> <td width="192"></td></tr> <tr> <td></td> <td><a href="http://lh5.ggpht.com/-l3uuRJe7O4s/VARVGQ333PI/AAAAAAAAGDA/ZjN6N9cXOhM/s1600-h/clip_image036%25255B4%25255D.jpg"><img title="clip_image036" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="246" alt="clip_image036" src="http://lh6.ggpht.com/-Vwu9ZuZHLHI/VARVHiivFJI/AAAAAAAAGDI/GBcqjOKloPk/clip_image036_thumb%25255B1%25255D.jpg?imgmax=800" width="329" border="0"></a></td></tr></tbody></table><br><u><b>If you want to build the circuit without an IC…</b></u> <p><b></b> <p><b>C MJE 3055T</b> <p>What if you want to make your own Darlington pair. Well ofcource you can. <p>Here I show the circuit using very high current gain robust npn transistor Mje 3055T. <p>Mmm…I tried to make it on paint, but my mice drawing being very poor I will explain it… <p>· Connect the optocpupler input from parallel port as described above. <p>· Now, you don’t need additional 5 V supply as you can take 12 V from the other circuit by making these simple changes: <p>o Connect the emitter of optocoupler to base of transistor. <p>o Connect the collector of optocoupler to the collector of the transistor. <p>What this will do is act as a switch. As soon as the photo-diode is activated it infrared light, which falls on the base of optocoupler, making it saturate. It will hence pass current from collector to emitter. This will trigger base of 3055T transistor to go into saturation. <p>· Ground the emitter of 3055T transistor to ground of 12V supply. <p>· Put diodes IN4007 in reverse bias direction from negative and positive supply of 12 V with the collector. That is, positive end in the negative supply and the other to collector. And the negative side of diode to positive supply of 12V and other end to collector just to make sure that any back current doesn’t flow. <p>· If you want, put a good capacitor (which can sustain) between negative and positive supply of 12V as a filter in the circuit. I have used 100 Micro F, 63V electrolytic capacitor. <p>· Now all set and done in securing and enhancing the circuit… Now connect the common cord of stepper motor to positive supply and rest four into the collector of the transistors. <p><b><u>The Programming part</u></b> <p><b><u></u></b> <p><b><u>Before Coding</u></b> <p><b>Mmmm… A problem that plagues Windows NT/2000 and Windows XP</b> <p><b></b> <p>Unlike Windows 95 & 98, Windows NT/2000/XP will cause an exception (Privileged Instruction) if an attempt is made to access a port that you are not privileged to talk too. Actually it's not Windows NT that does this, but any 386 or higher processor running in protected mode. <p>Accessing I/O Ports in protected mode is governed by two events, The I/O privilege level (IOPL) in the EFLAGS register and the I/O permission bit map of a Task State Segment (TSS). <p>Under Windows NT, there are only two I/O privilege levels used, level 0 & level 3. Usermode programs will run in privilege level 3, while device drivers and the kernel will run in privilege level 0, commonly referred to as ring 0. This allows the trusted operating system and drivers running in kernel mode to access the ports, while preventing less trusted usermode processes from touching the I/O ports and causing conflicts. All usermode programs should talk to a device driver which arbitrates access. <p>The I/O permission bitmap can be used to allow programs not privileged enough (I.e. usermode programs) the ability to access the I/O ports. When an I/O instruction is executed, the processor will first check if the task is privileged enough to access the ports. Should this be the case, the I/O instruction will be executed. However if the task is not allowed to do I/O, the processor will then check the I/O permission bitmap. <p>The I/O permission bitmap, as the name suggests uses a single bit to represent each I/O address. If the bit corresponding to a port is set, then the instruction will generate an exception however if the bit is clear then the I/O operation will proceed. This gives a means to allow certain processes to access certain ports. There is one I/O permission bitmap per task. <p><b>Accessing I/O Ports under NT/2000/XP</b><b></b> <p>There are two solutions to solving the problem of I/O access under Windows NT. The first solution is to write a device driver which runs in ring 0 (I/O privilege level 0) to access your I/O ports on your behalf. Data can be passed to and from your usermode program to the device driver via IOCTL calls. The driver can then execute your I/O instructions. The problem with this, is that it assumes you have the source code to make such a change. <p>Another possible alternative is to modify the I/O permission bitmap to allow a particular task, access to certain I/O ports. This grants your usermode program running in ring 3 to do unrestricted I/O operations on selected ports, per the I/O permission bitmap. This method is not really recommended, but provides a means of allowing existing applications to run under windows NT/2000. Writing a device driver to support your hardware is the preferred method. The device driver should check for any contentions before accessing the port. <p>Well, there are lots of routines, source codes, device drivers, dlls available on the internet who will make your task easy. Like userport1, porttalk, give-io, remove-give-io, inpout32, etc etc. <p>You can run userport1 routine and get freed, or if you need dlls get ipout32.dll(latest version) and use it. <p><b>Now Lets make the code to do the rest</b> <p>I used <i>inpout32.dll</i> in my application as the Sir (Ram Kishore) who thought me about this knows Visual Basic very well, so I learned VB and worked with him. You can check the workflow below for <i>inpout32.dll</i> and also you can get the source of the dll from the internet. <table cellspacing="0" cellpadding="0"> <tbody> <tr> <td width="24"></td></tr> <tr> <td></td> <td><a href="http://lh5.ggpht.com/-IDHwZ9Aa6pc/VARVIr_ixaI/AAAAAAAAGDQ/u4WN43Cwbo0/s1600-h/clip_image038%25255B4%25255D.gif"><img title="clip_image038" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="326" alt="clip_image038" src="http://lh6.ggpht.com/-r9F4ZqjvbVo/VARVJlKTwUI/AAAAAAAAGDY/0utp5o9Qj2M/clip_image038_thumb%25255B1%25255D.gif?imgmax=800" width="375" border="0"></a></td></tr></tbody></table><br><b>Note</b>: I am importing it with the reference of http://www.logix4u.net/ So for further info about the driver check out the site... <p><b>The Program</b> <p>I made the coding in Microsoft Excel VB editor as in excel, it complies automatically and you can make dynamic changes. It doesn’t create the exe file, but excel worksheet act as a form. <p>In Excel go to tool->Macros->VB editor. <p>In new window, click insert Module. <p>In module type: <p>Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" _ <p>(ByVal PortAddress As Integer) _ <p>As Integer <p>Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" _ <p>(ByVal PortAddress As Integer, _ <p>ByVal Value As Integer) <table cellspacing="0" cellpadding="0"> <tbody> <tr> <td width="24"></td></tr> <tr> <td></td> <td><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5p7ZQaA_9hfxWA0CJNSLDDiGd2fpsH5Fto16h2C6Wl2RfgOIujFNNidWEduZ4N4tFiK1uFlSnP2CiceNNerp_NmZub4TKYgOsG3dyS_ENq4CC6pwestwzuX34Wnh2ezhyrH6IWC9EQi8/s1600-h/clip_image040%25255B4%25255D.jpg"><img title="clip_image040" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="255" alt="clip_image040" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4PQ5Bh0LeV4pYCSJMmWc1od7KOJbmGx4X2E9GIY3X8g-8yHXavXDnIq8qPhUPJQ_N5AII6g4oEMYOm09XYEbz_5Aw6LM3vVKO2JuaMhFEK8aVFulDfiTu7Ao7buRUs6pg1so78XGanFI/?imgmax=800" width="502" border="0"></a></td></tr></tbody></table><br>This will call ipout32.dll from system32 directory of your windows, and your port will also open. <p>Now create buttons in worksheet <p>In editor, <p>Edit buttons as follows <p>Private Sub CommandButton1_Click() <p>countit = 0 <p>myTimer = 0 <p>countit = Sheet1.Cells(4, 1) <p>MsgBox "Before Starting...Please be Patience as it may take few minutes" <p>Do While countit > 0 <p>myTimer = Sheet1.Cells(4, 3) <p>Out 888, 3 <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>myTimer = Sheet1.Cells(4, 3) <p>Out 888, 6 <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>Out 888, 12 <p>myTimer = Sheet1.Cells(4, 3) <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>Out 888, 9 <p>myTimer = Sheet1.Cells(4, 3) <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>countit = countit - 1 <p>Loop <p>Out 888, 0 <p>MsgBox "Done" <p>End Sub <p>Private Sub CommandButton2_Click() <p>Out 888, 0 <p>End Sub <p>Private Sub CommandButton3_Click() <p>countit = 0 <p>myTimer = 0 <p>countit = Sheet1.Cells(4, 1) <p>MsgBox "Before Starting...Please be Patience as it may take few minutes" <p>Do While countit > 0 <p>myTimer = Sheet1.Cells(4, 3) <p>Out 888, 1 <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>myTimer = Sheet1.Cells(4, 3) <p>Out 888, 2 <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>Out 888, 4 <p>myTimer = Sheet1.Cells(4, 3) <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>Out 888, 8 <p>myTimer = Sheet1.Cells(4, 3) <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>countit = countit - 1 <p>Loop <p>Out 888, 0 <p>End Sub <p>Private Sub CommandButton4_Click() <p>countit = 0 <p>myTimer = 0 <p>countit = Sheet1.Cells(4, 1) <p>MsgBox "Before Starting...Please be Patience as it may take few minutes" <p>Do While countit > 0 <p>myTimer = Sheet1.Cells(4, 3) <p>Out 888, 1 <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>myTimer = Sheet1.Cells(4, 3) <p>Out 888, 3 <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>Out 888, 2 <p>myTimer = Sheet1.Cells(4, 3) <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>Out 888, 6 <p>myTimer = Sheet1.Cells(4, 3) <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>myTimer = Sheet1.Cells(4, 3) <p>Out 888, 4 <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>myTimer = Sheet1.Cells(4, 3) <p>Out 888, 12 <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>Out 888, 8 <p>myTimer = Sheet1.Cells(4, 3) <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>Out 888, 9 <p>myTimer = Sheet1.Cells(4, 3) <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>countit = countit - 1 <p>Loop <p>Out 888, 0 <p>End Sub <p>Private Sub CommandButton5_Click() <p>countit = 0 <p>myTimer = 0 <p>countit = Sheet1.Cells(4, 1) <p>MsgBox "Before Starting...Please be Patience as it may take few minutes" <p>Do While countit > 0 <p>myTimer = Sheet1.Cells(4, 3) <p>Out 888, 8 <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>myTimer = Sheet1.Cells(4, 3) <p>Out 888, 4 <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>Out 888, 2 <p>myTimer = Sheet1.Cells(4, 3) <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>Out 888, 1 <p>myTimer = Sheet1.Cells(4, 3) <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>countit = countit - 1 <p>Loop <p>Out 888, 0 <p>End Sub <p>Private Sub CommandButton6_Click() <p>countit = 0 <p>myTimer = 0 <p>countit = Sheet1.Cells(4, 1) <p>MsgBox "Before Starting...Please be Patience as it may take few minutes" <p>Do While countit > 0 <p>myTimer = Sheet1.Cells(4, 3) <p>Out 888, 9 <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>myTimer = Sheet1.Cells(4, 3) <p>Out 888, 12 <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>Out 888, 6 <p>myTimer = Sheet1.Cells(4, 3) <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>Out 888, 3 <p>myTimer = Sheet1.Cells(4, 3) <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>countit = countit - 1 <p>Loop <p>Out 888, 0 <p>MsgBox "Done" <p>End Sub <p>Private Sub CommandButton7_Click() <p>countit = 0 <p>myTimer = 0 <p>countit = Sheet1.Cells(4, 1) <p>MsgBox "Before Starting...Please be Patience as it may take few minutes" <p>Do While countit > 0 <p>myTimer = Sheet1.Cells(4, 3) <p>Out 888, 9 <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>myTimer = Sheet1.Cells(4, 3) <p>Out 888, 8 <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>Out 888, 12 <p>myTimer = Sheet1.Cells(4, 3) <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>Out 888, 4 <p>myTimer = Sheet1.Cells(4, 3) <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>myTimer = Sheet1.Cells(4, 3) <p>Out 888, 6 <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>myTimer = Sheet1.Cells(4, 3) <p>Out 888, 2 <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>Out 888, 3 <p>myTimer = Sheet1.Cells(4, 3) <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>Out 888, 1 <p>myTimer = Sheet1.Cells(4, 3) <p>Do While myTimer > 0 <p>myTimer = myTimer - 1 <p>Loop <p>countit = countit - 1 <p>Loop <p>Out 888, 0 <p>End Sub <p><b><u>Also I/O Port Access in Turbo C, Borland C/C++</u></b> <p><b><u></u></b> <p>Turbo C and Borland C/C++ provide access to the I/O ports on the 80x86 CPU via the predefined functions <b>inportb</b> / <b>inport</b> and <b>outportb</b> / <b>outport</b>. <p>int inportb(int <i>portid</i>); /* returns a byte read from the I/O port <i>portid</i> */ <p>int inport(int <i>portid</i>); /* returns a word read from the I/O port <i>portid</i> */ <p>void outportb(int <i>portid</i>, unsigned char <i>value</i>); <p>/* writes the byte <i>value</i> to the I/O port <i>portid</i> */ <p>void outport(int <i>portid</i>, int <i>value</i>); <p>/* writes the word <i>value</i> to the I/O port <i>portid</i> */ <table cellspacing="0" cellpadding="0" border="0"> <tbody> <tr> <td valign="top"> <p>#include <stdio.h> <p>#include <dos.h> <p>#define Data 0x378 <p>#define Status 0x379 <p>#define Control 0x37a <p>unsigned char Bits; <p>outportb(Data,Bits); /* output data */ <p>Bits = inportb(Status); /* input data */</p></td></tr></tbody></table> <p><b>I got a program for same to run in UNIX. I have not checked it, neither I had made. But it has been tested and run. I got it from, Mr. Rachit Rastogi doing final year M.Tech in IS from IIITA. Heres the code…</b> <p><b></b> <p>#include<unistd.h> <p>#include<sys/io.h> <p>#include<stdio.h> <p>#include <termios.h> <p>#include <curses.h> <p>#include <term.h> <p>// global data required for terminal settings and char value <p>static struct termios initial_settings,new_settings; <p>static char key; <p>static int stepData[4]={1,2,4,8}; <p>static int pos=1; <p>static int peek_char=-1; <p>// global data declaring port values <p>#define DATAPORT 0x378 <p>#define CONTROLPORT 0x37a <p>//functions declarations <p>void init_kb(); <p>void close_kb(); <p>void move_right(); <p>void move_left(); <p>void move_forward(); <p>void move_backward(); <p>void stop(); <p>enum mot {still,forward,backward}; <p>static enum mot motVal=still; <p>int kbhit(); <p>int readch(); <p>int main(void) <p>{ <p>int x,temp,id,uid; <p>// uid=getuid(); <p>init_kb(); //initialize keyboard <p>if(ioperm(DATAPORT,3,1)!=0) // if permissions failed <p>{ <p>printf("premission to the ports denied"); <p>close_kb(); <p>return 0; <p>} <p>printf("permission to the port granted\n"); <p>outb(0,CONTROLPORT); //set the mode of the parallel port to write mode <p>//setuid(uid); <p>printf("port mode successfully changed to write mode\n\n"); <p>outb(0,DATAPORT); <p>printf("motor intialized\n "); <p>printf("entering the motor control area\n"); <p>while(1) <p>{ <p>key=kbhit(); <p>if(key=='q') <p>break; <p>if(key=='6') <p>move_right(); <p>if(key=='4') <p>move_left(); <p>if(key=='8') <p>move_forward(); <p>if(key=='2') <p>move_backward(); <p>if(key=='5') <p>stop(); <p>} <p>outb(0,DATAPORT); <p>close_kb(); <p>exit(0); <p>} <p>// function definitions <p>void stop() <p>{ <p>motVal=still; <p>outb(0,DATAPORT); <p>} <p>void move_right() <p>{ <p>if(motVal==forward) <p>outb(9,DATAPORT); <p>if(motVal==backward) <p>outb(10,DATAPORT); <p>if(motVal==still) <p>outb(8,DATAPORT); <p>//outb(stepData[pos++],DATAPORT); <p>//pos=pos%4; <p>} <p>void move_left() <p>{ <p>if(motVal==forward) <p>outb(5,DATAPORT); <p>if(motVal==backward) <p>outb(6,DATAPORT); <p>if(motVal==still) <p>outb(4,DATAPORT); <p>//outb(stepData[pos--],DATAPORT); <p>//pos=(pos+4)%4; <p>} <p>void move_forward() <p>{ <p>motVal=forward; <p>outb(1,DATAPORT); <p>} <p>void move_backward() <p>{ <p>motVal=backward; <p>outb(2,DATAPORT); <p>} <p>void init_kb() <p>{ <p>tcgetattr(0,&initial_settings); <p>new_settings=initial_settings; <p>new_settings.c_lflag &= ~ICANON; <p>new_settings.c_lflag &= ~ECHO; <p>new_settings.c_lflag &= ~ISIG; <p>new_settings.c_cc[VMIN] = 1; <p>new_settings.c_cc[VTIME] = 0; <p>tcsetattr(0,TCSANOW,&new_settings); <p>} <p>void close_kb() <p>{ <p>tcsetattr(0,TCSANOW,&initial_settings); <p>} <p>int kbhit() <p>{ <p>char ch; <p>int nread; <p>if(peek_char !=-1) <p>return 1; <p>new_settings.c_cc[VMIN] = 0; <p>tcsetattr(0,TCSANOW,&new_settings); <p>nread=read(0,&ch,1); <p>new_settings.c_cc[VMIN]=1; <p>tcsetattr(0,TCSANOW,&new_settings); <p>if(nread ==1) <p>{ <p>peek_char=-1; <p>return ch; <p>} <p>return 0; <p>} <p>int readch() <p>{ <p>char ch; <p>if(peek_char !=-1) <p>{ <p>ch=peek_char; <p>peek_char=-1; <p>return ch; <p>} <p>read(0,&ch,1); <p>return ch; <p>} mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-19631692254384662232014-09-01T02:28:00.001-07:002014-09-01T02:59:45.781-07:00Sheet Metal Work using SolidWorks<b>Sheet Metal Work using SolidWorks</b> <br />
<b>Creating a base flange</b> <br />
When you develop a sheet metal part, you generally design the part in the folded state. To create a sheet metal part, you sketch an open profile and use the base flange feature to create the thin feature and the bends. <br />
<h3>
Step 1 Select the part drawing component</h3>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKzg_JZSFWCpi9xk-87hM7NAQAxiv2wXQPe6CxUuchNUL1STwVOpcaIZ6hi1GP0-jZ75h2S0H1R_RUVpZ0n1L9gB6wHiiDuYAa5UvZIpJQKynv7oAqXKjBFvUO47x1Q01XeZ6zf5QFa1o/s1600-h/clip_image002%25255B7%25255D%25255B2%25255D.jpg"><img alt="clip_image002[7]" border="0" src="http://lh3.ggpht.com/-JNIk8zTR6bY/VAQ61ln4C3I/AAAAAAAAF1Q/gmhrZwOqGKA/clip_image002%25255B7%25255D_thumb.jpg?imgmax=800" height="154" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image002[7]" width="244" /></a> <br />
<h3>
Step 2 Click on the base-Flange/Tab in sheet metal tool bar</h3>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjHfR6DNKCllfnMd9-EheFJ5aAxjhQPbDM36bSteZHJX-GpFUbhFHOJ4HqOASGXBAoiO05zFDKaB5B088O6VdEFNGe0l1v3CcDI9IY2cZvXefepEKawGZkEp2-NdTBgyH5rYKfgvn2Snlk/s1600-h/clip_image004%25255B5%25255D%25255B2%25255D.jpg"><img alt="clip_image004[5]" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3FHWSaRoA_gQ0v9KfMnvd4OAv-IdjUtmPycMmgILrKsq69z-zgzjIvLWR1Ifklb5DmLPv20O91gs6ChZftCcAJDCvHikdWuM3LnjSmU-f4sZxIClR_4v1MJ894f1VzAiseJg_qiOzxws/?imgmax=800" height="154" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image004[5]" width="244" /></a> <br />
<h3>
Step 3 Select the plane to draw the cross-section of the sheet metal part</h3>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifS3fC9-7mABjCH7_LGDMeUxDNhgbIqsiWEWpchSo3x3moknsHaNKuH5qSG-YaX7vTjEdWuOsAJKY8zeWIuDOVFk7xIDOQqb9_XCt0yx0gnm00nHGgGCeoinxl8k185ppGn13jNTHGpWw/s1600-h/clip_image006%25255B5%25255D%25255B2%25255D.jpg"><img alt="clip_image006[5]" border="0" src="http://lh3.ggpht.com/-WJVp3YzJX6s/VAQ6741nvrI/AAAAAAAAF1w/y0u_YpJ4Uck/clip_image006%25255B5%25255D_thumb.jpg?imgmax=800" height="154" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image006[5]" width="244" /></a> <br />
<h3>
Step 4 Draw the cross section using lines then you can give thickness later</h3>
<a href="http://lh3.ggpht.com/-IHtCESHoBIY/VAQ68zn3bSI/AAAAAAAAF14/G2Bf9-zVZOs/s1600-h/clip_image008%25255B5%25255D%25255B2%25255D.jpg"><img alt="clip_image008[5]" border="0" src="http://lh4.ggpht.com/-Px1c_PwoRiY/VAQ6-ltJPZI/AAAAAAAAF2A/YpbQ3exOLnM/clip_image008%25255B5%25255D_thumb.jpg?imgmax=800" height="177" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image008[5]" width="244" /></a> <br />
<h3>
Step 5 Then click on exit sketch icon</h3>
<a href="http://lh4.ggpht.com/-2gNV_EnfnxQ/VAQ6_fiWTxI/AAAAAAAAF2I/gCnUyOczO6U/s1600-h/clip_image010%25255B5%25255D%25255B2%25255D.jpg"><img alt="clip_image010[5]" border="0" src="http://lh3.ggpht.com/-fdYRWXJJGyU/VAQ7ApYomvI/AAAAAAAAF2Q/nMq7Xh6Cz0Y/clip_image010%25255B5%25255D_thumb.jpg?imgmax=800" height="195" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image010[5]" width="244" /></a> <br />
<h3>
Step 6 Give the length of the part</h3>
<a href="http://lh4.ggpht.com/-JDdkJOUZyLc/VAQ7BkkpGCI/AAAAAAAAF2Y/64WM9WWYfIQ/s1600-h/clip_image012%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image012[4]" border="0" src="http://lh6.ggpht.com/-XMb-3uwnSvI/VAQ7C0xq5ZI/AAAAAAAAF2g/9EF-nVNKy7c/clip_image012%25255B4%25255D_thumb.jpg?imgmax=800" height="244" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image012[4]" width="138" /></a> <br />
<h3>
Step 7 Give the K factor it is a material property</h3>
<a href="http://lh5.ggpht.com/-O2rTalyHwhY/VAQ7ElwKgwI/AAAAAAAAF2o/5d1E59b5hmU/s1600-h/clip_image014%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image014[4]" border="0" src="http://lh5.ggpht.com/-cgV5H0JY_RI/VAQ7Fl_C4SI/AAAAAAAAF2w/oOFlbpWX-cs/clip_image014%25255B4%25255D_thumb.jpg?imgmax=800" height="227" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image014[4]" width="244" /></a> <br />
<h3>
Step 8 Click on the right corner tick mark</h3>
<a href="http://lh4.ggpht.com/-xBlIvaQaZzQ/VAQ7GhmFQ_I/AAAAAAAAF24/yYsnT1vYDHY/s1600-h/clip_image016%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image016[4]" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhu1x-Pml_61C6xLOWa-Vc8SDxmm0C1C-JNngjeCHTCMxZm0uQbf1ZgG9GvjCDpM2WxnAsCBwE7T7AAGXXYXwGujq6e2gVbPSKe5txT39HJL-Mlwl4D-2QaiE_9-TlRrvRwPFSHIHiDazE/?imgmax=800" height="244" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image016[4]" width="235" /></a> <br />
<h3>
Finish</h3>
<a href="http://lh6.ggpht.com/-JDnzyp7XemQ/VAQ7JRKQmMI/AAAAAAAAF3I/Oo0rhHoqgvE/s1600-h/clip_image018%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image018[4]" border="0" src="http://lh4.ggpht.com/-G0VId02Qc3c/VAQ7Kb9CrsI/AAAAAAAAF3Q/5gUAey2WZKg/clip_image018%25255B4%25255D_thumb.jpg?imgmax=800" height="181" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image018[4]" width="244" /></a>. <br />
<h1>
1. Adding a miter flange</h1>
You can add flanges to your sheet metal part with corners that are automatically mitered. First you add a notch to limit the propagation of the miter flange. Then you add and dimension the sketch for the miter flange.<br />
<h3>
Step1</h3>
<a href="http://lh5.ggpht.com/-U5ps8Ha4IKU/VAQ7L8e5R2I/AAAAAAAAF3Y/Iy82uvVUr3M/s1600-h/clip_image020%25255B4%25255D%25255B3%25255D.jpg"><img alt="clip_image020[4]" border="0" src="http://lh3.ggpht.com/-6iaAB1gCBWY/VAQ7NfHdsuI/AAAAAAAAF3g/OFkSvKj1OpY/clip_image020%25255B4%25255D_thumb%25255B1%25255D.jpg?imgmax=800" height="283" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image020[4]" width="318" /></a><br />
<br />
<h3>
Step2</h3>
<a href="http://lh3.ggpht.com/-Yfx2zdDwG3M/VAQ7OBAiwUI/AAAAAAAAF3o/R616G8Sct0c/s1600-h/clip_image022%25255B4%25255D%25255B3%25255D.jpg"><img alt="clip_image022[4]" border="0" src="http://lh5.ggpht.com/-xCJFBnt8ibs/VAQ7PrGKBeI/AAAAAAAAF3w/wGSl_jWR0R0/clip_image022%25255B4%25255D_thumb%25255B1%25255D.jpg?imgmax=800" height="251" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image022[4]" width="374" /></a> . <br />
<h3>
Step3</h3>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiq-y-KOHUje8NL1Um-GMW-L4XGMoEfI7VYaAo53LwFKuBLkOyyw9QmDFPm7tqFuTTIWKUmabA1GXvKKwTe7xKfPPeoeaUYnIc4WEuKN3iASBqsTI5WkowIc7F5axNCu8Mt85Di7WS4W9k/s1600-h/clip_image024%25255B4%25255D%25255B3%25255D.jpg"><img alt="clip_image024[4]" border="0" src="http://lh6.ggpht.com/-D7pUwZQhHFo/VAQ7RyNKWqI/AAAAAAAAF4A/YfWwKkvYUWs/clip_image024%25255B4%25255D_thumb%25255B1%25255D.jpg?imgmax=800" height="267" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image024[4]" width="382" /></a> <br />
<h3>
Step4</h3>
<a href="http://lh3.ggpht.com/-Nj0aDdxh4b4/VAQ7TChG1GI/AAAAAAAAF4I/BGFWSL45S5Q/s1600-h/clip_image026%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image026[4]" border="0" src="http://lh6.ggpht.com/--iuP2m93WKU/VAQ7UAoNQAI/AAAAAAAAF4Q/SuSyV7AJY8k/clip_image026%25255B4%25255D_thumb.jpg?imgmax=800" height="176" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image026[4]" width="244" /></a><br />
<h3>
Step5</h3>
<a href="http://lh5.ggpht.com/-JQV1DCvYfzk/VAQ7VTV7ApI/AAAAAAAAF4U/YUrEgcrtpzA/s1600-h/clip_image028%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image028[4]" border="0" src="http://lh6.ggpht.com/-KuQ3Eh54Qb4/VAQ7WR7AAzI/AAAAAAAAF4c/aX6mmOX5d_Y/clip_image028%25255B4%25255D_thumb.jpg?imgmax=800" height="197" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image028[4]" width="244" /></a> <br />
<br />
<h3>
Step6</h3>
<a href="http://lh4.ggpht.com/-qfSrv9vACfM/VAQ7XtER3DI/AAAAAAAAF4o/04VPm4lbgOI/s1600-h/clip_image030%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image030[4]" border="0" src="http://lh4.ggpht.com/-dif3_HbyOzk/VAQ7Y4IUHZI/AAAAAAAAF4w/HfGdecxCqQ4/clip_image030%25255B4%25255D_thumb.jpg?imgmax=800" height="244" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image030[4]" width="239" /></a> <br />
<h3>
Step7</h3>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRRiPv0oSBFoa2H5SXZSCNemtI4kZL4lo91LJd6L3L-MkDHr59P8kLqH8JJHEXzjM5NIO7DkOYJ56vjafPbGmUOMTUduzJmDyYLrTyRCgbDddCzm9ljcK1gbeirc96oLtlAQgCH_7yQyU/s1600-h/clip_image032%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image032[4]" border="0" src="http://lh6.ggpht.com/-7rhj_70-rLs/VAQ7bYJsTuI/AAAAAAAAF5A/UThUCoJ8Z6E/clip_image032%25255B4%25255D_thumb.jpg?imgmax=800" height="149" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image032[4]" width="139" /></a> <br />
<h3>
Step8</h3>
<a href="http://lh6.ggpht.com/-j1IFUbouB6s/VAQ7cWa8ZNI/AAAAAAAAF5I/KdSYP6y45bA/s1600-h/clip_image034%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image034[4]" border="0" src="http://lh4.ggpht.com/-hGc5hFg8YJI/VAQ7dth1TOI/AAAAAAAAF5Q/N0W4papBtwg/clip_image034%25255B4%25255D_thumb.jpg?imgmax=800" height="244" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image034[4]" width="225" /></a>8. <br />
<h1>
2. Adding an edge flange and editing its sketch profile</h1>
Create an edge flange using the edit sketch profile and offset options<br />
<h3>
Step1</h3>
<a href="http://lh4.ggpht.com/-yJzGxPh25WQ/VAQ7feEujeI/AAAAAAAAF5Y/hMB_7WIQfvo/s1600-h/clip_image036%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image036[4]" border="0" src="http://lh3.ggpht.com/-10fb_hTjPFA/VAQ7ge5BLDI/AAAAAAAAF5g/SMN2w3oIgCM/clip_image036%25255B4%25255D_thumb.jpg?imgmax=800" height="241" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image036[4]" width="244" /></a> <br />
<br />
<h3>
Step2</h3>
<img alt="clip_image038[4]" border="0" src="http://lh6.ggpht.com/-foKkq3gMn24/VAQ7hEJNiRI/AAAAAAAAF5k/WRgiAwfDbTY/clip_image038%25255B4%25255D_thumb.jpg?imgmax=800" height="183" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image038[4]" width="244" /><br />
<h3>
Step3</h3>
<b></b><b></b><b></b><b></b><b></b><b></b><b></b> <a href="http://lh5.ggpht.com/-Qqpe9xc3DV0/VAQ7iAowBGI/AAAAAAAAF5w/ySl7DERXK7Q/s1600-h/clip_image040%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image040[4]" border="0" src="http://lh3.ggpht.com/-BKZ-JkqMZY8/VAQ7jTKBZBI/AAAAAAAAF54/gxhx18QZ4Ro/clip_image040%25255B4%25255D_thumb.jpg?imgmax=800" height="170" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image040[4]" width="244" /></a> <br />
<h3>
Step4</h3>
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<a href="http://lh6.ggpht.com/-r-GI8saPpJM/VAQ7kk3nl5I/AAAAAAAAF6A/b2C4SUBrl0E/s1600-h/clip_image042%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image042[4]" border="0" src="http://lh3.ggpht.com/-73LF7Vy2YFA/VAQ7l-ZvOOI/AAAAAAAAF6I/a-SVPnyZCWI/clip_image042%25255B4%25255D_thumb.jpg?imgmax=800" height="244" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image042[4]" width="149" /></a><a href="http://lh6.ggpht.com/-nCyDpE0W5F0/VAQ7nDLdkKI/AAAAAAAAF6Q/JhIKTHG7wUU/s1600-h/clip_image044%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image044[4]" border="0" src="http://lh5.ggpht.com/-PU_H7oS3v4s/VAQ7oUSDzUI/AAAAAAAAF6Y/ZPJOBxAB7ms/clip_image044%25255B4%25255D_thumb.jpg?imgmax=800" height="244" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image044[4]" width="92" /></a> <br />
<h3>
Step5</h3>
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<a href="http://lh5.ggpht.com/-GLV6RY4RAgM/VAQ7pYpTO3I/AAAAAAAAF6g/uxM95GptwcM/s1600-h/clip_image046%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image046[4]" border="0" src="http://lh4.ggpht.com/-M--HIQK6TAU/VAQ7qTxu1KI/AAAAAAAAF6o/oJnGvHbXObA/clip_image046%25255B4%25255D_thumb.jpg?imgmax=800" height="106" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image046[4]" width="162" /></a> <br />
<h3>
Finish</h3>
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<a href="http://lh6.ggpht.com/-21PA4R-jiu8/VAQ7rUEYBfI/AAAAAAAAF6w/6WVvoi5Ku7M/s1600-h/clip_image048%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image048[4]" border="0" src="http://lh3.ggpht.com/-CZb9A6KuEq0/VAQ7suMMG7I/AAAAAAAAF64/RooGdTRv7Rw/clip_image048%25255B4%25255D_thumb.jpg?imgmax=800" height="200" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image048[4]" width="244" /></a><b> </b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<h1>
3. Adding a tab</h1>
<h3>
Step1</h3>
<a href="http://lh5.ggpht.com/-u2LNttjHizA/VAQ7tgruFiI/AAAAAAAAF68/_eq6KbI2QsI/s1600-h/clip_image050%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image050[4]" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEgdz4AEUqJiWx2002GigZSpSYv6_XI8LanMk2WOqqdsa9pKO8DJuwWUQpp_NrHdgSEYnArSJjkxV_8AgoClve3z4MOJ8DNLHGb9gF68o-81rdjxL-R0tCFajXZjE797cDG-t_oEiGvUM/?imgmax=800" height="191" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image050[4]" width="244" /></a> <br />
<h3>
Step2</h3>
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<a href="http://lh4.ggpht.com/-35nWEXBadY8/VAQ7wRWqQjI/AAAAAAAAF7Q/D2htXKfQvSE/s1600-h/clip_image052%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image052[4]" border="0" src="http://lh5.ggpht.com/-tT7b4sL-s5c/VAQ7xl9C0FI/AAAAAAAAF7Y/HR7oYF4eLbM/clip_image052%25255B4%25255D_thumb.jpg?imgmax=800" height="87" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image052[4]" width="244" /></a> <br />
<h3>
Step3</h3>
<b></b> <br />
<b></b> <br />
<b></b> <br />
<a href="http://lh4.ggpht.com/-x3jb_gYHBUE/VAQ7zNxfYqI/AAAAAAAAF7g/fvLDqMSE8aI/s1600-h/clip_image054%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image054[4]" border="0" src="http://lh6.ggpht.com/-7MjZ27qFj3A/VAQ70qhHbNI/AAAAAAAAF7o/aH_xItbKxC8/clip_image054%25255B4%25255D_thumb.jpg?imgmax=800" height="230" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image054[4]" width="244" /></a> <br />
<h3>
Step4</h3>
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg71zgJway8fPcVe4BUp27NyuIn_hYUyjsTMqfKtt90e75WWfr6wAyJUkLF3HJGhusJuUYAxZSRwvpoMuA_c5bmqo0_4VPFp6iLI_4GocYGUcpfrZcqwvBuuTSgcWOplv-e6JBQq9hYZ1c/s1600-h/clip_image056%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image056[4]" border="0" src="http://lh5.ggpht.com/-G5ODzSyLf4c/VAQ73OYw-EI/AAAAAAAAF74/xqgg-bnPMlk/clip_image056%25255B4%25255D_thumb.jpg?imgmax=800" height="145" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image056[4]" width="171" /></a> <br />
<h3>
Finish</h3>
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgg3XKu5u1MCJgpo2QGk6j9ktxUD8RlS5df_qM_BCKPWmbLKpgQ3fQyPnaCVsBFaxXsjs_ddAf7izBVwDsk6LyzHRGtwzS50YCS28d7zyZlkNSXY0SS8n3KI-eCtXPnizjBm7ZGdxFp1V0/s1600-h/clip_image058%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image058[4]" border="0" src="http://lh6.ggpht.com/--Dms9U9fm4I/VAQ75k9ntQI/AAAAAAAAF8I/en9FL2RQdH0/clip_image058%25255B4%25255D_thumb.jpg?imgmax=800" height="240" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image058[4]" width="244" /></a><b>5. </b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<h1>
Bending a tab</h1>
Now you specify how to bend the tab. <br />
<h3>
Step1</h3>
<a href="http://lh6.ggpht.com/-ZzWmj-2rfPs/VAQ7651aCeI/AAAAAAAAF8Q/t6IYKNWX9Fw/s1600-h/clip_image060%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image060[4]" border="0" src="http://lh6.ggpht.com/-hrCI6s7Klms/VAQ77vMHCQI/AAAAAAAAF8Y/8ggHfj5tveU/clip_image060%25255B4%25255D_thumb.jpg?imgmax=800" height="168" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image060[4]" width="244" /></a><br />
<h3>
Step2</h3>
<b></b><b></b><b></b><b></b><b></b><b></b><b></b> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0HwNVZ5kUPyBoQ1dOQHpjpG5Go61VpfwT_-Z7i3oYMkN1hOx7eyZlQby2UgADbSoCueczhDMD1OQmf6aXmulshk1tKYCPF15TK8PZwHI50yb41YslDq2YCjC7tgWfbtWznAVXbWs9ueo/s1600-h/clip_image062%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image062[4]" border="0" src="http://lh4.ggpht.com/-bCmZSUjAaSY/VAQ79wWwydI/AAAAAAAAF8o/S4c__M0UgZY/clip_image062%25255B4%25255D_thumb.jpg?imgmax=800" height="213" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image062[4]" width="244" /></a><br />
<h3>
Step3</h3>
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFPmAoX9io7kYPf6YFxxcT6cerVobHyADWaDvk3kQJBvhvB-SBfjlqm5XO7F2UYcW_w304MleMSThn7WxaFkthXsPyIZ0xSNWQC1w3s7K7LByeXigxFbL2WTgb2nxQSjvuZ8Ay4LbllR0/s1600-h/clip_image064%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image064[4]" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKWqqzAWnECu2Eajrz7E2QWdSwUYRjR5fz_5TiBXBazAAan30WTditBykkNAmpkZQNzCGHj061fk1bmtXbBG53L6GeKrR_YOmwrT9mqkXgppXwiTNMl908PHJGuqEpi1XuPm8m2bJjYLg/?imgmax=800" height="244" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image064[4]" width="226" /></a><b></b> <br />
<h3>
Step4</h3>
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhFf_gl3Ynp3qI6oVfX-gh4ZYg6JcUeBRu7pZnFpesBLLVGfdu0MEQGAwCj1r4herqH8Mgb2S6zy0NLcq8dQ_G3kYD-rdDOnBuXKwSaEkfX0flrbcNTIaN0vCYB1BnJX0zlXTHJy3AIyE/s1600-h/clip_image066%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image066[4]" border="0" src="http://lh4.ggpht.com/-Hex4IXAC3Xg/VAQ8Dpa9K9I/AAAAAAAAF9I/HqzWWicc6CM/clip_image066%25255B4%25255D_thumb.jpg?imgmax=800" height="120" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image066[4]" width="174" /></a><br />
<h3>
Step5</h3>
<br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<img alt="clip_image068[4]" border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdkvIxeFEPSvcgp29hrzrQx-gPIPdwRl9IoYyP9ZYywbLipKnfkLgTOLIqu0BhSik9QZD1u_4NysVBPkdfa_A6Qn5Dbp6ZDFTfukT62xZwncw4Ej9qpFNci31DXVTWzIc2iCqZnTZHUq4/?imgmax=800" height="213" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image068[4]" width="244" /> <br />
<h3>
Step6</h3>
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<a href="http://lh4.ggpht.com/-_bgLDNChvKM/VAQ8HC0Ph1I/AAAAAAAAF9Y/tEeEvnbGfI4/s1600-h/clip_image070%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image070[4]" border="0" src="http://lh4.ggpht.com/-jo0WskZYpUY/VAQ8IvwxX4I/AAAAAAAAF9g/Mr0J7ZsEx38/clip_image070%25255B4%25255D_thumb.jpg?imgmax=800" height="244" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image070[4]" width="194" /></a> <br />
<h3>
Finish</h3>
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<a href="http://lh6.ggpht.com/-75W5JtPtQdU/VAQ8KlKPZ0I/AAAAAAAAF9o/5hjkFrIdBYI/s1600-h/clip_image072%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image072[4]" border="0" src="http://lh3.ggpht.com/-z-F_X9Pp7uU/VAQ8MC6u3oI/AAAAAAAAF9w/u4unoZugn5I/clip_image072%25255B4%25255D_thumb.jpg?imgmax=800" height="243" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image072[4]" width="244" /></a> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<h1>
Adding a cut across the bend </h1>
<a href="http://lh3.ggpht.com/-JMWm9V0CsWs/VAQ8NgEoo4I/AAAAAAAAF94/hlRRUjnqMBk/s1600-h/clip_image074%25255B4%25255D%25255B2%25255D.jpg"><img alt="clip_image074[4]" border="0" src="http://lh4.ggpht.com/-uEFXe_xC1NA/VAQ8PQVOB0I/AAAAAAAAF-A/4clgqDdST9s/clip_image074%25255B4%25255D_thumb.jpg?imgmax=800" height="238" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image074[4]" width="244" /></a><b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<b></b> <br />
<h3>
Step1</h3>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-53878902630706062502014-08-30T02:27:00.001-07:002014-08-30T03:06:08.582-07:00ANSYS Tutorial <h2 style="text-align: center;">
<span style="font-size: x-large;">ANSYS Tutorial </span></h2>
<h2>
<span style="font-size: x-large;"> </span><iframe height="800" src="https://docs.google.com/document/d/1rrRZNkrXLPXb3LvIDd21mEQxaz5uF6zbta8eV2ZFQ5w/pub?embedded=true" width="600"></iframe></h2>
mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-58215533331195661132012-01-18T19:46:00.001-08:002022-03-10T20:19:55.709-08:00Programing PIC microcontrollers<div align="justify"><b>Introduction to Microcontrollers</b> </div><div align="justify">Introduction<br />
History<br />
Microcontrollers versus microprocessors<br />
1.1 Memory unit<br />
1.2 Central processing unit<br />
1.3 Buses<br />
1.4 Input-output unit<br />
1.5 Serial communication<br />
1.6 Timer unit<br />
1.7 Watchdog<br />
1.8 Analog to digital converter<br />
1.9 Program</div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Introduction"><b>Introduction</b></a> </div><div align="justify">Circumstances that we find ourselves in today in the field of microcontrollers had their beginnings in the development of technology of integrated circuits. This development has made it possible to store hundreds of thousands of transistors into one chip. That was a prerequisite for production of microprocessors , and the first computers were made by adding external peripherals such as memory, input-output lines, timers and other. Further increasing of the volume of the package resulted in creation of integrated circuits. These integrated circuits contained both processor and peripherals. That is how the first chip containing a microcomputer , or what would later be known as a microcontroller came about. </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="History"><b>History</b></a> </div><div align="justify">It was year 1969, and a team of Japanese engineers from the BUSICOM company arrived to United States with a request that a few integrated circuits for calculators be made using their projects. The proposition was set to INTEL, and Marcian Hoff was responsible for the project. Since he was the one who has had experience in working with a computer (PC) PDP8, it occured to him to suggest a fundamentally different solution instead of the suggested construction. This solution presumed that the function of the integrated circuit is determined by a program stored in it. That meant that configuration would be more simple, but that it would require far more memory than the project that was proposed by Japanese engineers would require. After a while, though Japanese engineers tried finding an easier solution, Marcian's idea won, and the first microprocessor was born. In transforming an idea into a ready made product , Frederico Faggin was a major help to INTEL. He transferred to INTEL, and in only 9 months had succeeded in making a product from its first conception. INTEL obtained the rights to sell this integral block in 1971. First, they bought the license from the BUSICOM company who had no idea what treasure they had. During that year, there appeared on the market a microprocessor called 4004. That was the first 4-bit microprocessor with the speed of 6 000 operations per second. Not long after that, American company CTC requested from INTEL and Texas Instruments to make an 8-bit microprocessor for use in terminals. Even though CTC gave up this idea in the end, Intel and Texas Instruments kept working on the microprocessor and in April of 1972, first 8-bit microprocessor appeard on the market under a name 8008. It was able to address 16Kb of memory, and it had 45 instructions and the speed of 300 000 operations per second. That microprocessor was the predecessor of all today's microprocessors. Intel kept their developments up in April of 1974, and they put on the market the 8-bit processor under a name 8080 which was able to address 64Kb of memory, and which had 75 instructions, and the price began at $360.<br />
In another American company Motorola, they realized quickly what was happening, so they put out on the market an 8-bit microprocessor 6800. Chief constructor was Chuck Peddle, and along with the processor itself, Motorola was the first company to make other peripherals such as 6820 and 6850. At that time many companies recognized greater importance of microprocessors and began their own developments. Chuck Peddle leaved Motorola to join MOS Technology and kept working intensively on developing microprocessors.<br />
At the WESCON exhibit in United States in 1975, a critical event took place in the history of microprocessors. The MOS Technology announced it was marketing microprocessors 6501 and 6502 at $25 each, which buyers could purchase immediately. This was so sensational that many thought it was some kind of a scam, considering that competitors were selling 8080 and 6800 at $179 each. As an answer to its competitor, both Intel and Motorola lowered their prices on the first day of the exhibit down to $69.95 per microprocessor. Motorola quickly brought suit against MOS Technology and Chuck Peddle for copying the protected 6800. MOS Technology stopped making 6501, but kept producing 6502. The 6502 was a 8-bit microprocessor with 56 instructions and a capability of directly addressing 64Kb of memory. Due to low cost , 6502 becomes very popular, so it was installed into computers such as: KIM-1, Apple I, Apple II, Atari, Comodore, Acorn, Oric, Galeb, Orao, Ultra, and many others. Soon appeared several makers of 6502 (Rockwell, Sznertek, GTE, NCR, Ricoh, and Comodore takes over MOS Technology) which was at the time of its prosperity sold at a rate of 15 million processors a year!<br />
Others were not giving up though. Frederico Faggin leaves Intel, and starts his own Zilog Inc.<br />
In 1976 Zilog announced the Z80. During the making of this microprocessor, Faggin made a pivotal decision. Knowing that a great deal of programs have been already developed for 8080, Faggin realized that many would stay faithful to that microprocessor because of great expenditure which redoing of all of the programs would result in. Thus he decided that a new processor had to be compatible with 8080, or that it had to be capable of performing all of the programs which had already been written for 8080. Beside these characteristics, many new ones have been added, so that Z80 was a very powerful microprocessor in its time. It was able to address directly 64 Kb of memory, it had 176 instructions, a large number of registers, a built in option for refreshing the dynamic RAM memory, single-supply, greater speed of work etc. Z80 was a great success and everybody converted from 8080 to Z80. It could be said that Z80 was without a doubt commercially most successful 8-bit microprocessor of that time. Besides Zilog, other new manufacturers like Mostek, NEC, SHARP, and SGS also appeared. Z80 was the heart of many computers like Spectrum, Partner, TRS703, Z-3 . <br />
In 1976, Intel came up with an improved version of 8-bit microprocessor named 8085. However, Z80 was so much better that Intel soon lost the battle. Altough a few more processors appeared on the market (6809, 2650, SC/MP etc.), everything was actually already decided. There weren't any more great improvements to make manufacturers convert to something new, so 6502 and Z80 along with 6800 remained as main representatives of the 8-bit microprocessors of that time. </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Microcontrollers_versus_Microprocessors"><b>Microcontrollers versus Microprocessors</b></a> </div><div align="justify">Microcontroller differs from a microprocessor in many ways. First and the most important is its functionality. In order for a microprocessor to be used, other components such as memory, or components for receiving and sending data must be added to it. In short that means that microprocessor is the very heart of the computer. On the other hand, microcontroller is designed to be all of that in one. No other external components are needed for its application because all necessary peripherals are already built into it. Thus, we save the time and space needed to construct devices. </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="1.1_Memory_unit"><b>1.1 Memory unit</b></a> </div><div align="justify">Memory is part of the microcontroller whose function is to store data. <br />
The easiest way to explain it is to describe it as one big closet with lots of drawers. If we suppose that we marked the drawers in such a way that they can not be confused, any of their contents will then be easily accessible. It is enough to know the designation of the drawer and so its contents will be known to us for sure. </div><div align="justify"><a href="http://lh5.ggpht.com/-YjleROKoLFw/TxZT2wOHlJI/AAAAAAAABuI/64RAnMaDcwM/s1600-h/clip_image001%25255B4%25255D.gif"><img alt="clip_image001" border="0" height="376" src="http://lh4.ggpht.com/-UwBi9ekIu4Q/TxZT3gMPgZI/AAAAAAAABuQ/CFUu9yQZTX0/clip_image001_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image001" width="573" /></a></div><div align="justify">Memory components are exactly like that. For a certain input we get the contents of a certain addressed memory location and that's all. Two new concepts are brought to us: addressing and memory location. Memory consists of all memory locations, and addressing is nothing but selecting one of them. This means that we need to select the desired memory location on one hand, and on the other hand we need to wait for the contents of that location. Beside reading from a memory location, memory must also provide for writing onto it. This is done by supplying an additional line called control line. We will designate this line as R/W (read/write). Control line is used in the following way: if r/w=1, reading is done, and if opposite is true then writing is done on the memory location. Memory is the first element, and we need a few operation of our microcontroller . </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="1.2_Central_Processing_Unit"><b>1.2 Central Processing Unit</b></a> </div><div align="justify">Let add 3 more memory locations to a specific block that will have a built in capability to multiply, divide, subtract, and move its contents from one memory location onto another. The part we just added in is called "central processing unit" (CPU). Its memory locations are called registers. </div><div align="justify"><a href="http://lh3.ggpht.com/-CSFnUdPNrZU/TxZT4piKwOI/AAAAAAAABuU/5qOQmuASTTE/s1600-h/clip_image002%25255B4%25255D.gif"><img alt="clip_image002" border="0" height="260" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs3JPl6isdRQKkNT6A4usPT1LCpjMjtt-yxG_LjKNvjmVk8RWY7uhuCaYoOfhNTU6SMBpwvev9eLaCgOP8Cn5gyKnWG4FedDQ5WtaIrUNY2tshNjiFU41Ga3hPRq_VReFZOqWr_ytCbBY/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image002" width="637" /></a></div><div align="justify">Registers are therefore memory locations whose role is to help with performing various mathematical operations or any other operations with data wherever data can be found. Look at the current situation. We have two independent entities (memory and CPU) which are interconnected, and thus any exchange of data is hindered, as well as its functionality. If, for example, we wish to add the contents of two memory locations and return the result again back to memory, we would need a connection between memory and CPU. Simply stated, we must have some "way" through data goes from one block to another. </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="1.3_Bus"><b>1.3 Bus</b></a> </div><div align="justify">That "way" is called "bus". Physically, it represents a group of 8, 16, or more wires <br />
There are two types of buses: address and data bus. The first one consists of as many lines as the amount of memory we wish to address, and the other one is as wide as data, in our case 8 bits or the connection line. First one serves to transmit address from CPU memory, and the second to connect all blocks inside the microcontroller. </div><div align="justify"><a href="http://lh3.ggpht.com/-pTqFxhA-dnM/TxZT6Oi4sgI/AAAAAAAABuo/o-ZKu1OADiA/s1600-h/clip_image003%25255B4%25255D.gif"><img alt="clip_image003" border="0" height="405" src="http://lh4.ggpht.com/-1KB0ris09pU/TxZT7gpTnzI/AAAAAAAABuw/ggLYI0GgMWk/clip_image003_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image003" width="617" /></a></div><div align="justify">As far as functionality, the situation has improved, but a new problem has also appeared: we have a unit that's capable of working by itself, but which does not have any contact with the outside world, or with us! In order to remove this deficiency, let's add a block which contains several memory locations whose one end is connected to the data bus, and the other has connection with the output lines on the microcontroller which can be seen as pins on the electronic component. </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="1.4_Input-output_unit"><b>1.4 Input-output unit</b></a> </div><div align="justify">Those locations we've just added are called "ports". There are several types of ports : input, output or bidiectional ports. When working with ports, first of all it is necessary to choose which port we need to work with, and then to send data to, or take it from the port. </div><div align="justify"><a href="http://lh6.ggpht.com/-GJ-HXFLSdfY/TxZT8WjyIGI/AAAAAAAABu4/fU2ziqcEMo4/s1600-h/clip_image004%25255B4%25255D.gif"><img alt="clip_image004" border="0" height="301" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHwxmjLRCFulxXrYJnDc-wvMwa4RYjkiWY8tZ9mx5UwZHqGccjtXMxi56vW2kIo-pCuaJjZbOm4PpPdVvyqqNmE9J6Zo6Ki0Ti8NRBX23WSBXRGzTWbmlJ_99AyISIGJFdpcFDMCJ9ZnM/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image004" width="648" /></a></div><div align="justify">When working with it the port acts like a memory location. Something is simply being written into or read from it, and it could be noticed on the pins of the microcontroller. </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="1.5_Serial_communication"><b>1.5 Serial communication</b></a> </div><div align="justify">Beside stated above we've added to the already existing unit the possibility of communication with an outside world. However, this way of communicating has its drawbacks. One of the basic drawbacks is the number of lines which need to be used in order to transfer data. What if it is being transferred to a distance of several kilometers? The number of lines times number of kilometers doesn't promise the economy of the project. It leaves us having to reduce the number of lines in such a way that we don't lessen its functionality. Suppose we are working with three lines only, and that one line is used for sending data, other for receiving, and the third one is used as a reference line for both the input and the output side. In order for this to work, we need to set the rules of exchange of data. These rules are called protocol. Protocol is therefore defined in advance so there wouldn't be any misunderstanding between the sides that are communicating with each other. For example, if one man is speaking in French, and the other in English, it is highly unlikely that they will quickly and effectively understand each other. Let's suppose we have the following protocol. The logical unit "1" is set up on the transmitting line until transfer begins. Once the transfer starts, we lower the transmission line to logical "0" for a period of time (which we will designate as T), so the receiving side will know that it is receiving data, and so it will activate its mechanism for reception. Let's go back now to the transmission side and start putting logic zeros and ones onto the transmitter line in the order from a bit of the lowest value to a bit of the highest value. Let each bit stay on line for a time period which is equal to T, and in the end, or after the 8th bit, let us bring the logical unit "1" back on the line which will mark the end of the transmission of one data. The protocol we've just described is called in professional literature NRZ (Non-Return to Zero). </div><div align="justify"><a href="http://lh5.ggpht.com/-mzlFulXTSsM/TxZT_MxO78I/AAAAAAAABvI/ICUXb2ur9nY/s1600-h/clip_image005%25255B4%25255D.gif"><img alt="clip_image005" border="0" height="317" src="http://lh5.ggpht.com/-e7P71cJ-osQ/TxZT_4-3aDI/AAAAAAAABvQ/1PBxO9ILYtk/clip_image005_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image005" width="644" /></a></div><div align="justify">As we have separate lines for receiving and sending, it is possible to receive and send data (info.) at the same time. So called full-duplex mode block which enables this way of communication is called a serial communication block. Unlike the parallel transmission, data moves here bit by bit, or in a series of bits what defines the term serial communication comes from. After the reception of data we need to read it from the receiving location and store it in memory as opposed to sending where the process is reversed. Data goes from memory through the bus to the sending location, and then to the receiving unit according to the protocol. </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="1.6_Timer_unit"><b>1.6 Timer unit</b></a> </div><div align="justify">Since we have the serial communication explained, we can receive, send and process data. </div><div align="justify"><a href="http://lh6.ggpht.com/-QEmzHKWAjmU/TxZUBDYffBI/AAAAAAAABvY/RFIleQXYHtc/s1600-h/clip_image006%25255B4%25255D.gif"><img alt="clip_image006" border="0" height="201" src="http://lh4.ggpht.com/-tIDCTxw7b38/TxZUCBRJ5cI/AAAAAAAABvg/PaywBwHMVnM/clip_image006_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image006" width="652" /></a></div><div align="justify">However, in order to utilize it in industry we need a few additionally blocks. One of those is the timer block which is significant to us because it can give us information about time, duration, protocol etc. The basic unit of the timer is a free-run counter which is in fact a register whose numeric value increments by one in even intervals, so that by taking its value during periods T1 and T2 and on the basis of their difference we can determine how much time has elapsed. This is a very important part of the microcontroller whose understanding requires most of our time. </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="1.7_Watchdog"><b>1.7 Watchdog</b></a> </div><div align="justify">One more thing is requiring our attention is a flawless functioning of the microcontroller <br />
during its run-time. Suppose that as a result of some interference (which often does occur in industry) our microcontroller stops executing the program, or worse, it starts working incorrectly. </div><div align="justify"><a href="http://lh6.ggpht.com/-Sf78ThgAy6w/TxZUC8owHCI/AAAAAAAABvk/nnfT9yvpv70/s1600-h/clip_image007%25255B3%25255D.gif"><img alt="clip_image007" border="0" height="97" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihpbRVSP-_mpmhSHyrcjPAywoChzD7AE3Vb-Pmag4GWkkAMsNW6PsqC3Xf84YIMAvGsTZ1RSVie_SwB4uik1J6bNgkqhRVWdJlqRuZp-v0NLP99ysCXoXVWAPIwi9ekNabf1tF-HdMjIA/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image007" width="221" /></a></div><div align="justify">Of course, when this happens with a computer, we simply reset it and it will keep working. However, there is no reset button we can push on the microcontroller and thus solve our problem. To overcome this obstacle, we need to introduce one more block called watchdog. This block is in fact another free-run counter where our program needs to write a zero in every time it executes correctly. In case that program gets "stuck", zero will not be written in, and counter alone will reset the microcontroller upon achieving its maximum value. This will result in executing the program again, and correctly this time around. That is an important element of every program to be reliable without man's supervision. </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="1.8_Analog-Digital_Converter"><b>1.8 Analog to Digital Converter</b></a> </div><div align="justify">As the peripheral signals usually are substantially different from the ones that microcontroller can understand (zero and one), they have to be converted into a pattern which can be comprehended by a microcontroller. This task is performed by a block for analog to digital conversion or by an ADC. This block is responsible for converting an information about some analog value to a binary number and for follow it through to a CPU block so that CPU block can further process it. </div><div align="justify"><a href="http://lh6.ggpht.com/-uxa3R-7FlZE/TxZUEbkCodI/AAAAAAAABv0/f3D3e4zN3FI/s1600-h/clip_image008%25255B4%25255D.gif"><img alt="clip_image008" border="0" height="156" src="http://lh4.ggpht.com/-DyJL1o7_6Wg/TxZUFZssGQI/AAAAAAAABwA/Z2oCLFs-oA8/clip_image008_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image008" width="638" /></a></div><div align="justify">Finnaly, the microcontroller is now completed, and all we need to do now is to assemble it into an electronic component where it will access inner blocks through the outside pins. The picture below shows what a microcontroller looks like inside. </div><div align="justify"><a href="http://lh6.ggpht.com/-QHwZ3LGrIFs/TxZUGqIVPNI/AAAAAAAABwI/BkQt-DW1XvE/s1600-h/clip_image009%25255B3%25255D.gif"><img alt="clip_image009" border="0" height="204" src="http://lh3.ggpht.com/-uf6Rh2OhSB4/TxZUH8mRe_I/AAAAAAAABwQ/vDroyvjlrnc/clip_image009_thumb.gif?imgmax=800" style="border-color: -moz-use-text-color; border-style: none; border-width: 0px; display: inline;" title="clip_image009" width="204" /></a></div><div align="justify"><b>Physical configuration of the interior of a microcontroller</b> </div><div align="justify">Thin lines which lead from the center towards the sides of the microcontroller represent wires connecting inner blocks with the pins on the housing of the microcontroller so called bonding lines. Chart on the following page represents the center section of a microcontroller. </div><div align="justify"><a href="http://lh6.ggpht.com/-FvMLrHwx__w/TxZUIyug5eI/AAAAAAAABwY/RcTJcMAjRUs/s1600-h/clip_image010%25255B4%25255D.gif"><img alt="clip_image010" border="0" height="546" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUoO5jRAi0IPv5wpM8I3Jbwe7M7CQJid6ZUrC_B1CwdEeDosqjDPFvDESN_K4DtGmI0bXoZhgExRmvVFHUYDajzrq-SibpNRsOTnqtMtgyt3qZT3hGBHJA0QK_hyphenhyphen5UEDBRK3-aGNBFC7k/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image010" width="557" /></a></div><div align="justify"><b>Microcontroller outline with its basic elements and internal connections</b> </div><div align="justify">For a real application, a microcontroller alone is not enough. Beside a microcontroller, we need a program that would be executed, and a few more elements which make up a interface logic towards the elements of regulation (which will be discussed in later chapters). </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="1.9_Program"><b>1.9 Program</b></a> </div><div align="justify">Program writing is a special field of work with microcontrollers and is called "programming". Try to write a small program in a language that we will make up ourselves first and then would be understood by anyone. <br />
<b>START<br />
REGISTER1=MEMORY LOCATION_A<br />
REGISTER2=MEMORY LOCATION_B<br />
PORTA=REGISTER1 + REGISTER2<br />
END</b><br />
The program adds the contents of two memory locations, and views their sum on port A. The first line of the program stands for moving the contents of memory location "A" into one of the registers of central processing unit. As we need the other data as well, we will also move it into the other register of the central processing unit. The next instruction instructs the central processing unit to add the contents of those two registers and send a result to port A, so that sum of that addition would be visible to the outside world. For a more complex problem, program that works on its solution will be bigger. <br />
Programming can be done in several languages such as Assembler, C and Basic which are most commonly used languages. Assembler belongs to lower level languages that are programmed slowly, but take up the least amount of space in memory and gives the best results where the speed of program execution is concerned. As it is the most commonly used language in programming microcontrollers it will be discussed in a later chapter. Programs in C language are easier to be written, easier to be understood, but are slower in executing from assembler programs. Basic is the easiest one to learn, and its instructions are nearest a man's way of reasoning, but like C programming language it is also slower than assembler. In any case, before you make up your mind about one of these languages you need to consider carefully the demands for execution speed, for the size of memory and for the amount of time available for its assembly.<br />
After the program is written, we would install the microcontroller into a device and run it. In order to do this we need to add a few more external components necessary for its work. First we must give life to a microcontroller by connecting it to a power supply (power needed for operation of all electronic instruments) and oscillator whose role is similar to the role that heart plays in a human body. Based on its clocks microcontroller executes instructions of a program. As it receives supply microcontroller will perform a small check up on itself, look up the beginning of the program and start executing it. How the device will work depends on many parameters, the most important of which is the skillfulness of the developer of hardware, and on programmer's expertise in getting the maximum out of the device with his program. </div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><b>CHAPTER 2</b> <br />
<b>Microcontroller PIC16F84</b> <br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_01chapter.htm#Introduction">Introduction</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_01chapter.htm#CISC,%20RISC"><br />
CISC, RISC</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_01chapter.htm#Applications">Applications</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_01chapter.htm#Clock%20/%20instruction%20cycle">Clock/instruction cycle</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_01chapter.htm#Pipelining">Pipelining</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_01chapter.htm#Meaning%20of%20pins">Pin description</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_02chapter.htm">2.1 Clock generator - oscillator</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_03chapter.htm">2.2 Reset</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_04chapter.htm">2.3 Central processing unit</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_05chapter.htm">2.4 Ports</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_06chapter.htm">2.5 Memory organization</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_07chapter.htm">2.6 Interrupts</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_08chapter.htm">2.7 Free timer TMR0</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/2_09chapter.htm">2.8 EEPROM Data memory</a> <br />
<a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Introduction"><b>Introduction</b></a> <br />
<b>PIC16F84</b> belongs to a class of 8-bit microcontrollers of RISC architecture. Its general structure is shown on the following map representing basic blocks.<br />
<b>Program memory</b> (FLASH)- for storing a written program. <br />
Since memory made in FLASH technology can be programmed and cleared more than once, it makes this microcontroller suitable for device development. <br />
<b>EEPROM</b> - data memory that needs to be saved when there is no supply.<br />
It is usually used for storing important data that must not be lost if power supply suddenly stops. For instance, one such data is an assigned temperature in temperature regulators. If during a loss of power supply this data was lost, we would have to make the adjustment once again upon return of supply. Thus our device looses on self-reliance. <br />
<b>RAM </b>- data memory used by a program during its execution.<br />
In RAM are stored all inter-results or temporary data during run-time. <br />
<b>PORTA and PORTB</b> are physical connections between the microcontroller and the outside world. Port A has five, and port B has eight pins. <br />
<b>FREE-RUN TIMER</b> is an 8-bit register inside a microcontroller that works independently of the program. On every fourth clock of the oscillator it increments its value until it reaches the maximum (255), and then it starts counting over again from zero. As we know the exact timing between each two increments of the timer contents, timer can be used for measuring time which is very useful with some devices. <br />
<b>CENTRAL PROCESSING UNIT</b> has a role of connective element between other blocks in the microcontroller. It coordinates the work of other blocks and executes the user program. <br />
<a href="http://lh6.ggpht.com/-shZ-LPxezJ8/TxZdr1Kcl-I/AAAAAAAAB44/nCHtR4g5o6A/s1600-h/clip_image001%25255B4%25255D.gif"><img alt="clip_image001" border="0" height="416" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiY23JwRDt5s6JZGBClyloHOSy4LMZ6y-Mp8FuK8tabH4HfP82arS2XYgCimOeenpFxS4vrM04i8sh9bFJP50BIofkoxWXSCns-AC83ZugxBXi_Iucft-wEr0ODlpOcbqkFkpxYtaYQ_Uo/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image001" width="525" /></a> <br />
<a href="http://lh4.ggpht.com/-xYAleRFg9uA/TxZdtv9X-cI/AAAAAAAAB5I/Jl9bcNC2rgk/s1600-h/clip_image002%25255B4%25255D.gif"><img alt="clip_image002" border="0" height="251" src="http://lh4.ggpht.com/-zbnwdMD3maQ/TxZdupV7MkI/AAAAAAAAB5Q/PH5IkBuf7Pg/clip_image002_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image002" width="546" /></a> <br />
<a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="CISC,_RISC"><b>CISC, RISC</b></a> <br />
It has already been said that PIC16F84 has a RISC architecture. This term is often found in computer literature, and it needs to be explained here in more detail. Harvard architecture is a newer concept than von-Neumann's. It rose out of the need to speed up the work of a microcontroller. In Harvard architecture, data bus and address bus are separate. Thus a greater flow of data is possible through the central processing unit, and of course, a greater speed of work. Separating a program from data memory makes it further possible for instructions not to have to be 8-bit words. PIC16F84 uses 14 bits for instructions which allows for all instructions to be one word instructions. It is also typical for Harvard architecture to have fewer instructions than von-Neumann's, and to have instructions usually executed in one cycle. <br />
Microcontrollers with Harvard architecture are also called "RISC microcontrollers". RISC stands for Reduced Instruction Set Computer. Microcontrollers with von-Neumann's architecture are called 'CISC microcontrollers'. Title CISC stands for Complex Instruction Set Computer. <br />
Since PIC16F84 is a RISC microcontroller, that means that it has a reduced set of instructions, more precisely 35 instructions . (ex. Intel's and Motorola's microcontrollers have over hundred instructions) All of these instructions are executed in one cycle except for jump and branch instructions. According to what its maker says, PIC16F84 usually reaches results of 2:1 in code compression and 4:1 in speed in relation to other 8-bit microcontrollers in its class. <br />
<a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Applications"><b>Applications</b></a> <br />
PIC16F84 perfectly fits many uses, from automotive industries and controlling home appliances to industrial instruments, remote sensors, electrical door locks and safety devices. It is also ideal for smart cards as well as for battery supplied devices because of its low consumption. <br />
EEPROM memory makes it easier to apply microcontrollers to devices where permanent storage of various parameters is needed (codes for transmitters, motor speed, receiver frequencies, etc.). Low cost, low consumption, easy handling and flexibility make PIC16F84 applicable even in areas where microcontrollers had not previously been considered (example: timer functions, interface replacement in larger systems, coprocessor applications, etc.). <br />
In System Programmability of this chip (along with using only two pins in data transfer) makes possible the flexibility of a product, after assembling and testing have been completed. This capability can be used to create assembly-line production, to store calibration data available only after final testing, or it can be used to improve programs on finished products. <br />
<a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Clock_/_instruction_cycle"><b>Clock / instruction cycle</b></a> <br />
Clock is microcontroller's main starter, and is obtained from an external component called an "oscillator". If we want to compare a microcontroller with a time clock, our "clock" would then be a ticking sound we hear from the time clock. In that case, oscillator could be compared to a spring that is wound so time clock can run. Also, force used to wind the time clock can be compared to an electrical supply. <br />
Clock from the oscillator enters a microcontroller via OSC1 pin where internal circuit of a microcontroller divides the clock into four even clocks Q1, Q2, Q3, and Q4 which do not overlap. These four clocks make up one instruction cycle (also called machine cycle) during which one instruction is executed. <br />
Execution of instruction starts by calling an instruction that is next in string. Instruction is called from program memory on every Q1 and is written in instruction register on Q4. Decoding and execution of instruction are done between the next Q1 and Q4 cycles. On the following diagram we can see the relationship between instruction cycle and clock of the oscillator (OSC1) as well as that of internal clocks Q1-Q4. Program counter (PC) holds information about the address of the next instruction. <br />
<a href="http://lh6.ggpht.com/-nneyajE_gKA/TxZdvcJS6XI/AAAAAAAAB5Y/9EWKYsVldGc/s1600-h/clip_image003%25255B4%25255D.gif"><img alt="clip_image003" border="0" height="401" src="http://lh6.ggpht.com/-6VLDLgqBdqs/TxZdwCqj8II/AAAAAAAAB5g/xvmXdH4syHo/clip_image003_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image003" width="593" /></a> <br />
<a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Pipelining"><b>Pipelining</b></a> <br />
Instruction cycle consists of cycles Q1, Q2, Q3 and Q4. Cycles of calling and executing instructions are connected in such a way that in order to make a call, one instruction cycle is needed, and one more is needed for decoding and execution. However, due to pipelining, each instruction is effectively executed in one cycle. If instruction causes a change on program counter, and PC doesn't point to the following but to some other address (which can be the case with jumps or with calling subprograms), two cycles are needed for executing an instruction. This is so because instruction must be processed again, but this time from the right address. Cycle of calling begins with Q1 clock, by writing into instruction register (IR). Decoding and executing begins with Q2, Q3 and Q4 clocks. <br />
<a href="http://lh4.ggpht.com/-nChw7cO1SXc/TxZdxV70NqI/AAAAAAAAB5k/T2HAfs7c2p4/s1600-h/clip_image004%25255B4%25255D.gif"><img alt="clip_image004" border="0" height="211" src="http://lh6.ggpht.com/-EPwMBRyYWW0/TxZdyCR7b_I/AAAAAAAAB5w/iGTmNPiLRTI/clip_image004_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image004" width="545" /></a> <br />
<b>TCY0</b> reads in instruction MOVLW 55h (it doesn't matter to us what instruction was executed, because there is no rectangle pictured on the bottom).<br />
<b>TCY1</b> executes instruction MOVLW 55h and reads in MOVWF PORTB.<br />
<b>TCY2</b> executes MOVWF PORTB and reads in CALL SUB_1.<br />
<b>TCY3</b> executes a call of a subprogram CALL SUB_1, and reads in instruction BSF PORTA, BIT3. As this instruction is not the one we need, or is not the first instruction of a subprogram SUB_1 whose execution is next in order, instruction must be read in again. This is a good example of an instruction needing more than one cycle. <br />
<b>TCY4</b> instruction cycle is totally used up for reading in the first instruction from a subprogram at address SUB_1.<br />
<b>TCY5</b> executes the first instruction from a subprogram SUB_1 and reads in the next one. <br />
<a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Meaning_of_pins"><b>Pin description</b></a> <br />
PIC16F84 has a total of 18 pins. It is most frequently found in a DIP18 type of case but can also be found in SMD case which is smaller from a DIP. DIP is an abbreviation for Dual In Package. SMD is an abbreviation for Surface Mount Devices suggesting that holes for pins to go through when mounting, aren't necessary in soldering this type of a component. <br />
<a href="http://lh5.ggpht.com/-qdbMwgT1zAw/TxZdzNfCF-I/AAAAAAAAB50/VY0AZ6dUDfo/s1600-h/clip_image005%25255B3%25255D.gif"><img alt="clip_image005" border="0" height="206" src="http://lh5.ggpht.com/-I1ophlokzEs/TxZdz_kLalI/AAAAAAAAB6A/cmtOeLGIuis/clip_image005_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image005" width="116" /></a> <br />
Pins on PIC16F84 microcontroller have the following meaning:<br />
Pin no.1 <b>RA2</b> Second pin on port A. Has no additional function<br />
Pin no.2 <b>RA3</b> Third pin on port A. Has no additional function.<br />
Pin no.3 <b>RA4</b> Fourth pin on port A. TOCK1 which functions as a timer is also found on this pin <br />
Pin no.4 <b>MCLR</b> Reset input and Vpp programming voltage of a microcontroller<br />
Pin no.5 <b>Vss</b> Ground of power supply.<br />
Pin no.6 <b>RB0</b> Zero pin on port B. Interrupt input is an additional function.<br />
Pin no.7 <b>RB1</b> First pin on port B. No additional function.<br />
Pin no.8 <b>RB2</b> Second pin on port B. No additional function. <br />
Pin no.9 <b>RB3</b> Third pin on port B. No additional function. <br />
Pin no.10 <b>RB4</b> Fourth pin on port B. No additional function.<br />
Pin no.11 <b>RB5</b> Fifth pin on port B. No additional function.<br />
Pin no.12 <b>RB6</b> Sixth pin on port B. 'Clock' line in program mode.<br />
Pin no.13 <b>RB7</b> Seventh pin on port B. 'Data' line in program mode.<br />
Pin no.14 <b>Vdd</b> Positive power supply pole.<br />
Pin no.15 <b>OSC2</b> Pin assigned for connecting with an oscillator<br />
Pin no.16 <b>OSC1</b> Pin assigned for connecting with an oscillator<br />
Pin no.17 <b>RA2</b> Second pin on port A. No additional function<br />
Pin no.18 <b>RA1</b> First pin on port A. No additional function.<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div align="justify"><b>2.1 Clock generator - oscillator</b> </div><div align="justify">Oscillator circuit is used for providing a microcontroller with a clock. Clock is needed so that microcontroller could execute a program or program instructions.<br />
Types of oscillators<br />
PIC16F84 can work with four different configurations of an oscillator. Since configurations with crystal oscillator and resistor-capacitor (RC) are the ones that are used most frequently, these are the only ones we will mention here. Microcontroller type with a crystal oscillator has in its designation XT, and a microcontroller with resistor-capacitor pair has a designation RC. This is important because you need to mention the type of oscillator when buying a microcontroller. <br />
XT Oscillator</div><table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr> <td width="277">Crystal oscillator is kept in metal housing with two pins where you have written down the frequency at which crystal oscillates. One ceramic capacitor of 30pF whose other end is connected to the ground needs to be connected with each pin. <br />
Oscillator and capacitors can be packed in joint case with three pins. Such element is called ceramic resonator and is represented in charts like the one below. Center pins of the element is the ground, while end pins are connected with OSC1 and OSC2 pins on the microcontroller. When designing a device, the rule is to place an oscillator nearer a microcontroller, so as to avoid any interference on lines on which microcontroller is receiving a clock.</td> <td width="476"><a href="http://lh4.ggpht.com/-LDBRYSKKGJQ/TxZVA21KDyI/AAAAAAAABwo/6ufA4qzNGE4/s1600-h/clip_image001%25255B6%25255D.gif"><img alt="clip_image001" border="0" height="231" src="http://lh6.ggpht.com/-4QDnfPv5hY8/TxZVBpX1bcI/AAAAAAAABww/wiFHltij4BQ/clip_image001_thumb%25255B3%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image001" width="373" /></a></td></tr>
<tr> <td width="476"><br />
</td></tr>
<tr> <td width="476"><a href="http://lh4.ggpht.com/-6k6_-PxUwUw/TxZVCoOflqI/AAAAAAAABw0/VvJ4KpiueHM/s1600-h/clip_image002%25255B4%25255D.gif"><img alt="clip_image002" border="0" height="224" src="http://lh4.ggpht.com/-OKKo2KZUdM0/TxZVDd28rPI/AAAAAAAABw8/1q2AOz8ZnWs/clip_image002_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image002" width="309" /></a></td></tr>
<tr> <td width="476"><br />
</td></tr>
</tbody></table><div align="justify">RC Oscillator<br />
In applications where great time precision is not necessary, RC oscillator offers additional savings during purchase. Resonant frequency of RC oscillator depends on supply voltage rate, resistance R, capacity C and working temperature. It should be mentioned here that resonant frequency is also influenced by normal variations in process parameters, by tolerance of external R and C components, etc.</div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjX37M04Ew25q4w3U_G_0dEdyF0ZgZ44oxd41yTmB7BnD3YoQ7xKhj7jkNgN7ZBtV8S0I7bQnLVQmyXJ2rovZ2awhOtG3VIqlXSSk0Ba-qyGwoJoxHAy4kI0IvKQE-8uA0SyFpiZTg10Kw/s1600-h/clip_image003%25255B4%25255D.gif"><img alt="clip_image003" border="0" height="222" src="http://lh3.ggpht.com/-T18mE_s8lIM/TxZVFWA7u4I/AAAAAAAABxQ/wllBUWe9K3Q/clip_image003_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image003" width="523" /></a></div><div align="justify">Above diagram shows how RC oscillator is connected with PIC16F84. With value of resistor R being below 2.2k, oscillator can become unstable, or it can even stop the oscillation. With very high value of R (ex.1M) oscillator becomes very sensitive to noise and humidity. It is recommended that value of resistor R should be between 3 and 100k. Even though oscillator will work without an external capacitor (C=0pF), capacitor above 20pF should still be used for noise and stability. No matter which oscillator is being used, in order to get a clock that microcontroller works upon, a clock of the oscillator must be divided by 4. Oscillator clock divided by 4 can also be obtained on OSC2/CLKOUT pin, and can be used for testing or synchronizing other logical circuits. </div><div align="justify"><a href="http://lh5.ggpht.com/-wjLWlyabMkA/TxZVGppYinI/AAAAAAAABxU/80E0Cqx5RuA/s1600-h/clip_image004%25255B4%25255D.gif"><img alt="clip_image004" border="0" height="180" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXmrLwLldUUQ_-F4Ii9tyhWoP62xSv0EnHnLGJEWTiKderFG80hvBednlYirGYJ6zpnFtfaMOzACyTVQ8JZFrH8d0D8eQqaVCFMKjWH4n2bFlq5IH1LTtnrpv9tiMbM2qAA-nJbhQARrE/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image004" width="625" /></a></div><div align="justify">Following a supply, oscillator starts oscillating. Oscillation at first has an unstable period and amplitude, but after some period of time it becomes stabilized. </div><div align="justify"><a href="http://lh6.ggpht.com/-UNDLuXSFc6k/TxZVHwBMX0I/AAAAAAAABxk/to4ybU28d-o/s1600-h/clip_image005%25255B4%25255D.gif"><img alt="clip_image005" border="0" height="264" src="http://lh4.ggpht.com/-XqzFSHT3N2M/TxZVIzd2B-I/AAAAAAAABxs/QDTsJftdMy0/clip_image005_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image005" width="622" /></a></div><div align="justify">To prevent such inaccurate clock from influencing microcontroller's performance, we need to keep the microcontroller in reset state during stabilization of oscillator's clock. Diagram above shows a typical shape of a signal which microcontroller gets from the quartz oscillator. </div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><b>Chapter 2.2 Reset</b> </div><div align="justify">Reset is used for putting the microcontroller into a 'known' condition. That practically means that microcontroller can behave rather inaccurately under certain undesirable conditions. In order to continue its proper functioning it has to be reset, meaning all registers would be placed in a starting position. Reset is not only used when microcontroller doesn't behave the way we want it to, but can also be used when trying out a device as an interrupt in program execution, or to get a microcontroller ready when loading a program.</div><table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr> <td width="350">In order to prevent from bringing a logical zero to MCLR pin accidentally (line above it means that reset is activated by a logical zero), MCLR has to be connected via resistor to the positive supply pole. Resistor should be between 5 and 10K. This kind of resistor whose function is to keep a certain line on a logical one as a preventive, is called a pull up.</td> <td width="403"><br />
</td></tr>
<tr> <td width="350"><br />
</td> <td width="403"><br />
</td></tr>
</tbody></table><a href="http://lh6.ggpht.com/-xkx8E-rXvtI/TxZWCv8ZKRI/AAAAAAAABx4/fCP33IhecB8/s1600-h/clip_image001%25255B4%25255D%25255B4%25255D.gif"><img alt="clip_image001[4]" border="0" height="368" src="http://lh4.ggpht.com/-JkrWofDzD7Q/TxZWDWB0aXI/AAAAAAAAByA/jlSNGNEMuR0/clip_image001%25255B4%25255D_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image001[4]" width="623" /></a><br />
<div align="justify">Microcontroller PIC16F84 knows several sources of resets:<br />
a) Reset during power on, POR (Power-On Reset)<br />
b) Reset during regular work by bringing logical zero to MCLR microcontroller's pin.<br />
c) Reset during SLEEP regime<br />
d) Reset at watchdog timer (WDT) overflow<br />
e) Reset during at WDT overflow during SLEEP work regime.<br />
The most important reset sources are a) and b). The first one occurs each time a power supply is brought to the microcontroller and serves to bring all registers to a starting position initial state. The second one is a product of purposeful bringing in of a logical zero to MCLR pin during normal operation of the microcontroller. This second one is often used in program development. <br />
During a reset, RAM memory locations are not being reset. They are unknown during a power up and are not changed at any reset. Unlike these, SFR registers are reset to a starting position initial state. One of the most important effects of a reset is setting a program counter (PC) to zero (0000h) , which enables the program to start executing from the first written instruction. <br />
Reset at supply voltage drop below the permissible (Brown-out Reset)<br />
Impulse for resetting during voltage voltage-up is generated by microcontroller itself when it detects an increase in supply Vdd (in a range from 1.2V to 1.8V). That impulse lasts 72ms which is enough time for an oscillator to get stabilized. These 72ms are provided by an internal PWRT timer which has its own RC oscillator. Microcontroller is in a reset mode as long as PWRT is active. However, as device is working, problem arises when supply doesn't drop to zero but falls below the limit that guarantees microcontroller's proper functioning. This is a likely case in practice, especially in industrial environment where disturbances and instability of supply are an everyday occurrence. To solve this problem we need to make sure that microcontroller is in a reset state each time supply falls below the approved limit. </div><div align="justify"><a href="http://lh6.ggpht.com/-gLWapJcaX5o/TxZWEY-eVaI/AAAAAAAAByI/u4E5hz7qhGQ/s1600-h/clip_image002%25255B4%25255D%25255B4%25255D.gif"><img alt="clip_image002[4]" border="0" height="383" src="http://lh6.ggpht.com/-Zaxt5tooGgo/TxZWFrYlKfI/AAAAAAAAByQ/5KGGWkWYFW4/clip_image002%25255B4%25255D_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image002[4]" width="665" /></a></div><div align="justify">If, according to electrical specification, internal reset circuit of a microcontroller can not satisfy the needs, special electronic components can be used which are capable of generating the desired reset signal. Beside this function, they can also function in watching over supply voltage. If voltage drops below specified level, a logical zero would appear on MCLR pin which holds the microcontroller in reset state until voltage is not within limits that guarantee accurate performance. </div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><b>2.3 Central Processing Unit of a PIC microcontroller</b> </div><div align="justify">Central processing unit (CPU) is the brain of a microcontroller. That part is responsible for finding and fetching the right instruction which needs to be executed, for decoding that instruction, and finally for its execution. </div><div align="justify">Central processing unit connects all parts of the microcontroller into one whole. Surely, its most important function is to decode program instructions. When programmer writes a program, instructions have a clear form like MOVLW 0x20. However, in order for a microcontroller to understand that, this 'letter' form of an instruction must be translated into a series of zeros and ones which is called an 'opcode'. This transition from a letter to binary form is done by translators such as assembler translator (also known as an assembler). Instruction thus fetched from program memory must be decoded by a central processing unit. We can then select from the table of all the instructions a set of actions which execute a assigned task defined by instruction. As instructions may within themselves contain assignments which require different transfers of data from one memory into another, from memory onto ports, or some other calculations, CPU must be connected with all parts of the microcontroller. This is made possible through a data bus and an address bus. </div><div align="justify">Arithmetic logic unit is responsible for performing operations of adding, subtracting, moving (left or right within a register) and logic operations. Moving data inside a register is also known as 'shifting'. PIC16F84 contains an 8-bit arithmetic logic unit and 8-bit work registers. </div><div align="justify">In instructions with two operands, ordinarily one operand is in work register (W register), and the other is one of the registers or a constant. By operand we mean the contents on which some operation is being done, and a register is any one of the GPR or SFR registers. GPR is an abbreviation for 'General Purposes Registers', and SFR for 'Special Function Registers'. In instructions with one operand, an operand is either W register or one of the registers. As an addition in doing operations in arithmetic and logic, ALU controls status bits (bits found in STATUS register). Execution of some instructions affects status bits, which depends on the result itself. Depending on which instruction is being executed, ALU can affect values of Carry (C), Digit Carry (DC), and Zero (Z) bits in STATUS register. </div><div align="justify">STATUS Register </div><div align="justify"><a href="http://lh6.ggpht.com/-T9cCQMmFsV0/TxZWpABfPlI/AAAAAAAAByY/8eMflrZTAko/s1600-h/clip_image001%25255B6%25255D.gif"><img alt="clip_image001" border="0" height="198" src="http://lh5.ggpht.com/-MY89eRKViB4/TxZWpxsnqEI/AAAAAAAAByc/F19piyBhn5g/clip_image001_thumb%25255B3%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image001" width="547" /></a></div><div align="justify"><i>bit 7</i> <b>IRP</b> (Register Bank Select bit) <br />
Bit whose role is to be an eighth bit for purposes of indirect addressing the internal RAM.<br />
1 = bank 2 and 3<br />
0 = bank 0 and 1 (from 00h to FFh)</div><div align="justify"><i>bits 6:5</i> <b>RP1:RP0</b> (Register Bank Select bits) <br />
These two bits are upper part of the address for direct addressing. As instructions which address the memory directly have only seven bits, they need one more bit in order to address all 256 bytes which is how many bytes PIC16F84 has. RP1 bit is not used, but is left for some future expansions of this microcontroller.<br />
01 = first bank<br />
00 = zero bank</div><div align="justify"><i>bit 4</i> <b>TO</b> Time-out ; Watchdog overflow.<br />
Bit is set after turning on the supply and execution of CLRWDT and SLEEP instructions. Bit is reset when watchdog gets to the end signaling that overflow took place.<br />
1 = overflow did not occur<br />
0 = overflow did occur</div><div align="justify"><i>bit 3</i> <b>PD</b> (Power-down bit)<br />
This bit is set whenever power supply is brought to a microcontroller : as it starts running, after each regular reset and after execution of instruction CLRWDT. Instruction SLEEP resets it when microcontroller falls into low consumption mode. Its repeated setting is possible via reset or by turning the supply off/on . Setting can be triggered also by a signal on RB0/INT pin, change on RB port, upon writing to internal DATA EEPROM, and by a Watchdog.<br />
1 = after supply has been turned on<br />
0 = executing SLEEP instruction</div><div align="justify"><i>bit 2</i> <b>Z</b> (Zero bit) Indication of a zero result<br />
This bit is set when the result of an executed arithmetic or logic operation is zero. <br />
1 = result equals zero<br />
0 = result does not equal zero</div><div align="justify"><i>bit 1</i> <b>DC</b> (Digit Carry) DC Transfer<br />
Bit affected by operations of addition, subtraction. Unlike C bit, this bit represents transfer from the fourth resulting place. It is set in case of subtracting smaller from greater number and is reset in the other case. <br />
1 = transfer occurred on the fourth bit according to the order of the result<br />
0 = transfer did not occur<br />
DC bit is affected by ADDWF, ADDLW, SUBLW, SUBWF instructions.</div><div align="justify"><i>bit 0</i> <b>C</b> (Carry) Transfer<br />
Bit that is affected by operations of addition, subtraction and shifting. <br />
1 = transfer occurred from the highest resulting bit <br />
0 = transfer did not occur<br />
C bit is affected by ADDWF, ADDLW, SUBLW, SUBWF instructions.</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr> <td width="100%"><b>2.4 Ports of a PIC microcontroller </b> <br />
Term "port" refers to a group of pins on a microcontroller which can be accessed simultaneously, or on which we can set the desired combination of zeros and ones, or read from them an existing status. Physically, port is a register inside a microcontroller which is connected by wires to the pins of a microcontroller. Ports represent physical connection of Central Processing Unit with an outside world. Microcontroller uses them in order to monitor or control other components or devices. Due to functionality, some pins have twofold roles like PA4/TOCKI for instance, which is in the same time the fourth bit of port A and an external input for free-run counter. Selection of one of these two pin functions is done in one of the configuration registers. An illustration of this is the fifth bit T0CS in OPTION register. By selecting one of the functions the other one is disabled. <br />
All port pins can be designated as input or output, according to the needs of a device that's being developed. In order to define a pin as input or output pin, the right combination of zeros and ones must be written in TRIS register. If the appropriate bit of TRIS register contains logical "1", then that pin is an input pin, and if the opposite is true, it's an output pin. Every port has its proper TRIS register. Thus, port A has TRISA, and port B has TRISB. Pin direction can be changed during the course of work which is particularly fitting for one-line communication where data flow constantly changes direction. PORTA and PORTB state registers are located in bank 0, while TRISA and TRISB pin direction registers are located in bank 1.<br />
PORTB and TRISB<br />
PORTB has adjoined 8 pins. The appropriate register for data direction is TRISB. Setting a bit in TRISB register defines the corresponding port pin as input, and resetting a bit in TRISB register defines the corresponding port pin as output. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkELOOZSwhi7bcxcj69FiEekbIBBwszZhBF4LI5CrjWewOUqUHBLNz6jv5R8fuYwnqW4dBME_seSppeBxM8tnSQhVZMRxC9EPgpxtbpjmiN-8vjoCbN19bsx7DQ1Vq5KzdCC-XZM7XS3E/s1600-h/clip_image001%25255B5%25255D.gif"><img alt="clip_image001" border="0" height="357" src="http://lh5.ggpht.com/-KNyEU0s2fRI/TxZXrXflhxI/AAAAAAAAByw/XVTJFdCUKS8/clip_image001_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image001" width="476" /></a> <br />
Each PORTB pin has a weak internal pull-up resistor (resistor which defines a line to logic one) which can be activated by resetting the seventh bit RBPU in OPTION register. These 'pull-up' resistors are automatically being turned off when port pin is configured as an output. When a microcontroller is started, pull-ups are disabled.<br />
Four pins PORTB, RB7:RB4 can cause an interrupt which occurs when their status changes from logical one into logical zero and opposite. Only pins configured as input can cause this interrupt to occur (if any RB7:RB4 pin is configured as an output, an interrupt won't be generated at the change of status.) This interrupt option along with internal pull-up resistors makes it easier to solve common problems we find in practice like for instance that of matrix keyboard. If rows on the keyboard are connected to these pins, each push on a key will then cause an interrupt. A microcontroller will determine which key is at hand while processing an interrupt It is not recommended to refer to port B at the same time that interrupt is being processed. <br />
<table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr> <td width="56">bsf</td> <td width="118">STATUS, RP0</td> <td width="276">;Bank1</td></tr>
<tr> <td width="56">movlw</td> <td width="118">0x0F</td> <td width="276">;Defining input and output pins</td></tr>
<tr> <td width="56">movwf</td> <td width="118">TRISB</td> <td width="276">;Writing to TRISB register</td></tr>
<tr> <td width="56">bcf</td> <td width="118">STATUS, RP0</td> <td width="276">;Bank0</td></tr>
<tr> <td width="56">bsf</td> <td width="118">PORTB, 4</td> <td width="276">;PORTB <7:4>=0</td></tr>
<tr> <td width="56">bsf</td> <td width="118">PORTB, 5</td> <td width="276"><br />
</td></tr>
<tr> <td width="56">bsf</td> <td width="118">PORTB, 6</td> <td width="276"><br />
</td></tr>
<tr> <td width="56">bsf</td> <td width="118">PORTB, 7</td> <td width="276"><br />
</td></tr>
</tbody></table>The above example shows how pins 0, 1, 2, and 3 are designated input, and pins 4, 5, 6, and 7 for output, after which PORTB output pins are set to one.<br />
PORTA and TRISA<br />
PORTA has 5 adjoining pins. The corresponding register for data direction is TRISA at address 85h. Like with port B, setting a bit in TRISA register defines also the corresponding port pin as input, and clearing a bit in TRISA register defines the corresponding port pin as output. <br />
It is important to note that PORTA pin RA4 can be input only. On that pin is also situated an external input for timer TMR0. Whether RA4 will be a standard input or an input for a counter depends on T0CS bit (<i>TMR0 Clock Source Select bit</i>). This pin enables the timer TMR0 to increment either from internal oscillator or via external impulses on RA4/T0CKI pin. <br />
<table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr> <td width="7%"><br />
</td> <td width="93%"><i>RA4 pin </i>can<i> be designated output, but in that case it has to be externally connected to PULL-UP resistor.</i></td></tr>
</tbody></table>Configuring port A: <br />
<table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr> <td width="57">bsf</td> <td width="127">STATUS, RP0</td> <td width="310">;Bank1</td></tr>
<tr> <td width="57">movlw</td> <td width="127">b'11111100'</td> <td width="310">;Defining input and output pins</td></tr>
<tr> <td width="57">movwf</td> <td width="127">TRISA</td> <td width="310">;Writing to TRISA register</td></tr>
<tr> <td width="57">bcf</td> <td width="127">STATUS, RP0</td> <td width="310">;Bank0</td></tr>
</tbody></table>Example shows how pins 0, 1, 2, 3, and 4 are designated input, and pins 5, 6, and 7 output. After this, it is possible to read the pins RA2, RA3, RA4, and to set logical zero or one to pins RA0 and RA1. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEidZzlmk6njkU-bkJM93Fr56Td9yBWWqK9_RDMpEIvVBdd2CLkibtf70hmChhiU6akxblWeU7OopfCoChYd2h2BOdwQ2A5wj-xDyaHspST3GzyFJEedt5SgcEhbA0RjNH9ay0ZhLCfFNjc/s1600-h/clip_image003%25255B4%25255D.gif"><img alt="clip_image003" border="0" height="365" src="http://lh4.ggpht.com/-nqkHxzSi19Q/TxZXtVrUsJI/AAAAAAAABzA/Yu7nj9PcInk/clip_image003_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image003" width="489" /></a></td></tr>
</tbody></table><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><b>2.5 Memory organization of a PIC microcontroller</b> </div><div align="justify">PIC16F84 has two separate memory blocks, one for data and the other for program. EEPROM memory with GPR and SFR registers in RAM memory make up the data block, while FLASH memory makes up the program block. <br />
Program memory<br />
Program memory has been carried out in FLASH technology which makes it possible to program a microcontroller many times before it's installed into a device, and even after its installment if eventual changes in program or process parameters should occur. The size of program memory is 1024 locations with 14 bits width where locations zero and four are reserved for reset and interrupt vector.<br />
Data memory<br />
Data memory consists of EEPROM and RAM memories. EEPROM memory consists of 64 eight bit locations whose contents is not lost during loosing of power supply. EEPROM is not directly addressable, but is accessed indirectly through EEADR and EEDATA registers. As EEPROM memory usually serves for storing important parameters (for example, of a given temperature in temperature regulators) , there is a strict procedure for writing in EEPROM which must be followed in order to avoid accidental writing. RAM memory for data occupies space on a memory map from location 0x0C to 0x4F which comes to 68 locations. Locations of RAM memory are also called GPR registers which is an abbreviation for <i>General Purpose Registers</i>. GPR registers can be accessed regardless of which bank is selected at the moment. <br />
SFR registers<br />
Registers which take up first 12 locations in banks 0 and 1 are registers of specialized function assigned with certain blocks of the microcontroller. These are called <i>Special Function Registers</i>.</div><div align="justify"><a href="http://lh6.ggpht.com/-ozj4TK6rGe4/TxZYfpu1cBI/AAAAAAAABzI/-W2Rt2Hc47g/s1600-h/clip_image001%25255B5%25255D.gif"><img alt="clip_image001" border="0" height="664" src="http://lh3.ggpht.com/-dZta8VxxM8Q/TxZYgc_PtmI/AAAAAAAABzQ/o4ZG2pJ17es/clip_image001_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image001" width="565" /></a></div><div align="justify">Memory Banks<br />
Beside this 'length' division to SFR and GPR registers, memory map is also divided in 'width' (see preceding map) to two areas called 'banks'. Selecting one of the banks is done via RP0 bit in STATUS register.<br />
<b>Example:</b><br />
bcf STATUS, RP0 <br />
Instruction BCF clears bit RP0 (RP0=0) in STATUS register and thus sets up bank 0.<br />
bsf STATUS, RP0 <br />
Instruction BSF sets the bit RP0 (RP0=1) in STATUS register and thus sets up bank1.<br />
It is useful to consider what would happen if the wrong bank was selected. Let's assume that we have selected bank 0 at the beginning of the program, and that we now want to write to certain register located in bank 1, say TRISB. Although we specified the name of the register TRISB, data will be actually stored to a bank 0 register at the appropriate address, which is PORTB in our example.</div><div align="justify">BANK0 macro<br />
Bcf STATUS, RP0 ;Select memory bank 0<br />
endm<br />
BANK1 macro<br />
Bsf STATUS, RP0 ;Select memory bank 1<br />
endm</div><div align="justify">Bank selection can be also made via directive <i>banksel</i> after which name of the register to be accessed is specified. In this manner, there is no need to memorize which register is in which bank.</div><table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr> <td width="55"><br />
</td> <td width="545"><i>Locations 0Ch - 4Fh are general purpose registers (GPR) which are used as RAM memory. When locations 8Ch - CFh in Bank 1 are accessed, we actually access the exact same locations in Bank 0. In other words , whenever you wish to access one of the GPR registers, there is no need to worry about which bank we are in!</i></td></tr>
</tbody></table><div align="justify">Program Counter<br />
Program counter (PC) is a 13-bit register that contains the address of the instruction being executed. It is physically carried out as a combination of a 5-bit register PCLATH for the five higher bits of the address, and the 8-bit register PCL for the lower 8 bits of the address.</div><div align="justify">By its incrementing or change (i.e. in case of jumps) microcontroller executes program instructions step-by-step.<br />
Stack<br />
PIC16F84 has a 13-bit stack with 8 levels, or in other words, a group of 8 memory locations, 13 bits wide, with special purpose. Its basic role is to keep the value of program counter after a jump from the main program to an address of a subprogram . In order for a program to know how to go back to the point where it started from, it has to return the value of a program counter from a stack. When moving from a program to a subprogram, program counter is being pushed onto a stack (example of this is CALL instruction). When executing instructions such as RETURN, RETLW or RETFIE which were executed at the end of a subprogram, program counter was taken from a stack so that program could continue where was stopped before it was interrupted. These operations of placing on and taking off from a program counter stack are called PUSH and POP, and are named according to similar instructions on some bigger microcontrollers.<br />
In System Programming<br />
In order to program a program memory, microcontroller must be set to special working mode by bringing up MCLR pin to 13.5V, and supply voltage Vdd has to be stabilized between 4.5V to 5.5V. Program memory can be programmed serially using two 'data/clock' pins which must previously be separated from device lines, so that errors wouldn't come up during programming.<br />
Addressing modes<br />
RAM memory locations can be accessed directly or indirectly.<br />
Direct Addressing<br />
Direct Addressing is done through a 9-bit address. This address is obtained by connecting 7th bit of direct address of an instruction with two bits (RP1, RP0) from STATUS register as is shown on the following picture. Any access to SFR registers is an example of direct addressing. </div><div align="justify">Bsf STATUS, RP0 ;Bankl<br />
movlw 0xFF ;w=0xFF<br />
movwf TRISA ;address of TRISA register is taken from<br />
;instruction movwf </div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiboMGXCaS0ad7h0vam3hzvu3Hqe4MWiqdtVsEZmOCM_gBzPw7IRLMmfqZ7WBtX21ymglb1csU64D8dqamidzCNqvH3RSHNJp-ZLEguo5Xnc86SOLrJzHPUXseWFF8kX6dUUNheYgeZlOA/s1600-h/clip_image003%25255B4%25255D.gif"><img alt="clip_image003" border="0" height="456" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5xJwUEcA2sjbY47y5DqMv5ErpBOOFh-LtfVhK025ewdIH8zjkXGiGndsPH_O8OTBrFP6s2LEq0J7CACR35nH8FkIl72amMxb-9gqQSjtISDGe3FOMbVnHh_3_YTZNmtWzF0Vj2MhrsKU/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image003" width="451" /></a></div><div align="justify"><b>Direct addressing</b> </div><div align="justify">Indirect Addressing<br />
Indirect unlike direct addressing does not take an address from an instruction but derives it from IRP bit of STATUS and FSR registers. Addressed location is accessed via INDF register which in fact holds the address indicated by a FSR. In other words, any instruction which uses INDF as its register in reality accesses data indicated by a FSR register. Let's say, for instance, that one general purpose register (GPR) at address 0Fh contains a value of 20. By writing a value of 0Fh in FSR register we will get a register indicator at address 0Fh, and by reading from INDF register, we will get a value of 20, which means that we have read from the first register its value without accessing it directly (but via FSR and INDF). It appears that this type of addressing does not have any advantages over direct addressing, but certain needs do exist during programming which can be solved smoothly only through indirect addressing.</div><div align="justify">Indirect addressing is very convenient for manipulating data arrays located in GPR registers. In this case, it is necessary to initialize FSR register with a starting address of the array, and the rest of the data can be accessed by incrementing the FSR register. </div><div align="justify"><a href="http://lh3.ggpht.com/-A4CbDXKLQtQ/TxZYjQKjOPI/AAAAAAAABzk/RkrUcwX4FLI/s1600-h/clip_image004%25255B4%25255D.gif"><img alt="clip_image004" border="0" height="444" src="http://lh3.ggpht.com/-IY91nWntGEs/TxZYk3URQaI/AAAAAAAABzw/jVAvL6W7EXc/clip_image004_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image004" width="451" /></a></div><div align="justify">Such examples include sending a set of data via serial communication, working with buffers and indicators (which will be discussed further in a chapter with examples), or erasing a part of RAM memory (16 locations) as in the following instance. </div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUcGjsUohS7dKSO9RALV-1yPUHwIvGbS_TJKELoj0UMrkk_8MnE3Cu0TN0Dq946mLg3DxSECFv2vFaXho15RPh5E0enWT8moaYc7Qcl1oMgTOCPIpc50FCXVTh4L3SOZglfHMYgSuNNgs/s1600-h/clip_image005%25255B4%25255D.gif"><img alt="clip_image005" border="0" height="164" src="http://lh6.ggpht.com/-zjzuqD1O6YI/TxZYmRsm5FI/AAAAAAAAB0A/h8LQ1b-m7NA/clip_image005_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image005" width="498" /></a></div><div align="justify">Reading data from INDF register when the contents of FSR register is equal to zero returns the value of zero, and writing to it results in NOP operation (no operation). </div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr> <td width="100%"><b>2.6 Interrupts</b> <br />
Interrupts are a mechanism of a microcontroller which enables it to respond to some events at the moment they occur, regardless of what microcontroller is doing at the time. This is a very important part, because it provides connection between a microcontroller and environment which surrounds it. Generally, each interrupt changes the program flow, interrupts it and after executing an interrupt subprogram (interrupt routine) it continues from that same point on. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjA2xxtKBwFr3HZ8VwPQcHrsGNrMmyOfDCgHKZwLLxv2c_H4rkyUAdXNxW844PvbbphlsSyCtfHSzTeUS15IhveWhi8Yus74oEOybczE8i7ChF_0NXg-d8ZYB0BolMevwyb93FHyPqd4tE/s1600-h/clip_image001%25255B4%25255D.gif"><img alt="clip_image001" border="0" height="365" src="http://lh4.ggpht.com/--wBhLn8qW0A/TxZb32VihMI/AAAAAAAAB0Q/k3lyupIXkmU/clip_image001_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image001" width="561" /></a> <br />
<b>One of the possible sources of interrupt and how it affects the main program</b> <br />
Control register of an interrupt is called INTCON and can be accessed regardless of the bank selected. Its role is to allow or disallowed interrupts, and in case they are not allowed, it registers single interrupt requests through its own bits.<br />
INTCON Register <br />
<a href="http://lh3.ggpht.com/-16_K6JbaDWU/TxZb4owaBzI/AAAAAAAAB0U/D1p4jZiYZLY/s1600-h/clip_image002%25255B4%25255D.gif"><img alt="clip_image002" border="0" height="255" src="http://lh4.ggpht.com/-WYFltebbrko/TxZb5ZRoseI/AAAAAAAAB0g/UutWWQleRC0/clip_image002_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image002" width="585" /></a> <br />
<i>Bit 7</i> <b>GIE</b> (<i>Global Interrupt Enable bit</i>) Bit which enables or disables all interrupts.<br />
1 = all interrupts are enabled<br />
0 = all interrupts are disabled <br />
<i>Bit 6</i> <b>EEIE</b> (<i>EEPROM Write Complete Interrupt Enable bit</i>) Bit which enables an interrupt at the end of a writing routine to EEPROM<br />
1 = interrupt enabled<br />
0 = interrupt disabled<br />
If EEIE and EEIF (which is in EECON1 register) are set simultaneously , an interrupt will occur. <br />
<i>bit 5</i> <b>T0IE</b> (<i>TMR0 Overflow Interrupt Enable bit</i>) Bit which enables interrupts during counter TMR0 overflow.<br />
1 = interrupt enabled<br />
0 = interrupt disabled<br />
If T0IE and T0IF are set simultaneously, interrupt will occur. <br />
<i>bit 4</i> <b>INTE</b> (<i>INT External Interrupt Enable bit</i>) Bit which enables external interrupt from pin RB0/INT.<br />
1 = external interrupt enabled<br />
0 = external interrupt disabled<br />
If INTE and INTF are set simultaneously, an interrupt will occur. <br />
<i>bit 3</i> <b>RBIE</b> (<i>RB port change Interrupt Enable bit</i>) Enables interrupts to occur at the change of status of pins 4, 5, 6, and 7 of port B. <br />
1 = enables interrupts at the change of status<br />
0 =interrupts disabled at the change of status<br />
If RBIE and RBIF are simultaneously set, an interrupt will occur. <br />
<i>bit 2</i> <b>T0IF</b> (<i>TMR0 Overflow Interrupt Flag bit</i>) Overflow of counter TMR0.<br />
1 = counter changed its status from FFh to 00h<br />
0 = overflow did not occur<br />
Bit must be cleared in program in order for an interrupt to be detected. <br />
<i>bit 1</i> <b>INTF</b> (<i>INT External Interrupt Flag bit</i>) External interrupt occurred.<br />
1 = interrupt occurred<br />
0 = interrupt did not occur<br />
If a rising or falling edge was detected on pin RB0/INT, (which is defined with bit INTEDG in OPTION register), bit INTF is set. <br />
<i>bit 0</i> <b>RBIF</b> (<i>RB Port Change Interrupt Flag bit</i>) Bit which informs about changes on pins 4, 5, 6 and 7 of port B.<br />
1 = at least one pin has changed its status<br />
0 = no change occurred on any of the pins<br />
Bit has to be cleared in an interrupt subroutine to be able to detect further interrupts. <br />
<a href="http://lh3.ggpht.com/-9xG6dUfQptY/TxZb69b945I/AAAAAAAAB0o/XV4_-oyQZKU/s1600-h/clip_image003%25255B4%25255D.gif"><img alt="clip_image003" border="0" height="301" src="http://lh6.ggpht.com/-U7GAebxdwJQ/TxZb7gERWhI/AAAAAAAAB0s/B-AaNqmpEWU/clip_image003_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image003" width="574" /></a> <br />
PIC16F84 has four interrupt sources:<br />
1. Termination of writing data to EEPROM<br />
2. TMR0 interrupt caused by timer overflow<br />
3. Interrupt during alteration on RB4, RB5, RB6 and RB7 pins of port B.<br />
4. External interrupt from RB0/INT pin of microcontroller<br />
Generally speaking, each interrupt source has two bits joined to it. One enables interrupts, and the other detects when interrupts occur. There is one common bit called GIE which can be used to disallow or enable all interrupts simultaneously. This bit is very useful when writing a program because it allows for all interrupts to be disabled for a period of time, so that execution of some important part of a program would not be interrupted. When instruction which resets GIE bit was executed (GIE=0, all interrupts disallowed), any interrupt that remained unsolved should be ignored. Interrupts which remained unsolved and were ignored, are processed when GIE bit (GIE=1, all interrupts allowed) would be cleared. When interrupt was answered, GIE bit was cleared so that any additional interrupts would be disabled, return address was pushed onto stack and address 0004h was written in program counter - only after this does replying to an interrupt begin! After interrupt is processed, bit whose setting caused an interrupt must be cleared, or interrupt routine would automatically be processed over again during a return to the main program.<br />
Keeping the contents of important registers<br />
Only return value of program counter is stored on a stack during an interrupt (by return value of program counter we mean the address of the instruction which was to be executed, but wasn't because interrupt occurred). Keeping only the value of program counter is often not enough. Some registers which are already in use in the main program can also be in use in interrupt routine. If they were not retained, main program would during a return from an interrupt routine get completely different values in those registers, which would cause an error in the program. One example for such a case is contents of the work register W. If we suppose that main program was using work register W for some of its operations, and if it had stored in it some value that's important for the following instruction, then an interrupt which occurs before that instruction would change the value of work register W which would directly be influenced the main program.<br />
Procedure of recording important registers before going to an interrupt routine is called PUSH, while the procedure which brings recorded values back, is called POP. PUSH and POP are instructions with some other microcontrollers (Intel), but are so widely accepted that a whole operation is named after them. PIC16F84 does not have instructions like PUSH and POP, and they have to be programmed. <br />
<a href="http://lh5.ggpht.com/-ylUPKXcYZtQ/TxZb8O3utcI/AAAAAAAAB00/IuItuqfws1E/s1600-h/clip_image004%25255B4%25255D.gif"><img alt="clip_image004" border="0" height="399" src="http://lh3.ggpht.com/-PjF3MiYNjEI/TxZb9bjLmEI/AAAAAAAAB08/y7ndyfS_py8/clip_image004_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image004" width="568" /></a> <br />
<b>Common error: saving the value wasn't done before entering the interrupt routine</b> <br />
Due to simplicity and frequent usage, these parts of the program can be made as macros. The concept of a Macro is explained in "Program assembly language". In the following example, contents of W and STATUS registers are stored in W_TEMP and STATUS_TEMP variables prior to interrupt routine. At the beginning of PUSH routine we need to check presently selected bank because W_TEMP and STATUS_TEMP are found in bank 0. For exchange of data between these registers, SWAPF instruction is used instead of MOVF because it does not affect the STATUS register bits.<br />
Example is an assembler program for following steps:<br />
1. Testing the current bank<br />
2. Storing W register regardless of the current bank<br />
3. Storing STATUS register in bank 0.<br />
4. Executing interrupt routine for interrupt processing (ISR)<br />
5. Restores STATUS register<br />
6. Restores W register<br />
If there are some more variables or registers that need to be stored, then they need to be kept after storing STATUS register (step 3), and brought back before STATUS register is restored (step 5). <br />
<a href="http://lh4.ggpht.com/-hiUK9d0PcTo/TxZb-FhVZBI/AAAAAAAAB1I/6hdJp43VGc4/s1600-h/clip_image005%25255B4%25255D.gif"><img alt="clip_image005" border="0" height="495" src="http://lh6.ggpht.com/-TxvKIB9cuAc/TxZcAYUGqLI/AAAAAAAAB1Q/lx1Qr5q--xk/clip_image005_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image005" width="464" /></a> <br />
The same example can be carried out using macros, thus getting a more legible program. Macros that are already defined can be used for writing new macros. Macros BANK1 and BANK0 which are explained in "Memory organization" chapter are used with macros 'push' and 'pop'. <br />
<a href="http://lh4.ggpht.com/-QqH3Po_qv8w/TxZcBN0h80I/AAAAAAAAB1Y/I4jOwz3n8ag/s1600-h/clip_image006%25255B4%25255D.gif"><img alt="clip_image006" border="0" height="349" src="http://lh3.ggpht.com/-B1qzG0BhJvg/TxZcCjMyRmI/AAAAAAAAB1g/qfkTwZAfvxQ/clip_image006_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image006" width="509" /></a> <br />
External interrupt on RB0/INT pin of microcontroller<br />
External interrupt on RB0/INT pin is triggered by rising signal edge (if bit INTEDG=1 in OPTION<6> register), or falling edge (if INTEDG=0). When correct signal appears on INT pin, INTF bit is set in INTCON register. INTF bit (INTCON<1>) must be cleared in interrupt routine, so that interrupt wouldn't occur again while going back to the main program. This is an important part of the program which programmer must not forget, or program will constantly go into interrupt routine. Interrupt can be turned off by resetting INTE control bit (INTCON<4>). Possible application of this interrupt could be measuring the impulse width or pause length, i.e. input signal frequency. Impulse duration can be measured by first enabling the interrupt on rising edge, and upon its appearing, starting the timer and then enabling the interrupt on falling edge. Timer should be stopped upon the appearing of falling edge - measured time period represents the impulse duration.<br />
Interrupt during a TMR0 counter overflow<br />
Overflow of TMR0 counter (from FFh to 00h) will set T0IF (INTCON<2>) bit. This is very important interrupt because many real problems can be solved using this interrupt. One of the examples is time measurement. If we know how much time counter needs in order to complete one cycle from 00h to FFh, then a number of interrupts multiplied by that amount of time will yield the total of elapsed time. In interrupt routine some variable would be incremented in RAM memory, value of that variable multiplied by the amount of time the counter needs to count through a whole cycle, would yield total elapsed time. Interrupt can be turned on/off by setting/resetting T0IE (INTCON<5>) bit.<br />
Interrupt upon a change on pins 4, 5, 6 and 7 of port B<br />
Change of input signal on PORTB <7:4> sets RBIF (INTCON<0>) bit. Four pins RB7, RB6, RB5 and RB4 of port B, can trigger an interrupt which occurs when status on them changes from logic one to logic zero, or vice versa. For pins to be sensitive to this change, they must be defined as input. If any one of them is defined as output, interrupt will not be generated at the change of status. If they are defined as input, their current state is compared to the old value which was stored at the last reading from port B.<br />
Interrupt upon finishing write-subroutine to EEPROM<br />
This interrupt is of practical nature only. Since writing to one EEPROM location takes about 10ms (which is a long time in the notion of a microcontroller), it doesn't pay off to a microcontroller to wait for writing to end. Thus interrupt mechanism is added which allows the microcontroller to continue executing the main program, while writing in EEPROM is being done in the background. When writing is completed, interrupt informs the microcontroller that writing has ended. EEIF bit, through which this informing is done, is found in EECON1 register. Occurrence of an interrupt can be disabled by resetting the EEIE bit in INTCON register. <br />
Interrupt initialization<br />
In order to use an interrupt mechanism of a microcontroller, some preparatory tasks need to be performed. These procedures are in short called "initialization". By initialization we define to what interrupts the microcontroller will respond, and which ones it will ignore. If we do not set the bit that allows a certain interrupt, program will not execute an interrupt subprogram. Through this we can obtain control over interrupt occurrence, which is very useful. <br />
<a href="http://lh5.ggpht.com/-X3Ko40Laefc/TxZcDDp6zJI/AAAAAAAAB1k/-Pa4qMYsJeQ/s1600-h/clip_image007%25255B4%25255D.gif"><img alt="clip_image007" border="0" height="79" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQbfeTSuEDR_KZZWIl62TT3z6kjQ64-0y2oh3mDXwcFVYBOmQzJ680YuygPCIvlFnceSdPlZUbBW3sJPSa9AmAAPjY9wBhX1XTLagUkDyCusVL8bGrEov1UE9TOhzsk9CnJxwdSeMfY7k/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image007" width="558" /></a> <br />
The above example shows initialization of external interrupt on RB0 pin of a microcontroller. Where we see one being set, that means that interrupt is enabled. Occurrence of other interrupts is not allowed, and interrupts are disabled altogether until GIE bit is set to one.<br />
The following example shows a typical way of handling interrupts. PIC16F84 has got a single location for storing the address of an interrupt subroutine. This means that first we need to detect which interrupt is at hand (if more than one interrupt source is available), and then we can execute that part of a program which refers to that interrupt. <br />
<a href="http://lh5.ggpht.com/-EHix_wlr7IQ/TxZcFxG34PI/AAAAAAAAB14/YUBVGT4RTec/s1600-h/clip_image008%25255B4%25255D.gif"><img alt="clip_image008" border="0" height="525" src="http://lh3.ggpht.com/-I6I4SYECdZs/TxZcGxtxvWI/AAAAAAAAB2A/Hu3upEDwFos/clip_image008_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image008" width="519" /></a> <br />
<table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr> <td width="50"><br />
</td> <td width="705"><i>Return from interrupt routine can be accomplished with instructions RETURN, RETLW and RETFIE. It is recommended that instruction RETFIE be used because that instruction is the only one which automatically sets the GIE bit which allows new interrupts to occur.</i></td></tr>
</tbody></table></td></tr>
</tbody></table></div><div align="justify"><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<b>2.7 Free-run timer TMR0</b> <br />
Timers are usually the most complicated parts of a microcontroller, so it is necessary to set aside more time for understanding them thoroughly. Through their application it is possible to establish relations between a real dimension such as "time" and a variable which represents status of a timer within a microcontroller. Physically, timer is a register whose value is continually increasing to 255, and then it starts all over again: 0, 1, 2, 3, 4...255....0,1, 2, 3......etc. <br />
<a href="http://lh3.ggpht.com/-nCpP5BfP-Wo/TxZccWO72UI/AAAAAAAAB2I/DLupGYoQv-o/s1600-h/clip_image001%25255B4%25255D.gif"><img alt="clip_image001" border="0" height="463" src="http://lh5.ggpht.com/-AvzF_pZBLZ4/TxZcdNFW4bI/AAAAAAAAB2Q/RhSy4UM3xjc/clip_image001_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image001" width="526" /></a> <br />
This incrementing is done in the background of everything a microcontroller does. It is up to programmer to think up a way how he will take advantage of this characteristic for his needs. One of the ways is increasing some variable on each timer overflow. If we know how much time a timer needs to make one complete round, then multiplying the value of a variable by that time will yield the total amount of elapsed time. <br />
PIC16F84 has an 8-bit timer. Number of bits determines what value timer counts to before starting to count from zero again. In the case of an 8-bit timer, that number is 256. A simplified scheme of relation between a timer and a prescaler is represented on the previous diagram. Prescaler is a name for the part of a microcontroller which divides oscillator clock before it will reach logic that increases timer status. Number which divides a clock is defined through first three bits in OPTION register. The highest divisor is 256. This actually means that only at every 256th clock, timer value would increase by one. This provides us with the ability to measure longer timer periods. <br />
<a href="http://lh3.ggpht.com/-gfQWoS_CBxk/TxZced1nCKI/AAAAAAAAB2Y/zXe8t9PSMVI/s1600-h/clip_image002%25255B4%25255D.gif"><img alt="clip_image002" border="0" height="262" src="http://lh6.ggpht.com/-auyE-FerBxQ/TxZcfWhGpnI/AAAAAAAAB2g/NH3YmKBLq40/clip_image002_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image002" width="591" /></a> <br />
After each count up to 255, timer resets its value to zero and starts with a new cycle of counting to 255. During each transition from 255 to zero, T0IF bit in INTCOM register is set. If interrupts are allowed to occur, this can be taken advantage of in generating interrupts and in processing interrupt routine. It is up to programmer to reset T0IF bit in interrupt routine, so that new interrupt, or new overflow could be detected. Beside the internal oscillator clock, timer status can also be increased by the external clock on RA4/TOCKI pin. Choosing one of these two options is done in OPTION register through T0CS bit. If this option of external clock was selected, it would be possible to define the edge of a signal (rising or falling), on which timer would increase its value. <br />
<a href="http://lh3.ggpht.com/-1PpNB4uwU7k/TxZcgk2uZaI/AAAAAAAAB2o/jI2JR-zzgPg/s1600-h/clip_image003%25255B4%25255D.gif"><img alt="clip_image003" border="0" height="376" src="http://lh4.ggpht.com/-GD-tlLZARlE/TxZch9OqzrI/AAAAAAAAB2w/e3iC1aHZlcs/clip_image003_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image003" width="569" /></a> <br />
In practice, one of the typical example that is solved via external clock and a timer is counting full turns of an axis of some production machine, like transformer winder for instance. Let's wind four metal screws on the axis of a winder. These four screws will represent metal convexity. Let's place now the inductive sensor at a distance of 5mm from the head of a screw. Inductive sensor will generate the falling signal every time the head of the screw is parallel with sensor head. Each signal will represent one fourth of a full turn, and the sum of all full turns will be found in TMR0 timer. Program can easily read this data from the timer through a data bus. <br />
The following example illustrates how to initialize timer to signal falling edges from external clock source with a prescaler 1:4. Timer works in "polig" mode. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvZxDpKyKCGEkljVpFt-F6ZZfXGfrmtsXiH5XeRXSBQ_FNlo4LcEN83ArZ9w7NM4d5vYgajan4j0QJ2kgUFtHMKtOzOgc-EDpc1GLWxQQD_HgmUw1_FkOPlWk3mzsROfcySqb3dYxJEeI/s1600-h/clip_image004%25255B4%25255D.gif"><img alt="clip_image004" border="0" height="252" src="http://lh6.ggpht.com/-88GqvpNJH48/TxZck0fsfQI/AAAAAAAAB3A/XhFr8Hhssvw/clip_image004_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image004" width="599" /></a> <br />
The same example can be carried out through an interrupt in the following way: <br />
<a href="http://lh5.ggpht.com/-6WFiCY21-Vk/TxZclhJYyQI/AAAAAAAAB3E/2IQjisWDQm8/s1600-h/clip_image005%25255B4%25255D.gif"><img alt="clip_image005" border="0" height="422" src="http://lh4.ggpht.com/-8idHFxsMkKU/TxZcmv6XcEI/AAAAAAAAB3Q/QUT1jjUIDJw/clip_image005_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image005" width="615" /></a> <br />
Prescaler can be assigned either timer TMR0 or a watchdog. Watchdog is a mechanism which microcontroller uses to defend itself against programs getting stuck. As with any other electrical circuit, so with a microcontroller too can occur failure, or some work impairment. Unfortunately, microcontroller also has program where problems can occur as well. When this happens, microcontroller will stop working and will remain in that state until someone resets it. Because of this, watchdog mechanism has been introduced. After a certain period of time, watchdog resets the microcontroller (microcontroller in fact resets itself). Watchdog works on a simple principle: if timer overflow occurs, microcontroller is reset, and it starts executing a program all over again. In this way, reset will occur in case of both correct and incorrect functioning. Next step is preventing reset in case of correct functioning, which is done by writing zero in WDT register (instruction CLRWDT) every time it nears its overflow. Thus program will prevent a reset as long as it's executing correctly. Once it gets stuck, zero will not be written, overflow of WDT timer and a reset will occur which will bring the microcontroller back to correct functioning again. <br />
Prescaler is accorded to timer TMR0, or to watchdog timer trough PSA bit in OPTION register. By clearing PSA bit, prescaler will be accorded to timer TMR0. When prescaler is accorded to timer TMR0, all instructions of writing to TMR0 register (CLRF TMR0, MOVWF TMR0, BSF TMR0,...) will clear prescaler. When prescaler is assigned to a watchdog timer, only CLRWDT instruction will clear a prescaler and watchdog timer at the same time . Prescaler change is completely under programmer's control, and can be changed while program is running. <br />
<table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr> <td width="50"><br />
</td> <td width="550"><i>There is only one prescaler and one timer. Depending on the needs, they are assigned either to timer TMR0 or to a watchdog.</i></td></tr>
</tbody></table>OPTION Control Register <br />
<a href="http://lh5.ggpht.com/-GtR_T3cVl48/TxZcnRzZIeI/AAAAAAAAB3Y/GRXFPgV1Ppo/s1600-h/clip_image007%25255B4%25255D.gif"><img alt="clip_image007" border="0" height="163" src="http://lh6.ggpht.com/-3ORAMRFdhNE/TxZcoS3GhKI/AAAAAAAAB3g/znwsl-igDd0/clip_image007_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image007" width="617" /></a> <br />
<i>bit 7</i> <b>RBPU</b> (<i>PORTB Pull-up Enable bit</i>) <br />
This bit turns internal pull-up resistors on port B on or off. <br />
1 = 'pull-up' resistors turned on<br />
0 = 'pull-up' resistors turned off <br />
<i>bit 6</i> I<b>NTEDG</b> (<i>Interrupt Edge Select bit</i>)<br />
If occurrence of interrupts was enabled, this bit would determine at what edge interrupt on RB0/INT pin would occur.<br />
1 = rising edge<br />
0 = falling edge <br />
<i>bit 5</i> <b>T0CS</b> (<i>TMR0 Clock Source Select bit</i>)<br />
This pin enables a free-run timer to increment its value either from an internal oscillator, i.e. every 1/4 of oscillator clock, or via external impulses on RA4/T0CKI pin.<br />
1 = external impulses<br />
0 = 1/4 internal clock <br />
<i>bit 4</i> <b>T0SE</b> (<i>TMR0 Source Edge Select bit</i>)<br />
If trigger TMR0 was enabled with impulses from a RA4/T0CKI pin, this bit would determine whether it would be on the rising or falling edge of a signal. <br />
1 = falling edge<br />
0 = rising edge <br />
<i>bit 3</i> <b>PSA</b> (<i>Prescaler Assignment bit</i>)<br />
Bit which assigns prescaler between TMR0 and watchdog timer.<br />
1 = prescaler is assigned to watchdog timer.<br />
0 = prescaler is assigned to free timer TMR0 <br />
<i>Bit 0:2</i> <b>PS0, PS1, PS2</b> (<i>Prescaler Rate Select bit</i>) <br />
In case of 4MHz oscillator, one instruction cycle (4 internal clocks) lasts 1µs. Numbers in the following table show the time period in µs between incrementing TMR or WDT. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivMI9vqveJhezPxSuueDO0S3KrVwSDxJpy_XQ-41x9KT95cE0vTHGxyoMdNMU0it08be3utfrYNzLEXbs8QXDBdSnQ9GlrZPyZCzKIfUEwOzV8DBostoU8yMv7niBqcv3IaqQt2yBP8t8/s1600-h/clip_image008%25255B4%25255D.gif"><img alt="clip_image008" border="0" height="184" src="http://lh3.ggpht.com/-BZ8k4sSDHsw/TxZcqTgnw3I/AAAAAAAAB3w/Jf1iGiGwew0/clip_image008_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image008" width="381" /></a> </div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div align="justify"><b>2.8 EEPROM Data memory in PIC microcontrollers</b> </div><div align="justify">PIC16F84 has 64 bytes of EEPROM memory locations on addresses from 00h to 63h that can be written to or read from. The most important characteristic of this memory is that it does not lose its contents with the loss of power supply. Data can be retained in EEPROM without power supply for up to 40 years (as manufacturer of PIC16F84 microcontroller states), and up to 1 million cycles of writing can be executed. <br />
In practice, EEPROM memory is used for storing important data or process parameters.<br />
One such parameter is a given temperature, assigned when setting up a temperature regulator to some process. If that data wasn't retained, it would be necessary to adjust a given temperature after each loss of supply. Since this is very impractical (and even dangerous), manufacturers of microcontrollers have began installing one smaller type of EEPROM memory.<br />
EEPROM memory is placed in a special memory space and can be accessed through special registers. These registers are:</div><table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr> <td valign="top" width="74"><b>EEDATA</b></td> <td valign="top" width="396">Holds read data or that to be written.</td></tr>
<tr> <td valign="top" width="74"><b>EEADR</b></td> <td valign="top" width="396">Contains an address of EEPROM location being accessed.</td></tr>
<tr> <td valign="top" width="74"><b>EECON1</b></td> <td valign="top" width="396">Contains control bits.</td></tr>
<tr> <td valign="top" width="74"><b>EECON2</b></td> <td valign="top" width="396">This register does not exist physically and serves to protect EEPROM from accidental writing.</td></tr>
</tbody></table><div align="justify">EECON1 register is a control register with five implemented bits. Bits 5, 6 and 7 are not used, and by reading always are zero. Interpretation of EECON1 register bits follows.<br />
EECON1 Register</div><div align="justify"><a href="http://lh5.ggpht.com/-1Oez46TQru0/TxZdQ_vX0RI/AAAAAAAAB34/8gPqmducXxY/s1600-h/clip_image001%25255B5%25255D.gif"><img alt="clip_image001" border="0" height="135" src="http://lh5.ggpht.com/-59maykFzg6o/TxZdRgTsRrI/AAAAAAAAB38/u3JJGPqnyPc/clip_image001_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image001" width="510" /></a></div><div align="justify">bit 4 <b>EEIF</b> (<i>EEPROM Write Operation Interrupt Flag bit</i>) Bit used to inform that writing data to EEPROM has ended.<br />
When writing has terminated, this bit would be set automatically. Programmer must clear EEIF bit in his program in order to detect new termination of writing. <br />
1 = writing terminated<br />
0 = writing not terminated yet, or has not started</div><div align="justify">bit 3 <b>WRERR</b> (<i>Write EEPROM Error Flag</i>) Error during writing to EEPROM<br />
This bit was set only in cases when writing to EEPROM had been interrupted by a reset signal or by running out of time in watchdog timer (if activated).<br />
1 = error occurred<br />
0 = error did not occur</div><div align="justify">bit 2 <b>WREN</b> (<i>EEPROM Write Enable bit</i>) Enables writing to EEPROM<br />
If this bit was not set, microcontroller would not allow writing to EEPROM.<br />
1 = writing allowed<br />
0 = writing disallowed</div><div align="justify">bit 1 <b>WR</b> (<i>Write Control bit</i>) <br />
Setting of this bit initializes writing data from EEDATA register to the address specified trough EEADR register. <br />
1 = initializes writing<br />
0 = does not initialize writing</div><div align="justify">bit 0 <b>RD</b> (<i>Read Control bit</i>)<br />
Setting this bit initializes transfer of data from address defined in EEADR to EEDATA register. Since time is not as essential in reading data as in writing, data from EEDATA can already be used further in the next instruction.<br />
1 = initializes reading<br />
0 = does not initialize reading<br />
Reading from EEPROM Memory<br />
Setting the RD bit initializes transfer of data from address found in EEADR register to EEDATA register. As in reading data we don't need so much time as in writing, data taken over from EEDATA register can already be used further in the next instruction. <br />
Sample of the part of a program which reads data in EEPROM, could look something like the following: </div><div align="justify"><a href="http://lh3.ggpht.com/-vL_FQA_zawA/TxZdS_05M9I/AAAAAAAAB4I/l7FPGJtgg5I/s1600-h/clip_image002%25255B4%25255D.gif"><img alt="clip_image002" border="0" height="169" src="http://lh4.ggpht.com/-VDsdO--IIk8/TxZdTlSPOUI/AAAAAAAAB4Q/9PqrnjeH_nE/clip_image002_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image002" width="578" /></a></div><div align="justify">After the last program instruction, contents from an EEPROM address zero can be found in working register w. <br />
Writing to EEPROM Memory<br />
In order to write data to EEPROM location, programmer must first write address to EEADR register and data to EEDATA register. Only then is it useful to set WR bit which sets the whole action in motion. WR bit will be reset, and EEIF bit set following a writing what may be used in processing interrupts. Values 55h and AAh are the first and the second key whose disallow for accidental writing to EEPROM to occur. These two values are written to EECON2 which serves only that purpose, to receive these two values and thus prevent any accidental writing to EEPROM memory. Program lines marked as 1, 2, 3, and 4 must be executed in that order in even time intervals. Therefore, it is very important to turn off interrupts which could change the timing needed for executing instructions. After writing, interrupts can be enabled again .<br />
Example of the part of a program which writes data 0xEE to first location in EEPROM memory could look something like the following: </div><div align="justify"><a href="http://lh3.ggpht.com/-buUEn6b0gSc/TxZdUpf2d_I/AAAAAAAAB4U/-3N1lnQyPyk/s1600-h/clip_image003%25255B4%25255D.gif"><img alt="clip_image003" border="0" height="346" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheDmTM8F1BQ4HILevckDIp_-r8mSWvB5NC4VzQ6HtMWh4zeKMw7MaUJyY9aJ9bRerVQ_mO6xU0e2oDyvUtzJ0IcXsoTjtXrob-CT_BurqaVK9aigGO_0WAqTnMA9qBgAMPoYnEGHsxks4/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image003" width="628" /></a></div><table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr> <td valign="top" width="50"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0rttVC8stgblC7ZumO6g3vGWyUUc0W-hY96TVjfbnktYKumzQF9l_c5IKmFyDnUM8el4qPMKMSIRY7soZbz5vhYX4t1Z8pFyJOiSSE4T4j8q0knf9IQ7oLmzJu0Ls9RThyphenhyphenOY9kCup7lg/s1600-h/clip_image004%25255B3%25255D.gif"><img alt="clip_image004" border="0" height="64" src="http://lh3.ggpht.com/-_7Ho_SBsOSo/TxZdXVDrd8I/AAAAAAAAB4s/oqJ_QcnKLOI/clip_image004_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image004" width="21" /></a></td> <td width="705"><i>It is recommended that WREN be turned off the whole time except when writing data to EEPROM, so that possibility of accidental writing would be minimal. <br />
All writing to EEPROM will automatically clear a location prior to writing a new!</i></td></tr>
</tbody></table><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div align="justify"><b>CHAPTER 3</b> </div><div align="justify"><b>Assembly Language Programming</b> </div><div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#Introduction">Introduction</a> </div><div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.1%20Representing%20numbers%20in%20assembler">3.1 Representing numbers in assembler</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.2%20Assembly%20language%20elements">3.2 Assembly language elements</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.3%20Writing%20a%20sample%20program">3.3 Writing a sample program</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.4%20Control%20directives">3.4 Control directives</a></div><ul><li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.1%20#DEFINE%20Exchanging%20text%20for%20another%20one">define</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.2%20INCLUDE%20Include%20an%20additional%20file%20into%20a%20program">include</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.3%20CONSTANT%20Gives%20a%20constant%20numeric%20value%20to%20the%20textual%20designation">constant</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.4%20VARIABLE%20Gives%20a%20variable%20numeric%20value%20to%20textual%20designation">variable</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.5%20SET%20Defining%20assembler%20variable">set</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.6%20EQU%20Defining%20assembler%20constant">equ</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.7%20ORG%20Defines%20an%20address%20from%20which%20the%20program%20is%20stored%20in%20microcontroller%20memory">org</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.8%20END%20End%20of%20program">end</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.9%20IF%20Conditional%20program%20branching">if</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.10%20ELSE%20%27IF%27%20alternative%20to%20program%20block%20with%20conditional%20terms">else</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.11%20ENDIF%20End%20of%20conditional%20program%20section">endif</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.12%20WHILE%20Execution%20of%20program%20section%20as%20long%20as%20condition%20is%20met">while</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.13%20ENDW%20End%20of%20conditional%20part%20of%20the%20program">endw</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.14%20IFDEF%20Execution%20of%20a%20part%20of%20the%20program%20if%20symbol%20is%20defined">ifdef</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.15%20IFNDEF%20Execution%20of%20a%20part%20of%20the%20program%20if%20symbol%20is%20defined">ifndef</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.16%20CBLOCK%20Defining%20a%20block%20for%20the%20named%20constants">cblock</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.16%20CBLOCK%20Defining%20a%20block%20for%20the%20named%20constants">endc</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.18%20DB%20Defining%20one%20byte%20data">db</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.19%20DE%20Defining%20the%20EEPROM%20memory%20byte">de</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.20%20DT%20Defining%20the%20data%20table">dt</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.21_%20CONFIG%20Setting%20the%20configurational%20bits">CONFIG</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.22%20PROCESSOR%20Defining%20microcontroller%20model">Processor</a></div></li>
</ul><div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/3_chapter.htm#3.5%20Files%20created%20as%20a%20result%20of%20program%20translation">3.5 Files created as a result of program translation</a> </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Introduction"><b>Introduction</b></a> </div><div align="justify">The ability to communicate is of great importance in any field. However, it is only possible if both communication partners know the same language, i.e follow the same rules during communication. Using these principles as a starting point, we can also define communication that occurs between microcontrollers and man . Language that microcontroller and man use to communicate is called "assembly language". The title itself has no deeper meaning, and is analogue to names of other languages , ex. English or French. More precisely, "assembly language" is just a passing solution. Programs written in assembly language must be translated into a "language of zeros and ones" in order for a microcontroller to understand it. "Assembly language" and "assembler" are two different notions. The first represents a set of rules used in writing a program for a microcontroller, and the other is a program on the personal computer which translates assembly language into a language of zeros and ones. A program that is translated into "zeros" and "ones" is also called "machine language". </div><div align="justify"><a href="http://lh5.ggpht.com/-2IztYW8aPQM/TxZePI_WNTI/AAAAAAAAB6I/rM372HdJo-U/s1600-h/clip_image001%25255B4%25255D.gif"><img alt="clip_image001" border="0" height="280" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlo8Sl63AiJlWS6vd-3xsT5C_Pdkiz89SX30mDlut0a4Ppmyj2562VVzx9TxmpHK7EqbS3z49YI0_Xhs8M6aE_R7fMBoUrrA-4BMEbKDVDNXrZsn8wzEhPvwzuYuakz2H8AF546zx4P9k/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image001" width="530" /></a></div><div align="justify"><b>The process of communication between a man and a microcontroller</b> </div><div align="justify">Physically, "<b>Program</b>" represents a file on the computer disc (or in the memory if it is read in a microcontroller), and is written according to the rules of assembler or some other language for microcontroller programming. Man can understand assembler language as it consists of alphabet signs and words. When writing a program, certain rules must be followed in order to reach a desired effect. A <b>Translator</b> interprets each instruction written in assembly language as a series of zeros and ones which have a meaning for the internal logic of the microcontroller. Lets take for instance the instruction "RETURN" that a microcontroller uses to return from a sub-program. When the assembler translates it, we get a 14-bit series of zeros and ones which the microcontroller knows how to interpret. <b>Example:</b> RETURN 00 0000 0000 1000 Similar to the above instance, each assembler instruction is interpreted as corresponding to a series of zeros and ones. The place where this translation of assembly language is found, is called an "execution" file. We will often meet the name "HEX" file. This name comes from a hexadecimal representation of that file, as well as from the suffix "hex" in the title, ex. "test.hex". Once it is generated, the execution file is read in a microcontroller through a programmer. An <b>Assembly Language</b> program is written in a program for text processing (editor) and is capable of producing an ASCII file on the computer disc or in specialized surroundings such as MPLAB,which will be explained in the next chapter.</div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.1_Representing_numbers_in_assembler"><b>3.1 Representing numbers in assembler</b></a> </div><div align="justify">In assembly language MPLAB, numbers can be represented in decimal, hexadecimal or binary form. We will illustrate this with a number 240:</div><table border="0" cellpadding="0" cellspacing="0"><tbody>
<tr> <td width="50%">.240</td> <td width="50%">decimal</td></tr>
<tr> <td width="50%">0xF0</td> <td width="50%">hexadecimal</td></tr>
<tr> <td width="50%">b'11110000'</td> <td width="50%">binary</td></tr>
</tbody></table><div align="justify">Decimal numbers start with a dot, hexadecimal with 0x, and binary start with b with the number itself under quotes '. </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.2_Assembly_language_elements"><b>3.2 Assembly language elements</b></a> </div><div align="justify">Basic elements of assembly language are: </div><ul><li> <div align="justify">Labels</div></li>
<li> <div align="justify">Instructions</div></li>
<li> <div align="justify">Operands</div></li>
<li> <div align="justify">Directives</div></li>
<li> <div align="justify">Comments</div></li>
</ul><div align="justify">Labels A <b>Label</b> is a textual designation (generally an easy-to-read word) for a line in a program, or section of a program where the micro can jump to - or even the beginning of set of lines of a program. It can also be used to execute program branching (such as Goto .......) and the program can even have a condition that must be met for the Goto instruction to be executed. It is important for a label to start with a letter of the alphabet or with an underline "_". The length of the label can be up to 32 characters. It is also important that a label starts in the first clumn.</div><div align="justify"><a href="http://lh3.ggpht.com/-7B3ZopvJ8kw/TxZeQdlz_YI/AAAAAAAAB6Y/0S1tPOJSezE/s1600-h/clip_image002%25255B4%25255D.gif"><img alt="clip_image002" border="0" height="256" src="http://lh5.ggpht.com/-tJxTb2ryLgk/TxZeR7HHn-I/AAAAAAAAB6g/1jswE2ttNRo/clip_image002_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image002" width="538" /></a></div><div align="justify">Instructions Instructions are already defined by the use of a specific microcontroller, so it only remains for us to follow the instructions for their use in assembly language. The way we write an instruction is also called instruction "syntax". In the following example, we can recognize a mistake in writing because instructions movlp and gotto do not exist for the PIC16F84 microcontroller.</div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhTkbYIwiDHengCj0ZrN5Mg83u625L0pPC5J00jUb6UILh9Xl0LG23wLvq1qNaduy5v1FyCDMvys-tWF_CHoFLbtckRGXjMcRDRvDgynuRD_kuND5nB_1zHf9lxIVtzBulso7nrzsF5L8/s1600-h/clip_image003%25255B4%25255D.gif"><img alt="clip_image003" border="0" height="372" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjupHHLSLKIlUlHP2wbQtMgBWQPo1BZGFLZsXBA4I8yS7X6TbiNO0oP4aJwzcZBirSnrBnrJ_hJrDT8JYTtQLofXNVOO5xhHCstEH_GgUM-_TLahd0ITJSwOgF09YYuamGDmsMEizkaKmk/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image003" width="556" /></a></div><div align="justify">Operands Operands are the instruction elements for the instruction is being executed. They are usually <b>registers</b> or <b>variables</b> or <b>constants</b>. </div><div align="justify"><a href="http://lh6.ggpht.com/-ks48mJbz0Oo/TxZeUoo1F4I/AAAAAAAAB64/sEcOqsvWizc/s1600-h/clip_image004%25255B4%25255D.gif"><img alt="clip_image004" border="0" height="318" src="http://lh5.ggpht.com/-wldAtO3Xzlk/TxZeVlh8RqI/AAAAAAAAB7A/MHwaN8T08FA/clip_image004_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image004" width="564" /></a></div><div align="justify">Comments <b>Comment</b> is a series of words that a programmer writes to make the program more clear and legible. It is placed after an instruction, and must start with a semicolon ";". Directives A <b>directive</b> is similar to an instruction, but unlike an instruction it is independent on the microcontroller model, and represents a characteristic of the assembly language itself. Directives are usually given purposeful meanings via variables or registers. For example, LEVEL can be a designation for a variable in RAM memory at address 0Dh. In this way, the variable at that address can be accessed via LEVEL designation. This is far easier for a programmer to understand than for him to try to remember address 0Dh contains information about LEVEL.</div><div align="justify"><a href="http://lh6.ggpht.com/-9K4CcLvjIp4/TxZeWSoSHAI/AAAAAAAAB7E/VGfXNGqo7UU/s1600-h/clip_image005%25255B4%25255D.gif"><img alt="clip_image005" border="0" height="150" src="http://lh6.ggpht.com/-FpWK4MIqk8w/TxZeYLZTFaI/AAAAAAAAB7Q/Ie5sPSJd1EY/clip_image005_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image005" width="566" /></a></div><div align="justify"><b>3.3 W<a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.3_Writing_a_sample_program">riting a sample program</a></b> </div><div align="justify">The following example illustrates a simple program written in assembly language respecting the basic rules. When writing a program, beside mandatory rules, there are also some rules that are not written down but need to be followed. One of them is to write the name of the program at the beginning, what the program does, its version, date when it was written, type of microcontroller it was written for, and the programmer's name.</div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjboIAClarG2VFX89nlEUmQUyqy3bu4JFLrCV8C3ky0nlih7Sy-WYAMslfh01KjzXJiDHrw462zfa4a7ow3bxiOb06bde6qk9Nj2h66ejFPPob2CABh3KjK1lfBd4frmz6wZvrcB5qfMRU/s1600-h/clip_image006%25255B5%25255D.gif"><img alt="clip_image006" border="0" height="497" src="http://lh3.ggpht.com/-QDyw9aKB6v8/TxZeZoJ-LcI/AAAAAAAAB7g/MBWVn62Buj4/clip_image006_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image006" width="611" /></a></div><div align="justify">Since this data isn't important for the assembly translator, it is written as <b>comments</b>. It should be noted that a comment always begins with a semicolon and it can be placed in a new row or it can follow an instruction. After the opening comment has been written, the <b>directive </b>must be included. This is shown in the example above. In order to function properly, we must define several microcontroller parameters such as: - type of oscillator, - whether watchdog timer is turned on, and - whether internal reset circuit is enabled. All this is defined by the following directive: _CONFIG _CP_OFF&_WDT_OFF&PWRTE_ON&XT_OSC When all the needed elements have been defined, we can start writing a program. First, it is necessary to determine an address from which the microcontroller starts, following a power supply start-up. This is (org 0x00). The address from which the program starts if an interrupt occurs is (org 0x04). Since this is a simple program, it will be enough to direct the microcontroller to the beginning of a program with a "<b>goto Main</b>" instruction. The instructions found in the <b>Main </b> select memory bank1 (BANK1) in order to access TRISB register, so that port B can be declared as an output (movlw 0x00, movwf TRISB). The next step is to select memory bank 0 and place status of logic one on port B (movlw 0xFF, movwf PORTB), and thus the main program is finished. We need to make another loop where the micro will be held so it doesn't "wander" if an error occurs. For that purpose, one infinite loop is made where the micro is retained while power is connected. The necessary "end" at the end of each program informs the assembly translator that no more instructions are in the program.</div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.4_Control_directives"><b>3.4 Control directives</b></a> </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.1_#DEFINE_Exchanging_text_for_another_">3.1 #DEFINE Exchanges one part of text for another</a> <b>Syntax:</b> #define<text> [<another text>] <b>Description:</b> Each time <text> appears in the program , it will be exchanged for <another text >. <b>Example:</b> #define turned_on 1 #define turned_off 0 <b>Similar directives:</b> #UNDEFINE, IFDEF,IFNDEF <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.2_INCLUDE_Include_an_additional_file_i">3.2 INCLUDE Include an additional file in a program</a> <b>Syntax:</b> #include <file_name> #include "file_name" <b>Description:</b> An application of this directive has the effect as though the entire file was copied to a place where the "include" directive was found. If the file name is in the square brackets, we are dealing with a system file, and if it is inside quotation marks, we are dealing with a user file. The directive "include" contributes to a better layout of the main program. <b>Example:</b> #include <regs.h> #include "subprog.asm" <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.3_CONSTANT_Gives_a_constant_numeric_va">3.3 CONSTANT Gives a constant numeric value to the textual designation</a> <b>Syntax:</b> Constant <name>=<value> <b>Description:</b> Each time that <name> appears in program, it will be replaced with <value>. <b>Example:</b> Constant MAXIMUM=100 Constant Length=30 <b>Similar directives:</b> SET, VARIABLE <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.4_VARIABLE_Gives_a_variable_numeric_va">3.4 VARIABLE Gives a variable numeric value to textual designation</a> <b>Syntax:</b> Variable<name>=<value> <b>Description:</b> By using this directive, textual designation changes with particular value. It differs from CONSTANT directive in that after applying the directive, the value of textual designation can be changed. <b>Example:</b> variable level=20 variable time=13 <b>Similar directives:</b> SET, CONSTANT <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.5_SET_Defining_assembler_variable">3.5 SET Defining assembler variable</a> <b>Syntax:</b> <name_variable>set<value> <b>Description:</b> To the variable <name_variable> is added expression <value>. SET directive is similar to EQU, but with SET directive name of the variable can be redefined following a definition. <b>Example:</b> level set 0 length set 12 level set 45 <b>Similar directives:</b> EQU, VARIABLE <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.6_EQU_Defining_assembler_constant">3.6 EQU Defining assembler constant</a> <b>Syntax:</b> <name_constant> equ <value> <b>Description:</b> To the name of a constant <name_constant> is added value <value> <b>Example:</b> five equ 5 six equ 6 seven equ 7 <b>Similar instructions:</b> SET <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.7_ORG_Defines_an_address_from_which_th">3.7 ORG Defines an address from which the program is stored in microcontroller memory</a> <b>Syntax:</b> <label>org<value> <b>Description:</b> This is the most frequently used directive. With the help of this directive we define where some part of a program will be start in the program memory. <b>Example:</b> Start org 0×00 movlw 0xFF movwf PORTB The first two instructions following the first 'org' directive are stored from address 00, and the other two from address 10. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.8_END_End_of_program">3.8 END End of program</a> <b>Syntax:</b> end <b>Description:</b> At the end of each program it is necessary to place 'end' directive so that assembly translator would know that there are no more instructions in the program. <b>Example:</b> . . movlw 0xFF movwf PORTB end </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.9_IF_Conditional_program_branching">3.9 IF Conditional program branching</a> <b>Syntax:</b> if<conditional_term> <b>Description:</b> If condition in <conditional_term> was met, part of the program which follows IF directive would be executed. And if it wasn't, then the part following ELSE or ENDIF directive would be executed. <b>Example:</b> if level=100 goto FILL else goto DISCHARGE endif <b>Similar directives:</b> #ELSE, ENDIF <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.10_ELSE_'IF'_alternative_to_program_bl">3.10 ELSE The alternative to 'IF' program block with conditional terms</a> <b>Syntax:</b> Else <b>Description:</b> Used with IF directive as an alternative if conditional term is incorrect. <b>Example:</b> If time< 50 goto SPEED UP else goto SLOW DOWN endif <b>Similar instructions:</b> ENDIF, IF <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.11_ENDIF_End_of_conditional_program_se">3.11 ENDIF End of conditional program section</a> <b>Syntax:</b> endif <b>Description:</b> Directive is written at the end of a conditional block to inform the assembly translator that it is the end of the conditional block <b>Example:</b> If level=100 goto LOADS else goto UNLOADS endif <b>Similar directives:</b> ELSE, IF <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.12_WHILE_Execution_of_program_section_">3.12 WHILE Execution of program section as long as condition is met</a> <b>Syntax:</b> while<condition> . endw <b>Description:</b> Program lines between WHILE and ENDW would be executed as long as condition was met. If a condition stopped being valid, program would continue executing instructions following ENDW line. Number of instructions between WHILE and ENDW can be 100 at the most, and number of executions 256. <b>Example:</b> While i<10 i=i+1 endw <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.13_ENDW_End_of_conditional_part_of_the">3.13 ENDW End of conditional part of the program</a> <b>Syntax:</b> endw <b>Description:</b> Instruction is written at the end of the conditional WHILE block, so that assembly translator would know that it is the end of the conditional block <b>Example:</b> while i<10 i=i+1 endw <b>Similar directives:</b> WHILE <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.14_IFDEF_Execution_of_a_part_of_the_pr">3.14 IFDEF Execution of a part of the program if symbol was defined</a> <b>Syntax:</b> ifdef<designation> <b>Description:</b> If designation <designation> was previously defined (most commonly by #DEFINE instruction), instructions which follow would be executed until ELSE or ENDIF directives are not would be reached. <b>Example:</b> #define test . ifdef test ;how the test was defined ......; instructions from these lines would execute endif <b>Similar directives:</b> #DEFINE, ELSE, ENDIF, IFNDEF, #UNDEFINE <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.15_IFNDEF_Execution_of_a_part_of_the_p">3.15 IFNDEF Execution of a part of the program if symbol was defined</a> <b>Syntax:</b> ifndef<designation> <b>Description:</b> If designation <designation> was not previously defined, or if its definition was erased with directive #UNDEFINE, instructions which follow would be executed until ELSE or ENDIF directives would be reached. <b>Example:</b> #define test .......... #undefine test .......... ifndef test ;how the test was undefined ..... .; instructions from these lines would execute endif <b>Similar directives:</b> #DEFINE, ELSE, ENDIF, IFDEF, #UNDEFINE </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.16_CBLOCK_Defining_a_block_for_the_nam">3.16 CBLOCK Defining a block for the named constants</a> <b>Syntax:</b> Cblock [<term>] <label>[:<increment>], <label>[:<increment>]...... endc <b>Description:</b> Directive is used to give values to named constants. Each following term receives a value greater by one than its precursor. If <increment> parameter is also given, then value given in <increment> parameter is added to the following constant. Value of <term> parameter is the starting value. If it is not given, it is considered to be zero. <b>Example:</b> Cblock 0x02 First, second, third ;first=0x02, second=0x03, third=0x04 endc cblock 0x02 first : 4, second : 2, third ;first=0x06, second=0x08, third=0x09 endc <b>Similar directives:</b> ENDC <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.17_ENDC_End_of_constant_block_definiti">3.17 ENDC End of constant block definition</a> <b>Syntax:</b> endc <b>Description:</b> Directive was used at the end of a definition of a block of constants so assembly translator could know that there are no more constants. <b>Similar directives:</b> CBLOCK <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.18_DB_Defining_one_byte_data">3.18 DB Defining one byte data</a> <b>Syntax:</b> [<label>]db <term> [, <term>,.....,<term>] <b>Description:</b> Directive reserves a byte in program memory. When there are more terms which need to be assigned a byte each, they will be assigned one after another. <b>Example:</b> db 't', 0×0f, 'e', 's', 0×12 <b>Similar instructions:</b> DE, DT <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.19_DE_Defining_the_EEPROM_memory_byte">3.19 DE Defining the EEPROM memory byte</a> <b>Syntax:</b> [<term>] de <term> [, <term>,....., <term>] <b>Description:</b> Directive is used for defining EEPROM memory byte. Even though it was first intended only for EEPROM memory, it could be used for any other location in any memory. <b>Example:</b> org H'2100' de "Version 1.0" , 0 <b>Similar instructions:</b> DB, DT <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.20_DT_Defining_the_data_table">3.20 DT Defining the data table</a> <b>Syntax:</b> [<label>] dt <term> [, <term>,........., <term>] <b>Description:</b> Directive generates RETLW series of instructions, one instruction per each term. <b>Example:</b> dt "Message", 0 dt first, second, third <b>Similar directives:</b> DB, DE </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.21__CONFIG_Setting_the_configurational">3.21 _CONFIG Setting the configurational bits</a> <b>Syntax:</b> _ _config<term> or_ _config<address>,<term> <b>Description:</b> Oscillator, watchdog timer application and internal reset circuit are defined. Before using this directive, the processor must be defined using PROCESSOR directive. <b>Example:</b> _CONFIG _CP_OFF&_WDT_OFF&_PWRTE_ON&_XT_OSC <b>Similar directives:</b> _IDLOCS, PROCESSOR <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.22_PROCESSOR_Defining_microcontroller_">3.22 PROCESSOR Defining microcontroller model</a> <b>Syntax:</b> Processor <microcontroller_type> <b>Description:</b> Instruction sets the type of microcontroller where programming is done. <b>Example:</b> processor 16F84 </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="3.5_Files_created_as_a_result_of_program"><b>3.5 Files created as a result of program translation</b></a> </div><div align="justify">As a result of the process of translating a program written in assembler language we get files like: </div><ul><li> <div align="justify">Executing file (Program_Name.HEX) </div></li>
<li> <div align="justify">Program errors file (Program_Name.ERR) </div></li>
<li> <div align="justify">List file (Program_Name.LST) </div></li>
</ul><div align="justify">The first file contains translated program which was read in microcontroller by programming. Its contents can not give any information to programmer, so it will not be considered any further. The second file contains possible errors that were made in the process of writing, and which were noticed by assembly translator during translation process. Errors can be discovered in a "list" file as well. This file is more suitable though when program is big and viewing the 'list' file takes longer. The third file is the most useful to programmer. Much information is contained in it, like information about positioning instructions and variables in memory, or error signalization. Example of 'list' file for the program in this chapter follows. At the top of each page is stated information about the file name, date when it was translated, and page number. First column contains an address in program memory where a instruction from that row is placed. Second column contains a value of any variable defined by one of the directives : SET, EQU, VARIABLE, CONSTANT or CBLOCK. Third column is reserved for the form of a translated instruction which PIC is executing. The fourth column contains assembler instructions and programmer's comments. Possible errors will appear between rows following a line in which the error occurred. </div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiOzKQv2_h2sWaeUS8_4Mg79sMLDgMA0kJajbQAOTc0Y3oHbtjzQFM5uTwiSHUwO2O89QUd3BaloaNH62q4omrMA8GSN9OWaQzRSSGTUKSDi-U1fBYJjQuhcZztf8iudHS3fU5ZYhr58o/s1600-h/clip_image007%25255B7%25255D.gif"><img alt="clip_image007" border="0" height="977" src="http://lh6.ggpht.com/-355o--AdWOY/TxZecYxKHII/AAAAAAAAB7w/c5nAfv0fPSo/clip_image007_thumb%25255B4%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image007" width="560" /></a></div><div align="justify">At the end of the "list" file there is a table of symbols used in a program. Useful element of 'list' file is a graph of memory utilization. At the very end, there is an error statistic as well as the amount of remaining program memory. </div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><b>CHAPTER 4</b> </div><div align="justify"><b>MPLAB</b> </div><div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/4_01chapter.htm#Introduction">Introduction</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/4_01chapter.htm#4.1%20Installing%20the%20program%20-MPLAB">4.1 Installing the MPLAB program package</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/4_02chapter.htm">4.2 Welcome to MPLAB</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/4_03chapter.htm">4.3 Designing a project</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/4_04chapter.htm">4.4 Designing new Assembler file</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/4_05chapter.htm">4.5 Writing a program</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/4_06chapter.htm">4.6 Toolbar icons</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/4_07chapter.htm">4.7 MPSIM simulator</a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Introduction"><b>Introduction</b></a> </div><div align="justify">MPLAB is a Windows program package that makes writing and developing a program easier. It could best be described as developing environment for a standard program language that is intended for programming a PC. Some operations which were done from the instruction line with a large number of parameters until the discovery of IDE "Integrated Development Environment" are now made easier by using the MPLAB. Still, our tastes differ, so even today some programmers prefer the standard editors and compilers from instruction line. In any case, the written program is legible, and a well documented help is also available. </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="4.1_Installing_the_program_-MPLAB"><b>4.1 Installing the program -MPLAB</b></a> </div><div align="justify"><a href="http://lh3.ggpht.com/-2Q0xFA3gHOs/TxZe5ETgBHI/AAAAAAAAB74/qJHyHW1xhWM/s1600-h/clip_image001%25255B4%25255D.jpg"><img alt="clip_image001" border="0" height="422" src="http://lh6.ggpht.com/-ARZwLoU7XOQ/TxZe6KJb1eI/AAAAAAAAB8A/inyKszZIyeU/clip_image001_thumb%25255B1%25255D.jpg?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image001" width="422" /></a></div><div align="justify">MPLAB consists of several parts:<br />
- Grouping the projects files into one project (Project Manager)<br />
- Generating and processing a program (Text Editor)<br />
- Simulator of the written program used for simulating program function on the microcontroller.<br />
Besides these, there are support systems for Microchip products such as PICStart Plus and ICD (In Circuit Debugger). As this book does not cover them , they will be mentioned as options only. <br />
Minimal hardware requirements for starting the MPLAB are:<br />
· PC compatible computer 486 or higher<br />
· Microsoft Windows 3.1x or Windows 95 and new versions of the Windows operating system<br />
· VGA graphic card<br />
· 8MB memory (32MB recommended)<br />
· 20MBs of free space on hard disk<br />
· Mouse<br />
In order to start the MPLAB we need to install it first. Installing is a process of copying MPLAB files from the CD onto a hard disc of your computer. There is an option on each new window which helps you return to a previous one, so errors should not present a problem or become a stressful experience. Installation itself works much the same as installation of most Windows programs. First you get the Welcome screen, then you can choose the options followed by installation itself, and, at the end, you get the message which says your installed program is ready to start.<br />
Steps for installing MPLAB:<br />
1. Start-up the Microsoft Windows<br />
2. Place the Microchip CD into CD ROM drive<br />
3. Click on START in the bottom left corner of the screen and choose the RUN option <br />
4. Click on BROWSE and select CD ROM drive of your computer.<br />
5. Find directory called MPLAB on your CD ROM<br />
6. Click on MPLAB v6.31.EXE and then on OK .<br />
7. Click again on OK in your RUN window<br />
Installing begins after these seven steps. The following images explain specific installation stages. At the very beginning, small blue window will appear to notify you that the installation has begun.</div><div align="justify"><a href="http://lh4.ggpht.com/-fSFEla5bVZY/TxZe6w2WZsI/AAAAAAAAB8I/RrlxhWYh8Dg/s1600-h/clip_image002%25255B4%25255D.gif"><img alt="clip_image002" border="0" height="164" src="http://lh6.ggpht.com/-YCG9uHkS3qE/TxZe8XWiMLI/AAAAAAAAB8Q/ewDCZZdC1PI/clip_image002_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image002" width="412" /></a></div><div align="justify"><b>Initializing Wise Installation Wizard</b> </div><div align="justify">The following window will warn you to close all the running applications, or preferably run this installation program from a re-boot. </div><div align="justify"><a href="http://lh3.ggpht.com/-kl53LSuUPKw/TxZe9PCcnmI/AAAAAAAAB8U/3SmVTFIodLY/s1600-h/clip_image003%25255B4%25255D.gif"><img alt="clip_image003" border="0" height="358" src="http://lh6.ggpht.com/-r9e_8hqA2EE/TxZe-I7DciI/AAAAAAAAB8g/splTbQdHe_I/clip_image003_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image003" width="462" /></a></div><div align="justify"><b>Welcome screen and an advice to re-boot prior to installation</b> </div><div align="justify">Next is Software License Agreement window. In order to proceed with the installation, read the conditions, select the option "I Agree" and click on NEXT. </div><div align="justify"><a href="http://lh3.ggpht.com/-N9TSM2eKw-w/TxZe_SsjIxI/AAAAAAAAB8k/JgQvbztwx5A/s1600-h/clip_image004%25255B4%25255D.gif"><img alt="clip_image004" border="0" height="367" src="http://lh6.ggpht.com/-DTVo8Zg2nU4/TxZfAbCiN1I/AAAAAAAAB8w/26NpL0Y8zdU/clip_image004_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image004" width="474" /></a></div><div align="justify"><b>Software License Agreement window</b> </div><div align="justify">The following window concerns the installation folder. Unless there is a specific reason for changing the default destination, you should leave it be. </div><div align="justify"><a href="http://lh5.ggpht.com/-Hr6YmpcrbM0/TxZfBUONs0I/AAAAAAAAB80/FmSmod1ZhPU/s1600-h/clip_image005%25255B6%25255D.gif"><img alt="clip_image005" border="0" height="388" src="http://lh3.ggpht.com/-9q7GLW7jU9U/TxZfCYer-mI/AAAAAAAAB9A/jxxJe0EPO7M/clip_image005_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image005" width="502" /></a></div><div align="justify"><b>Determining the destination directory for MPLAB</b> </div><div align="justify">Next option is meant for users who owned previous version(s) of MPLAB. Purpose of the option is to backup all files that will replaced during the installation of the latest version. Assuming that this is our first installation of MPLAB, you should leave NO selected and click on NEXT. </div><div align="justify"><a href="http://lh3.ggpht.com/-y_xAoikcP10/TxZfDLMUIAI/AAAAAAAAB9I/eohxQbsVYI0/s1600-h/clip_image005%25255B1%25255D%25255B3%25255D.gif"><img alt="clip_image005[1]" border="0" height="406" src="http://lh5.ggpht.com/-qKgO18bDNtc/TxZfEMy28LI/AAAAAAAAB9Q/P-5CjFGCTMo/clip_image005%25255B1%25255D_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image005[1]" width="525" /></a></div><div align="justify"><b>Option to backup old files from the previous version</b> </div><div align="justify">Installation Wizard will ask you if you want to create shortcuts to access MPLAB from the start menu. Click on NEXT to proceed with installation. </div><div align="justify"><a href="http://lh6.ggpht.com/-qEzxUzdZISg/TxZfE-qk7aI/AAAAAAAAB9Y/zTj9SWcwfOU/s1600-h/clip_image006%25255B4%25255D.gif"><img alt="clip_image006" border="0" height="421" src="http://lh5.ggpht.com/-qJSTPaxDdYc/TxZfGMUqIgI/AAAAAAAAB9g/7Ytlv1WR668/clip_image006_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image006" width="544" /></a></div><div align="justify"><b>Adding MPLAB to the Start Menu</b> </div><div align="justify">It is certainly useful to have MPLAB icon on desktop if you will be using the program frequently. We suggest clicking on Yes. Then, click on NEXT to proceed with installation. </div><div align="justify"><a href="http://lh3.ggpht.com/-9n4ZNm59XlA/TxZfG3Sxd9I/AAAAAAAAB9k/l44HQ9w_yDI/s1600-h/clip_image007%25255B4%25255D.gif"><img alt="clip_image007" border="0" height="439" src="http://lh5.ggpht.com/-jZTvoaBl_aQ/TxZfHwqLfbI/AAAAAAAAB9w/ULHGk7-ADDc/clip_image007_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image007" width="568" /></a></div><div align="justify"><b>Adding MPLAB to the Start Menu</b> </div><div align="justify">Ready to install! Click on NEXT to start copying the necessary files to your PC. </div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLvLz_U-T_ij_jzEmW_DEIJwFCDc7k5NFNpRWGbiIPWEJM0WylFhuXmhqKhyNnhIW_a75vHjeSdOtsup0fbgtkEASJsSMzBtyLEeaGwhrpebUQFT2tNX_ILmN8jLgOvNo6xf6Lraf6qUQ/s1600-h/clip_image008%25255B4%25255D.gif"><img alt="clip_image008" border="0" height="455" src="http://lh4.ggpht.com/-iZ0ewpbD9Ew/TxZfKGdNhCI/AAAAAAAAB-A/HWbSDXRxdxI/clip_image008_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image008" width="588" /></a></div><div align="justify"><b>Screen prior to installation</b> </div><div align="justify">Installation does not take long, and the installation flow can be monitored on a small window in the right corner of the screen. </div><div align="justify"><a href="http://lh5.ggpht.com/-ak1rYbGbE4s/TxZfL3y_ZXI/AAAAAAAAB-I/_0VcFSnIJH0/s1600-h/clip_image009%25255B4%25255D.gif"><img alt="clip_image009" border="0" height="217" src="http://lh6.ggpht.com/-nEcKlhY-co8/TxZfMtV13qI/AAAAAAAAB-Q/FprsyuCJ0C0/clip_image009_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image009" width="456" /></a></div><div align="justify"><b>Installation flow</b> </div><div align="justify">After installation have been completed, there are two dialog screens, one for the last minute information regarding program versions and corrections, and the other is the welcome screen. If text files (Readme.txt) have opened, they would need to be closed. </div><div align="justify"><b><a href="http://lh4.ggpht.com/-oXiRZuK4qgo/TxZfNc7UhJI/AAAAAAAAB-Y/uaS27IJKXxE/s1600-h/clip_image010%25255B4%25255D.gif"><img alt="clip_image010" border="0" height="387" src="http://lh5.ggpht.com/-SR47c2SpUDg/TxZfOtMIIHI/AAAAAAAAB-g/zdSBwtU1ozM/clip_image010_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image010" width="500" /></a></b></div><div align="justify"><b>View README files?</b> </div><div align="justify">In order to install the USB device driver for MPLAB ICD2 you need to follow the instructions that will be displayed by executing Ddicd2XP.htm in the explorer window that has been opened during this installation. The installation is automatic when the MPLAB ICD2 is connected to the USB port. The instructions are for reference. </div><div align="justify">By clicking on Finish, installation of MPLAB is finished. </div><div align="justify"><a href="http://lh5.ggpht.com/-PAASIJ0pKmU/TxZfP1xLw3I/AAAAAAAAB-o/vBgqCKEQw_4/s1600-h/clip_image011%25255B5%25255D.gif"><img alt="clip_image011" border="0" height="415" src="http://lh3.ggpht.com/-5JpRNO-ny8A/TxZfRCMEUMI/AAAAAAAAB-w/nFJZTkrC4pQ/clip_image011_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image011" width="532" /></a></div><div align="justify"><br />
</div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<b>4.2 Program package MPLAB</b> <br />
Following the installation procedure, you can launch MPLAB by double-clicking the desktop icon. As you can see, MPLAB has the familiar look of Windows programs: a drop menu (uppermost line with standard options - File, Edit..etc.), toolbar (illustrated shortcuts for common actions) and a status line below the working area. There is a rule of thumb in Windows of taking the most frequently used program options and placing them below the menu, too. Thus, we can access them more quickly and speed up the work. In other words, what you have in the toolbar you also have in the menu. <br />
<a href="http://lh5.ggpht.com/-0Hx-fzwz5sk/TxZfa8IXTEI/AAAAAAAAB-4/zkJyML1GnJ0/s1600-h/clip_image001%25255B5%25255D.gif"><img alt="clip_image001" border="0" height="415" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCLIZJVcTpEfmaKMC0494ReOhWMOHLNq9LeLnMPFHHZ4gJr3VRjXAQu8fVgrA5HoLUXH5DPuBlCFKCKFO646-1QUT6DjiybL0HNM0QQBsu0kLWA2YfNZ_EXXdNqj25TIUwyhKMiR0FRCc/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="clip_image001" width="556" /></a> <br />
<b>The screen after starting MPLAB</b><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<b>4.3 Designing a project</b> <br />
Preparing the program for loading into microcontroller can boil down to few basic steps: <br />
1. Designing a project<br />
2. Writing the program<br />
3. Converting to zero-one code comprehensible by microcontroller, i.e. compiling.<br />
<a href="http://lh5.ggpht.com/-ZsrnWxJOLyo/TxZfyNFKyUI/AAAAAAAAB_I/pcPTW0kP358/s1600-h/mplab_01%25255B4%25255D.gif"><img alt="mplab_01" border="0" height="459" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg319rGl0FsLdUYdvTW2hNCpCJHyc8SdnE27gcOljZCn5Ih5iI5wyxWmYC8r-8TtUEkeF3CCgo4EuiDxHFp89GH5gsRC4KvMs1Jv5YmmDrYcGtQufl9idcstMj1zhnzbMV1s8uFTlDI7wU/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="mplab_01" width="626" /></a><br />
<b>Opening a new project</b> <br />
To create a project, click on the option PROJECT and the click on PROJECT WIZARD, which will open the following window.. <br />
<a href="http://lh4.ggpht.com/-zGx92TxZPnQ/TxZf0Bn9KAI/AAAAAAAAB_U/9E5ixAIkXZU/s1600-h/mplab_02%25255B4%25255D.gif"><img alt="mplab_02" border="0" height="484" src="http://lh5.ggpht.com/--g3cA5CMH1I/TxZf1TLJ_tI/AAAAAAAAB_g/cPh95AQpPXE/mplab_02_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="mplab_02" width="622" /></a><br />
<b>Creating a new project</b> <br />
Click on NEXT to continue. Next thing to do is to choose the appropriate microcontroller. In our case, it is PIC16F84A. <br />
<a href="http://lh3.ggpht.com/-C1Y8p7H_2xU/TxZf2LCYhNI/AAAAAAAAB_k/iQ7FGUD8l8Y/s1600-h/mplab_03%25255B4%25255D.gif"><img alt="mplab_03" border="0" height="498" src="http://lh6.ggpht.com/-tkFyH20z0Wo/TxZf29qEfOI/AAAAAAAAB_w/VzlyrM7P_CU/mplab_03_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="mplab_03" width="641" /></a><br />
<b>Choosing the appropriate microcontroller</b> <br />
Next step is defining the program language to be used. In our case it is Assembler, so we will select that option as shown on the image below. <br />
<b><a href="http://lh3.ggpht.com/-kU1gN1vvMeE/TxZf4NmQvXI/AAAAAAAAB_0/ddBdH1ScuXI/s1600-h/mplab_04%25255B4%25255D.gif"><img alt="mplab_04" border="0" height="476" src="http://lh6.ggpht.com/-ZnJzpPjIW0o/TxZf4xh0a9I/AAAAAAAAB_8/uIlR2Q3e8WY/mplab_04_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="mplab_04" width="612" /></a></b><br />
<b>Selecting a language toolsuite</b> <br />
All that is left is to name our project. The name should reflect the purpose and content of the program. Project can be stored in any folder according to your needs. It is a good thing to have that folder remind you of PIC microcontrollers; we named the folder simply PIC in the image below. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglgByWiX793cgcmJm1LdnDTDOtHmECk3aDMQ-reOFMxA2DfUq4Gha7obBJBkhALHxCAhZcev3wSon0GYThwxUgIqUJRRY6LqokPo1n9YfT_JO72C5jk_Ny3sv0vpS73H7OVnbCPJj_w_Q/s1600-h/mplab_05%25255B4%25255D.gif"><img alt="mplab_05" border="0" height="473" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjp5hDCLqPEn8Sy-9_RUu1lRpXTGUdPjqY3x5UOIUSa_cHSUaUMT0_CoMMf2_rvwqMyxwhkJFEriEMYV2I1kOIFmNpon4nMiuh2gLAU-7X6jmEWrBJvDi5QxOTxz8JaqAkPxhyphenhyphenJsXZ17oE/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="mplab_05" width="608" /></a><br />
<b>Naming the project</b> <br />
Upon naming the project, click on NEXT to open the summary window. <br />
<a href="http://lh5.ggpht.com/-7xVm1LiXI9g/TxZf7SZtTsI/AAAAAAAACAY/aVkBcUiQvJ8/s1600-h/mplab_06%25255B5%25255D.gif"><img alt="mplab_06" border="0" height="476" src="http://lh5.ggpht.com/-IuoaCIbKxuw/TxZf8QTxSRI/AAAAAAAACAg/Yd4ABiNQXRU/mplab_06_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="mplab_06" width="609" /></a><br />
<b>Summary containing the defined parameters</b> <br />
Click on FINISH to create the project. The summary window contains the project parameters.<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div align="justify"><b>4.4 Creating a new assembler file</b> </div><div align="justify">When 'project' part of the job is done, the following screen should appear. </div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-qDQPaA7udciPHQQ68r0SwejsNfOh87jcdsb5m7Kdew9wQQQlhMOT67su0kojhsjk3XKZJbFVBp7qrzmfSikDmqnMqn5z5MiIRjZkJ-55cHMLEVluVvoPjiWD1UQve8eELvOtxcaJSI4/s1600-h/mplab_07%25255B4%25255D.gif"><img alt="mplab_07" border="0" height="431" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUzyIW7EJZcmDwMJo_ZNLWPBJHvMuCmQcTAY_rbNHYuB-qg4o_WJyt2AuGfdV9jDQHZODB8E_vDgsfVDzvEXan5eupyI4aFIWAWc-els7qu3KIYUQHEjVa4snhuiUSV0ybxMpVClb6Lzc/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="mplab_07" width="584" /></a></div><div align="justify"><b>New project opened</b> </div><div align="justify">Next step is writing the program, which requires new file to be opened. Click on FILE > NEW, opening the text window within the MPLAB working area (new window represents the file program will be written to). Upon opening the new file, it should be saved to folder C:\PIC under a name "Blink.asm", to reflect the nature of the program (example for blinking diodes on microcontroller port B). </div><div align="justify">New file, "Blink.asm" should now be included into the project. Right-click on the source file in the window "Test.msw". This will open a small window with two available options - choose the first one, "Add Files". </div><div align="justify"><a href="http://lh4.ggpht.com/-K94cnveaCQs/TxZgOOy5EcI/AAAAAAAACA0/LkN_kO7xvA4/s1600-h/mplab_08%25255B4%25255D.gif"><img alt="mplab_08" border="0" height="413" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNo_kbQhGagTrxATpBxASJJKmkb6KPVs4eYD4o2U3vvxfxtbwzIDb-zBoYHu7jCKjSMgf7IBCTVwzFG3dA4RH5fp-ZBoIH41oo8657lNK0DRAdQYLdOsIa4_pHcotCEQpW3ZA44pKurWQ/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="mplab_08" width="282" /></a></div><div align="justify"><b>Inserting</b><b> new Assembler file into project</b> </div><div align="justify">In a newly opened browse window find our PIC folder and select the file "Blink.asm", as shown on the image below. </div><div align="justify"><a href="http://lh4.ggpht.com/-N431NZ0oc8I/TxZgPhbjm8I/AAAAAAAACBI/rCMDPkRqxOc/s1600-h/mplab_09%25255B4%25255D.gif"><img alt="mplab_09" border="0" height="318" src="http://lh3.ggpht.com/-W_JvUaSH8lY/TxZgRHlkfoI/AAAAAAAACBM/SjLOXnflIb8/mplab_09_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="mplab_09" width="442" /></a></div><div align="justify"><b>Selecting the desired file</b> </div><div align="justify">The looks of the project window after the file blink.asm has been included is shown in the image below. </div><div align="justify"><a href="http://lh6.ggpht.com/-2cQZfiXyRc0/TxZgRlApA_I/AAAAAAAACBU/o1Knpb2DYZE/s1600-h/mplab_10%25255B4%25255D.gif"><img alt="mplab_10" border="0" height="390" src="http://lh4.ggpht.com/-fH-ACxJ5guE/TxZgSexUyeI/AAAAAAAACBc/ihYmHlzDuY8/mplab_10_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="mplab_10" width="266" /></a></div><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div align="justify"><b>4.5 Writing a program</b> </div><div align="justify">Only after all of the preceding operations have been completed we are able to start writing a program. This sample program is fairly simple and serves to illustrate creation of a project. </div><div align="justify"><a href="http://lh6.ggpht.com/-3JHx3kiaT6Y/TxZggB1b_rI/AAAAAAAACBo/bgg7ZVSHBvk/s1600-h/mplab_11%25255B4%25255D.gif"><img alt="mplab_11" border="0" height="485" src="http://lh3.ggpht.com/-ohJJPnCfBmU/TxZghI90mrI/AAAAAAAACBw/rxpGk3Lyh-M/mplab_11_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="mplab_11" width="483" /></a></div><div align="justify">You should re-write the program to the newly opened window or just copy/paste it from the disk. </div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNv2IV4G1Zyt-l-bJ1wEsLlOVoHAFZ5OtSFL2jfVzjryl9b5RwP06uJSPExcEOhXzPZGJNiNSoBmbXgEKRb-gMechHIsDNzY0eC_2i1LTFwwdnFjqCH408DJ9rAisj9mSPuYmekablvBw/s1600-h/mplab_12%25255B4%25255D.gif"><img alt="mplab_12" border="0" height="373" src="http://lh6.ggpht.com/-821r3ReYRNE/TxZgjkQ1WCI/AAAAAAAACCA/6KjM-eNhUIo/mplab_12_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="mplab_12" width="506" /></a></div><div align="justify"><b>Main window with blink.asm program</b> </div><div align="justify">When the program is copied to "Blink.asm" window, we can use PROJECT -> BUILD ALL command to translate the program to executable HEX form. The last sentence in the window is the most important one, because it shows whether translation was successful or not. "BUILD SUCCEEDED" is a message stating that translation was successful and that there were no errors.<br />
In case that error does show up, you need to double click on error message in 'Output' window. This will automatically take you to the assembler program, to the line where the error was encountered.</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><b>4.6 Toolbar icons</b> </div><div align="justify">The following table contains detailed description of each toolbar icon. </div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLqyOYGz4VaflINeIx0wI911pMasKGUfyigtKWkohZdR51SzfotCB3GIuz2fKAjO_yb6cF6Uzcj-9VUVTumeRODKBiPmBlqmi53H7ucMQOOoRyUK4z960vCfCoHNYn8sGvUBcEdm631mQ/s1600-h/toolbar_00%25255B3%25255D.gif"><img alt="toolbar_00" border="0" height="28" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxB2N1DU5V8hNeQ81TITMNJpKRab53Rpy4dZYINP9NZueZO4UEd9RJuvl9fje4YSX4AhkeUqtVtdDM_wBw-uz_11v7SJlhi0OgI2Fi7ZrGOqZqj_z7lLUcpTbYSZGHULHssSnwcpZ1kQs/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="toolbar_00" width="29" /></a><br />
New Assembler file. It is commonly used for including an Assembler file into existing project.</div><div align="justify"><a href="http://lh6.ggpht.com/-QKDm1Ugi9sw/TxZhBtE9dpI/AAAAAAAACCU/kXYglkwVoUg/s1600-h/toolbar_01%25255B3%25255D.gif"><img alt="toolbar_01" border="0" height="28" src="http://lh3.ggpht.com/-4oeSLi6YK3I/TxZhCa8HMpI/AAAAAAAACCc/mXv__MJlOlU/toolbar_01_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="toolbar_01" width="29" /></a><br />
Open an existing Assembler file.</div><div align="justify"><a href="http://lh3.ggpht.com/-PfBXT0KFFIw/TxZhDVHfQDI/AAAAAAAACCk/ca1ySz9zWsU/s1600-h/toolbar_02%25255B3%25255D.gif"><img alt="toolbar_02" border="0" height="28" src="http://lh5.ggpht.com/-JSmUCVvlZV4/TxZhEEwa1NI/AAAAAAAACCw/f6W11le_o1c/toolbar_02_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="toolbar_02" width="29" /></a><br />
Save program (Assembler file)</div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3Hp2vmSts3zArfvpNuERblMUlKpSdzdXSGkU661sV2r3na3s9qiniKR4f2OV3ZVXJtmDpm5aWfQJSblcBZnpiDAodISydeUqZk91OH3KDIv-3GOCNaQiRBozZVGOC_AAf505WIaEO9JA/s1600-h/toolbar_03%25255B3%25255D.gif"><img alt="toolbar_03" border="0" height="28" src="http://lh5.ggpht.com/-7lhkmNLQ8lA/TxZhG5obvSI/AAAAAAAACC8/rBdthw38irc/toolbar_03_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="toolbar_03" width="29" /></a><br />
Cut text. This and the following 3 icons are standard for all text processors. As every program code is actually a text file, these options are commonly used.</div><div align="justify"><a href="http://lh4.ggpht.com/-hyzViN8Uzhg/TxZhHmaPQ-I/AAAAAAAACDI/qumK6GQbI48/s1600-h/toolbar_04%25255B3%25255D.gif"><img alt="toolbar_04" border="0" height="28" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOGt5lL7clClsucvdU87i0dGilpQJErLiACEk5fuvbmaEBbqke6ePmoFoeC1fkaSERGPJS4vQUWUL_7ErQTC-MgidCecwpKyfxAQBNA9q7rbqCsthwe4YW94I4GRuA2ALtHp3N1HVz2VE/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="toolbar_04" width="29" /></a><br />
Copy text. Unlike the previous one, this icon leaves the selected text on screen while storing it into clipboard.</div><div align="justify"><a href="http://lh6.ggpht.com/-PHav_ZQzTyc/TxZhJqxZBfI/AAAAAAAACDU/Dy3wXDzXuws/s1600-h/toolbar_05%25255B3%25255D.gif"><img alt="toolbar_05" border="0" height="28" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLd4As4dw9pcQAGoTeQy5ByxJUojdjJQeoG3cChqZ9g5iEkkwng1h6gReQCDWhfbJg2PhIAkytV-mmlwYhL0mqL0slufkQBt6lOqDUA2-XHUY6AMH1c6Y_MqjaY_SubHlOEtGmgFp2Gm8/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="toolbar_05" width="29" /></a><br />
Paste text. When part of the text is copied or cut, it is stored to clipboard, where it can be called upon via this command.</div><div align="justify"><a href="http://lh6.ggpht.com/-LJhTmNhdRe0/TxZhK1IAJII/AAAAAAAACDo/VQu0UZLed7Y/s1600-h/toolbar_06%25255B3%25255D.gif"><img alt="toolbar_06" border="0" height="28" src="http://lh4.ggpht.com/-Plb-KgfRsHU/TxZhL36eoAI/AAAAAAAACDs/alI4P_z9iM4/toolbar_06_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="toolbar_06" width="29" /></a><br />
Print open file in which Assembler program is located.</div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjje8NK_PzGe4v06RcUx57QJTJjqmO38dFmPJdgdh8fGcXj_KW7utDcU5aSqoQf8OQMBV14nWh7PSql-j1FSUPfbOuhQl7MCfC34iiKjDKKTr84inhOmObXeqFx0a0yHPH82qR33Umabd4/s1600-h/toolbar_07%25255B3%25255D.gif"><img alt="toolbar_07" border="0" height="28" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4E7SgaGHjV3yFYGOtKKnIjjJb2jocePtX_t9LZdXHrCImAIcNTzGjGEZexm9fx6OMqfJNWs4tTvsC7L8hmVMhEhSTszYax96uruN2ZBOGcleT5JyDLMPjKPz0InKanDVyr2IwWKcCzX8/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="toolbar_07" width="29" /></a><br />
Help for the project section and the entire MPLAB.</div><div align="justify"><a href="http://lh4.ggpht.com/-fsThXG5c66Y/TxZhO8SisMI/AAAAAAAACEE/5iVhRMKX87g/s1600-h/toolbar_08%25255B3%25255D.gif"><img alt="toolbar_08" border="0" height="28" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhx624tw837t7tY8oaKIu1ylFuZTV4fEYSlaEF7RM7SqYbfECmwOCfYnOefoOiiGf7FPb6Gu1w1iS3WW-BXPSHU9wHt8Txh5RNByzw1OiFnGG_aD_oNabB29_MA7E75EmkJbSsfa1vYhw/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="toolbar_08" width="29" /></a><br />
Create a new project. This command is straightforward as it avoids the use of Wizard - just name the project and type the path line to the appropriate folder.</div><div align="justify"><a href="http://lh3.ggpht.com/-N_od-abqbOI/TxZhTYFrspI/AAAAAAAACEY/BlgGxs5MMtU/s1600-h/toolbar_09%25255B3%25255D.gif"><img alt="toolbar_09" border="0" height="28" src="http://lh5.ggpht.com/-dJhxDlVl5i0/TxZhUIUmbCI/AAAAAAAACEc/HP8KMeB4LvM/toolbar_09_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="toolbar_09" width="29" /></a><br />
Open the existing project. Project opened in this way keeps all the previous settings.</div><div align="justify"><a href="http://lh5.ggpht.com/-Hoo3DRs_0eI/TxZhU1nb-1I/AAAAAAAACEo/ynOu8LebXp8/s1600-h/toolbar_10%25255B3%25255D.gif"><img alt="toolbar_10" border="0" height="28" src="http://lh5.ggpht.com/-lzNfMYYojLI/TxZhV5And_I/AAAAAAAACEw/f2Da1fCqxXs/toolbar_10_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="toolbar_10" width="29" /></a><br />
Save Workspace. Workspace saved in this way keeps all the parameter and window settings, so that when it's loaded you get the exact look of the work area it had at the moment of saving. Save your project frequently, especially if you work with multiple windows in simulator and you have them arranged to your liking.</div><div align="justify"><a href="http://lh4.ggpht.com/-oYrWL1A6PZ4/TxZhWjaPhXI/AAAAAAAACE0/_VlTenhSMHU/s1600-h/toolbar_11%25255B3%25255D.gif"><img alt="toolbar_11" border="0" height="28" src="http://lh5.ggpht.com/-a5s65nrhAnQ/TxZhXDLSorI/AAAAAAAACE8/jSt98anouik/toolbar_11_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="toolbar_11" width="29" /></a><br />
Build options.</div><div align="justify"><a href="http://lh3.ggpht.com/-K8n-YIl_UVk/TxZhXznNyOI/AAAAAAAACFE/D3i8t0lfsdY/s1600-h/toolbar_12%25255B3%25255D.gif"><img alt="toolbar_12" border="0" height="28" src="http://lh5.ggpht.com/-XMvFvjOdLss/TxZhY46XloI/AAAAAAAACFM/WE0qP9ONFJs/toolbar_12_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="toolbar_12" width="29" /></a><br />
When eventual errors have been spotted during the simulation process, program needs to be repaired. As simulator uses HEX file as its input, program should be translated anew in order to take the changes to the simulator. This icon (Make) translates the project from the start and creates the latest version of the HEX file for the simulator.</div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFxTvpvrb2TG1CNAegXOW3u0jKV2aZsxyL2FYEksy67Iu1hYOqlKjryNvFiG8s90ce8U7LC41PfPWivcAu8Cc7GM24qu-L0BInjMhW5AQdrxA4JkmergSmxpH27FlQ_9AXevZ1Z4ywTnw/s1600-h/toolbar_13%25255B3%25255D.gif"><img alt="toolbar_13" border="0" height="28" src="http://lh5.ggpht.com/--4z2fCU9WCw/TxZhaLCiBRI/AAAAAAAACFc/JPIJfwc333Y/toolbar_13_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="toolbar_13" width="29" /></a><br />
Similar to the previous icon, except that the whole project is translated and not just the Assembler file whose code has been changed.</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><b>4.7 MPSIM Simulator</b> </div><div align="justify">Simulator is part of the MPLAB environment which provides a better insight into the workings of a microcontroller. Through a simulator, we can monitor current variable values, register values and status of port pins. Truthfully, simulator does not have the same value in all programs. If a program is simple (like the one given here as an example), simulation is not of great importance because setting port B pins to logic one is not a difficult task. However, simulator can be of great help with more complicated programs which include timers, different conditions where something happens and other similar requirements (especially with mathematical operations). Simulation, as the name indicates "simulates the work of a microcontroller". As microcontroller executes instructions one by one, simulator is conceived - programmer moves through a program step-by-step (line-by-line) and follows what goes on with data within the microcontroller. When writing is completed, it is a good trait for a programmer to first test his program in a simulator, and then run it in a real situation. Unfortunately, as with many other good habits, man tends to avoid this one too, more or less. Reasons for this are partly personality, and partly a lack of good simulators. </div><div align="justify"><a href="http://lh6.ggpht.com/-5wlGmnS0oik/TxZlDkvBTtI/AAAAAAAACFo/PkVJzA5d4xU/s1600-h/sim_00%25255B4%25255D.gif"><img alt="sim_00" border="0" height="248" src="http://lh4.ggpht.com/-P-MZ25XEoSw/TxZlEeFMBsI/AAAAAAAACFw/yzOGFitFAyA/sim_00_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="sim_00" width="425" /></a></div><div align="justify"><b>Starting the program simulation</b> </div><div align="justify">Simulator is activated by clicking on DEBUGGER > SELECT TOOL > MPLAB SIM, as shown in the image above. Four new icons appear to the right. They are related to simulator only, and have the following meaning: </div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNpEK3UDkodpwstgR6eZVLbOylKml2JHfO7pGbb9O9KM9I1fmxP7BiBCKfaCzi4yv2LDvkj_ZQmbQ02K2QYCearJ6bmDf0lveIk2LQF9plR_jsIyaojZknxCQ99s3tn7S9JRssgVjOR8s/s1600-h/sim_01%25255B3%25255D.gif"><img alt="sim_01" border="0" height="28" src="http://lh6.ggpht.com/-gIfUTWISmQo/TxZlF3vEv9I/AAAAAAAACF8/KHXw3FZ9ETs/sim_01_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="sim_01" width="29" /></a><br />
Start the program execution at full speed. When started, simulator executes the program until "paused" by the icon below (just as with cassette or CD player).</div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiS1b6xZ7xfeLZqSyRZon-aMtSIS-LkjX-JGh0KAKt_2y65xC1qY1pf8ETsZ-G3sbEErg1gtn1Dsz2xUVEYv20Z2gJFkJP6OgSTSYBM6nvTD_OjUXBVQVJFgcBM61jDNDtwROTlQ_5ljLA/s1600-h/sim_02%25255B3%25255D.gif"><img alt="sim_02" border="0" height="28" src="http://lh6.ggpht.com/-VQxqp25kz3c/TxZlIQKuUvI/AAAAAAAACGQ/uMPnre-5ky4/sim_02_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="sim_02" width="29" /></a><br />
Stops full-speed program execution. After this icon has been clicked, program execution may be continued step-by-step or at full-speed.</div><div align="justify"><a href="http://lh5.ggpht.com/-CD9e5_ZyS3k/TxZlJFU6GEI/AAAAAAAACGU/ZpPG4im3Z7Y/s1600-h/sim_03%25255B3%25255D.gif"><img alt="sim_03" border="0" height="28" src="http://lh5.ggpht.com/-IxV1H1Pit9Q/TxZlKxoDqmI/AAAAAAAACGg/8EZzULb9wbE/sim_03_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="sim_03" width="29" /></a><br />
Step Into icon. Step-by-step program execution. Clicking on this icon executes the succeeding program line. It enters the macros and subroutines.</div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9-YTW_x-66ZkgRRIRJvZHlZnQZ4P4ZVCa_F9Q-HCQL34zrrPsiyRh2FZmCZf4mK-rCvet_HLEmABF16XlaiFjHbHCVRrgMEs5h3IFNzq8szcmB_lxQ71CpxJ5Y8KPqt4BbfRXTZJaEcU/s1600-h/sim_04%25255B3%25255D.gif"><img alt="sim_04" border="0" height="28" src="http://lh3.ggpht.com/-MYyOjryyoyo/TxZlMDqYTCI/AAAAAAAACGs/Xiu-gpAYAFI/sim_04_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="sim_04" width="29" /></a><br />
Same as the previous icon, except it does not enter the macros and subroutines.</div><div align="justify"><a href="http://lh6.ggpht.com/--gjDtYsN6_4/TxZlNHhD30I/AAAAAAAACG4/3mLl41Y2EZs/s1600-h/sim_05%25255B3%25255D.gif"><img alt="sim_05" border="0" height="28" src="http://lh3.ggpht.com/-s0qeQuGtk_8/TxZlONcU_TI/AAAAAAAACHE/xtxeJD3Ww4A/sim_05_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="sim_05" width="29" /></a><br />
Resets the microcontroller. Clicking on this icon positions the program counter to the beginning of program and simulation may begin.</div><div align="justify">First thing we need to do, as in a real situation, is to reset a microcontroller with DEBUGGER > RESET command or by clicking on the reset icon. This command results in green marker line positioned at the beginning of the program, and program counter PCL is positioned at zero which can also be seen in <i>Special Functions Registers</i> window. </div><div align="justify"><a href="http://lh5.ggpht.com/-21LnEV7LOWo/TxZlPcpNY8I/AAAAAAAACHI/EgX58HNGE50/s1600-h/sim_06%25255B4%25255D.gif"><img alt="sim_06" border="0" height="400" src="http://lh4.ggpht.com/-47DuGYZw8nY/TxZlQL-d_iI/AAAAAAAACHQ/JZ10bc88kIQ/sim_06_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="sim_06" width="300" /></a></div><div align="justify">One of the main simulator features is the ability to view register status within a microcontroller. These registers are also called special function registers, or SFR registers. We can get a window with SFR registers by clicking on VIEW > SPECIAL FUNCTION REGISTERS.<br />
Beside SFR registers, it is useful to have an insight into file registers. Window with file registers can be opened by clicking on VIEW > FILE REGISTERS.</div><div align="justify">If there are variables in the program, it is good to monitor them, too. Each variable is assigned one window (<i>Watch Windows</i>) by clicking on VIEW > WATCH. </div><div align="justify"><a href="http://lh5.ggpht.com/-gRYUeSjM7rE/TxZlRFhiTgI/AAAAAAAACHc/JrtjF_Y_UUo/s1600-h/sim_07%25255B5%25255D.gif"><img alt="sim_07" border="0" height="504" src="http://lh3.ggpht.com/-5hGjG_UhzI4/TxZlSRZfA6I/AAAAAAAACHk/Qcdep4B9bIU/sim_07_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="sim_07" width="680" /></a></div><div align="justify"><b>Simulator with open <i>SFR registers</i> and <i>File registers</i> windows</b> </div><div align="justify">When all the variables and registers of interest are placed on the simulator working area, simulation may begin. Next command can be either <i>Step Into</i> or <i>Step Over</i>, as we may want to go into subroutines or not. Same commands can be issued via keyboard, by clicking F7 or F8. </div><div align="justify">In the SFR registers window, we can observe how register W receives value 0xFF and delivers it to port B. </div><div align="justify">By clicking on F7 key again, we don't achieve anything because program has arrived to an "infinite loop". Infinite loop is a term we will meet often. It represents a loop from which a microcontroller cannot get out until interrupt takes place (if it is used in a program), or until a microcontroller is reset. </div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><b>CHAPTER 5</b> <br />
<b>Macros and subprograms</b> <br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_chapter.htm#Introduction">Introduction</a> <br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_chapter.htm#Macros">5.1 Macros</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_chapter.htm#Subprograms">5.2 Subprograms</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_chapter.htm#Macros%20used%20in%20examples">5.3 Macros used in the examples</a> <br />
<b><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Introduction">Introduction</a></b> <br />
Same or similar sequence of instructions is frequently used during programming. Assembly language is very demanding. Programmer is required to take care of every single detail when writing a program, because just one incorrect instruction or label can bring about wrong results or make the program doesn't work at all. Solution to this problem is to use already tested program parts repeatedly. For this kind of programming logic, macros and subprograms are used. <br />
<b><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Macros">5.1 Macros</a></b> <br />
Macro is defined with directive <b>macro </b>containing the name of macro and parameters if needed. In program, definition of macro has to be placed before the instruction line where macro is called upon. When during program execution macro is encountered, it is replaced with an appropriate set of instructions stated in the macro's definition. <br />
macro_name <br />
<b>macro</b> par1, par2,.. <br />
set of instructions <br />
set of instructions <br />
<b>endm</b> <br />
The simplest use of macro could be naming a set of repetitive instructions to avoid errors during retyping. As an example, we could use a macro for selecting a bank of SFR registers or for a global permission of interrupts. It is much easier to have a macro BANK1 in a program than having to memorize which status bit defines the mentioned bank. This is illustrated below: banks 0 and 1 are selected by setting or clearing bit 5 (RP0) of status register, while interrupts are enabled by bit 7 of INTCON register. First two macros are used for selecting a bank, while other two enable and disable interrupts. <br />
bank0<br />
<b>macro</b><br />
; Macro bank0 <br />
bcf STATUS, RP0<br />
; Reset RP0 bit = Bank0 <br />
<b>endm</b><br />
; End of macro <br />
bank1<br />
<b>macro</b><br />
; Macro bank1 <br />
bsf STATUS, RP0<br />
; Set RP0 bit = Bank1 <br />
<b>endm</b><br />
; End of macro <br />
enableint<br />
<b>macro</b><br />
; Interrupts are globally enabled <br />
bsf INTCON, 7<br />
; Set the bit <br />
<b>endm</b><br />
; End of macro <br />
disableint<br />
<b>macro</b><br />
; Interrupts are globally disabled <br />
bcf INTCON, 7<br />
; Reset the bit <br />
<b>endm</b><br />
; End of macro <br />
These macros are to be saved in a special file with extension INC (abbrev. for INCLUDE file). The following image shows the file bank.inc which contains two macros, bank0 and bank1. <br />
<br />
<i>Macros Bank0 and Bank1 are given for illustrational purposes more than practical, since directive <b>BANKSEL NameSFR</b> does the same job. Just write BANKSEL TRISB and the bank containing the TRISB register will be selected.</i> <br />
<a href="http://lh5.ggpht.com/-ZkzkeIXbFH8/TxZl2lV0k8I/AAAAAAAACHs/9DSr32e33gU/s1600-h/bank_inc%25255B4%25255D.gif"><img alt="bank_inc" border="0" height="458" src="http://lh4.ggpht.com/-SEmTf1CNj-Q/TxZl3QfgpFI/AAAAAAAACH0/6Kq3ehRANGg/bank_inc_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="bank_inc" width="604" /></a> <br />
As can be seen above, first four macros do not have parameters. However, parameters can be used if needed. This will be illustrated with the following macros, used for changing direction of pins on ports. Pin is designated as input if the appropriate bit is set (with the position matching the appropriate pin of TRISB register, bank1) , otherwise it's output. <br />
input<br />
<b>macro</b> par1, par2<br />
; Macro input <br />
bank1<br />
; In order to access TRIS registers <br />
bsf par1, par2<br />
; Set the given bit - 1 = input <br />
bank0<br />
; Macro for selecting bank0 <br />
<b>endm</b><br />
; End of macro <br />
output<br />
<b>macro</b> par1, par2<br />
; Macro output <br />
bank1<br />
; In order to access TRIS registers <br />
bcf par1, par2<br />
; Reset the given bit - 0 = output <br />
bank0<br />
; Macro for selecting bank0 <br />
<b>endm</b><br />
; End of macro <br />
Macro with parameters can be called upon in following way: <br />
<b>output TRISB, 7</b> ; pin RB7 is output <br />
When calling macro first parameter TRISB takes place of the first parameter, <i>par1</i>, in macro's definition. Parameter 7 takes place of parameter par2, thus generating the following code: <br />
output<br />
TRISB, 7<br />
; Macro output <br />
<b>bsf</b> STATUS, RP0<br />
; Set RP0 bit = BANK1 <br />
<b>bcf</b> TRISB, 7<br />
; Designate RB7 as output <br />
<b>bcf</b> STATUS, RP0<br />
; Reset RP0 bit = BANK0 <br />
<b>endm</b><br />
; End of macro <br />
Apparently, programs that use macros are much more legible and flexible. Main drawback of macros is the amount of memory used - every time macro name is encountered in the program, the appropriate code from the definition is inserted. This doesn't necessarily have to be a problem, but be warned if you plan to use sizeable macros frequently in your program. <br />
In case that macro uses labels, they have to be defined as local using the directive <b>local</b>. As an example, below is the macro for calling certain function if <i>carry</i> bit in STATUS register is set. If this is not the case, next instruction in order is executed. <br />
callc<br />
<b>macro</b> label<br />
; Macro callc <br />
<i>local</i><br />
Exit<br />
; Defining local label within macro <br />
<b>bnc</b> Exit<br />
; If C=0 jump to Exit and exit macro <br />
<b>call</b> label<br />
; If C=1 call subprogram at the <br />
; address label outside macro <br />
Exit<br />
; Local label within macro <br />
<b>endm</b><br />
; End of macro <br />
<b><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Subprograms">5.2 Subprograms</a></b> <br />
Subprogram represents a set of instructions beginning with a label and ending with the instruction <i>return</i> or <i>retlw</i>. Its main advantage over macro is that this set of instructions is placed in only one location of program memory. These will be executed every time instruction <i>call subprogram_name</i> is encountered in program. Upon reaching <i>return </i>instruction<i>,</i> program execution continues at the line succeeding the one subprogram was called from. Definition of subprogram can be located anywhere in the program, regardless of the lines in which it is called. <br />
Label<br />
; subprogram is called with "call Label" <br />
set of instructions <br />
set of instructions <br />
set of instructions <br />
<b>return</b> or <b>retlw</b> <br />
With macros, use of input and output parameters is very significant. With subprograms, it is not possible to define parameters within the subprogram as can be done with macros. Still, subprogram <i>can</i> use predefined variables from the main program as its parameters. <br />
Common course of events would be: defining variables, calling the subprogram that uses them, and then reading the variables which may have been changed by the subprogram. <br />
The following example, <i>addition.asm</i> adds two variables, PAR1 and PAR2, and stores the result to variable RES. As 2-byte variables are in question, lower and higher byte has to be defined for each of these. The program itself is quite simple; it first adds lower bytes of variables PAR1 and PAR2, then it adds higher bytes. If two lower bytes total exceeds 255 (maximum for a byte) carry is added to variable RESH. <br />
<br />
<i>Basic difference between macro and subprogram is that the macro stands for its definition code (sparing the programmer from additional typing) and can have its own parameters while subprogram saves memory, but cannot have its own parameters.</i> <br />
<a href="http://lh4.ggpht.com/-ZFwLT4u0Gto/TxZl45XaK_I/AAAAAAAACH8/2J0EBq0bgbo/s1600-h/addition%25255B5%25255D.gif"><img alt="addition" border="0" height="874" src="http://lh6.ggpht.com/-8c9e8MsvFkc/TxZl6SpCYyI/AAAAAAAACIE/WzqWIDGq3o4/addition_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="addition" width="618" /></a> <br />
<b><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Macros used in examples">5.3 Macros used in the examples</a></b> <br />
Examples given in chapter 6 frequently use macros <i>ifbit</i>, <i>ifnotbit</i>, <i>digbyte</i>, and <i>pausems</i>, so these will be explained in detail. The most important thing is to comprehend the function of the following macros and the way to use them, without unnecessary bothering with the algorithms itself. All macros are included in the file <i>mikroel84.inc</i> for easier reference. <br />
<b>5.3.1 Jump to label if bit is set</b> <br />
ifbit<br />
<b>macro</b> par1, par2, par3 <br />
<b>btfsc</b> par1, par2 <br />
<b>goto</b> par3 <br />
<b>endm</b> <br />
Macro is called with : ifbit Register, bit, label <br />
<b>5.3.2 Jump to label if bit is cleared</b> <br />
ifnotbit<br />
<b>macro</b> par1, par2, par3 <br />
<b>btfs</b><b>s</b> par1, par2 <br />
<b>goto</b> par3 <br />
<b>endm</b> <br />
Macro is called with : ifnotbit Register, bit, label <br />
Next example shows how to use a macro. Pin 0 on port A is checked and if set, program jumps to label <i>ledoff</i>, otherwise macro <i>ifnotbit</i> executes, directing the program to label <i>ledon</i>. <br />
<a href="http://lh4.ggpht.com/--KmLVKzWk9o/TxZl7WpwqhI/AAAAAAAACII/-snR5F71dAc/s1600-h/macrotest%25255B4%25255D.gif"><img alt="macrotest" border="0" height="487" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWHzv3EhaSCgLxhnsIzuyR2S5_EWcLXVnGDNWKYdVD59IlIJo6PNqlAbVqBJ4beLhTa1NL4JH5qJYD5YSsPakHwE-qdBp7LA1JdKn07jn7uUPGTOYMo5BIGN8MNYFII6MjvRmXEEbIajM/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="macrotest" width="623" /></a> <br />
<b>5.3.3 Extracting ones, tens and hundreds from variable</b> <br />
Typical use for this macro is displaying variables on LCD or 7seg display. <br />
digbyte<br />
<b>macro</b> par0 <br />
<i>local</i> Pon0 <br />
<i>local</i> Exit1 <br />
<i>local</i> Exit2 <br />
<i>local</i> Positive <br />
<i>local</i> Negative <br />
<b>clrf</b> Dig1 <br />
<b>clrf</b> Dig2 <br />
<b>clrf</b> Dig3 <br />
Positive <br />
<b>movf</b> par0, w <br />
<b>movwf</b> Digtemp <br />
<b>movlw</b> .100 <br />
Pon0<br />
<b>incf</b> Dig1<br />
;computing hundreds digit <br />
<b>subwf</b> Digtemp <br />
<b>btfsc</b> STATUS, C <br />
<b>goto</b> Pon0 <br />
<b>decf</b> Dig1, w <br />
<b>addwf</b> Digtemp, f <br />
Exit1<br />
<b>movlw</b> .10<br />
;computing tens digit <br />
<b>incf</b> Dig2, f <br />
<b>subwf</b> Digtemp, f <br />
<b>btfsc</b> STATUS, C <br />
<b>goto</b> Exit1 <br />
<b>decf</b> Dig2, f <br />
<b>addwf</b> Digtemp, f <br />
Exit2<br />
<b>movf</b> Digtemp, w<br />
;computing ones digit <br />
<b>movwf</b> Dig3 <br />
<b>endm</b> <br />
Macro is called with : <br />
<b> movlw</b> .156<br />
; w = 156 <br />
<b> movwf</b> RES<br />
; RES = w <br />
<b> digbyte</b> RES<br />
; now Dec1<-1, Dec2<-5, Dec3<-6 <br />
The following example shows how to use macro <i>digbyte</i> in program. At the beginning, we have to define variables for storing the result, <i>Dig1</i>, <i>Dig2</i>, <i>Dig3</i>, as well as auxiliary variable <i>Digtemp</i>. <br />
<a href="http://lh5.ggpht.com/-aFD2GpYePpk/TxZl9ZNNXxI/AAAAAAAACIc/xFDmE1Lqrds/s1600-h/extract%25255B5%25255D.gif"><img alt="extract" border="0" height="619" src="http://lh4.ggpht.com/-Lg10UZSbRrc/TxZl-cIQmYI/AAAAAAAACIk/Gi0CTmWUulw/extract_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="extract" width="632" /></a> <br />
<b>5.3.4 Generating pause in miliseconds (1~65535ms)</b> <br />
Purpose of this macro is to provide exact time delays in program. <br />
pausems<br />
<b>macro</b> par1 <br />
<i> local</i><br />
Loop1 <br />
<i> local</i><br />
dechi <br />
<i> local</i><br />
Delay1ms <br />
<i> local</i><br />
Loop2 <br />
<i> local</i><br />
End <br />
<b>movlw</b> high par1<br />
; Higher byte of parameter 1 goes to HIcnt <br />
<b>movwf</b> HIcnt <br />
<b>movlw</b> low par1<br />
; Lower byte of parameter 1 goes to LOcnt <br />
<b>movwf</b> LOcnt <br />
Loop1 <br />
<b>movf</b> LOcnt, f<br />
; Decrease HIcnt and LOcnt necessary <br />
<b>btfsc</b> STATUS, Z<br />
; number of times and call subprogram Delay1ms <br />
<b>goto</b> dechi <br />
<b>call</b> Delay1ms <br />
<b>decf</b> LOcnt, f <br />
<b>goto</b> Loop1 <br />
dechi <br />
<b>movf</b> HIcnt, f <br />
<b>btfsc</b> STATUS, Z <br />
<b>goto</b> End <br />
<b>call</b> Delay1ms <br />
<b>decf</b> HIcnt, f <br />
<b>decf</b> LOcnt, f <br />
<b>goto</b> Loop1 <br />
Delay1ms:<br />
; Delay1ms produces a one milisecond delay <br />
<b>movlw</b> .100<br />
; 100*10us=1ms <br />
<b>movwf</b> LOOPcnt<br />
; LOOPcnt<-100 <br />
Loop2: <br />
<b>nop</b> <br />
<b>nop</b> <br />
<b>nop</b> <br />
<b>nop</b> <br />
<b>nop</b> <br />
<b>nop</b> <br />
<b>nop</b> <br />
<b>decfsz</b> LOOPcnt, f <br />
<b>goto</b> Loop2<br />
; Time period necessary to execute loop Loop2 <br />
<b>return</b><br />
; equals 10us <br />
End <br />
<b>endm</b> <br />
This macro is written for an 4MHz oscillator. For instance, with 8MHz oscillator, pause will be halved. It has very wide range of applications, from simple code such as blinking diodes to highly complicated programs that demand accurate timing. Following example demonstrates use of macro <i>pausems</i> in a program. At the beginning of the program we have to define auxiliary variables <i>HIcnt</i>, <i>LOcnt</i>, and <i>LOPcnt</i>. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_lyyMa8ztmF_nU1jWJkSp1Ku3PyNDQaPWGpj2YkmN1rHXSZwnoUHFG72Nks2SVh2_KVI7CzgG049tB_JwkIJ4ACTYaGf07PwBVBdMOhkvHRq6syGiA9vICbvMEy-Kc9SO0wM3NWz1joE/s1600-h/ledblink%25255B6%25255D.gif"><img alt="ledblink" border="0" height="664" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitrgXdYofUxzx5xEFn3aipPI5MKguQXf3jQJtr24lmsKmJX42OnR50Ze1Z8HZ8muRkiwlrga1DLs90iSeSuuawEdS7a2059hpRHGGHo12-ks7V-Etct92Y3KPfWHqBBzSnzRxTshzYwq4/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="ledblink" width="618" /></a> <br />
<div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><b>CHAPTER 6</b> </div><div align="justify"><b>Examples for subsystems within microcontroller</b> </div><div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/6_chapter.htm#Introduction">Introduction</a> </div><div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/6_chapter.htm#6.1%20Writing%20to%20and%20reading%20from%20EEPROM">6.1 Writing to and reading from EEPROM</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/6_chapter.htm#6.2%20Processing%20interrupt%20caused%20by%20changes%20on%20pins%20RB4-RB7">6.2 Processing interrupt caused by changes on pins RB4-RB7</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/6_chapter.htm#6.3%20Processing%20interrupt%20caused%20by%20change%20on%20pin%20RB0">6.3 Processing interrupt caused by change on pin RB0</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/6_chapter.htm#6.4%20Processing%20interrupt%20caused%20by%20overflow%20on%20timer%20TMR0">6.4 Processing interrupt caused by overflow on timer TMR0</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/6_chapter.htm#6.5%20Processing%20interrupt%20caused%20by%20overflow%20on%20TMR0%20connected%20to%20external%20input%20%28TOCKI%29">6.5 Processing interrupt caused by overflow on TMR0 connected to external input (TOCKI)</a></div><div align="justify"><b><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Introduction">Introduction</a></b> </div><div align="justify">Every microcontroller comprises a number of subsystems allowing for flexibility and wide range of applications. These include internal EEPROM memory, AD converters, serial or other form of communication, timers, interrupts, etc. Two most commonly utilized elements are interrupts and timers. One of these or several in combination can create a basis for useful and practical programs. </div><div align="justify"><b><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="6.1 Writing to and reading from EEPROM">6.1 Writing to and reading from EEPROM</a></b> </div><div align="justify">Program "eeprom.asm" uses EEPROM memory for storing certain microcontroller parameters. Transfer of data between RAM and EEPROM has two steps - calling macros <i>eewrite</i> and <i>eeread</i>. Macro <i>eewrite</i> writes certain variable to a given address, while <i>eeread</i> reads the given address of EEPROM and stores the value to a variable. </div><div align="justify">Macro <i>eewrite</i> writes the address to EEADR register and the variable to EEDATA register. It then calls the subprogram which executes the standard procedure for initialization of writing data (setting WREN bit in EECON1 register and writing control bytes 0x55 and 0xAA to EECON2). </div><div align="justify"><a href="http://lh6.ggpht.com/-d1PugfR_8sM/TxZoXY8qVLI/AAAAAAAACI8/R4b3YdfCdvo/s1600-h/eeprom_inc%25255B5%25255D.gif"><img alt="eeprom_inc" border="0" height="553" src="http://lh6.ggpht.com/-n7soB1sVuHw/TxZoYT4O_FI/AAAAAAAACJE/iJtSAhYjpG8/eeprom_inc_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="eeprom_inc" width="610" /></a></div><div align="justify">For data to be actually stored in EEPROM, 10ms delay is necessary. This is achieved by using macro <i>pausems</i>. In case that this pause is unacceptable for any reason, problem can be solved by using an interrupt for signaling that data is written to EEPROM. </div><div align="justify">eewrite<br />
<b>macro</b> addr, var</div><div align="justify"><b>addr</b><br />
Destination address. With PIC16F84, there are 68 bytes </div><div align="justify">of EEPROM for a total address range of 0x00 - 0x44. </div><div align="justify"><b>var</b><br />
Name of the variable to be stored to EPROM</div><div align="justify">eeread<br />
<b>macro</b> addr, var</div><div align="justify"><b>addr</b><br />
Destination address. With PIC16F84, there are 68 bytes</div><div align="justify">of EEPROM for a total address range of 0x00 - 0x44. </div><div align="justify"><b>var</b><br />
Name of the variable into which data read from EPROM will be stored.</div><div align="justify">Example: Variable <i>volume</i>, which is set via buttons RA0 and RA1, will be stored to the address 0 of EEPROM. After reboot, when the program is started, it first loads the last known value of variable <i>volume</i> from EEPROM. </div><div align="justify"><a href="http://lh6.ggpht.com/-hisHKqjcyBo/TxZoZCTb__I/AAAAAAAACJI/p-70JxSTpV0/s1600-h/eeprom_asm%25255B6%25255D.gif"><img alt="eeprom_asm" border="0" height="1013" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJmT0vgN2TMUXBxwW43cE6OMoUMJyB31j0HtILSGl7wA1daH2YHNBdkQFS8qTYLznw7AilJRkLhyphenhyphenrhNPw5cQL4ZV9zU3qhsCxDGQhyphenhyphensUOC9-RyuLg0KvnircqMzkczwEm8KfR1DBDuuSA/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="eeprom_asm" width="640" /></a></div><div align="justify"><b><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="6.2 Processing interrupt caused by changes on pins RB4-RB7">6.2 Processing interrupt caused by changes on pins RB4-RB7</a></b> </div><div align="justify">Program "intportb.asm" illustrates how interrupt can be employed for indicating changes on pins RB4-RB7. Upon pushing any of the buttons, program enters the interrupt routine and determines which pin caused an interrupt. This program could be utilized in systems with battery power supply, where power consumption plays an important role. It is useful to set microcontroller to low consumption mode with a <i>sleep</i> instruction. Microcontroller is practically on stand-by, saving energy until the occurrence of interrupt. </div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsxz-QW_t-M2k8QImrnIF2mZkiNB76QeLEtIVGPLTyk6mHXacCIGcUtiDDPhkPogVPwhEB27LAS-pGv8iAZ41YIqZbuLLSvgWIg1EHULeiT_pkIhpjSokLJ3eylWslXVQObO2HecAm9JE/s1600-h/int_62%25255B5%25255D.gif"><img alt="int_62" border="0" height="426" src="http://lh3.ggpht.com/-NhuDGTDvs-0/TxZodJkkjqI/AAAAAAAACJk/2tApEY_8KD8/int_62_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="int_62" width="631" /></a></div><div align="justify"><b>Example of processing interrupt caused by changes on pins RB4-RB7</b> </div><div align="justify"><a href="http://lh6.ggpht.com/-VfEbplNv35c/TxZoeSr2UJI/AAAAAAAACJs/PhQns7i4QpA/s1600-h/intportb_asm%25255B5%25255D.gif"><img alt="intportb_asm" border="0" height="954" src="http://lh3.ggpht.com/-Lq0QCRsS-b8/TxZofn3OJcI/AAAAAAAACJ0/xRhLNeT8xPk/intportb_asm_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="intportb_asm" width="617" /></a></div><div align="justify"><b><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="6.3 Processing interrupt caused by change on pin RB0">6.3 Processing interrupt caused by change on pin RB0</a></b> </div><div align="justify">Example "intrb0.asm" demonstrates use of interrupt RB0/INT. Upon falling edge of the impulse coming to RB0/INT pin, program jumps to subprogram for processing interrupt. This routine then performs a certain operation, in our case it blinks the LED diode on PORTB, 7. </div><div align="justify"><a href="http://lh4.ggpht.com/-gsCE-UBSk60/TxZogaBg7xI/AAAAAAAACJ8/zesYN6B1R4o/s1600-h/int_63%25255B4%25255D.gif"><img alt="int_63" border="0" height="364" src="http://lh5.ggpht.com/-lJFCHHabPaM/TxZoh7TXvAI/AAAAAAAACKE/R35Wr4bIll8/int_63_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="int_63" width="629" /></a></div><div align="justify"><b>Example of processing interrupt caused by changes on pin RB0</b> </div><div align="justify"><a href="http://lh4.ggpht.com/-oiM2fdi5rpc/TxZoimSzU8I/AAAAAAAACKM/Hfhf4dDzl_w/s1600-h/intrb0_asm%25255B5%25255D.gif"><img alt="intrb0_asm" border="0" height="780" src="http://lh5.ggpht.com/-fapBE0EZH48/TxZoj0PPhQI/AAAAAAAACKU/UeYkxb8KmaE/intrb0_asm_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="intrb0_asm" width="633" /></a></div><div align="justify"><b><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="6.4 Processing interrupt caused by overflow on timer TMR0">6.4 Processing interrupt caused by overflow on timer TMR0</a></b> </div><div align="justify">Program "inttmr0.asm" illustrates how interrupt TMR0 can be employed for generating specific periods of time. Diodes on port B are switched on and off alternately every second. Interrupt is generated every 5.088ms; in interrupt routine variable <i>cnt</i> is incremented to the cap of 196, thus generating approx. 1 second pause (5.088ms*196 is actually 0.99248s). Pay attention to initialization of OPTION register which enables this mode of work for timer TMR0. </div><div align="justify"><a href="http://lh4.ggpht.com/-1WhAHIoq6O4/TxZokihDREI/AAAAAAAACKY/97x-1e0fTtM/s1600-h/int_64%25255B5%25255D.gif"><img alt="int_64" border="0" height="650" src="http://lh6.ggpht.com/-ZD6KRV88VXY/TxZoln4JB7I/AAAAAAAACKk/Qb-EAhmAclY/int_64_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="int_64" width="640" /></a></div><div align="justify"><b>Example of processing interrupt caused by overflow on timer TMR0</b> </div><div align="justify"><a href="http://lh6.ggpht.com/-X5o9hRWSvYk/TxZomhKZsgI/AAAAAAAACKs/XwR2vKShFS0/s1600-h/inttmr0_asm%25255B5%25255D.gif"><img alt="inttmr0_asm" border="0" height="847" src="http://lh3.ggpht.com/-Vd80xkg1cpM/TxZooPL0WiI/AAAAAAAACK0/l8tqUzdhyEs/inttmr0_asm_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="inttmr0_asm" width="542" /></a></div><div align="justify"><a href="http://lh6.ggpht.com/-lxNR3saYBeA/TxZoouHZveI/AAAAAAAACK4/_uR3uELdL5I/s1600-h/inttmr0_graph%25255B5%25255D.gif"><img alt="inttmr0_graph" border="0" height="450" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVfNYRjSReGsSilDrJGzZaxCK-M1V6hGasSN4r4mxjomDvzOzecUZOfdzsqWFt9CfE-c4UAOMewqvAFKYnNi3A2olqXIjInDBsC3A1UfH9x6j7siLd58pWwOGd-IFuaQlI2-bLkbG39rw/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="inttmr0_graph" width="551" /></a></div><div align="justify"><b><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="6.5 Processing interrupt caused by overflow on TMR0 connected to external input (TOCKI)">6.5 Processing interrupt caused by overflow on TMR0 connected to external input (TOCKI)</a></b> </div><div align="justify">Counter TMR0 increments upon signal change on pin RA4/TOCKI. Prescaler is set to 4, meaning that TMR0 will be incremented on every fourth impulse. Pay attention to initialization of OPTION register which enables this mode of work for timer TMR0 (this mode is common for devices such as counters). </div><div align="justify"><a href="http://lh4.ggpht.com/-sNi9LeM0c1o/TxZoqN1JD2I/AAAAAAAACLI/2UpyzBWLSVU/s1600-h/int_65%25255B4%25255D.gif"><img alt="int_65" border="0" height="501" src="http://lh4.ggpht.com/-W6Wwy31acAg/TxZoq1d-PeI/AAAAAAAACLU/9wG3jv_jGMw/int_65_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="int_65" width="487" /></a></div><div align="justify"><b>Example of processing interrupt caused by overflow on timer TMR0 connected to TOCKI</b> </div><div align="justify"><a href="http://lh5.ggpht.com/-xPkSRWBXrp8/TxZorw_XxzI/AAAAAAAACLc/3oLCJCXbdVA/s1600-h/inttmr0_a_asm%25255B8%25255D.gif"><img alt="inttmr0_a_asm" border="0" height="1006" src="http://lh5.ggpht.com/-Feeid1-QXcY/TxZotMxKeFI/AAAAAAAACLk/wKjquYK_d5Y/inttmr0_a_asm_thumb%25255B5%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="inttmr0_a_asm" width="635" /></a></div><div align="justify"><br />
</div><b> </b> <br />
<div align="justify"><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<b>CHAPTER </b><b>7</b> <br />
<b>Examples</b> <br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_01chapter.htm#Introduction">Introduction</a> <br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_01chapter.htm#7.1%20Supplying%20the%20microcontroller">7.1 Supplying the microcontroller</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_02chapter.htm">7.2 LED diodes</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_03chapter.htm">7.3 Push buttons</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_04chapter.htm">7.4 Optocoupler</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_04chapter.htm">7.4.1 Optocouper on input line</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_04chapter.htm">7.4.2 Optocoupler on output line</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_05chapter.htm">7.5 Relay</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_06chapter.htm">7.6 Generating sound</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_07chapter.htm">7.7 Shift registers</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_07chapter.htm">7.7.1 Input shift register</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_07chapter.htm">7.7.2 Output shift register</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_08chapter.htm">7.8 7-seg display (multiplexing)</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_09chapter.htm">7.9 LCD display</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_10chapter.htm">7.10 Software SCI communication</a> <br />
<b><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Introduction">Introduction</a></b> <br />
Examples given in this chapter will show you how to connect the PIC microcontroller with other peripheral components or devices when developing your own microcontroller system. Each example contains detailed description of hardware with electrical outline and comments on the program. All programs can be taken directly from the 'MikroElektronika' Internet presentation. <br />
<b><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="7.1 Supplying the microcontroller">7.1 Supplying the microcontroller</a></b> <br />
Generally speaking, the correct voltage supply is of utmost importance for the proper functioning of the microcontroller system. It can easily be compared to a man breathing in the air. It is more likely that a man who is breathing in fresh air will live longer than a man who's living in a polluted environment.<br />
For a proper function of any microcontroller, it is necessary to provide a stable source of supply, a sure reset when you turn it on and an oscillator. According to technical specifications by the manufacturer of PIC microcontroller, supply voltage should move between 2.0V to 6.0V in all versions. The simplest solution to the source of supply is using the voltage stabilizer LM7805 which gives stable +5V on its output. One such source is shown in the picture below. <br />
<a href="http://lh5.ggpht.com/-cqfR4oQCrs4/TxZpDxG3-LI/AAAAAAAACLs/N6ZLhlLcM68/s1600-h/01%25255B4%25255D.gif"><img alt="01" border="0" height="325" src="http://lh3.ggpht.com/-cMtSkG0Iz_I/TxZpEn46VkI/AAAAAAAACL0/k06-mzfuT9s/01_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="01" width="602" /></a> <br />
In order to function properly, or in order to have stable 5V at the output (pin 3), input voltage on pin 1 of LM7805 should be between 7V through 24V. Depending on current consumption of device we will use the appropriate type of voltage stabilizer LM7805. There are several versions of LM7805. For current consumption of up to 1A we should use the version in TO-220 case with the capability of additional cooling. If the total consumption is 50mA, we can use 78L05 (stabilizer version in small TO - 92 packaging for current of up to 100mA).<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div align="justify"><b>7.2 LED diodes</b> </div><div align="justify">LEDs are surely one of the most commonly used elements in electronics. LED is an abbreviation for 'Light Emitting Diode'. When choosing a LED, several parameters should be looked at: diameter, which is usually 3 or 5 mm (millimeters), working current which is usually about 10mA (It can be as low as 2mA for LEDs with high efficiency - high light output), and color of course, which can be red or green though there are also orange, blue, yellow....<br />
LEDs must be connected around the correct way, in order to emit light and the current-limiting resistor must be the correct value so that the LED is not damaged or burn out (overheated). The positive of the supply is taken to the anode, and the cathode goes to the negative or ground of the project (circuit). In order to identify each lead, the cathode is the shorter lead and the LED "bulb" usually has a cut or "flat" on the cathode side. Diodes will emit light only if current is flowing from anode to cathode. Otherwise, its PN junction is reverse biased and current won't flow. In order to connect a LED correctly, a resistor must be added in series that to limit the amount of current through the diode, so that it does not burn out. The value of the resistor is determined by the amount of current you want to flow through the LED. Maximum current flow trough LED was defined by manufacturer.</div><div align="justify">To determine the value of the dropper-resistor, we need to know the value of the supply voltage. From this we subtract the characteristic voltage drop of a LED. This value will range from 1.2v to 1.6v depending on the color of the LED. The answer is the value of <b>Ur.</b> Using this value and the current we want to flow through the LED (0.002A to 0.01A) we can work out the value of the resistor from the formula <b>R=Ur/I</b>. <br />
<a href="http://lh5.ggpht.com/-RVKI2HYb4FE/TxZpe7Ovf4I/AAAAAAAACL8/4_jLO0y7yD4/s1600-h/06%25255B4%25255D.gif"><img alt="06" border="0" height="374" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYyc9pUypilPKPdcJsT6_mEHadwYbHKoclVYTIaeFVYANrg3j74j2ygM-uWGhIW12iDNRDgLZTAU3tNctvlSl4v0bWPlUbEdGrvTvTMjcwyuaI5ypaV46GO_tUENdZE0taRAusRgCPx8M/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="06" width="483" /></a></div><div align="justify">LEDs are connected to a microcontroller in two ways. One is to switch them on with logic zero, and other to switch them on with logic one. The first is called NEGATIVE logic and the other is called POSITIVE logic. The next diagram shows how to connect POSITIVE logic. Since POSITIVE logic provides a voltage of +5V to the diode and dropper resistor, it will emit light each time a pin of port B is provided with a logic 1. The other way is to connect all anodes to +5V and to deliver logical zero to cathodes. </div><div align="justify"><a href="http://lh3.ggpht.com/-JxzJgtBdCko/TxZpgbBLPfI/AAAAAAAACMM/Nxh98AcfPIg/s1600-h/07%25255B4%25255D.gif"><img alt="07" border="0" height="534" src="http://lh5.ggpht.com/-DKFYLGt84LY/TxZphb-pu_I/AAAAAAAACMU/tDoQrsH6qZk/07_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="07" width="513" /></a></div><div align="justify"><b>Connecting LED diodes to PORTB microcontroller</b> </div><div align="justify">The following example initializes port B as output and alternately switches on and off LED diodes every 0.5sec. For pause we used macro <i>pausems</i>, which is defined in the file mikroel84.inc. </div><div align="justify"><a href="http://lh3.ggpht.com/-nj62ufGD9tc/TxZph2AxzkI/AAAAAAAACMc/ibRJsZqGqQM/s1600-h/led_asm%25255B6%25255D.gif"><img alt="led_asm" border="0" height="696" src="http://lh3.ggpht.com/-9S--dG7oMy0/TxZpjKUAT2I/AAAAAAAACMk/T39tfa2uzrw/led_asm_thumb%25255B3%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="led_asm" width="498" /></a></div></div><div align="justify"><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div align="justify"><b>7.3 </b><b>Push buttons</b> </div><div align="justify">Buttons are mechanical devices used to execute a break or make connection between two points. They come in different sizes and with different purposes. Buttons that are used here are also called "dip-buttons". They are soldered directly onto a printed board and are common in electronics. They have four pins (two for each contact) which give them mechanical stability. </div><div align="justify"><a href="http://lh6.ggpht.com/-L9Xv_hhb-Do/TxZp18lU9-I/AAAAAAAACMs/Wy4-mfATMa4/s1600-h/09%25255B4%25255D.gif"><img alt="09" border="0" height="365" src="http://lh6.ggpht.com/-WneU8FJQISI/TxZp2qbd5iI/AAAAAAAACM0/5HXQTKadYek/09_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="09" width="538" /></a></div><div align="justify"><b>Example of connecting buttons to microcontroller pins</b> </div><div align="justify">Button function is simple. When we push a button, two contacts are joined together and connection is made. Still, it isn't all that simple. The problem lies in the nature of voltage as an electrical dimension, and in the imperfection of mechanical contacts. That is to say, before contact is made or cut off, there is a short time period when vibration (oscillation) can occur as a result of unevenness of mechanical contacts, or as a result of the different speed in pushing a button (this depends on person who pushes the button). The term given to this phenomena is called SWITCH (CONTACT) DEBOUNCE. If this is overlooked when program is written, an error can occur, or the program can produce more than one output pulse for a single button push. In order to avoid this, we can introduce a small delay when we detect the closing of a contact. This will ensure that the push of a button is interpreted as a single pulse. The debounce delay is produced in software and the length of the delay depends on the button, and the purpose of the button. The problem can be partially solved by adding a capacitor across the button, but a well-designed program is a much-better answer. The program can be adjusted until false detection is completely eliminated. Image below shows what actually happens when button is pushed. </div><div align="justify"><a href="http://lh5.ggpht.com/-ndl0TMGVHFk/TxZp3RB5rFI/AAAAAAAACM8/_ZKE69CPb6Q/s1600-h/deboncing%25255B4%25255D.gif"><img alt="deboncing" border="0" height="407" src="http://lh5.ggpht.com/-tPfEXUFuQVo/TxZp4XaV6bI/AAAAAAAACNE/2mBKIVVEY-4/deboncing_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="deboncing" width="558" /></a></div><div align="justify">As buttons are very common element in electronics, it would be smart to have a macro for detecting the button is pushed. Macro will be called <i>button</i>. <i>Button</i> has several parameters that deserve additional explanation. </div><div align="justify">button <b>macro </b> port, pin, hilo, label <br />
<b>Port</b> is a microcontroller's port to which a button is connected. In case of a PIC16F84 microcontroller, it can be PORTA or PORTB.<br />
<b>Pin</b> is port's pin to which the button is connected.<br />
<b>HiLo</b> can be '0' or '1' which represents the state when the button is pushed.<br />
<b>Label</b> is a destination address for jump to a service subprogram which will handle the event (button pushed).</div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizoHGU-TED3Eqought3ExMtvHKSnlfFuNyh6XDXIKbPhrL-DXQWnTrzlvJXlC5iyTI_wYkWwIqwdTRouRlA4rPQdUBbOBxKqb2CM3MBDOmfbpjNj0_9fGdiBM5g1QV-jdWfK88p24Qrx0/s1600-h/button_inc%25255B4%25255D.gif"><img alt="button_inc" border="0" height="412" src="http://lh6.ggpht.com/-R6X1NBgm-rw/TxZp6HHzGhI/AAAAAAAACNU/Ax0_myN_HAk/button_inc_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="button_inc" width="544" /></a></div><div align="justify"><b>Example 1:</b> </div><div align="justify">button PORTA, 3, 1, Button1 </div><div align="justify">Button T1 is connected to pin RA3 and to the mass across a pull-down resistor, so it generates logical one upon push. When the button is released, program jumps to the label Button1. </div><div align="justify"><b>Example 2:</b> </div><div align="justify">button PORTA, 2, 0, Button2 </div><div align="justify">Button T1 is connected to pin RA1 and to the mass across a pull-up resistor, so it generates logical zero upon push. When the button is released, program jumps to the label Button2. </div><div align="justify">The following example illustrates use of macro <i>button</i> in a program. Buttons are connected to the supply across pull-up resistors and connect to the mass when pushed. Variable <i>cnt</i> is displayed on port B LEDs;<i> cnt </i>is incremented by pushing the button RA0, and is decremented by pushing the button RA1. </div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCNFDcmh8rj5Nz7Voe28OCvgnmGR7pOYnPtIvBpMMQJ3wZSR2gB_P7I0ALMCBCjw1SOIMH21Og7KTB4L21l447OW4blEbDJbUcahAqqUBd6xy-vL9ap_d4Nc71PPqt-3NBemjG8FMd2Ps/s1600-h/button_asm%25255B5%25255D.gif"><img alt="button_asm" border="0" height="808" src="http://lh5.ggpht.com/-e3TnTGq8hEA/TxZp8OKOcsI/AAAAAAAACNk/s3--AkOgF3c/button_asm_thumb%25255B2%25255D.gif?imgmax=800" style="border-color: -moz-use-text-color; border-style: none; border-width: 0px; display: inline;" title="button_asm" width="621" /></a></div><div align="justify">It is important to note that this kind of debouncing has certain drawbacks, mainly concerning the idle periods of microcontroller. Namely, microcontroller is in the state of waiting from the moment the button is pushed until it is released, which can be a very long time period in certain applications. if you want the program to be attending to a number of things at the same time, different approach should be used from the start. Solution is to use the interrupt routine for each push of a button, which will occur periodically with pause adequate to compensate for repeated pushes of button. </div><div align="justify">The idea is simple. Every 10ms, button state will be checked upon and compared to the previous input state. This comparison can detect rising or falling edge of the signal. In case that states are same, there were apparently no changes. In case of change from 0 to a 1, rising edge occurred. If succeeding 3 or 4 checks yield the same result (logical one), we can be positive that the button is pushed. </div><div align="justify"><a href="http://lh4.ggpht.com/-Z9Xn96B7o0c/TxZp8-q-c_I/AAAAAAAACNo/TC_AIyA7gk4/s1600-h/deboncing2%25255B5%25255D.gif"><img alt="deboncing2" border="0" height="205" src="http://lh6.ggpht.com/-lV7FN-aZNrc/TxZp-pyZVLI/AAAAAAAACN0/fHgL_cKNwzc/deboncing2_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="deboncing2" width="590" /></a></div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><b>7.4 Optocouplers</b> </div><div align="justify">Optocouplers were discovered right aer photo-transistors (like any other transistor, except it is stimulated by light), by combining a LED and photo-transistor in the same case. The purpose of an optocoupler is to separate two parts of a circuit. </div><div align="justify">This is done for a number of reasons: </div><ul><li> <div align="justify">Interference<b>.</b> Typical examples are industrial units with lots of interferences which affect signals in the wires. If these interferences affected the function of control section, errors would occur and the unit would stop working.</div></li>
<li> <div align="justify">Simultaneous separation and intensification of a signal<b>.</b> Typical examples are relays which require higher current than microcontroller pin can provide. Usually, optocoupler is used for separating microcontroller supply and relay supply.</div></li>
<li> <div align="justify">In case of a breakdown, optocoupled part of device stays safe in its casing, reducing the repair costs.</div></li>
</ul><div align="justify">Optocouplers can be used as either input or output devices. They can have additional functions such as intensification of a signal or Schmitt triggering (the output of a Schmitt trigger is either 0 or 1 - it changes slow rising and falling waveforms into definite low or high values). Optocouplers come as a single unit or in groups of two or more in one casing. Each optocoupler needs two supplies in order to function. They can be used with one supply, but the voltage isolation feature, which is their primary purpose, is lost.</div><div align="justify"><b>7.4.1 Optocoupler on an input line</b> </div><div align="justify">The way it works is simple: when a signal arrives, the LED within the optocoupler is turned on, and it illuminates the base of a photo-transistor within the same case. When the transistor is activated, the voltage between collector and emitter falls to 0.7V or less and the microcontroller sees this as a logic zero on its RA4 pin. </div><div align="justify">The example below is a simplified model of a counter, element commonly utilized in industry (it is used for counting products on a production line, determining motor speed, counting the number of revolutions of an axis, etc). We will have sensor set off the LED every time axis makes a full revolution. LED in turn will 'send' a signal by means of photo-transistor to a microcontroller input RA4 (TOCKI). As prescaler is set to 1:2 in this example, every second signal will increment TMR0. Current status of the counter is displayed on PORTB LEDs. </div><div align="justify"><a href="http://lh4.ggpht.com/-EX3JXF1fT0M/TxZqSVkwnfI/AAAAAAAACN8/0qF4Nje5gUM/s1600-h/12%25255B4%25255D.gif"><img alt="12" border="0" height="272" src="http://lh4.ggpht.com/-4LCyVSY55dg/TxZqTIypt_I/AAAAAAAACOE/Bu3WjdL32gM/12_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="12" width="548" /></a></div><div align="justify"><b>Example of optocoupler on an input line</b> </div><div align="justify"><a href="http://lh3.ggpht.com/-qhkJnYqiShc/TxZqT4lh2MI/AAAAAAAACOM/RGLlB8gj1ac/s1600-h/optoin_asm%25255B4%25255D.gif"><img alt="optoin_asm" border="0" height="549" src="http://lh5.ggpht.com/-CDjnMyAaPKo/TxZqU06zt5I/AAAAAAAACOU/E8Cd_pNI_Jw/optoin_asm_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="optoin_asm" width="558" /></a></div><div align="justify"><b>7.4.2 Optocoupler on an output line</b> </div><div align="justify">An Optocoupler can be also used to separate the output signals. If optocoupler LED is connected to microcontroller pin, logical zero on pin will activate optocoupler LED, thus activating the transistor. This will consequently switch on LED in the part of device working on 12V. Layout of this connection is shown below. </div><div align="justify"><a href="http://lh5.ggpht.com/-viWkOQ5VWtY/TxZqVxqHmXI/AAAAAAAACOc/htqjFqYFk4k/s1600-h/14%25255B4%25255D.gif"><img alt="14" border="0" height="300" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbh2ANKuiTaFGvfud-BH2FUAVFU22_i0_D-qabKCuHqbAqs5mMIWw3eaGYH_Z9srNODLfjdewX7sosPgZGmr2z7aEEz0EM8cJDDWdsPA0-ygsOj2g0VoohzQQ2TbURUfZlHZvByUikKNo/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="14" width="591" /></a></div><div align="justify"><b>Ex</b><b>ample of optocoupler on output line</b> </div><div align="justify">The program for this example is simple. By delivering a logical one to the third pin of port A, the transistor will be activated in the optocoupler, switching on the LED in the part of device working on 12V. </div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><b>7.5 Relay</b> </div><div align="justify">The relay is an electromechanical device, which transforms an electrical signal into mechanical movement. It consists of a coil of insulated wire on a metal core, and a metal armature with one or more contacts. When a supply voltage was delivered to the coil, current would flow and a magnetic field would be produced that moves the armature to close one set of contacts and/or open another set. When power is removed from the relay, the magnetic flux in the coil collapses and produces a fairly high voltage in the opposite direction. This voltage can damage the driver transistor and thus a reverse-biased diode is connected across the coil to "short-out" the spike when it occurs. </div><div align="justify"><a href="http://lh6.ggpht.com/-jsV6IvOgCVM/TxZqoVA2o_I/AAAAAAAACOs/mAjDT24Bvs8/s1600-h/15%25255B5%25255D.gif"><img alt="15" border="0" height="461" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2edO-gg1nM6dSRmGYk7rASc2CrX3Ur6xmdpDIy15mWK7tbbWqizCtON0Nw9dJ9uzh8FUhiPADkkvALMpqkPAgpQwD_Mjxu3A-vK6L5JrmqvyNRgrf6ums3HtEyrF7UhwKJGI_W7l-sgE/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="15" width="599" /></a></div><div align="justify"><b>Connecting a relay to the microcontroller via transistor</b> </div><div align="justify">Since microcontroller cannot provide sufficient supply for a relay coil (approx. 100+mA is required; microcontroller pin can provide up to 25mA), a transistor is used for adjustment purposes, its collector circuit containing the relay coil. When a logical one is delivered to transistor base, transistor activates the relay, which then, using its contacts, connects other elements in the circuit. Purpose of the resistor at the transistor base is to keep a logical zero on base to prevent the relay from activating by mistake. This ensures that only a clean logical one on RA3 activates the relay. </div><div align="justify"><a href="http://lh6.ggpht.com/-SrWKiffnMdE/TxZqp7VoidI/AAAAAAAACO4/KUeJyMETU1k/s1600-h/16%25255B4%25255D.gif"><img alt="16" border="0" height="465" src="http://lh4.ggpht.com/-GIrbHwo5zEc/TxZqqsMvqlI/AAAAAAAACPE/1JrmEnlhdrA/16_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="16" width="610" /></a></div><div align="justify"><b>Connecting the optocoupler and relay to a microcontroller</b> </div><div align="justify">A relay can also be activated via an optocoupler which at the same time amplifies the current related to the output of the microcontroller and provides a high degree of isolation. High current optocouplers usually contain a 'Darlington' output transistor to provide high output current. </div><div align="justify">Connecting via an optocoupler is recommended especially for microcontroller applications, where relays are used fro starting high power load, such as motors or heaters, whose voltage instability can put the microcontroller at risk. In our example, when LED is activated on some of the output port pins, the relay is started. Below is the program needed to activate the relay, and includes some of the already discussed macros. </div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiWRUyP-T8idSImoFUeX3uEUp9rVBuso2yOCs8U7fvvI7qWXMguLRD9d4CBzj5LwKXQ5MvCfGzu4Y1zAOnWurOIJjxC67ErlPgDw3DkABt93OTeV2nXlEpXicCKsIjOnGUML8qFCKgmE0/s1600-h/relay_asm%25255B7%25255D.gif"><img alt="relay_asm" border="0" height="866" src="http://lh6.ggpht.com/-NizwqrrfqUQ/TxZqsroByWI/AAAAAAAACPU/y-flN3qlHW0/relay_asm_thumb%25255B4%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="relay_asm" width="600" /></a></div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><b>7.6 Generating sound</b> <br />
In microcontroller systems, beeper is used for indicating certain occurrences, such as push of a button or an error. To have the beeper started, it needs to be delivered a string in binary code - in this way, you can create sounds according to your needs. Connecting the beeper is fairly simple: one pin is connected to the mass, and the other to the microcontroller pin through a capacitor, as shown on the following image. <br />
<a href="http://lh4.ggpht.com/-he1Ag-FbcSA/TxZq7-_KZ4I/AAAAAAAACPc/olqjpjNsNOM/s1600-h/18%25255B4%25255D.gif"><img alt="18" border="0" height="337" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1xD23U5AbZ1U_RqYezEqOru97-63M6_dte-AVCOIwl3qFJOxUg0W4a1f87pVKQB6peerBNAqrc1GSWGT_lljA0TyaMoBEX_gaV3sZ-Z9f-MtFu18yGFWpxQkqZdWDBUhyphenhyphenMusHUgir39U/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="18" width="531" /></a> <br />
As with a button, you can employ a macro that will deliver a BEEP ROUTINE into a program when needed. Macro BEEP has two arguments:<br />
BEEP <b>macro</b> freq , duration:<br />
<b>freq:</b> frequency of the sound. The higher number produces higher frequency<br />
<b>duration: </b> sound duration. Higher the number, longer the sound.<br />
<b>Example 1:</b> BEEP 0xFF, 0x02<br />
The output has the highest frequency and duration at 2 cycles per 65.3mS which gives 130.6 mS<br />
<b>Example2:</b> BEEP 0x90, 0x05<br />
The output has a frequency of 0x90 and duration of 5 cycles per 65.3mS. It is best to determine these macro parameters through experimentation and select the sound that best suits the application.<br />
The following is the BEEP Macro listing: <br />
<a href="http://lh6.ggpht.com/-DLgJAld-ofQ/TxZq9HcvmUI/AAAAAAAACPo/G4wmUfpsgJc/s1600-h/beep_inc%25255B5%25255D.gif"><img alt="beep_inc" border="0" height="664" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM6QdeM8Gj2s6vG_2DSDGwVrOe3LKu1uxCngR8_Lpf-VOKu06BKz2Hn3fkWHLrEGCYELgcXKkGJRwODfOTm8ulAygTZz8bTxTnJ56Lrzff54Mv_iytKxTHzcjb7H1b_FJihd3mNt69Ggk/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="beep_inc" width="532" /></a> <br />
The following example shows the use of a macro in a program. The program produces two melodies which are obtained by pressing T1 or T2. Some of the previously discussed macros are included in the program. <br />
<a href="http://lh6.ggpht.com/-vGibGH8c7dY/TxZq-8vM9NI/AAAAAAAACP4/7RIc8651esM/s1600-h/beep_asm%25255B7%25255D.gif"><img alt="beep_asm" border="0" height="844" src="http://lh6.ggpht.com/-3TiRHy8X1uY/TxZrAJkTU0I/AAAAAAAACQE/ObC6dnxmxuM/beep_asm_thumb%25255B4%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="beep_asm" width="564" /></a> <br />
<div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><b>7.7 Shift registers</b> </div><div align="justify">There are two types of shift registers: <b>input and output</b>. <b>Input shift registers</b> receive data in parallel, through 8 lines and then send it serially through two lines to a microcontroller. <b>Output shift registers</b> work in the opposite direction; they receive serial data and on a "latch" line signal, they turn it into parallel data. Shift registers are generally used to expand the number of input-output lines of a microcontroller. They are not so much in use any more though, because most modern microcontrollers have a large number of pins. However, their use with microcontrollers such as PIC16F84 is very important. </div><div align="justify"><b>7.7.1 Input shift register 74HC597</b> </div><div align="justify">Input shift registers transform parallel data into serial data and transfers it to a microcontroller. Their working is quite simple. There are four lines for the transfer of data: <b>Clock, Latch, Load and Data</b>. Data is first read from the input pins by an internal register through a 'latch' signal. Then, with a 'load' signal, data is transferred from the input latch register to the shift register, and from there it is serially transferred to a microcontroller via 'data' and 'clock' lines. </div><div align="justify"><a href="http://lh5.ggpht.com/-QI_vh7wlhSs/TxZrVptY75I/AAAAAAAACQM/iO4zjgA_Jfw/s1600-h/21%25255B4%25255D.gif"><img alt="21" border="0" height="408" src="http://lh4.ggpht.com/-JjuewnRXe3c/TxZrWehMN3I/AAAAAAAACQU/T2XvU9OH4Uo/21_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="21" width="506" /></a></div><div align="justify">An outline of the connection of the shift register 74HC597 to a micro, is shown below. </div><div align="justify"><a href="http://lh4.ggpht.com/-cbZ02qcIMtQ/TxZrXPmBnLI/AAAAAAAACQc/_FRGyVd-big/s1600-h/22%25255B4%25255D.gif"><img alt="22" border="0" height="385" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRvk-fSPRF-nwkqa9l0k7kEt_oeXztxOjwABXq8gxZ7p0fvT8DAZTVYDF9gX9L9ccteF-GWAGroqaGlsPWgEpYA12z4DfFa3t2ASHjXZLhQNobQbhDCYPS3wep5tuEVLuqQU1_9loErhw/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="22" width="552" /></a></div><div align="justify">In order to simplify the main program, a macro can be used for the input shift register. Macro HC597 has two parameters:<br />
HC597 macro Var, Var1<br />
<b>Var</b> variable where data from shift register input pins is transferred<br />
<b>Var1</b> loop counter<br />
<b>Example:</b> HC597 data, counter<br />
Data from the input pins of the shift register is stored in data variable. Timer/counter variable is used as a loop counter. <br />
Macro listing:</div><div align="justify"><a href="http://lh5.ggpht.com/-dv7PZdF4x5E/TxZrY0rjzOI/AAAAAAAACQs/pdV7g2TrRds/s1600-h/hc597_inc%25255B4%25255D.gif"><img alt="hc597_inc" border="0" height="516" src="http://lh4.ggpht.com/-FnztatHqbnY/TxZraoGPgpI/AAAAAAAACQ0/UVOgBSucQCA/hc597_inc_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="hc597_inc" width="575" /></a></div><div align="justify">Example of how to use the HC597 macro is given in the following program. Program receives data from a parallel input of the shift register and moves it serially into the RX variable of the microcontroller. LEDs connected to port B will indicate the result of the data input. </div><div align="justify"><a href="http://lh3.ggpht.com/-xxZUy50mCXo/TxZrbMZM4sI/AAAAAAAACQ4/wWGWcdR7i_0/s1600-h/hc597_asm%25255B5%25255D.gif"><img alt="hc597_asm" border="0" height="783" src="http://lh4.ggpht.com/-1BjWewdogtk/TxZrcKnZYnI/AAAAAAAACRE/J9sMKKl0Lbs/hc597_asm_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="hc597_asm" width="596" /></a></div><div align="justify"><b>7.7.2 Output shift register</b> </div><div align="justify">Output shift registers transform serial data into parallel data. On every rising edge of the clock, the shift register reads the value from data line, stores it in temporary register, and then repeats this cycle 8 times. On a signal from 'latch' line, data is copied from the shift register to input register, thus data is transformed from serial into parallel data. </div><div align="justify"><a href="http://lh5.ggpht.com/-ffSifL21PaU/TxZrdJMuEcI/AAAAAAAACRI/cLj-BlWntMM/s1600-h/25%25255B4%25255D.gif"><img alt="25" border="0" height="403" src="http://lh3.ggpht.com/-dFFP21lGtdA/TxZrd7gh_HI/AAAAAAAACRU/ZtQYEhNkObM/25_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="25" width="631" /></a></div><div align="justify">An outline of the 74HC595 shift register connections is shown on the diagram below: </div><div align="justify"><a href="http://lh3.ggpht.com/-3jsWiyycClg/TxZre-LV4GI/AAAAAAAACRY/qMVoK_YxR4g/s1600-h/26%25255B4%25255D.gif"><img alt="26" border="0" height="270" src="http://lh6.ggpht.com/-ovou50fzmno/TxZrfiUlBmI/AAAAAAAACRg/rzBuCy00yak/26_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="26" width="558" /></a></div><div align="justify">Macro used in this example can be found in hc595.inc file, and is called HC595.<br />
Macro HC595 has two parameters:<br />
HC595 macro Var, Var1<br />
<b>Var</b> variable whose contents is transferred to outputs of shift register.<br />
<b>Var1</b> loop counter<br />
<b>Example:</b> HC595 Data, counter<br />
The data we want to transfer is stored in data variable, and counter variable is used as a loop counter.</div><div align="justify"><a href="http://lh3.ggpht.com/-nLeRWukIHEk/TxZrgVAzVjI/AAAAAAAACRo/kUlSuuJpB4g/s1600-h/hc595_inc%25255B5%25255D.gif"><img alt="hc595_inc" border="0" height="455" src="http://lh5.ggpht.com/-gy3AFYsbDrs/TxZrhL8GCOI/AAAAAAAACR0/IRMD6JelPxc/hc595_inc_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="hc595_inc" width="606" /></a></div><div align="justify">An example of how to use the HC595 macro is given in the following program. Data from variable TX is serially transferred to shift register. LEDs connected to the parallel output of the shift register will indicate the state of the lines. In this example value 0xCB (1100 1011) is sent so that the seventh, sixth, third, first, and zero LEDs are illuminated. </div><div align="justify"> </div><div align="justify"><a href="http://lh6.ggpht.com/-PwhpIX1UgcQ/TxZrh5vg-bI/AAAAAAAACSE/TOuVeTip23M/s1600-h/hc595_asm%25255B6%25255D.gif"><img alt="hc595_asm" border="0" height="710" src="http://lh5.ggpht.com/-gEG5hi_ojF8/TxZrkrMIGeI/AAAAAAAACSI/Up4_hNkocrA/hc595_asm_thumb%25255B3%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="hc595_asm" width="591" /></a></div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><b>7.8 Seven-Segment Display (multiplexing)</b> <br />
The segments in a 7-segment display are arranged to form a single digit from 0 to F as shown in the animation: <br />
<a href="http://lh5.ggpht.com/-JasJ8dWuzms/TxZr7xmDRCI/AAAAAAAACSQ/74RLTrY0U58/s1600-h/7-SegDisplay%25255B5%25255D.gif"><img alt="7-SegDisplay" height="261" src="http://lh3.ggpht.com/--6bPIw6MJPA/TxZr8RuX56I/AAAAAAAACSU/_tdXpoAUHrI/7-SegDisplay_thumb%25255B2%25255D.gif?imgmax=800" style="display: inline;" title="7-SegDisplay" width="193" /></a> <br />
We can display a multi-digit number by connecting additional displays. Even though LCD displays are more comfortable to work with, 7-segment displays are still standard in the industry. This is due to their temperature robustness, visibility and wide viewing angle. Segments are marked with non-capital letters: a, b, c, d, e, f, g and dp, where dp is the decimal point. The 8 LEDs inside each display can be arranged with a common cathode or common anode. With a common cathode display, the common cathode must be connected to the 0V rail and the LEDs are turned on with a logic one. Common anode displays must have the common anode connected to the +5V rail. The segments are turned on with a logic zero. The size of a display is measured in millimeters, the height of the digit itself (not the housing, but the digit!). Displays are available with a digit height of 7,10, 13.5, 20, or 25 millimeters. They come in different colors, including: red, orange, and green. <br />
The simplest way to drive a display is via a display driver. These are available for up to 4 displays. Alternatively displays can be driven by a microcontroller and if more than one display is required, the method of driving them is called "multiplexing." <br />
The main difference between the two methods is the number of "drive lines." A special driver may need only a single "clock" line and the driver chip will access all the segments and increment the display. If a single display is to be driven from a microcontroller, 7 lines will be needed plus one for the decimal point. For each additional display, only one extra line is needed. To produce a 4, 5 or 6 digit display, all the 7-segment displays are connected in parallel. The common line (the common-cathode line) is taken out separately and this line is taken low for a short period of time to turn on the display. Each display is turned on at a rate above 100 times per second, and it will appear that all the displays are turned on at the same time. As each display is turned on, the appropriate information must be delivered to it so that it will give the correct reading. Up to 6 displays can be accessed like this without the brightness of each display being affected. Each display is turned on very hard for one-sixth the time and the POV (persistence of vision) of our eye thinks the display is turned on the whole time. Therefore, the program has to ensure the proper timing, else the unpleasant blinking of display will occur. <br />
<a href="http://lh6.ggpht.com/-Eju97sn8mxk/TxZr80YAR3I/AAAAAAAACSc/vInMnfSwnL8/s1600-h/29%25255B4%25255D.gif"><img alt="29" border="0" height="374" src="http://lh3.ggpht.com/-67b6J5NglgM/TxZr9rY63kI/AAAAAAAACSo/2GqbSPcoEtE/29_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="29" width="533" /></a> <br />
<b>Connecting a microcontroller to 7-segment displays in multiplex mode</b> <br />
Program "7seg.asm" displays decimal value of a number stored in variable D. <br />
Example: <br />
movlw .21 <br />
movlw D<br />
; number 21 will be printed on 7seg display <br />
Displaying digits is carried out in multiplex mode which means that the microcontroller alternately prints ones digit and tens digit. TMR0 interrupt serves for generating a time period, so that the program enters the interrupt routine every 5ms and performs multiplexing. In the interrupt routine, first step is deciding which segment should be turned on. In case that the tens digit was previously on, it should be turned off, set the mask for printing the ones digit on 7seg display which lasts 5ms, i.e. until the next interrupt. <br />
For extracting the ones digit and the tens digit, macro <i>digbyte</i> is used. It stores the hundreds digit, the tens digit, and the ones digit into variables Dig1, Dig2, and Dig3. In our case, upon macro execution, Dig1 will equal 0, Dig2 will equal 2, and Dig3 will equal 1. <br />
Realization of the macro is given in the following listing: <br />
<a href="http://lh5.ggpht.com/-x-SXXvwfndk/TxZr-mQEIkI/AAAAAAAACSw/Bh2rj5naXk8/s1600-h/digit_inc%25255B4%25255D.gif"><img alt="digit_inc" border="0" height="545" src="http://lh4.ggpht.com/-Gk1dt6TZplg/TxZr_Mm1mHI/AAAAAAAACS4/bzR1xiCUHVo/digit_inc_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="digit_inc" width="610" /></a> <br />
The following example shows the use of the macro in a program. Program prints a specified 2-digit number on a 7seg display in multiplex mode. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0F-gWoV0Xx8BWj3ixm19K337H2R0ERm6o-d8NThdIWJtXPcJpuPpyzzUbiChYibSDpLt9afBBEDhYGKwq5iSbl0fOYKc44VPO2sc2u3CmSQY8S0jEFHWNLjtOEcxIFf3tubgq5oNG1Ro/s1600-h/7seg_asm%25255B11%25255D.gif"><img alt="7seg_asm" border="0" height="1492" src="http://lh6.ggpht.com/-U0THa0_fOmw/TxZsBba2V_I/AAAAAAAACTI/cfn4tRiECGA/7seg_asm_thumb%25255B8%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="7seg_asm" width="661" /></a> <br />
<div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><b>7.9 </b><b>LCD Display</b> <br />
More microcontroller devices are using 'smart LCD' displays to output visual information. The following discussion covers the connection of a <b>Hitachi LCD display</b> to a PIC microcontroller. LCD displays designed around Hitachi's LCD HD44780 module, are inexpensive, easy to use, and it is even possible to produce a readout using the 8 x 80 pixels of the display. Hitachi LCD displays have a standard ASCII set of characters plus Japanese, Greek and mathematical symbols.<br />
<a href="http://lh5.ggpht.com/-VFV48E7PtBU/TxZs03cLR8I/AAAAAAAACTQ/HVbd399bNgM/s1600-h/LCD_display%25255B4%25255D.gif"><img alt="LCD_display" border="0" height="222" src="http://lh3.ggpht.com/-mxjXU8dngQA/TxZs2kmqkYI/AAAAAAAACTY/_YBHOYlZfZ4/LCD_display_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="LCD_display" width="462" /></a> <br />
<b>A 16x2 line Hitachi HD44780 display</b> <br />
For a 8-bit data bus, the display requires a +5V supply plus 11 I/O lines. For a 4-bit data bus it only requires the supply lines plus seven extra lines. When the LCD display is not enabled, data lines are tri-state which means they are in a state of high impendance (as though they are disconnected) and this means they do not interfere with the operation of the microcontroller when the display is not being addressed. <br />
The LCD also requires 3 "control" lines from the microcontroller. <br />
<b>Enable (E)</b><br />
This line allows access to the display through R/W and RS lines. When this line is low, the LCD is disabled and ignores signals from R/W and RS. When (E) line is high, the LCD checks the state of the two control lines and responds accordingly. <br />
<b>Read/Write (R/W)</b><br />
This line determines the direction of data between the LCD and microcontroller. When it is low, data is written to the LCD. When it is high, data is read from the LCD. <br />
<b>Register select (RS)</b><br />
With the help of this line, the LCD interprets the type of data on data lines. When it is low, an instruction is being written to the LCD. When it is high, a character is being written to the LCD. <br />
Logic status on control lines:<br />
<b>E</b> 0 Access to LCD disabled<br />
1 Access to LCD enabled<br />
<b>R/W</b> 0 Writing data to LCD<br />
1 Reading data from LCD<br />
<b>RS</b> 0 Instruction<br />
1 Character<br />
Writing data to the LCD is done in several steps:<br />
Set R/W bit to low <br />
Set RS bit to logic 0 or 1 (instruction or character)<br />
Set data to data lines (if it is writing)<br />
Set E line to high <br />
Set E line to low <br />
Read data from data lines (if it is reading)<br />
Reading data from the LCD is done in the same way, but control line R/W has to be high. When we send a high to the LCD, it will reset and wait for instructions. Typical instructions sent to LCD display after a reset are: turning on a display, turning on a cursor and writing characters from left to right. When the LCD is initialized, it is ready to continue receiving data or instructions. If it receives a character, it will write it on the display and move the cursor one space to the right. The Cursor marks the next location where a character will be written. When we want to write a string of characters, first we need to set up the starting address, and then send one character at a time. Characters that can be shown on the display are stored in data display (DD) RAM. The size of DDRAM is 80 bytes. <br />
The LCD display also possesses 64 bytes of Character-Generator (CG) RAM. This memory is used for characters defined by the user. Data in CG RAM is represented as an 8-bit character bit-map. Each character takes up 8 bytes of CG RAM, so the total number of characters, which the user can define is eight. In order to read in the character bit-map to the LCD display, we must first set the CG RAM address to starting point (usually 0), and then write data to the display. The definition of a 'special' character is given in the picture. <br />
<a href="http://lh6.ggpht.com/-hYcEYP3Gq3I/TxZs3TgqbZI/AAAAAAAACTc/Gx8yeF5xuxc/s1600-h/32%25255B4%25255D.gif"><img alt="32" border="0" height="306" src="http://lh6.ggpht.com/-j--OsB924WQ/TxZs4BNnLxI/AAAAAAAACTk/HL_dJ_R1-QQ/32_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="32" width="338" /></a> <br />
Before we access DD RAM after defining a special character, the program must set the DD RAM address. Writing and reading data from any LCD memory is done from the last address which was set up using set-address instruction. Once the address of DD RAM is set, a new written character will be displayed at the appropriate place on the screen. Until now we discussed the operation of writing and reading to an LCD as if it were an ordinary memory. But this is not so. The LCD controller needs 40 to 120 microseconds (uS) for writing and reading. Other operations can take up to 5 mS. During that time, the microcontroller can not access the LCD, so a program needs to know when the LCD is busy. We can solve this in two ways. <br />
<a href="http://lh6.ggpht.com/-D-yRZOcajGA/TxZs4rEF6TI/AAAAAAAACTw/ml9wJuX5CSc/s1600-h/33%25255B4%25255D.gif"><img alt="33" border="0" height="413" src="http://lh6.ggpht.com/-_VivyJHC4mI/TxZs5vLBw4I/AAAAAAAACT4/Mi3Za3irHX0/33_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="33" width="441" /></a> <br />
One way is to check the BUSY bit found on data line D7. This is not the best method because LCD's can get stuck, and program will then stay forever in a loop checking the BUSY bit. The other way is to introduce a delay in the program. The delay has to be long enough for the LCD to finish the operation in process. Instructions for writing to and reading from an LCD memory are shown in the previous table.<br />
At the beginning we mentioned that we needed 11 I/O lines to communicate with an LCD. However, we can communicate with an LCD through a 4-bit data bus. Thus we can reduce the total number of communication lines to seven. The wiring for connection via a 4-bit data bus is shown in the diagram below. In this example we use an LCD display with 2x16 characters, labeled LM16X212 by Japanese maker SHARP. The message 'character' is written in the first row: and two special characters '~' and '}' are displayed. In the second row we have produced the word 'mikroElektronika'. <br />
<a href="http://lh4.ggpht.com/-8Co9HGfZKoA/TxZs6lmLPvI/AAAAAAAACT8/tNlZcl_O8D8/s1600-h/34%25255B5%25255D.gif"><img alt="34" border="0" height="352" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg44-fpk6RR3aDaKqo6-91WbPwUZOFNjw14YU5GUIzvrkwYL4O5pcIxjSQIpYQVvTjxv3E9y0zY75HteuiCY8MrTrfOIoiF-hUf4yTuOTzoM9kUJ5Ka9nsFlQHvyOegX4XYrwtSkvKdLYA/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="34" width="638" /></a> <br />
<b>Connecting an LCD display to a microcontroller</b> <br />
File <b>lcd.inc</b> contains a group of macros for use when working with LCD displays. <br />
<a href="http://lh5.ggpht.com/-fpD_P8CPcak/TxZs8UqNlEI/AAAAAAAACUM/KZzK-7TdOQw/s1600-h/lcd_inc%25255B9%25255D.gif"><img alt="lcd_inc" border="0" height="2256" src="http://lh6.ggpht.com/-XWoY0YLjQVs/TxZs9-W8FYI/AAAAAAAACUY/oABAhx_GAOs/lcd_inc_thumb%25255B6%25255D.png?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="lcd_inc" width="662" /></a> <br />
<b>Using the macro for LCD support</b> <br />
<b>lcd</b><b>init</b><br />
Macro used to initialize port connected to LCD. LCD is configured to work in 4-bit mode. <br />
Example:<br />
lcdinit <br />
lcdtext<br />
lcdtext prints the text of up to 16 characters, which is specified as a macro parameter. First parameter selects the line in which to start printing. If select is zero, text is printed from the current cursor position. <br />
Example:<br />
lcdtext 1, "mikroelektronika" <br />
lcdtext 1, "Temperature1" ;Print the text starting from line 1, character 1 <br />
lcdtext 2, "temp=" ;Print the text starting from line 2, character 1 <br />
lcdtext 0, " C" ;Print C in the rest of the line 2 <br />
lcdcmd<br />
Sends command instructions <br />
LCDCLR<br />
= b'00000001'<br />
;Clear display, cursor home <br />
LCDCH<br />
= b'00000010'<br />
;Cursor home <br />
LCDCL<br />
= b'00000100'<br />
;Move the cursor to the left <br />
LCDCR<br />
= b'00000110'<br />
;Move the cursor to the right <br />
LCDSL<br />
= b'00011000'<br />
;Move the content of display to the left <br />
LCDSR<br />
= b'00011100'<br />
;Move the content of display to the right <br />
LCDL1<br />
= b'10000000'<br />
;Select line 1 <br />
LCDL2<br />
= b'11000000'<br />
;Select line 2 <br />
Example:<br />
lcdcmd LCDCH <br />
lcdbyte<br />
Prints one byte variable and omits leading zeros <br />
Example:<br />
lcdbyte Temperature <br />
When working with a microcontroller the numbers are presented in a binary form. As such, they cannot be displayed on a display. That's why it is necessary to change the numbers from a binary system into a decimal system so they can be easily understood. For printing the variables lcdbyte and lcdword we have used the macros <i>digbyte</i> and <i>digword</i> which convert the numbers from binary system into a decimal system and print the result on LCD. Main program has the purpose of demonstrating use of LCD display. At the start it's necessary to declare variables LCDbuf, LCDtemp, Digtemp, Dig1, Dig2, and Dig3 used by the macros for LCD support. It is also necessary to state the port of microcontroller that LCD is connected to. Program initializes the LCD and demonstrates printing text and 8-bit variable temp. <br />
<a href="http://lh4.ggpht.com/-S7IeJBwjnwA/TxZs-uF3osI/AAAAAAAACUg/-VGH22Uouz0/s1600-h/lcd_asm%25255B9%25255D.gif"><img alt="lcd_asm" border="0" height="1165" src="http://lh6.ggpht.com/-YajEZocV8u0/TxZs_5VwrbI/AAAAAAAACUo/wC1iDtSDo3E/lcd_asm_thumb%25255B6%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="lcd_asm" width="671" /></a> <br />
<div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><b>Instruction Set</b> </div><div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#Introduction">Introduction</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#Instruction%20Set%20in%20PIC16Cxx%20Microcontroller%20Family">Instruction set in PIC16Cxx microcontroller family</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#Data%20Transfer">Data Transfer</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#Arithmetic%20and%20logic">Arithmetic and logic</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#Bit%20Operations">Bit operations</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#Directing%20a%20program%20flow">Directing the program flow </a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#Instruction%20Execution%20Period">Instruction execution period</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#Word%20list">Word list</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#Instruction%20List">Instruction list</a></div><div align="justify"><b><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Introduction">Introduction</a></b> </div><div align="justify">We have already mentioned that microcontroller is not like any other integrated circuit. When they come out of production most integrated circuits are ready to be built into devices which is not the case with microcontrollers. In order to "make" microcontroller perform a task, we have to tell it exactly what to do, or in other words we must write the program microcontroller will execute. We will describe in this chapter instructions which make up the assembler, or lower-level program language for PIC microcontrollers. </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Instruction Set in PIC16Cxx Microcontroller Family">Instruction Set in PIC16Cxx Microcontroller Family</a> </div><div align="justify">Complete set which includes 35 instructions is given in the following table. A reason for such a small number of instructions lies primarily in the fact that we are talking about a RISC microcontroller whose instructions are well optimized considering the speed of work, architectural simplicity and code compactness. The only drawback is that programmer is expected to master "uncomfortable" technique of using a reduced set of 35 instructions. </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Data Transfer">Data transfer</a> </div><div align="justify">Transfer of data in a microcontroller is done between work (W) register and an 'f' register that represents any location in internal RAM (regardless whether those are special or general purpose registers).<br />
First three instructions (look at the following table) provide for a constant being written in W register (MOVLW is short for MOVe Literal to W), and for data to be copied from W register onto RAM and data from RAM to be copied onto W register (or on the same RAM location, at which point only the status of Z flag changes). Instruction CLRF writes constant 0 in 'f ' register, and CLRW writes constant 0 in register W. SWAPF instruction exchanges places of the 4-bit nibbles field inside a register. </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Arithmetic and logic">Arithmetic and logic</a> </div><div align="justify">Of all arithmetic operations, PIC like most microcontrollers supports only subtraction and addition. Flags C, DC and Z are set depending on a result of addition or subtraction, but with one exception: since subtraction is performed like addition of a negative value, C flag is inverse following a subtraction. In other words, it is set if operation is possible, and reset if larger number was subtracted from a smaller one. <br />
Logic unit of PIC has capability of performing operations AND, OR, EX-OR, complementing (COMF) and rotation (RLF and RRF).<br />
Instructions which rotate the register contents move bits inside a register through flag C by one space to the left (toward bit 7), or to the right (toward bit 0). Bit which "comes out" of a register is written in flag C, and value of C flag is written in a bit on the "opposite side" of the register. </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Bit Operations">Bit operations</a> </div><div align="justify">Instructions BCF and BSF do setting or cleaning of one bit anywhere in the memory. Even though this seems like a simple operation, it is executed so that CPU first reads the whole byte, changes one bit in it and then writes in the entire byte at the same place. </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Directing a program flow">Directing a program flow</a> </div><div align="justify">Instructions GOTO, CALL and RETURN are executed the same way as on all other microcontrollers, only stack is independent of internal RAM and limited to eight levels. <br />
'RETLW k' instruction is identical with RETURN instruction, except that before coming back from a subprogram a constant defined by instruction operand is written in W register. This instruction enables us to design easily the Look-up tables (lists). Mostly we use them by determining data position on our table adding it to the address at which the table begins, and then we read data from that location (which is usually found in program memory). <br />
Table can be formed as a subprogram which consists of a series of 'RETLW k' instructions, where 'k' constants are members of the table. </div><div align="justify"><a href="http://lh3.ggpht.com/-hSMF3L9S7dc/TxZ1rsdOufI/AAAAAAAACUw/d1wJVSQNXJE/s1600-h/prog1%25255B3%25255D.gif"><img alt="prog1" border="0" height="158" src="http://lh6.ggpht.com/-G2KF1uI5DCY/TxZ1spd5pyI/AAAAAAAACU4/zwEGmPBXthk/prog1_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="prog1" width="170" /></a></div><div align="justify">We write the position of a member of our table in W register, and using CALL instruction we call a subprogram which creates the table. First subprogram line ADDWF PCL, f adds the position of a W register member to the starting address of our table, found in PCL register, and so we get the real data address in program memory. When returning from a subprogram we will have in W register the contents of an addressed table member. In a previous example, constant 'k2' will be in W register following a return from a subprogram.<br />
RETFIE (RETurn From Interrupt - Interrupt Enable) is a return from interrupt routine and differs from a RETURN only in that it automatically sets GIE (Global Interrupt Enable) bit. Upon an interrupt, this bit is automatically cleared. As interrupt begins, only the value of program counter is put at the top of a stack. No automatic storing of register values and status is provided.<br />
Conditional jumps are synthesized into two instructions: BTFSC and BTFSS. Depending on a bit status in 'f' register that is being tested, instructions skip or don't skip over the next program instruction. </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Instruction Execution Period">Instruction Execution Period</a> </div><div align="justify">All instructions are executed in one cycle except for conditional branch instructions if condition was true, or if the contents of program counter was changed by some instruction. In that case, execution requires two instruction cycles, and the second cycle is executed as NOP (No Operation). Four oscillator clocks make up one instruction cycle. If we are using an oscillator with 4MHz frequency, the normal time for executing an instruction is 1 µs, and in case of conditional branching, execution period is 2 µs. </div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Word list">Word list</a> </div><div align="justify"><b>f</b> any memory location in a microcontroller<br />
<b>W</b> work register<br />
<b>b</b> bit position in 'f' register<br />
<b>d</b> destination bit<br />
<i>label</i> group of eight characters which marks the beginning of a part of the program<br />
<b>TOS</b> top of stack<br />
<b>[] </b>option<br />
<b><></b> bit position inside register</div><div align="justify"><a href="http://lh6.ggpht.com/-LfSQWIfsQyY/TxZ1tbh6ukI/AAAAAAAACU8/_HnDkwzQcdA/s1600-h/table%25255B5%25255D.gif"><img alt="table" border="0" height="787" src="http://lh6.ggpht.com/-C3XvxQhEr-k/TxZ1uLxXn7I/AAAAAAAACVI/jrIFAOEmgxE/table_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="table" width="651" /></a></div><div align="justify">*1 If I/O port is source operand, status on microcontroller pins is read<br />
*2 If this instruction is executed on TMR register and if d=1, prescaler assigned to that timer will automatically be cleared<br />
*3 If PC was modified, or test result =1, instruction was executed in two cycles.</div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Instruction List">Instruction List</a> </div><div align="justify">Appendix contains all instructions presented separately with examples for their use. Syntax, description and its effects on status bits are given for each instruction. </div><ul><li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.1%20Write%20constant%20in%20W%20register">A.1 MOVLW</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.2%20Copy%20W%20to%20f">A.2 MOVWF</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.3%20Copy%20f%20to%20d">A.3 MOVF</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.4%20Write%200%20in%20W">A.4 CLRW</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.5">A.5 CLRF</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.6%20Copy%20the%20nibbles%20from%20%27f%27%20to%20%27d%27%20crosswise">A.6 SWAPF</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.7%20Add%20W%20to%20a%20constant">A.7 ADDLW</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.8%20Add%20W%20to%20%27f%27">A.8 ADDWF</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.9%20Subtract%20W%20from%20a%20constant">A.9 SUBLW</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.10%20Subtract%20W%20from%20%27f%27">A.10 SUBWF</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.11%20Logic%20I%20W%20with%20constant">A.11 ANDLW</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.12%20Logic%20I%20W%20with%20f">A.12 ANDWF</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.13%20Logic%20ILI%20W%20with%20constant">A.13 IORLW</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.14%20Logic%20ILI%20W%20with%20f">A.14 IORWF</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.15%20Logic%20exclusive%20ILI%20W%20with%20constant">A.15 XORLW</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.16%20Logic%20exclusive%20ILI%20W%20with%20%27f%27">A.16 XORWF</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.17%20Increment%20%27f%27">A.17 INCF</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.18%20Decrement%20f">A.18 DECF</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.19%20Rotate%20f%20to%20the%20left%20through%20CARRY">A.19 RLF</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.20%20Rotate%20f%20to%20the%20right%20through%20CARRY">A.20 RRF</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.21%20Complement%20f">A.21 COMF</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.22%20Reset%20bit%20b%20in%20f">A.22 BCF</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.23%20Set%20bit%20b%20in%20f">A.23 BSF</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.24%20Test%20bit%20%27b%27%20in%20%27f%27,%20skip%20if%20it%20=%200%C2%A0">A.24 BTFSC</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.25%20Test%20bit%20%27b%27%20in%20%27f%27,%20skip%20if%20=1">A.25 BTFSS</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.26%20Increment%20%27f%27,%20skip%20if=0">A.26 INCFSZ</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.27%20Decrement%20f,%20skip%20if%20=%200">A.27 DECFSZ</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.28%20Jump%20to%20address">A.28 GOTO</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.29%20Call%20a%20program">A.29 CALL</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.30%20Return%20from%20a%20subprogram">A.30 RETURN</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.31%20Return%20from%20a%20subprogram%20with%20constant%20in%20W">A.31 RETLW</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.32%20Return%20from%20interrupt%20routine">A.32 RETFIE</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.33%20No%20operation">A.33 NOP</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.34%20Initialize%20watchdog%20timer">A.34 CLRWDT</a></div></li>
<li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.35%20Stand%20by%20mode">A.35 SLEEP</a></div></li>
</ul><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.1 Write constant in W register">A.1 MOVLW Write constant in W register</a> </div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLdU1GrARFqgHnCNWIW97XDWE3RNhOIBW34RqV5rV-TSi2yWayOtcmt6iun9xzGu-hh6KJlp4Pnu7vwKXxWmZF0NB7B3sQROoDoPIULKMpSh15S8YaVyI7Z4ELvVr2aeWDNRB9073nvRc/s1600-h/01%25255B4%25255D.gif"><img alt="01" border="0" height="303" src="http://lh5.ggpht.com/-a7i6cEGx_I0/TxZ1v6u_GCI/AAAAAAAACVU/OuW6h1fj92A/01_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="01" width="672" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.2 Copy W to f">A.2 MOVWF Copy W to f</a> </div><div align="justify"><a href="http://lh6.ggpht.com/-d2UWWiU7lrg/TxZ1ws4VWRI/AAAAAAAACVc/XPugxU4Nsac/s1600-h/02%25255B4%25255D.gif"><img alt="02" border="0" height="428" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi3CUD_VJ7X2gayraoPQ2RGv5pulv8Ian78DWSYrdwWDueBdbXsq4hlTp2a7hfh5maY-OOKNIt1yYrTqhZ8_-gKEkx6Pl-q0wWH5ehS2HJr08bw1quFfUCY7Z-EXpKh9nHIK20zLx40gk/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="02" width="675" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.3 Copy f to d">A.3 MOVF Copy f to d</a> </div><div align="justify"><a href="http://lh3.ggpht.com/-DOyEiSGRAIY/TxZ1y-VxnXI/AAAAAAAACVs/8jH4mIuyKaI/s1600-h/03%25255B4%25255D.gif"><img alt="03" border="0" height="553" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis0xUSXpWHtzM6G0muiwLABFOUJ-CiVjuxH5ylkhyGnifbVu1z-K4glNWZO8CBjpyEAqGbTo4oFo4siyV1qfy5Ycy4lwXJ0shCnlCV-J0ny9S4NL67FWz7z7OfKx4AYCErObaa_QhCNkQ/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="03" width="683" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.4 Write 0 in W">A.4 CLRW Write 0 in W</a> </div><div align="justify"><a href="http://lh4.ggpht.com/-p-5hx_MQ82Q/TxZ10uqTC_I/AAAAAAAACV8/drgKw1fPnDA/s1600-h/04%25255B4%25255D.gif"><img alt="04" border="0" height="281" src="http://lh3.ggpht.com/-vHQsfAANsLk/TxZ114vZzEI/AAAAAAAACWI/gc6KtZ7vWZI/04_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="04" width="697" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.5">A.5 Write 0 in f</a> </div><div align="justify"><a href="http://lh3.ggpht.com/-C4NACuKX_RM/TxZ12omKpEI/AAAAAAAACWQ/LHBJ2ZCHetM/s1600-h/05%25255B4%25255D.gif"><img alt="05" border="0" height="445" src="http://lh6.ggpht.com/-SXdKCZbx7l8/TxZ13yBM0wI/AAAAAAAACWY/9O8M2j3ctbU/05_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="05" width="706" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.6 Copy the nibbles from 'f' to 'd' crosswise">A.6 SWAPF Copy the nibbles from f to d crosswise</a> </div><div align="justify"><a href="http://lh6.ggpht.com/-s-4AI1ELxk4/TxZ14tP9xiI/AAAAAAAACWg/1P4bMuIQPtc/s1600-h/06%25255B4%25255D.gif"><img alt="06" border="0" height="424" src="http://lh5.ggpht.com/-2J8LphKknnA/TxZ16cTNYBI/AAAAAAAACWo/bfydRljGCoc/06_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="06" width="700" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.7 Add W to a constant">A.7 ADDLW Add W to a constant</a> </div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJZ5apF1YmHwrFHML3CLHLyrvrq60kP_BwsTf3-F9aso5tnDpKe2Tuyh27aLC1eTZC0Nw8yPcZozRuBKRLkvXzXmG_JFxDxA3KtpbL-bUvqYXxITHfGYB1PLC1TxoV314ttuCx-Q9onkM/s1600-h/07%25255B4%25255D.gif"><img alt="07" border="0" height="370" src="http://lh5.ggpht.com/-lbN4r_WpFzA/TxZ18ilguwI/AAAAAAAACW4/1ZJ1AzSjk0A/07_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="07" width="702" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.8 Add W to 'f'">A.8 ADDWF Add W to f</a> </div><div align="justify"><a href="http://lh3.ggpht.com/-uQq4D-M2Y48/TxZ19gQy8pI/AAAAAAAACXA/yQ3E6Mb3joA/s1600-h/08%25255B4%25255D.gif"><img alt="08" border="0" height="490" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKSHqzBQer0N2VbCRLTPh8RXqazpPIPknADvtVoYlAsY4YH9wHL1caIeK8VDvu9yZw7Y_dKBHojzbJek5488McNL17MwfbxkLwSgGzXkRP8bmTTp9rtxeghSKETOA45XaUl8XRw8U2nI8/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="08" width="694" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.9 Subtract W from a constant">A.9 SUBLW Subtract W from a constant</a> </div><div align="justify"><a href="http://lh5.ggpht.com/-jpbJ5ru3u0A/TxZ1_ufsNOI/AAAAAAAACXQ/Kv5xH-g4DZA/s1600-h/09%25255B4%25255D.gif"><img alt="09" border="0" height="485" src="http://lh3.ggpht.com/-AuyRD1lbkMc/TxZ2Aw4574I/AAAAAAAACXY/5PN7SUtCf9Q/09_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="09" width="684" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.10 Subtract W from 'f'">A.10 SUBWF Subtract W from f</a> </div><div align="justify"><a href="http://lh6.ggpht.com/-pPe56cdVl7k/TxZ2BeSqqrI/AAAAAAAACXg/2zs3Jj06qeg/s1600-h/10%25255B4%25255D.gif"><img alt="10" border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUJsOt4MkxrrPbWoY0EEhBF1pMXYhXFBHiRuL6pqET9AxqCYmouashjSSWE2qCjPT-srwcPS4zvgFseCSN4dCHzQCLeraOgJRtWis7osl7iIzBMvhkrnCwFes0jRVhgwoe8Z567KztVdg/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="10" width="692" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.11 Logic I W with constant">A.11 ANDLW Logic AND W with constant</a> </div><div align="justify"><a href="http://lh3.ggpht.com/-99Egh8IcmMw/TxZ2Dfs7ycI/AAAAAAAACXw/t3IfsaSvjR8/s1600-h/11%25255B4%25255D.gif"><img alt="11" border="0" height="437" src="http://lh3.ggpht.com/-wl73Q2ubG4E/TxZ2ErV25uI/AAAAAAAACX4/O0OrANRPyWg/11_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="11" width="693" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.12 Logic I W with f">A.12 ANDWF Logic AND W with f</a> </div><div align="justify"><a href="http://lh3.ggpht.com/-9FWEuZspvbA/TxZ2F085KcI/AAAAAAAACX8/yA8sVDHAX0M/s1600-h/12%25255B4%25255D.gif"><img alt="12" border="0" height="482" src="http://lh3.ggpht.com/-VlFEcbOlUGw/TxZ2GzCRiBI/AAAAAAAACYI/gL_CyeURfYc/12_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="12" width="703" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.13 Logic ILI W with constant">A.13 IORLW Logic OR W with constant</a> </div><div align="justify"><a href="http://lh3.ggpht.com/-Hex-FZiBgkw/TxZ2Hz5lBGI/AAAAAAAACYQ/OG6pCdiRzTg/s1600-h/13%25255B4%25255D.gif"><img alt="13" border="0" height="407" src="http://lh5.ggpht.com/-D-sfRoTN4Wg/TxZ2JS7t-EI/AAAAAAAACYY/p3GF80qZeX0/13_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="13" width="703" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.14 Logic ILI W with f">A.14 IORWF Logic OR W with f</a> </div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWV9lRFyp8__-SUpciTgpj2uDaquXfZKqdwPniwBjg6s1QbGFbDFJn3xpDlZUGE4q-lxQcwodHc4Fex4L9vmHZA8sJREN28DNcWGE4EKmq3zEOkhZkn8c3z9BU30gJWOTOwkLs3JVtXak/s1600-h/14%25255B4%25255D.gif"><img alt="14" border="0" height="437" src="http://lh5.ggpht.com/-xzBLC0uz32U/TxZ2K1eLseI/AAAAAAAACYo/14awaPlGec4/14_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="14" width="698" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.15 Logic exclusive ILI W with constant">A.15 XORLW Logic exclusive OR W with constant</a> </div><div align="justify"><a href="http://lh5.ggpht.com/-T8uSB8TVbP0/TxZ2Lsjg7jI/AAAAAAAACYw/NHE8CQf7tMw/s1600-h/15%25255B4%25255D.gif"><img alt="15" border="0" height="421" src="http://lh4.ggpht.com/-k18v_w0ISzg/TxZ2Mpx_dSI/AAAAAAAACY4/Tt5WmsF3EvQ/15_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="15" width="694" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.16 Logic exclusive ILI W with 'f'">A.16 XORWF Logic exclusive OR W with f</a> </div><div align="justify"><a href="http://lh4.ggpht.com/-FY3TpjIWYYw/TxZ2NexgOZI/AAAAAAAACY8/R6qUv0KEkWU/s1600-h/16%25255B4%25255D.gif"><img alt="16" border="0" height="469" src="http://lh3.ggpht.com/-iVl3j92H6ls/TxZ2OACUHEI/AAAAAAAACZI/uDr8DnoLDqw/16_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="16" width="688" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.17 Increment 'f'">A.17 INCF Increment f</a> </div><div align="justify"><a href="http://lh3.ggpht.com/-ZiPw5IavHi4/TxZ2O8YpRiI/AAAAAAAACZQ/hztvISilhCg/s1600-h/17%25255B4%25255D.gif"><img alt="17" border="0" height="486" src="http://lh5.ggpht.com/-UDTINF-KxpY/TxZ2QWeNEyI/AAAAAAAACZY/xmPQzmJZtVM/17_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="17" width="693" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.18 Decrement f">A.18 DECF Decrement f</a> </div><div align="justify"><a href="http://lh4.ggpht.com/-vNizhyjJLpQ/TxZ2Q0xSaZI/AAAAAAAACZc/uNQ_vE0tPZc/s1600-h/18%25255B4%25255D.gif"><img alt="18" border="0" height="485" src="http://lh6.ggpht.com/-JhO9M8WA7HI/TxZ2RpP5bmI/AAAAAAAACZo/lqa1VFCiJUg/18_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="18" width="691" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.19 Rotate f to the left through CARRY">A.19 RLF Rotate f to the left through CARRY</a> </div><div align="justify"><a href="http://lh4.ggpht.com/-5N1EySX8Mbo/TxZ2Se2UUsI/AAAAAAAACZw/-abpcECxP04/s1600-h/19%25255B4%25255D.gif"><img alt="19" border="0" height="486" src="http://lh6.ggpht.com/-rBoabP9pSgQ/TxZ2TvVJ7II/AAAAAAAACZ4/HXl_Un40FXM/19_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="19" width="689" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.20 Rotate f to the right through CARRY">A.20 RRF Rotate f to the right through CARRY</a> </div><div align="justify"><a href="http://lh5.ggpht.com/-WI-ezq8txZo/TxZ2UpFAeTI/AAAAAAAACZ8/Nu_3twGDORE/s1600-h/20%25255B5%25255D.gif"><img alt="20" border="0" height="511" src="http://lh3.ggpht.com/-CjrWJ87GmtI/TxZ2XLUgClI/AAAAAAAACaI/ZW9qs8sGm_s/20_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="20" width="693" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.21 Complement f">A.21 COMF Complement f</a> </div><div align="justify"><a href="http://lh4.ggpht.com/-07On0txNmtk/TxZ2X0D-aHI/AAAAAAAACaQ/Z4MBa9MpRfI/s1600-h/21%25255B4%25255D.gif"><img alt="21" border="0" height="459" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSF3vw-mek9LFeHiRSi0TaI4tfH1A6nEydIA0nQ961DhvjjFxeW0Cf_d7hFdGfTL-xHrEiedBaS9hJzbgX_CLTKstK65_eBcQ7tq08iROoAZ3tEF8-HrYQcQv0W6HEWlIulk1hL4LID3w/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="21" width="693" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.22 Reset bit b in f">A.22 BCF Reset bit b in f</a> </div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbYzCWksQPWrZ88OEs52jrgeNww8BiB9LAXj-U8n7UF6OiohV8JEjsW_nT2lEVXydL563SsJGYsseQTSmYWCzHhjfC2XlcrsSLBrgSjP9TLoenWO8D4NV5dVi_wUmoEdP7AD3CtRAabKY/s1600-h/22%25255B4%25255D.gif"><img alt="22" border="0" height="420" src="http://lh4.ggpht.com/-UY5dRpG1Cj4/TxZ2bGqJxfI/AAAAAAAACao/ZeHd-95zazo/22_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="22" width="693" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.23 Set bit b in f">A.23 BSF Set bit b in f</a> </div><div align="justify"><a href="http://lh5.ggpht.com/-OVAOur5HU_o/TxZ2b8znyPI/AAAAAAAACas/FM5ouSjiIvQ/s1600-h/23%25255B4%25255D.gif"><img alt="23" border="0" height="418" src="http://lh6.ggpht.com/-Gw7BxZ95eNw/TxZ2c4xkJwI/AAAAAAAACa4/xEnkllLRKUs/23_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="23" width="690" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.24 Test bit 'b' in 'f', skip if it = 0 ">A.24 BTFSC Test bit b in f, skip if it = 0</a> </div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikmUCEPgsXg8Y4hITjGAsWGTLIk9M4FXBt5iDCOKbAXtVcYxeFSAyi6EuY64HbX-7ldWNpisnDqQYYza3TmIiot0InBgRgKgQJVqC9F2Taqp3OP6KByqGgl-1FXad0K_XnpgDw0LFDUEU/s1600-h/24%25255B4%25255D.gif"><img alt="24" border="0" height="457" src="http://lh4.ggpht.com/-dLdoV8pDL7k/TxZ2ejfnoLI/AAAAAAAACbI/LbOwfEjROIM/24_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="24" width="694" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.25 Test bit 'b' in 'f', skip if =1">A.25 BTFSS Test bit b in f, skip if =1</a> </div><div align="justify"><a href="http://lh6.ggpht.com/-Rp9N2hOLFMo/TxZ2fc8Sn-I/AAAAAAAACbQ/yGJRXqTonzA/s1600-h/25%25255B4%25255D.gif"><img alt="25" border="0" height="455" src="http://lh3.ggpht.com/-hnBKROJdFdc/TxZ2hshugFI/AAAAAAAACbY/PqR21cGav5I/25_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="25" width="687" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.26 Increment 'f', skip if=0">A.26 INCFSZ Increment f, skip if=0</a> </div><div align="justify"><a href="http://lh5.ggpht.com/-EbHdJrDKp78/TxZ2ivqQHEI/AAAAAAAACbg/JpWB6ll896s/s1600-h/26%25255B4%25255D.gif"><img alt="26" border="0" height="455" src="http://lh5.ggpht.com/--IvsmDTs7wU/TxZ2klog6SI/AAAAAAAACbo/gm0lObTH_bk/26_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="26" width="692" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.27 Decrement f, skip if = 0">A.27 DECFSZ Decrement f, skip if = 0</a> </div><div align="justify"><a href="http://lh3.ggpht.com/-B2Qzk35YjyA/TxZ2lkpehSI/AAAAAAAACbw/BNooKDs1NNY/s1600-h/27%25255B4%25255D.gif"><img alt="27" border="0" height="457" src="http://lh5.ggpht.com/-0NwqfxreIxM/TxZ2oML2-aI/AAAAAAAACb4/7K9pY0BraTY/27_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="27" width="694" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.28 Jump to address">A.28 GOTO Jump to address</a> </div><div align="justify"><a href="http://lh5.ggpht.com/-sM8tbBzI23s/TxZ2o-lrgHI/AAAAAAAACcA/ejAfozV2Flk/s1600-h/28%25255B4%25255D.gif"><img alt="28" border="0" height="331" src="http://lh6.ggpht.com/-FgkRZ5onjWg/TxZ2ptcNVII/AAAAAAAACcI/c2DF7AlkRYk/28_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="28" width="692" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.29 Call a program">A.29 CALL Call a program</a> </div><div align="justify"><a href="http://lh5.ggpht.com/-40jCuBzfzyk/TxZ2qlMQBRI/AAAAAAAACcM/v1Jlx4pqwtY/s1600-h/29%25255B4%25255D.gif"><img alt="29" border="0" height="437" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3Z8USJvaUtPCcHsOVtBG_MY4IkyonUMhiZiKZL0HO4BmV_QhN6-nvdV73aG0F_-zE61SkCZyCOwSCa5ghB0p__k1luasWm-PONM5r7GOGyaqMNbD5Mq1Jd8HWfUijVIXWN-Bzu2JCS-0/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="29" width="694" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.30 Return from a subprogram">A.30 RETURN Return from a subprogram</a> </div><div align="justify"><a href="http://lh4.ggpht.com/-vdUpFFyL-Vk/TxZ2sGKxz3I/AAAAAAAACcc/U4wWIOxDfCw/s1600-h/30%25255B4%25255D.gif"><img alt="30" border="0" height="277" src="http://lh5.ggpht.com/-5_xvsb_oHwE/TxZ2tKMSbKI/AAAAAAAACco/xP8IVZWokOg/30_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="30" width="693" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.31 Return from a subprogram with constant in W">A.31 RETLW Return from a subprogram with constant in W</a> </div><div align="justify"><a href="http://lh3.ggpht.com/-_A8DFy_Kdf4/TxZ2t0WVWeI/AAAAAAAACcw/Kc3kq0WN7Zs/s1600-h/31%25255B4%25255D.gif"><img alt="31" border="0" height="332" src="http://lh3.ggpht.com/-SRiHdSHZMrE/TxZ2vHmgZ5I/AAAAAAAACc4/ochv1RGFeL4/31_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="31" width="693" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.32 Return from interrupt routine">A.32 RETFIE Return from interrupt routine</a> </div><div align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4lLa9BZjq-JJdpoTjor2QK1WFWvumb8TDh3L63UmUU4YGARa_8YQuQeHdEELwSKkP29y1aMS85P1_kvgHFDQ0Pe3X6JzFKXPzyk1qyFeczf5LTApCFiOwE-3nJwJpuzBLYYTuO8Gk0eQ/s1600-h/32%25255B4%25255D.gif"><img alt="32" border="0" height="298" src="http://lh3.ggpht.com/-MqH8LEupH9g/TxZ2wiY2HpI/AAAAAAAACdI/NLonUZ8Px08/32_thumb%25255B1%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="32" width="692" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.33 No operation">A.33 NOP No operation</a> </div><div align="justify"><a href="http://lh5.ggpht.com/--O0Yt8SaBMs/TxZ2xkmgIrI/AAAAAAAACdQ/U8GPKW2oJZw/s1600-h/33%25255B4%25255D.gif"><img alt="33" border="0" height="247" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM5rd0so_TOQ4BvEEqf33ImpfNK4BUkbMbq7p3nHrvyIfmkM4oIhtUOfYjw8HWo34z4qja-3pdXkDwhjYT2l62KkAahRnhHan2H6PHd-VduyIsFZDXEE3lVpyUCwhY7Dm_pakCanYzd0U/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="33" width="702" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.34 Initialize watchdog timer">A.34 CLRWDT Initialize watchdog timer</a> </div><div align="justify"><a href="http://lh5.ggpht.com/-221p-aPS0zI/TxZ2z1kDKXI/AAAAAAAACdg/i3gNJA-LgIY/s1600-h/34%25255B5%25255D.gif"><img alt="34" border="0" height="407" src="http://lh5.ggpht.com/-bA_JEgjkWFU/TxZ21WfxS6I/AAAAAAAACdo/Hhu2NxC3SmM/34_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="34" width="691" /></a></div><div align="justify"><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="A.35 Stand by mode">A.35 SLEEP Stand by mode</a> </div><div align="justify"><a href="http://lh5.ggpht.com/-D6vVx304Zzk/TxZ2116XVTI/AAAAAAAACdw/v9Fau5L7eEE/s1600-h/35%25255B5%25255D.gif"><img alt="35" border="0" height="367" src="http://lh6.ggpht.com/-E3uDS9L3xc8/TxZ23RxuADI/AAAAAAAACd4/4n19cfZhnbI/35_thumb%25255B2%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="35" width="622" /></a></div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
<br />
<br />
<br />
<br />
<br />
<br />
<b>Numerical Systems</b> <br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/B_appendix.htm#Introduction">Introduction</a> <br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/B_appendix.htm#B.1%20Decimal%20numeric%20system">B.1 Decimal numerical system</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/B_appendix.htm#B.2%20Binary%20numeric%20system">B.2 Binary numerical system</a><br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/B_appendix.htm#B.3%20Hexadecimal%20numeric%20system">B.3 Hexadecimal numerical system</a> <br />
<b><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Introduction">Introduction</a></b> <br />
It was always difficult for people to accept the fact that some things differ from them or their way of thinking. That is probably one of the reasons why numerical systems which differ from a decimal are still hard to understand. Still, whether we want it or not, reality is different. Decimal numerical system that people use in everyday life is so far behind the binary system used by millions of computers around the world. <br />
Each numerical system are based on some basis. With a decimal numerical system, that basis is 10, with binary 2, and with a hexadecimal system 16. The value of each decimal is determined by its position in relation to the whole number represented in the given numerical system. The sum of values of each decimal gives the value of the whole number. Binary and hexadecimal numerical systems are especially interesting for the subject of this book. Beside these, we will also discuss a decimal system, in order to compare it with the other two. Even though a decimal numerical system is a subject we are well acquainted with, we will discuss it here because of its relatedness to other numerical systems. <br />
<b><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="B.1 Decimal numeric system">B.1 Decimal numerical system</a></b> <br />
Decimal numerical system is defined by its basis 10 and decimal space that is counted from right to left, and consists of numbers 0,1, 2, 3, 4, 5, 6, 7, 8, 9. That means that the end right digit of the total sum is multiplied by 1, next one by 10, next by 100, etc. <br />
<b>Example:</b> <br />
<a href="http://lh5.ggpht.com/-so0lz-JuDys/TxamG9fjm2I/AAAAAAAADJQ/aeMgRuVPVhE/s1600-h/01%25255B3%25255D.gif"><img alt="01" border="0" height="142" src="http://lh5.ggpht.com/-UCgYYUGJM5g/TxamHaK9l9I/AAAAAAAADJU/Kz8_QsojQXY/01_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="01" width="229" /></a> <br />
Operations of addition, subtraction, division, and multiplication in a decimal numerical system are used in a way that is already known to us, so we won't discuss it further. <br />
<b><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="B.2 Binary numeric system">B.2 Binary numerical system</a></b> <br />
Binary numerical system differs in many aspects from the decimal system we are used to in our everyday lives. Its numerical basis is 2, and each number can have only two values, '1' or '0'. Binary numerical system is used in computers and microcontrollers because it is far more suitable for processing than a decimal system. Usually, binary number consists of binary digits 8, 16 or 32, and it is not important in view of the contents of our book to discuss why. It will be enough for now to adopt this information. <br />
<b>Example:</b> <br />
10011011 binary number with 8 digits <br />
In order to understand the logic of binary numbers, we will consider an example. Let's say that we have a small chest with four drawers, and that we need to tell someone to bring something from one of the drawers to us. Nothing is more simple, we will say left side, bottom (drawer), and the desired drawer is clearly defined. However, if we had to do this without the use of instructions like left, right, beneath, above, etc., then we would have a problem. There are many solution to this problem, but we should look for one that is most beneficent and practical! Lets designate rows with A, and types with B. If A=1, it refers to the upper row of drawers, and for A=0, bottom row. Similarly with columns, B=1 represents the left column, and B=0, the right (next picture). Now it is already easier to explain from which drawer we need something. We simply need to state one of the four combinations: 00, 01, 10 or 11. This characteristic naming of each drawer individually is nothing but binary numerical representation, or conversion of common numbers from a decimal into binary form. In other words, references like "first, second, third and fourth" are exchanged with "00,01, 10 and 11". <br />
<a href="http://lh6.ggpht.com/-exeTLYXnMz4/TxamIK8TieI/AAAAAAAADJc/8axRXnSkRPs/s1600-h/02%25255B3%25255D.gif"><img alt="02" border="0" height="155" src="http://lh6.ggpht.com/-XHW5uMUjunA/TxamIxr0BOI/AAAAAAAADJo/_7hYlM7s1O4/02_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="02" width="244" /></a> <br />
What remains is for us to get acquainted with logic that is used with binary numerical system, or how to get a numerical value from a series of zeros and ones in a way we can understand, of course. This procedure is called conversion from a binary to a decimal number.<br />
<b>Example:</b> <br />
<a href="http://lh4.ggpht.com/-9aS5mu9v2S8/TxamJmKLdPI/AAAAAAAADJw/GQOGRtKHw3c/s1600-h/03%25255B3%25255D.gif"><img alt="03" border="0" height="185" src="http://lh5.ggpht.com/-ngSTKeUgpVE/TxamKewlJAI/AAAAAAAADJ0/u9zGxBr4G5E/03_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="03" width="244" /></a> <br />
As you can see, converting a binary number into a decimal number is done by calculating the expression on the left side. Depending on the position in a binary number, digits carry different values which are multiplied by themselves, and by adding them we get a decimal number we can understand. Let's further suppose that there are few marbles in each of the drawers: 2 in the first one, 4 in the second drawer, 7 in the third and 3 in the fourth drawer. Let's also say to the one who's opening the drawers to use binary representation in answer. Under these conditions, question would be as follows: "How many marbles are there in 01?", and the answer would be: "There are 100 marbles in 01." It should be noted that both question and the answer are very clear even though we did not use the standard terms. It should further be noted that for decimal numbers from 0 to 3 it is enough to have two binary digits, and that for all values above that we must add new binary digits. So, for numbers from 0 to 7 it is enough to have three digits, for numbers from 0 to 15, four, etc. Simply said, the biggest number that can be represented by a binary digit is the one obtained when basis 2 is graded onto a number of binary digits in a binary number and thus obtained number is decremented by one.<br />
<b>Example:</b> <br />
<a href="http://lh3.ggpht.com/-MnmZ2AAx9zE/TxamLY2XlpI/AAAAAAAADKA/ZHzypeVEe7M/s1600-h/04%25255B3%25255D.gif"><img alt="04" border="0" height="25" src="http://lh4.ggpht.com/-JT5_SYHACFI/TxamMZdMNBI/AAAAAAAADKI/O0JXYdIhXQU/04_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="04" width="123" /></a> <br />
This means that it is possible to represent decimal numbers from 0 to 15 with 4 binary digits, including numbers '0' and '15', or 16 different values.<br />
Operations which exist in decimal numerical system also exist in a binary system. For reasons of clarity and legibility, we will review addition and subtraction only in this chapter. <br />
Basic rules that apply to binary addition are: <br />
<a href="http://lh3.ggpht.com/-EzHym1MTswI/TxamNIv458I/AAAAAAAADKQ/E52t6A7HybM/s1600-h/05%25255B3%25255D.gif"><img alt="05" border="0" height="66" src="http://lh6.ggpht.com/-AzCvJimPZ44/TxamOF2rzFI/AAAAAAAADKY/sL_JC5Uybz0/05_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="05" width="204" /></a> <br />
Addition is done so that digits in the same numerical positions are added, similar to the decimal numerical system. If both digits being added are zero, their sum remains zero, and if they are '0' and '1', result is '1'. The sum of two ones gives two, in binary representation it will be a zero, but with transferring '1' to a higher position that is added to digits from that position.<br />
<b>Example:</b> <br />
<a href="http://lh3.ggpht.com/-qzgB8xUkKDc/TxamO-iFRnI/AAAAAAAADKg/4T-uJGCrk98/s1600-h/06%25255B3%25255D.gif"><img alt="06" border="0" height="70" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhu7rZvExEOFGDgHjIIUZcu9fAhfBwr3sHsHB9epOwhOXeqaH2H6qADRKemaTVaj9ViCkRBsaa732xKUnPswzimyLZIl242jCjdS-C7o4I0TReBTIb-69vbyVUItyeWKaFCoSAoP548B7g/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="06" width="199" /></a> <br />
We can check whether result is correct by transferring these number to decimal numerical system and by performing addition in it. With a transfer we get a value 10 as the first number, value 9 as the second, and value 19 as the sum. Thus we have proven that operation was done correctly. Trouble comes when sum is greater than what can be represented by a binary number with a given number of binary digits. Different solutions can be applied then, one of which is expanding the number of binary digits in the sum as in the previous example.<br />
Subtraction, like addition is done on the same principle. The result of subtraction between two zeros, or two ones remains a zero. When subtracting one from zero, we have to borrow one from binary digit which has a higher value in the binary number.<br />
<b>Example:</b> <br />
<a href="http://lh3.ggpht.com/-9ITM2gbO2rA/TxamQhxi1wI/AAAAAAAADKw/L9gkECw7yxQ/s1600-h/07%25255B3%25255D.gif"><img alt="07" border="0" height="70" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil5wQe2FUoKPGmMHxWXP7dP3RnWjGfm20DMurb-VDsNlV34nFMRwqEq9rcz_Jy38yQCoHbfUSSkITCXkz-oysZRWHnpRjueulBKEmzwDL2gbmiOIlSwuGD0RvK05IAI36ZqTOpxWIpqn0/?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="07" width="219" /></a> <br />
By checking the result as we did with addition, when we translate these binary numbers we get decimal numbers 10 and 9. Their difference corresponds to number 1 which is what we get in subtraction. <br />
<b><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="B.3 Hexadecimal numeric system">B.3 Hexadecimal numerical system</a></b> <br />
Hexadecimal numerical system has a number 16 as its basis. Since the basis of a numerical system is 16, there are 16 different digits that can be found in a hexadecimal number. Those digits are "0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F". Letters A, B, C, D, E and F are nothing but values 10, 11, 12, 13, 14 and 15. They are introduced as a replacement to make writing easier. As with a binary system, here too, we can determine with same formula what is the biggest decimal number we can represent with a specific number of hexadecimal digits.<br />
<b>Example: With two hexadecimal digits</b> <br />
<a href="http://lh6.ggpht.com/-mYdLnce88pA/TxamSgj9deI/AAAAAAAADK8/OPRkLtV48RU/s1600-h/08%25255B3%25255D.gif"><img alt="08" border="0" height="25" src="http://lh4.ggpht.com/-jGLYbzZlVkg/TxamTdlgY0I/AAAAAAAADLI/LgZnyAbYjsE/08_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="08" width="153" /></a> <br />
Usually, hexadecimal number is written with a prefix "$" or "0x" ,or suffix"h" , to emphasize the numerical system. Thus, number A37E would be written more correctly as $A37E, 0xA37E, or A37Eh. In order to translate a hexadecimal number into a binary numerical system it is not necessary to perform any calculation but simple exchange of hexadecimal digits with binary digits. Since the maximum value of a hexadecimal number is 15, that means that it is enough to use 4 binary digits for one hexadecimal digit.<br />
<b>Example:</b> <br />
<a href="http://lh4.ggpht.com/-9oCNnnJ0CKc/TxamUJ3ZCtI/AAAAAAAADLM/AFMiRWcPbbU/s1600-h/09%25255B3%25255D.gif"><img alt="09" border="0" height="57" src="http://lh5.ggpht.com/-9eDzFQxmozA/TxamVJnOJkI/AAAAAAAADLY/4KtI58HOjwo/09_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="09" width="173" /></a> <br />
By checking, that is transferring both numbers into decimal numerical system, we get a number 228 which proves the accuracy of our action. <br />
In order to get a decimal equivalent of a hexadecimal number, we need to multiply each digit of a number with number 16 which is gradated by the position of that digit in hexadecimal number.<br />
<b>Example:</b> <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-WDqG5WAqZdCL4_wC7-ScT7zZpDIUuBIX2081_6qltn3Pgxu9v7kLecPFHRuKOmXOXuElxnXLGD8yw4zJv8L9oVo6AHuIj9BgTuZmK1TGaZwML9suBuK8jvkdp4loLI5dowTPSGFlPSA/s1600-h/10%25255B3%25255D.gif"><img alt="10" border="0" height="142" src="http://lh3.ggpht.com/-NN1dJxp7bKw/TxamW6SZ-uI/AAAAAAAADLo/E1KksWtK62k/10_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="10" width="229" /></a> <br />
Addition is, like in two preceding examples, performed in a similar manner.<br />
<b>Example:</b> <br />
<a href="http://lh6.ggpht.com/-mWYcxkp5b_w/TxamYAvD-5I/AAAAAAAADLs/Jv4uF6sg0fM/s1600-h/11%25255B3%25255D.gif"><img alt="11" border="0" height="63" src="http://lh5.ggpht.com/-kYj5sTFMfCU/TxamY_FHPpI/AAAAAAAADL0/Ei1wMoPlSiE/11_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="11" width="186" /></a> <br />
We need to add corresponding number digits. If their sum is equal 16, write 0 and transfer one to the next higher place. If their sum is greater than 16, write value above and transfer 1 to the next higher digit.Eg. if sum is 19 (19=16+3) write 3 and transfer 1 to the next higher place. By checking, we get 14891 as the first number, and second is 43457. Their sum is 58348, which is a number $E3EC when it is transferred into a decimal numerical system. Subtraction is an identical process to those in previous two numerical systems. If the number we are subtracting is smaller, we borrow from the next place of higher value.<br />
<b>Example:</b> <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2je5g_UMlLCPwNgko6D8vW8MIHBsC4zAl7MLhdbgI624IVDhbHVHVqokMtaWwTWX8YdhVY6cQ6pBlhv3SRicguLnb6zvWY5CpSWzEf72ajWQt-o2jM5gXG8NDgkdRHMFnPKYX9DuECKo/s1600-h/12%25255B3%25255D.gif"><img alt="12" border="0" height="63" src="http://lh6.ggpht.com/-Ca-zbI8r450/TxamaOL7N1I/AAAAAAAADME/7x3LFWr35gc/12_thumb.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="12" width="173" /></a> <br />
By checking this result, we get values 11590 for the first number and 5970 for the second, where their difference is 5620, which corresponds to a number $15F4 after a transfer into a decimal numerical system. <br />
Conclusion <br />
Binary numerical system is still the one that is most in use, decimal the one that's easiest to understand, and a hexadecimal is somewhere between those two systems. It's easy conversion to a binary numerical system and easy memorization make it, along with binary and decimal systems, one of the most important numerical systems. </div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><div align="justify"><br />
</div><b>Glossary</b> <br />
<a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Introduction">Introduction</a> <br />
<ul><li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Microcontroller">Microcontroller</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#I/O%20pin">I/O pin</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Software">Software</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Hardware">Hardware</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Simulator">Simulator</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#ICE">ICE</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#EPROM%20Emulator">EPROM Emulator</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#assembler">Assembler</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#HEX%20file">HEX file</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#List%20file">List file</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Source%20File">Source File</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Debugging">Debugging</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#ROM,%20EPROM,%20EEPROM,%20FLASH,%20RAM">ROM, EPROM, EEPROM, FLASH, RAM</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Addressing">Addressing</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#ASCII">ASCII</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Carry">Carry</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Code">Code</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Byte,%20Kilobyte,%20Megabyte">Byte, Kilobyte, Megabyte</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Flag">Flag</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Interrupt%20vector%20or%20interrupts">Interrupt vector or interrupts</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Programmer">Programmer</a><br />
</li>
<li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Product">Product</a></li>
</ul><b><a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Introduction">Introduction</a></b> <br />
Since all the fields of man's activity are regularly based on adequate and already adopted terms (through which other notions and definitions become), so in the field of microcontrollers we can single out some frequently used terms. Ideas are often connected so that correct understanding of one notion is needed in order to get acquainted with one or more of the other ideas. <br />
<a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Microcontroller">Microcontroller</a> Microprocessor with peripherals in one electronic component. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="I/O pin">I/O pin</a> External microcontroller's connector pin which can be configured as input or output. In most cases I/O pin enables a microcontroller to communicate, control or read information. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Software">Software</a> Information that microcontroller needs in order to be able to function. Software can not have any errors if we want the program and a device to function properly. Software can be written in different languages such as: Basic, C, pascal or assembler. Physically, that is a file on computer disc. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Hardware">Hardware</a> Microcontroller, memory, supply, signal circuits and all components connected with microcontroller. The other way of viewing this (especially if it's not working) is, that, hardware is something you can kick. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Simulator">Simulator</a> Software package for PC which simulates the internal function of microcontroller. It is ideal for checking software routines and all the parts of the code which do not have over demanding connections with an outside world. Options are installed to watch the code, movement around the program back and forth step by step, and debugging. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="ICE">ICE</a> ICE (In Circuit Emulator), internal emulator, very useful part of the equipment which connects a PC instead of microcontroller on a device that is being developed. It enables software to function on the PC computer, but to appear as if a real microcontroller exists in the device. ICE enables you to move through program in real time, to see what is going on in the microcontroller and how it communicates with an outside world. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="EPROM Emulator">EPROM Emulator</a> EPROM Emulator is a device which does not emulate the entire microcontroller like ICE emulator, but it only emulates its memory. It is mostly used in microcontrollers that have external memory. By using it we avoid constant erasing and writing of EPROM memory. <a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#assembler" name="assembler">Assembler</a> Software package which translates source code into a code which microcontroller can understand. It contains a section for discovering errors. This part is used when we debug a program from errors made when program was written. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="HEX file">HEX file</a> This is a file made by assembler translator when translating a source file, and has a form "understood" by microcontrollers. A continuation of the file is usually File_name.HEX where the name HEX file comes from. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="List file">List file</a> This is a file made by assembler translator and it contains all instructions from source file with addresses and comments programmer has written. This is a very useful file for keeping track of errors in the program. File extension is LST which is where its name comes from. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Source File">Source File</a> File written in the language understood by man and assembler translator. By translating the source file, we get HEX and LIST files. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Debugging">Debugging</a> Error made in writing a program, which error we are not aware of. Errors can be quite simple such as typing errors, and quite complex such as incorrect use of program language. Assembler will find most of these errors and report them to '.LST' file. Other errors will need to be searched for by trying it out and watching how device functions. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="ROM, EPROM, EEPROM, FLASH, RAM">ROM, EPROM, EEPROM, FLASH, RAM</a> Types of memories we meet with microcontroller use. First one can not be erased, what you write in it once, stays forever, and can not be erased. The second is erasable with UV lamp. Third one can be erased electrically, using voltage which microcontroller operates on. Fourth one is electrically erasable, but unlike EEPROM memory it does not have such a great number of cycles of writing and erasing at memory locations. Fifth one is fast, but it does not hold back the contents as the previous when there is supply shortage. Thus, program is not stored in it, but it serves for different variables and inter-results. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Addressing">Addressing</a> Determines and designates certain memory locations. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="ASCII">ASCII</a> Short for "American Standard Code for Information Interchange". It is widely accepted type of coding where each number and letter have their eight-bit code. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Carry">Carry</a> Transfer bit connected with arithmetic operations <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Code">Code</a> File, or section of a file which contains program instructions. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Byte, Kilobyte, Megabyte">Byte, Kilobyte, Megabyte</a> Terms designating amounts of information. The basic unit is a byte, and it has 8 bits. Kilobyte has 1024 bytes, and mega byte has 1024 kilobytes. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Flag">Flag</a> Bits from a status register. By their activation, programmer is informed about certain actions. Program activates its response if necessary. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Interrupt vector or interrupts">Interrupt vector or interrupts</a> Location in microcontroller memory. Microcontroller takes from this location information about a section of the program that is to be executed as an answer to some event of interest to programmer and device. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Programmer">Programmer</a> Device which makes it possible to write software in microcontroller memory, thus enabling the microcontroller to work independently. It consists of the hardware section usually connected with one of the ports and software section used on the computer as a program. <a href="http://www.blogger.com/page-edit.g?blogID=5922120083083455839&pageID=3316270153059277577" name="Product">Product</a> Product development is a combination of luck and experience. Short terms, or time-limits for production should be avoided because even with most simple assignments, much time is needed to develop and improve. When creating a project, we need time, quiet, logical mind and most importantly, a thorough understanding of consumer's needs. Typical course in creating a product would have the following algorithm. <br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglVA9IO5wEmz_r3edIz1cvo-kCN6_oCtzfyobgL0CP6TkDoKF9d_uC6BT1yJa1kyiwh0F2Az5C0ZkSX6I-0akIq4I4Zs-URLzUcgjA_7vZKxz5MC6nbTKbVG6hE5UDt5PQ-vLaujZT3uA/s1600-h/01%25255B6%25255D.gif"><img alt="01" border="0" height="707" src="http://lh4.ggpht.com/-jgg_7aSsRQ4/TxZ3hQCEqmI/AAAAAAAACeI/FQKx5KAzE6I/01_thumb%25255B3%25255D.gif?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="01" width="548" /></a> <br />
<div align="justify"><br />
</div></div>mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-37908857685313667482012-01-18T01:00:00.001-08:002022-03-10T20:19:26.970-08:00BASIC for PIC microcontrollers Book Part3<p><a href="http://lh4.ggpht.com/-dBFg14Tjcqc/TxaHxRpIRaI/AAAAAAAAC3Q/-mghGqSelAI/s1600-h/clip_image001%25255B4%25255D.jpg"><img title="clip_image001" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image001" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-oPJ3kIoGWI3AgXa2RF8dsYk-hY2yEa8_EZnzOWdHTtR3Pss60ZWIgubjS8Ldju53DRUcU9x8847usIrn4EezKml6f3sIkYNf9jD9MVtg45jo2pAj_vem2jCXXbt-vE1QpVV-BBTf7Ls/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-96sG-pUvArw/TxaH0KXvHNI/AAAAAAAAC3g/2usykhjxKzg/s1600-h/clip_image002%25255B4%25255D.jpg"><img title="clip_image002" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image002" src="http://lh3.ggpht.com/-xL-mY_GXzvU/TxaH1kV2atI/AAAAAAAAC3o/uiucrWY15h4/clip_image002_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-BD_TDKsDwtg/TxaH2XdFGsI/AAAAAAAAC3w/DpUFtbY6Bl0/s1600-h/clip_image003%25255B4%25255D.jpg"><img title="clip_image003" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image003" src="http://lh5.ggpht.com/-EMpnEXfezZg/TxaH3zIPxpI/AAAAAAAAC34/DP44t2-mECM/clip_image003_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-saU176wliH8/TxaH4q3DVhI/AAAAAAAAC4A/PnPoAIYBM3o/s1600-h/clip_image004%25255B4%25255D.jpg"><img title="clip_image004" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image004" src="http://lh5.ggpht.com/-zlsqrr7LuIo/TxaH6ZdxUXI/AAAAAAAAC4I/9qwbqGMC5Xc/clip_image004_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-FHRhSjd_qb8/TxaH7TviuGI/AAAAAAAAC4Q/0pXqkfXcd2w/s1600-h/clip_image005%25255B4%25255D.jpg"><img title="clip_image005" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image005" src="http://lh3.ggpht.com/-qIjePFvzRnw/TxaH8oFGpHI/AAAAAAAAC4Y/fHApuTFpVgc/clip_image005_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-TUWLycua8LI/TxaH9dtugkI/AAAAAAAAC4g/m8grnIJFEdQ/s1600-h/clip_image006%25255B4%25255D.jpg"><img title="clip_image006" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image006" src="http://lh4.ggpht.com/-kNoFqaEP3Vc/TxaH-BRxJ4I/AAAAAAAAC4o/IFj8aSK3yl8/clip_image006_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4PXaj1m4yCOTv-_C42u5-CDtmp49KQh8C5ycxGHjFD3scJ5o9YzTYhBqksCjBVh1sMHUkKUwgtXuMnb8f3vB1-o81U54cLVW0U0gAi8vclXvzjZj4gwQ3Zz7t8e2BdxhbjR7QqO37S20/s1600-h/clip_image007%25255B4%25255D.jpg"><img title="clip_image007" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image007" src="http://lh6.ggpht.com/--NZNC2JXuqQ/TxaIBMVHSMI/AAAAAAAAC44/osMbNmYz6eQ/clip_image007_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-tQ-VUxAiGOY/TxaIBlOXsKI/AAAAAAAAC48/ZLuJn8Y_NME/s1600-h/clip_image008%25255B4%25255D.jpg"><img title="clip_image008" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image008" src="http://lh3.ggpht.com/-UJXg4fqgryI/TxaICriaFQI/AAAAAAAAC5E/SpiD7wThP0k/clip_image008_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-ODpiKrOz1tF2PrZE4tLHpUH9Q0EVz780RIQa6CHjFHS7Nf2C9-NCuYCi22E813-OejLH7M46d-FQVy5jFlDN4Sj5XJhsqc1WsjhWtUfgasc1zUHnt9bMvAzT73RPvDg9z6PxMIz3JsU/s1600-h/clip_image009%25255B4%25255D.jpg"><img title="clip_image009" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image009" src="http://lh6.ggpht.com/-o3YHLpSikCI/TxaIEloRe3I/AAAAAAAAC5Y/NUA5umhYmVY/clip_image009_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-HvTIppp80x8/TxaIFfZ_JRI/AAAAAAAAC5g/fM2mJGbhjiM/s1600-h/clip_image010%25255B4%25255D.jpg"><img title="clip_image010" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image010" src="http://lh4.ggpht.com/-LvUoKhAIH6s/TxaIGnYTc4I/AAAAAAAAC5o/CeCjG17pfuU/clip_image010_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-WfARYD8-2IU/TxaIHgszp3I/AAAAAAAAC5w/VR8-ZeWu1Ug/s1600-h/clip_image011%25255B4%25255D.jpg"><img title="clip_image011" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image011" src="http://lh6.ggpht.com/-jU3BFc3O2uU/TxaIIueJShI/AAAAAAAAC54/E3in0Wvk2tA/clip_image011_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-N3OWmAu9Pao/TxaIKN_V9lI/AAAAAAAAC6A/AE5yy52_Kw0/s1600-h/clip_image012%25255B4%25255D.jpg"><img title="clip_image012" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image012" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSYbwRLN4QMZDCorVem9jp5AfGW54XeRIP84Webl-tYwyvsYllR7z2H4BOQxjAr3yeVZPntbxph1V6eDBAWzqhNNyCaPilVLRPZUeL5M4w0iyTIPYzWCFo_-5Qkmagu-aNdqLSESx6WKw/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-mSj-R81XK1U/TxaIL6puqjI/AAAAAAAAC6Q/UZEPgelxbLY/s1600-h/clip_image013%25255B4%25255D.jpg"><img title="clip_image013" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image013" src="http://lh5.ggpht.com/-UXzEgiRRUW8/TxaINZCZZUI/AAAAAAAAC6Y/taNWaAi8xQg/clip_image013_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-SsSnore3TM0/TxaIN8A56yI/AAAAAAAAC6g/HM6sVW5SIr4/s1600-h/clip_image014%25255B4%25255D.jpg"><img title="clip_image014" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image014" src="http://lh3.ggpht.com/-zNYekrr5ZOk/TxaIPXHPTJI/AAAAAAAAC6o/UGeMj2AsmSo/clip_image014_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-44ww8r1ChTU/TxaIQX-cHcI/AAAAAAAAC6w/niYj1VsHKpw/s1600-h/clip_image015%25255B4%25255D.jpg"><img title="clip_image015" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image015" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHSvus9eLglQAR-LVCD2MhuqTfMMHrG7RxVyHBhKuQoV_UawNZzrzQ3jGqnsxwUxcwPaCRaGs4l4w50k2o8U79popYZSyxhor0Wk8aS6TNW3oFfyF68TWcaFllMs0ylg-lwooVLgL_gyU/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-MlOIBwS83HY/TxaISereiLI/AAAAAAAAC7A/u3q7R4L50-M/s1600-h/clip_image016%25255B4%25255D.jpg"><img title="clip_image016" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image016" src="http://lh5.ggpht.com/-xWstgSgj1eE/TxaIT-d3kFI/AAAAAAAAC7E/Xnp72o0VuPw/clip_image016_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcN5v9wM48wCmUOEt5Rs__hIzAkATerTHvj0EXWpCItnn2V-S8_IiqI1zNqDTixeCcyT11-yFWlRKfEa5wBLLRKoPalS9RtA_n9A12XyntT9pDa76bvKvGQzzpI7NKMBAp9gpqW2D-PI4/s1600-h/clip_image017%25255B4%25255D.jpg"><img title="clip_image017" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image017" src="http://lh3.ggpht.com/-3rXTba0UoOU/TxaIVxl9ceI/AAAAAAAAC7Y/RLz5oHx7Yug/clip_image017_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-PWouWyWiCTM/TxaIWkWJXBI/AAAAAAAAC7g/iO3Q47gv8i4/s1600-h/clip_image018%25255B4%25255D.jpg"><img title="clip_image018" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image018" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1xAjrFlVxani0rIpDYUGXuWQiVpuBybN8VH5nzqMjw3vc8RSd21cdBoGPo2kYhcd0qlibPpPOWDFisNBfhKpFZurU_N_WQC4z8YbYzSD4KnROQoVBkgiLZd8Owsn4vapayWdA4UuJELQ/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-5WV4aB9rJJs/TxaIYg0edJI/AAAAAAAAC7w/nVHbYRUz0Sc/s1600-h/clip_image019%25255B4%25255D.jpg"><img title="clip_image019" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image019" src="http://lh4.ggpht.com/-9L7tIohLBUc/TxaIZ2ceGYI/AAAAAAAAC74/SvQnrfa0bfs/clip_image019_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-ua62jd5Bw4g/TxaIcDWoI3I/AAAAAAAAC8A/NvVELXLd3mo/s1600-h/clip_image020%25255B4%25255D.jpg"><img title="clip_image020" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image020" src="http://lh6.ggpht.com/-NYJamMnmhPE/TxaIdAOf5QI/AAAAAAAAC8I/_9pZvm-UmFs/clip_image020_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-JEPcZYQfCy4/TxaIeYkcVPI/AAAAAAAAC8Q/75Py5-F4rfY/s1600-h/clip_image021%25255B4%25255D.jpg"><img title="clip_image021" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image021" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6O5eq-LS2IVUc-eh6TsWuJr8TEvi0CRh22Nte5IbEnbPaCJTo36KM3RAw2QE6VfNzRe8XsZ5PMWmDWGFLE6BX5ldy0M-02xez1n5kvRTBg_yE8enExmvHTaAtIO08pZytFXh1s6i9a6Y/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-OGP7zDE_94I/TxaIgU00juI/AAAAAAAAC8g/WtEBeFrhX7M/s1600-h/clip_image022%25255B4%25255D.jpg"><img title="clip_image022" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image022" src="http://lh3.ggpht.com/-hgYRXyQ4ygQ/TxaIh3gtkDI/AAAAAAAAC8o/y6JD3cAwFuY/clip_image022_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-VPpB1jY97R8/TxaIihajf6I/AAAAAAAAC8w/9gXnXLnHzQw/s1600-h/clip_image023%25255B4%25255D.jpg"><img title="clip_image023" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image023" src="http://lh5.ggpht.com/-gn8LvCsUme4/TxaIjz-fTGI/AAAAAAAAC84/l8RGNbqtynE/clip_image023_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-Uis3StUCyXY/TxaIk1Rc0CI/AAAAAAAAC9A/ECTK4JXmfD4/s1600-h/clip_image024%25255B4%25255D.jpg"><img title="clip_image024" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image024" src="http://lh4.ggpht.com/-YbusZU6jBVk/TxaImJI5tKI/AAAAAAAAC9I/Nxy73t9rcq8/clip_image024_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-hbTyqI3aDGU/TxaIm1_NRDI/AAAAAAAAC9Q/6Ic6l_kqJ6M/s1600-h/clip_image025%25255B4%25255D.jpg"><img title="clip_image025" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image025" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjXscq0tgc02K-4dt3loRmHn0EvpAwPLyyNrKu_Klz1efIztJcfPLJ2dMeiMu40DYUDoMdwIdKDXwrY3vLMZukO2pwIie_yj2nOy-8b7Ni72_WVfltoT_UM_vDSI1eIkcx39lVPrpes9Q0/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-X8KnQbvDuqo/TxaIpkBUMTI/AAAAAAAAC9g/4g8jKnAf7Go/s1600-h/clip_image026%25255B4%25255D.jpg"><img title="clip_image026" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image026" src="http://lh3.ggpht.com/-2jkJsIr5-po/TxaIqcl7_VI/AAAAAAAAC9o/96PWcWJNwTM/clip_image026_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgXHA3BaI7m9vsKL9SIwzZYAhLWrua4LmF7X3bfMzXQMQfU1Q_3_DILpOwfI2Eqe_pvSM8DQUWiq3liALj8Hd5vwBE0W6peaPYoWShShf_bnf65hbLSNt_WO5LEPhbQb1UAMwhnzH22Hvk/s1600-h/clip_image027%25255B4%25255D.jpg"><img title="clip_image027" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image027" src="http://lh6.ggpht.com/-Xc6zvnBEmzs/TxaIs_T4BSI/AAAAAAAAC94/Yzdna90Rrac/clip_image027_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRI9FnM3dzkpvkKTNHtmI9XT7gINwLnmaf5M2ahCI7am9PJLGolMdvgTdMLTRYgern8R3CXKoyLURIVSVUaZxg0Fqks4ni8rSDcXXixv8P5HRkZc_vwZcY7QILzrYolCNkjYbDpk8tYe4/s1600-h/clip_image028%25255B4%25255D.jpg"><img title="clip_image028" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image028" src="http://lh6.ggpht.com/-2Zt24hAQyuU/TxaIuJhXGPI/AAAAAAAAC-E/Vt53nPhE2eA/clip_image028_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk8qHsgtJ4B9lg-wQrwG1cvm81MQmJzRzTA79F-eJizKxC44lffF0RkyVcn4mtvos_E-M1P7hL9nBV6tmjiUllWUzkhGPfsFpyIXQKU9_hGnLS3LZv3bQPysgWuyypHCs6Tf0F9JsUWn0/s1600-h/clip_image029%25255B4%25255D.jpg"><img title="clip_image029" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image029" src="http://lh5.ggpht.com/-Eoz6kMO107s/TxaIwFqi_fI/AAAAAAAAC-Y/CPBPCGRW7v4/clip_image029_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-WmVPT1U1FCg/TxaIxM3fNQI/AAAAAAAAC-g/ZeEjPBTm03w/s1600-h/clip_image030%25255B4%25255D.jpg"><img title="clip_image030" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image030" src="http://lh6.ggpht.com/-nkqCyfXHfsU/TxaIyf3yVGI/AAAAAAAAC-o/FRXkZupBu-M/clip_image030_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-sCIAI2mpEPQ/TxaIzJwHUII/AAAAAAAAC-w/LVXBa8DB6D8/s1600-h/clip_image031%25255B4%25255D.jpg"><img title="clip_image031" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image031" src="http://lh5.ggpht.com/-8_JhWSyCo9Q/TxaI0Y09bEI/AAAAAAAAC-4/JnPe_7KQAEQ/clip_image031_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-YKvXs9ik1dE/TxaI1SWhvMI/AAAAAAAAC_A/e9ytg8gkZyU/s1600-h/clip_image032%25255B4%25255D.jpg"><img title="clip_image032" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image032" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR7RXqkx7VmnKrTulZQT1AvEQo4zENozfnwgD8j7nND6-YMIUoWJPISceM6rk7JHGhKtZ03GzmAP3yxSv1o3YOuD8FLZv2ID2td5me7_zy93L_AST4n-PaIJEhMJhU1VDMeHIQGXXOuFg/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-2nH2Wbgu4BQ/TxaI3-j68oI/AAAAAAAAC_Q/x87CPanzjfs/s1600-h/clip_image033%25255B4%25255D.jpg"><img title="clip_image033" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image033" src="http://lh5.ggpht.com/-Oz2mM4UaNac/TxaI5Uct5FI/AAAAAAAAC_Y/mJZvwXzW4PA/clip_image033_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-qrSFl82csQI/TxaI6IPdeDI/AAAAAAAAC_g/uYn7X1CU_B4/s1600-h/clip_image034%25255B4%25255D.jpg"><img title="clip_image034" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image034" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix1MdK-LSr7bcataegihjzj4ZEPuKeQKBj4LmTqGk0jH5LHxuesqLXzk86OoH1mdrZOvO7eK1VBEPUr9JcQF7KpcwpoHZTjZg5rNb9TA62TqAnIL2n___Y4VF897tm74R83xlKSb8MSJo/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-qsSGtWrzIjY/TxaI9a2Iw5I/AAAAAAAAC_w/uS_yFxY3TlE/s1600-h/clip_image035%25255B4%25255D.jpg"><img title="clip_image035" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image035" src="http://lh6.ggpht.com/-ZkDo2f-Em64/TxaI-eoemgI/AAAAAAAAC_4/j175Wz0osxs/clip_image035_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-9JD6XOHyIQA/TxaI_FW-dlI/AAAAAAAAC_8/lWO2Sr9jMos/s1600-h/clip_image036%25255B4%25255D.jpg"><img title="clip_image036" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image036" src="http://lh4.ggpht.com/-DT1FrG4Iltk/TxaJABv9WPI/AAAAAAAADAI/zfNlZZy_XDU/clip_image036_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-B_EL4MVXDH8/TxaJB-yPSwI/AAAAAAAADAQ/vpUhDHNY9RM/s1600-h/clip_image037%25255B4%25255D.jpg"><img title="clip_image037" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image037" src="http://lh6.ggpht.com/-s4eNXJ8IPIY/TxaJCYemzHI/AAAAAAAADAY/KID6a428vug/clip_image037_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-hy5cnPq89cA/TxaJDYKOnPI/AAAAAAAADAg/9cjWftHph_c/s1600-h/clip_image038%25255B4%25255D.jpg"><img title="clip_image038" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image038" src="http://lh4.ggpht.com/-NeckA76EvqI/TxaJEs6ndGI/AAAAAAAADAo/Qch-0MsWTWU/clip_image038_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-qZmUvlATPG0/TxaJFf8AJ7I/AAAAAAAADAw/wlclld-5mV4/s1600-h/clip_image039%25255B4%25255D.jpg"><img title="clip_image039" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image039" src="http://lh4.ggpht.com/-VoVpRJodlZ4/TxaJGzSOGHI/AAAAAAAADA4/6PbpGYDAUto/clip_image039_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-zdjh_JAlXC8/TxaJHaTq-aI/AAAAAAAADA8/yyaRLzHNAeI/s1600-h/clip_image040%25255B4%25255D.jpg"><img title="clip_image040" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image040" src="http://lh4.ggpht.com/-vm_UusdQeo4/TxaJJXb4H4I/AAAAAAAADBI/KRRxIctCDSA/clip_image040_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-1cb1h2en7Zc/TxaJJ47QN8I/AAAAAAAADBQ/o155hPupNlY/s1600-h/clip_image041%25255B4%25255D.jpg"><img title="clip_image041" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image041" src="http://lh4.ggpht.com/-BexNhRXg3cU/TxaJLEKdbNI/AAAAAAAADBY/IJtZtOnUARI/clip_image041_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-u5FWNq0Mrww/TxaJMB5cNEI/AAAAAAAADBg/BBAVDCCdoTs/s1600-h/clip_image042%25255B4%25255D.jpg"><img title="clip_image042" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image042" src="http://lh5.ggpht.com/-r7lxFVoHjbI/TxaJNFmuUVI/AAAAAAAADBo/ues-olb6ZOk/clip_image042_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-9CpF67Wrhc8/TxaJN7uBBNI/AAAAAAAADBw/6vsV5_L5r48/s1600-h/clip_image043%25255B4%25255D.jpg"><img title="clip_image043" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image043" src="http://lh3.ggpht.com/-ISnmne_8fQc/TxaJPBJQzeI/AAAAAAAADB4/81mKcEJ3wZI/clip_image043_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-VStWfdA8rqA/TxaJP2DQyOI/AAAAAAAADCA/8adOxqN_wnk/s1600-h/clip_image044%25255B4%25255D.jpg"><img title="clip_image044" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image044" src="http://lh5.ggpht.com/-LD80AVXWE1g/TxaJRC2GWFI/AAAAAAAADCI/k2NAvFHTkGU/clip_image044_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-OfxsjSsgxuw/TxaJRilFDtI/AAAAAAAADCQ/m4v1VIInrHI/s1600-h/clip_image045%25255B4%25255D.jpg"><img title="clip_image045" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image045" src="http://lh6.ggpht.com/-LdiKnIYMs-s/TxaJTL7TEVI/AAAAAAAADCY/hdIOkBCUB2o/clip_image045_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-i4uIkGrxXps/TxaJT0GO4PI/AAAAAAAADCg/kMwBtbV3lds/s1600-h/clip_image046%25255B4%25255D.jpg"><img title="clip_image046" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image046" src="http://lh3.ggpht.com/-Kbl_rHnea_8/TxaJUxClZiI/AAAAAAAADCo/OAWfDUNpLck/clip_image046_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-nvA8s-k3Afk/TxaJV58uekI/AAAAAAAADCw/VSrjWwbwnms/s1600-h/clip_image047%25255B4%25255D.jpg"><img title="clip_image047" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image047" src="http://lh6.ggpht.com/-QWJdbladFZQ/TxaJXRiO8kI/AAAAAAAADC4/_tOfcQAiqdA/clip_image047_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-ooPciEzwwg0/TxaJX3x5XkI/AAAAAAAADDA/CPgUkrZr13s/s1600-h/clip_image048%25255B4%25255D.jpg"><img title="clip_image048" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image048" src="http://lh3.ggpht.com/-xKmz5h6o6n4/TxaJZGX4nSI/AAAAAAAADDI/o1qyPaOf1dw/clip_image048_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-2APTmq_qIv0/TxaJaNvr_UI/AAAAAAAADDQ/WYoG1ETyaI8/s1600-h/clip_image049%25255B4%25255D.jpg"><img title="clip_image049" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image049" src="http://lh4.ggpht.com/-YiaNyCrt6RA/TxaJbI1BjDI/AAAAAAAADDY/GvX_KOTwxy4/clip_image049_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-XNig9HzKq0w/TxaJcITgkWI/AAAAAAAADDg/l8Gh4mqgL38/s1600-h/clip_image050%25255B4%25255D.jpg"><img title="clip_image050" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image050" src="http://lh6.ggpht.com/-RyPuueZNMmY/TxaJdq7dBXI/AAAAAAAADDo/AQHpdAuy-lc/clip_image050_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYl8XVZolMhSDg5R6BMKw42Tfqt3MMIoYc2v0kZep3SMrkYqz4rk-NlAebUfpycODMdwsWmsitEVMoKkT4v4IZr45uBIIF2E8gNPdtpgeF-kIrBXGU26BRrHlZZtURhnqcZCPGU8NvsAM/s1600-h/clip_image051%25255B4%25255D.jpg"><img title="clip_image051" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image051" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQg31KlIBllmK3ZU6-qX0Q-h-ZsdDCQYSVzDSw-9sdGaxMvrkxeZ0FE__lRkmbCy6mFzfjdzMjHe_GQat6kW1gSKiMN3Rw2n3mI3OEt8A2W6qija8VtX3Mc3hWZziTkKjobVn6ZXOehHI/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-GVeeGxS3FXE/TxaJg-rKLfI/AAAAAAAADEA/Rgd8FweQXgE/s1600-h/clip_image052%25255B4%25255D.jpg"><img title="clip_image052" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image052" src="http://lh3.ggpht.com/-dhnGk2u3mic/TxaJh5ipS8I/AAAAAAAADEI/X3GA2qUOIlw/clip_image052_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-qN8wMm14NWY/TxaJisRpBJI/AAAAAAAADEQ/lPzt99TZ0N4/s1600-h/clip_image053%25255B4%25255D.jpg"><img title="clip_image053" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image053" src="http://lh3.ggpht.com/-yWvUmmCQ56E/TxaJj7C5ThI/AAAAAAAADEY/xucXPBSh2Fc/clip_image053_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-63aTscZJ_5I/TxaJkn-gRzI/AAAAAAAADEg/Gu1Lqm7l904/s1600-h/clip_image054%25255B4%25255D.jpg"><img title="clip_image054" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image054" src="http://lh3.ggpht.com/-Seg1TOorzuM/TxaJmHxUSqI/AAAAAAAADEo/5cdAQnzu-aA/clip_image054_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-KiY-aAKEWYI/TxaJnALHs7I/AAAAAAAADEw/wtZyoAIO5MQ/s1600-h/clip_image055%25255B4%25255D.jpg"><img title="clip_image055" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image055" src="http://lh3.ggpht.com/-QD4enIBI8yg/TxaJoqnCzoI/AAAAAAAADE4/Dr1IcsPpGIA/clip_image055_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-BIr6c8FInrA/TxaJplecC-I/AAAAAAAADFA/3aM8orbv0_M/s1600-h/clip_image056%25255B4%25255D.jpg"><img title="clip_image056" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image056" src="http://lh6.ggpht.com/-MHfukQ8AXJI/TxaJrFr7a5I/AAAAAAAADFI/I9lvdRc5KVk/clip_image056_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-GhuRDw46xS4/TxaJr3rVOmI/AAAAAAAADFQ/BD4KRGLWy6E/s1600-h/clip_image057%25255B4%25255D.jpg"><img title="clip_image057" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image057" src="http://lh6.ggpht.com/-xwPAZDjcvSw/TxaJtTA2iqI/AAAAAAAADFY/sstg_nHDRdA/clip_image057_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-F91-orFwpOI/TxaJubCNoyI/AAAAAAAADFg/gAyuvsdxlR4/s1600-h/clip_image058%25255B4%25255D.jpg"><img title="clip_image058" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image058" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKBATFoNEJ_p5KZELf8ogA2aerXFwSfi1AEZ8Bu4ZL8kEDI0YcbZddnYkppiWSYqhyphenhyphencW_G4lTG-xCREgr36FiZ3mVEtQVSl32wFhCGATwzertfkydCUDvJPEKX7WhqBoYVTRsyfZpQH5Y/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-g7iiphU70Hg/TxaJwqCKJ3I/AAAAAAAADFw/8MdTB8j0io0/s1600-h/clip_image059%25255B4%25255D.jpg"><img title="clip_image059" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image059" src="http://lh4.ggpht.com/-ioGSoD7wFAk/TxaJyNvdsnI/AAAAAAAADF4/yluCsHcN6kY/clip_image059_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-S4lvA783mE4/TxaJzv9gUGI/AAAAAAAADGA/jFVIcfhL13Q/s1600-h/clip_image060%25255B4%25255D.jpg"><img title="clip_image060" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image060" src="http://lh6.ggpht.com/-ln1VvJHHK0I/TxaJ09Sos7I/AAAAAAAADGI/dXIZZjQdrQo/clip_image060_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-v8rwt_ak-pQ/TxaJ1jWGF0I/AAAAAAAADGQ/2v0CceCSjG4/s1600-h/clip_image061%25255B4%25255D.jpg"><img title="clip_image061" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image061" src="http://lh6.ggpht.com/--uHeihd8wyw/TxaJ3I2rUEI/AAAAAAAADGY/2w1HbJqkPzI/clip_image061_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGa8FczU91NxYxy1o0dOZ1LNAlazLWyd9-lbDULWFQhRcyZROrTmOIFrkSZtvJIgRFCKAAtXJigcDoojOI8CPNgpLoaISS_es2zF8KxkQG1mgkJJjNqet1nU2AdQSSOju9e4r79j7BYo4/s1600-h/clip_image062%25255B4%25255D.jpg"><img title="clip_image062" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image062" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgniTWNyv0bA7O5RvLQ-1s646tp8aoepXIo3bTBE-aw_8uACJ-8W-kLB2OsK4opmCJlc-BAzsNRdyXxNN4hYzHS6yI2mV5XBIMpPzXfepkA28p0dXOVBqBAzwA1LBmv5WwnT58dSe1iNGE/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-1KH1VgDnFOw/TxaJ6EJqcvI/AAAAAAAADGw/oc1sSiiZCQ8/s1600-h/clip_image063%25255B4%25255D.jpg"><img title="clip_image063" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image063" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjR-2Y97zs6_b1O5JR3M0PX5sn_yrnuaWrtxA5sS0YKqPs9cVDQCKC2Jbh2B25Dy2ZwdO6RpN1BSSSgFMqg-9Yd849DJ7WNBnVmbgePfr5YNSekYHeOmfPxqxMPOBP316BJR8ltWtQ1DEc/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-dwI-oKUS868/TxaJ8qT9PyI/AAAAAAAADHA/VpoKj_NXR-A/s1600-h/clip_image064%25255B4%25255D.jpg"><img title="clip_image064" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image064" src="http://lh3.ggpht.com/-UBfoI393dWI/TxaJ9q5am1I/AAAAAAAADHI/gRO6owIol_E/clip_image064_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-ceGAw-nhSg0/TxaJ-ZhkbbI/AAAAAAAADHQ/EnUy2ZShs7Q/s1600-h/clip_image065%25255B4%25255D.jpg"><img title="clip_image065" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image065" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBVlfCX9XndCr7ddNIqkRzTZX8gNBDOwt-y4sM6xVDazbRF9kU33N6X2IJQYY3-eANtlbeZGIa59AmH5GvY2yBsTDV2ND2-fK2j5BeZvZvyQNuwxdBg7eCGcKvBI2xBLrfTrNylu-Os1w/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-wv2EOOFlU50/TxaKAn08XNI/AAAAAAAADHc/JW6mcX-Ql1k/s1600-h/clip_image066%25255B4%25255D.jpg"><img title="clip_image066" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image066" src="http://lh6.ggpht.com/-7ykLvBaiGcw/TxaKBiRFHXI/AAAAAAAADHo/nEsC-E-hgXE/clip_image066_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi914V8deobvlXbs3Eu0fGgZmlkucfeFFOdpajDXYzXkntbIxZZfBWlloL7_G-_vOFQEjYA3bRt4D-nZhPTvDFIZy_zmHSek2E-D0I9mTTU8PybpodvTZ7UviO2-opqzMYTxv6VJtOhkaI/s1600-h/clip_image067%25255B4%25255D.jpg"><img title="clip_image067" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image067" src="http://lh3.ggpht.com/-zjSaFIALU8o/TxaKD3d5jPI/AAAAAAAADH4/AdRZgbcTTDs/clip_image067_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsAJMwlp5g3ZI5qmwOKkB0BQUK6hbjm1qrX0ux_xqWxmYmUHJtF8R_gizzLptqqpJrSiBIm5eoHlCh6ZUexMvxPDvaQj_L_HWnUjtZw0gtsSI52G_UZlrPX_qeoxov4MTWhoq577QM6qI/s1600-h/clip_image068%25255B4%25255D.jpg"><img title="clip_image068" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image068" src="http://lh5.ggpht.com/-iYz88bFNl2A/TxaKF3s7VwI/AAAAAAAADII/yF9xkS8jtIM/clip_image068_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-tTfv4dReK6M/TxaKGj3AM-I/AAAAAAAADIQ/sWGRzYHc6Mg/s1600-h/clip_image069%25255B4%25255D.jpg"><img title="clip_image069" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image069" src="http://lh3.ggpht.com/-a1c1Zry6gMQ/TxaKH9q5yQI/AAAAAAAADIY/GTJ6P9M6NcA/clip_image069_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-47qOcoUutgs/TxaKIRDldyI/AAAAAAAADIg/geymkGHKYlk/s1600-h/clip_image070%25255B4%25255D.jpg"><img title="clip_image070" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image070" src="http://lh5.ggpht.com/-OCE4xRJMn0I/TxaKJzBb5hI/AAAAAAAADIo/dc7VVO5irdM/clip_image070_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-ePH_vGaXxK4/TxaKKiJIJcI/AAAAAAAADIw/foNUBt644B4/s1600-h/clip_image071%25255B4%25255D.jpg"><img title="clip_image071" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image071" src="http://lh5.ggpht.com/-qbGnICeuFbk/TxaKMUIBEtI/AAAAAAAADI4/4oQWKnMPp7M/clip_image071_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-_-Yx7c556JA/TxaKM-aSMAI/AAAAAAAADI8/iBN-LiRMSJQ/s1600-h/clip_image072%25255B4%25255D.jpg"><img title="clip_image072" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image072" src="http://lh3.ggpht.com/-7GjRX4AhuF0/TxaKNw89e_I/AAAAAAAADJI/JrMWMDZYir8/clip_image072_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-74721945874825678192012-01-18T00:34:00.001-08:002012-01-18T00:34:36.913-08:00BASIC for PIC microcontrollers Book Part2<p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUdn0JAfpaYyqzkr3qI9IQ51X-mqQENykDuVjMGc2EHHuBE-cDUSzp3ZrjH87F_fpPAzs-fni1aj1FHLYTaVMG6YOzrzNgTekH-_Q79afBZBvbnWHyd8JoYIjILPfYpYRk-_o_R9Xx93g/s1600-h/clip_image001%25255B4%25255D.jpg"><img title="clip_image001" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image001" src="http://lh5.ggpht.com/-C-92oglob7M/TxaCX1qvLfI/AAAAAAAACq4/zCunbN0uoPI/clip_image001_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-5hyDCeiq4B4/TxaCZDKkMWI/AAAAAAAACrA/wLuQ_22qhA8/s1600-h/clip_image002%25255B4%25255D.jpg"><img title="clip_image002" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image002" src="http://lh4.ggpht.com/-PXZynfZgiR0/TxaCaLWN7oI/AAAAAAAACrI/8JeALrzt5So/clip_image002_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-GnOcBp90QoE/TxaCbLvN1NI/AAAAAAAACrM/ObHiGIECe74/s1600-h/clip_image003%25255B4%25255D.jpg"><img title="clip_image003" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image003" src="http://lh6.ggpht.com/-9NKmIWKNc1w/TxaCcJtjMHI/AAAAAAAACrY/e581dRgvTYQ/clip_image003_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-fNxAWw0g0kw/TxaCc70YAxI/AAAAAAAACrg/XLwnFDTQ2-4/s1600-h/clip_image004%25255B4%25255D.jpg"><img title="clip_image004" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image004" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi415z-gvDWHwHb_bp_F6-WrPYNYW_n9F_Ghdcd_efdBhxxnfW256rdzoKdFKviNvX1i9mFT7OeyQ28vwzGy1QluvBLkwcZU84Z7mBTvHK3Qkb4Q1pOylpPuDHj9rWxeVgbSI0GDvkbfZo/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-EpLzCFy2Ruc/TxaCfMx1rCI/AAAAAAAACrw/_7YNn4tKT84/s1600-h/clip_image005%25255B4%25255D.jpg"><img title="clip_image005" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image005" src="http://lh3.ggpht.com/-qmgcdmb5dNI/TxaCgoxKfBI/AAAAAAAACr4/oQyB3Kd73cI/clip_image005_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-5ldJ3trzZok/TxaChQBfyWI/AAAAAAAACsA/KxuPfs8GPtw/s1600-h/clip_image006%25255B4%25255D.jpg"><img title="clip_image006" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image006" src="http://lh4.ggpht.com/-Ot6z2Xcv-J0/TxaCi4ZCTEI/AAAAAAAACsI/SX8TUhQSo-8/clip_image006_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-rYdss3Rfw4U/TxaCjd_vIlI/AAAAAAAACsM/ROqa59_TSCg/s1600-h/clip_image007%25255B4%25255D.jpg"><img title="clip_image007" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image007" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0QZpQNTdKTDqtr4BB5-bIVm5DB1Ld-EHHBcWVS18IZgNkWDC0yxqQ35MMU-U6HXmKjiJPDnx_8Ccto2VBFY2S83Zi075gAatp9sAph-04wDO_jQMe0Bqyior_L_oUuY7BeKasLSZhbAc/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-LJf1__a2N8Q/TxaCmLsiFHI/AAAAAAAACsg/_pxDAZsII1c/s1600-h/clip_image008%25255B4%25255D.jpg"><img title="clip_image008" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image008" src="http://lh4.ggpht.com/-d8OvpInWDIk/TxaCnXP84eI/AAAAAAAACso/38Y7iUF-ZDU/clip_image008_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-lGbyZnNLO-c/TxaCoPadi-I/AAAAAAAACsw/ViJBFQohqVU/s1600-h/clip_image009%25255B4%25255D.jpg"><img title="clip_image009" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image009" src="http://lh3.ggpht.com/-rg7AFJkOYiA/TxaCpbnfzSI/AAAAAAAACs4/8LUJcUuXdF4/clip_image009_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-4Dr-PjEhB68/TxaCqDwWDTI/AAAAAAAACtA/XsrYoR6dq8Q/s1600-h/clip_image010%25255B4%25255D.jpg"><img title="clip_image010" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image010" src="http://lh5.ggpht.com/-Dv89ovqCFfw/TxaCrOsSvkI/AAAAAAAACtI/8JgdwMr31yU/clip_image010_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-_H3HIZjbgpk/TxaCsU0nqfI/AAAAAAAACtQ/FXmuEQWDRWQ/s1600-h/clip_image011%25255B4%25255D.jpg"><img title="clip_image011" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image011" src="http://lh6.ggpht.com/-9jjgjBtKXwQ/TxaCuBg7YuI/AAAAAAAACtY/wvs3QO8n4K4/clip_image011_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-QL1_rA1BZi0/TxaCupBRT_I/AAAAAAAACtg/TjFaAIqStE4/s1600-h/clip_image012%25255B4%25255D.jpg"><img title="clip_image012" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image012" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUx8yO0UtZD21A340FnRWs5Wv6dXYjiQtBM9dgNrEPo03HudShMdTsmiqrA8tmT8RQSy4qpuuBn1_UpHidKo-VXp694Ti7m_Bf9lCxz4RiHfWX8ewbwC_uNguHmo2kaDYcs2NmT-LohW8/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-iYpth9R0kWc/TxaCw62jPCI/AAAAAAAACtw/zrkCKm3EHek/s1600-h/clip_image013%25255B4%25255D.jpg"><img title="clip_image013" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image013" src="http://lh6.ggpht.com/-O81cCtBMHow/TxaCyc9-b-I/AAAAAAAACt4/5CuK4yYCpNY/clip_image013_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-ZF-OKabo-x0/TxaC0JUa6BI/AAAAAAAACuA/gP7IKSLUygo/s1600-h/clip_image014%25255B4%25255D.jpg"><img title="clip_image014" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image014" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhamqLtTeypihYsY2NMYjaaAMxdanTvE_z3bCWlhtGDl-4CyqJ1qC-2Ynwv37qCnlrmU4U7HcyYsXiZ9bUAHacoZZ_Y-Xem5oBiMlX9YrEsfeIX_1LuCI3sNZUFmIdYDfLC_nhEbalnqvI/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-GTwyXNPCx-o/TxaC1zdoTjI/AAAAAAAACuM/0DfLJtDhiRM/s1600-h/clip_image015%25255B4%25255D.jpg"><img title="clip_image015" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image015" src="http://lh3.ggpht.com/-fbddlASXYkU/TxaC2w9ZX3I/AAAAAAAACuU/54AaBVlNUjI/clip_image015_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-_I7i86ZURpE/TxaC3tU9QII/AAAAAAAACug/UsH7TXE6EM8/s1600-h/clip_image016%25255B4%25255D.jpg"><img title="clip_image016" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image016" src="http://lh5.ggpht.com/-YSmmEAVGY_0/TxaC5FyywyI/AAAAAAAACuo/0GhbMkjC3vw/clip_image016_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-GBKXbeZ5aIs/TxaC5olqBkI/AAAAAAAACuw/-snM0hyg4FE/s1600-h/clip_image017%25255B4%25255D.jpg"><img title="clip_image017" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image017" src="http://lh4.ggpht.com/-mCgbqRJRgA4/TxaC61PmizI/AAAAAAAACu4/lm4KAWNN2DI/clip_image017_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-cXNVYaups50/TxaC77oEk1I/AAAAAAAACvA/uTIhI9D7Gjc/s1600-h/clip_image018%25255B4%25255D.jpg"><img title="clip_image018" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image018" src="http://lh6.ggpht.com/-0ZBajMt4KT4/TxaC9QHSk9I/AAAAAAAACvI/kJdQ9aOOjxc/clip_image018_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-1MqJEX4dd2M/TxaC-UsMUBI/AAAAAAAACvQ/e4S6YTr8fVs/s1600-h/clip_image019%25255B4%25255D.jpg"><img title="clip_image019" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image019" src="http://lh4.ggpht.com/-D-STbiFmmXU/TxaC_X4o9mI/AAAAAAAACvY/yK-CmGWufPA/clip_image019_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8DLtdxTd57NLywxJkg34A_j8xb8_jCtwxh4yfn1BHdPqFkMwmTyAiFGjjZCw3aMObxVRN5FdWOMRfodJREaz3kIl5iHXWKG_FGZLcSObbA9QCua9-XHDNxNkNrS4gPIueZu5bsg16ZgI/s1600-h/clip_image020%25255B4%25255D.jpg"><img title="clip_image020" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image020" src="http://lh5.ggpht.com/-n5JFvDKWOnc/TxaDBnZEa9I/AAAAAAAACvo/TmhlDgIiNVE/clip_image020_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhC3dL11jyfh0PiITT4hD8c1lpfgPz9H6HmPU2hmBVj8RGKYyipuCX8ZAhuwC2wF2q0L02qwrRAdmqEqnw31dNYX_W_2u7_m3QVQESnG_EBTR61QlnfTYXVN_5_BawVKOqMULV4JkSyTxw/s1600-h/clip_image021%25255B4%25255D.jpg"><img title="clip_image021" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image021" src="http://lh6.ggpht.com/-XMpUCoaxejg/TxaDDd0CSSI/AAAAAAAACv4/P0qSTsAFRRE/clip_image021_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkkPQJphbWAcBo49CNWWy2qrYbK4Hf9zQ2s2W3qGB-yIT8R8LKE5y-h5dZFnrgemoC8QRSCeTjQZlW26mXFEPQPRn7PQcNOf2ep7poyqgoPteEEyDNaarPT1Lzdbh37wIrumX3Pan2CM0/s1600-h/clip_image022%25255B4%25255D.jpg"><img title="clip_image022" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image022" src="http://lh4.ggpht.com/-udmUFyikb7E/TxaDFpdrzhI/AAAAAAAACwI/PgY3V6b8IRE/clip_image022_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-OmZoOF__A8I/TxaDGSm_V3I/AAAAAAAACwQ/WQH0tttSHkk/s1600-h/clip_image023%25255B4%25255D.jpg"><img title="clip_image023" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image023" src="http://lh5.ggpht.com/-BCwcYJ1Wrd8/TxaDIek5CFI/AAAAAAAACwY/I3fuM135BQw/clip_image023_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-ZUawdQ9GSpo/TxaDI75-HTI/AAAAAAAACwc/G2bnkM1Zwj0/s1600-h/clip_image024%25255B4%25255D.jpg"><img title="clip_image024" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image024" src="http://lh5.ggpht.com/-X58MwqwJP0I/TxaDJ4cXqUI/AAAAAAAACwo/tI0fY-osx9k/clip_image024_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-dVOnNNArFJU/TxaDK2QpcaI/AAAAAAAACww/SwD3MJdTI9M/s1600-h/clip_image025%25255B4%25255D.jpg"><img title="clip_image025" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image025" src="http://lh4.ggpht.com/-q1t723XV9uI/TxaDMDWJctI/AAAAAAAACw4/NKN-rAh6XGM/clip_image025_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-tIco9gj4x_A/TxaDMwLyjcI/AAAAAAAACxA/G9fnUrtH2hI/s1600-h/clip_image026%25255B4%25255D.jpg"><img title="clip_image026" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image026" src="http://lh6.ggpht.com/-vHMUUgmdeRo/TxaDOYpyD1I/AAAAAAAACxI/itAgI3TzAQM/clip_image026_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-XRkq5BoPBv8/TxaDPv0sL5I/AAAAAAAACxQ/qNMC1QcGkI0/s1600-h/clip_image027%25255B4%25255D.jpg"><img title="clip_image027" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image027" src="http://lh6.ggpht.com/--b38NM2S3sw/TxaDQoFtLJI/AAAAAAAACxY/3TZTZCPUWQE/clip_image027_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-U0-DjtSd2j8/TxaDRXcL75I/AAAAAAAACxg/LdWKEed4zsI/s1600-h/clip_image028%25255B4%25255D.jpg"><img title="clip_image028" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image028" src="http://lh6.ggpht.com/-UIhW89G7nVg/TxaDS59s4NI/AAAAAAAACxo/686Mv0z3kIQ/clip_image028_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-LIGhGAK5-BE/TxaDThG4RaI/AAAAAAAACxw/WiK8sayHZVQ/s1600-h/clip_image029%25255B4%25255D.jpg"><img title="clip_image029" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image029" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfydwPEIlGQO3a2AADN1pNXGxFTr57z0RnJzUj1TzNi_6V7FkbLim-oaNH4jJj5cWOS88Ixx85-L_zT7b42_ay9UNj5e3kg1SWX2VaQNutu46o3ghkIqsM3z4Bd82JnkV9hxgJYiBGFco/?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiqkhlJJQ26QQJvBg0ap46HyRg6-5T0vDzmWV5QtleT0blL8QFMLV4w9n6Q2s2zV9BhcWqHi-2c3hzdwpZZcROmdZQilIEUFbKq3RvH_MUHk1lKBIACaPnuCQIqeDYYTYGGZxybZaFtG1I/s1600-h/clip_image030%25255B4%25255D.jpg"><img title="clip_image030" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image030" src="http://lh4.ggpht.com/-gkAhtXRPzSo/TxaDXe6AOPI/AAAAAAAACyI/Qzfs02IJc54/clip_image030_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-F84BNqWsrlQ/TxaDYAOxnLI/AAAAAAAACyQ/YV4jzj5sTyU/s1600-h/clip_image031%25255B4%25255D.jpg"><img title="clip_image031" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image031" src="http://lh5.ggpht.com/-qBEvbdgVv0o/TxaDZUlhI3I/AAAAAAAACyU/Lj4W-_gJpv8/clip_image031_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhKRGnf_6DmQAuf_jQyo6XIa9RgkNBlYIHXbtTa42EUpvzhfRtK_NzfH-vTipl2UcGovSk1J6t5Li5l2_PsND2rqfzGk11DFoWq7KP_IDgalSrQVmf2G2MMGPbsZlTOp3FrSybS3BZx2Y/s1600-h/clip_image032%25255B4%25255D.jpg"><img title="clip_image032" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image032" src="http://lh5.ggpht.com/-TrXcDSSWXBA/TxaDc-4TFZI/AAAAAAAACyo/YhaHZ2c0lKw/clip_image032_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/--s615sF6Wcs/TxaDen41AUI/AAAAAAAACyw/9h2f7Sj15YM/s1600-h/clip_image033%25255B4%25255D.jpg"><img title="clip_image033" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image033" src="http://lh4.ggpht.com/-HDnC4owNLoA/TxaDggdTlOI/AAAAAAAACy4/RbOdKhQ_Ibc/clip_image033_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-xKiN2kccOQ4/TxaDhXUVIUI/AAAAAAAACzA/b3cB_1PK-oU/s1600-h/clip_image034%25255B4%25255D.jpg"><img title="clip_image034" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image034" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifyeoUXzZ57kS56t9wnQ-QujhEIN0B7tpyUs4ACxXhVCf5JqD6_B6UStNzlpaTuNQx6mB4gaV-17A02i1HLt2H2ixFkk6W8t-yWEANo3Qyf6QFjFKI5PDl_mKgyFC6gQ4zuG9yN7owz8A/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-qcICC2JEa-M/TxaDlAwX-2I/AAAAAAAACzQ/DjgmgGYUVag/s1600-h/clip_image035%25255B4%25255D.jpg"><img title="clip_image035" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image035" src="http://lh6.ggpht.com/-_9MrLwMeSAA/TxaDmTa291I/AAAAAAAACzY/ILV-bVa2Gqs/clip_image035_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-cY1qYKuL-qQ/TxaDnD-bfBI/AAAAAAAACzg/wi1BUobnzNQ/s1600-h/clip_image036%25255B4%25255D.jpg"><img title="clip_image036" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image036" src="http://lh3.ggpht.com/-g3zToyo3zDc/TxaDojiGjGI/AAAAAAAACzk/goZqrxhsWyw/clip_image036_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-HDL_F7lfwaQ/TxaDpdwhppI/AAAAAAAACzw/r5AGEDem14I/s1600-h/clip_image037%25255B4%25255D.jpg"><img title="clip_image037" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image037" src="http://lh5.ggpht.com/-9TZrcUn_ttQ/TxaDrX0VY8I/AAAAAAAACz4/anqSZDF9PIM/clip_image037_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-mxI7XML3jHw/TxaDsHiLrxI/AAAAAAAAC0A/mbO8--I2_Wo/s1600-h/clip_image038%25255B4%25255D.jpg"><img title="clip_image038" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image038" src="http://lh4.ggpht.com/-mFAhxcbYFUc/TxaDtfxoZOI/AAAAAAAAC0I/0FnrdHYxLvk/clip_image038_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-Jm8eIWXwpcY/TxaDuKriQGI/AAAAAAAAC0Q/XAePWI5M0sI/s1600-h/clip_image039%25255B4%25255D.jpg"><img title="clip_image039" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image039" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMjHQbMtWeJLWIBl7rBSRwnSoZqFvT_9gztJr5RLz5apFlocl3YamrRRVAipO9MrOFNn49yDGbD0h11zGkqk3oKlUUHWzWqqUJU-kVuazhRdT5A3U_qVJZJ4szI6dctEFYqI6qjMYNNL0/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-qhhoww40ibg/TxaDwQEFEhI/AAAAAAAAC0g/_FaJC0AMNBw/s1600-h/clip_image040%25255B4%25255D.jpg"><img title="clip_image040" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image040" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgNUNJhl-zeMVKbHzAcB1pImKeEBqfiq39_FbU07fcvqw7KWdZWVgzHcw5PP0vGNtSQ-E25Turk61Vbi15DUelFpZHb3w3GeVc7n5nWHRM6mhurKMMaorTCL7JKXsI6Ak_n27AfsV6OsGo/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-OU9JErkzYuY/TxaDynRTxAI/AAAAAAAAC0w/2Ix3Zekys08/s1600-h/clip_image041%25255B4%25255D.jpg"><img title="clip_image041" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image041" src="http://lh5.ggpht.com/-H2t66qyH_IE/TxaDz7VPuCI/AAAAAAAAC04/2rfTLS_ghHs/clip_image041_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-ky_Z7yfxwmQ/TxaD0uAPjWI/AAAAAAAAC1A/ZN6sabA8R5Q/s1600-h/clip_image042%25255B4%25255D.jpg"><img title="clip_image042" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image042" src="http://lh3.ggpht.com/-c0i_7wcWVgc/TxaD2KhcgOI/AAAAAAAAC1I/VEFTH5YwqTg/clip_image042_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-YFHZVpO6uMk/TxaD25uOkvI/AAAAAAAAC1Q/BytObcGea3U/s1600-h/clip_image043%25255B4%25255D.jpg"><img title="clip_image043" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image043" src="http://lh3.ggpht.com/-Ni2lgmtMjYE/TxaD4joO61I/AAAAAAAAC1Y/oIUa1-3Fs3g/clip_image043_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-AGlYppfcy0o/TxaD59BdjaI/AAAAAAAAC1g/isLdfX9ksQg/s1600-h/clip_image044%25255B4%25255D.jpg"><img title="clip_image044" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image044" src="http://lh5.ggpht.com/-unYDv3sxE3w/TxaD7H2-RpI/AAAAAAAAC1o/TLJLUQF7qD0/clip_image044_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-EBep2VYTihY/TxaD73nRPHI/AAAAAAAAC1w/p-M57uP3YAA/s1600-h/clip_image045%25255B5%25255D.jpg"><img title="clip_image045" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image045" src="http://lh5.ggpht.com/-jkj_8dWGba4/TxaD9cYdZ-I/AAAAAAAAC14/c3c0zZVVfCA/clip_image045_thumb%25255B2%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-hPpsqSBs5iw/TxaD97yAxcI/AAAAAAAAC2A/nbQB0_V3oto/s1600-h/clip_image046%25255B4%25255D.jpg"><img title="clip_image046" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image046" src="http://lh6.ggpht.com/-BJhLnyFs-6E/TxaD-w3Ei3I/AAAAAAAAC2I/yJTV4ycFnEA/clip_image046_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-v0ut7T2j2aA/TxaD_vr_WSI/AAAAAAAAC2Q/NK8muRHMf7U/s1600-h/clip_image047%25255B4%25255D.jpg"><img title="clip_image047" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image047" src="http://lh4.ggpht.com/-O1cXYw7gkHk/TxaEAnl7IuI/AAAAAAAAC2Y/si4bG9UEc10/clip_image047_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikjXV2XEASml09adh7KDq9UOUZVXj8mCLTz1LjQ3E9eggstGYF4dcoInM3CWi9xwtTGzbar6VtvThslZhEhQ_6mC9f0bItQ5aB8BHWufAL1GuhQqJ3exYdb6Udvoz8297pc6xY3i46GGE/s1600-h/clip_image048%25255B4%25255D.jpg"><img title="clip_image048" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image048" src="http://lh4.ggpht.com/-GyzJeLSvbQA/TxaEChVHvoI/AAAAAAAAC2o/kvJhiNeww7Q/clip_image048_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-P0tlI_Y86Kg/TxaEDUMq-cI/AAAAAAAAC2w/9UNMTlSD6fs/s1600-h/clip_image049%25255B4%25255D.jpg"><img title="clip_image049" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image049" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwIwbXQMC-Ui5KbLClygpCAR-edBtHiMJHIMQ51TNqoWd7mJMchQNiS7LJdDrbD6apWqW8VWk48lEknllJdnmxekTof7SIJp_L398hLkZtp9rxQl3PwI-nOy2S5DX_t1tK5Dh2PXzle64/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-rBN2peLWzDI/TxaEFmpdsfI/AAAAAAAAC3A/Meb-nBelbi0/s1600-h/clip_image050%25255B4%25255D.jpg"><img title="clip_image050" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image050" src="http://lh3.ggpht.com/-0gXAG2fh2YY/TxaEGvGa9jI/AAAAAAAAC3I/YvkPeAkjzQY/clip_image050_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-87522672716111154562012-01-18T00:17:00.001-08:002012-01-18T00:17:47.047-08:00BASIC for PIC microcontrollers book part1<p><a href="http://lh6.ggpht.com/-0myK_p3fmZA/TxZ-an19NyI/AAAAAAAACeQ/xyK_BeemId0/s1600-h/clip_image001%25255B18%25255D.jpg"><img title="clip_image001" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="858" alt="clip_image001" src="http://lh4.ggpht.com/-O-Grmc4Tjus/TxZ-cYVU24I/AAAAAAAACeY/CtTK4t0CXR4/clip_image001_thumb%25255B15%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-nZiGNULuJgo/TxZ-dFLZ7gI/AAAAAAAACeg/IBB-AT9igB0/s1600-h/clip_image002%25255B4%25255D.jpg"><img title="clip_image002" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image002" src="http://lh3.ggpht.com/-tqndgo5DPe8/TxZ-eakzCqI/AAAAAAAACeo/FxFctx2N2iY/clip_image002_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPvub8sUOibgBuBsuhkzjKqDbxBRaAlVhyIys9r3q5YSUnMUaMn359dcG-OuPPAAo_mccjmk1ssxhrSBXvLioY8d7Xxdhmg2Kv_TKnIHfvGBuvIfj5Rzy587Pvy-YycUamUW9Dbv4NznM/s1600-h/clip_image003%25255B4%25255D.jpg"><img title="clip_image003" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image003" src="http://lh3.ggpht.com/-7IHdeLIDQTo/TxZ-ha73gBI/AAAAAAAACe4/1IhOR5wNkL0/clip_image003_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsOuFvNQGXsgIz9hed4tWK_Qc0kpDIvW5wPkD78ah2J4Npr2j59-sSI22YhJic0_ujgU-oVsCia-mQu6yPO4u_NT57HUH_V_fMLlNb4sjnDlvmZz-usoXQ2tDAclmIUCBk_tT1_DpTCkw/s1600-h/clip_image004%25255B4%25255D.jpg"><img title="clip_image004" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image004" src="http://lh3.ggpht.com/-SHrY0rhx5Dc/TxZ-kefvjpI/AAAAAAAACfI/5qTmueiYPkI/clip_image004_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-MiT-3QRDKKM/TxZ-lC4AB9I/AAAAAAAACfQ/kU8vrtb1cAk/s1600-h/clip_image005%25255B4%25255D.jpg"><img title="clip_image005" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image005" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf8RDccN6AcLw6RNe_MHR0aIGqPEoaDJRspZIA5yxupazDf8qBj5m0XwsNLOCPzvhXAoUZs47drJXckdkN83tKOw4VUykyeuQM-q5mkOpHVBbMiGl4hXltlB3EdrH-f9jj8egAyEB4nGc/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/--jCgYdaYmBQ/TxZ-nPi6PZI/AAAAAAAACfg/vX9odGmtUrM/s1600-h/clip_image006%25255B4%25255D.jpg"><img title="clip_image006" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image006" src="http://lh4.ggpht.com/-tbxITbNUbKo/TxZ-pC-9XbI/AAAAAAAACfo/xJNFrJ2cU1w/clip_image006_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOPXzocu2KmbaRjgvUA11fvhCmxI5plwI6HVlSxkqG-9L9xIPfCZM4rvYRwH6o_io3_KByEkdYdv3nRneuAKKPfvdcmPe9Dlv0Joc3Dimj4SBsaGUtHsPX7c4UKa93Zi_AferP0bk6rFM/s1600-h/clip_image007%25255B4%25255D.jpg"><img title="clip_image007" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image007" src="http://lh3.ggpht.com/-P3ZfV9c0YMg/TxZ-rYgjp9I/AAAAAAAACf4/tfZQLwth7ok/clip_image007_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-hcdIICCX9gI/TxZ-sGquxFI/AAAAAAAACgA/Wv0eMQ4JFew/s1600-h/clip_image008%25255B4%25255D.jpg"><img title="clip_image008" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image008" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj70C_yK3rClAb2Gg-WPOtt7_7QY-r3uLerUI02rVtJ1heFALFwziDJrr8g72VUT74ytSp1JBE-yJE4D5gJ3YUcKniJacA9m77c-iLaE7V766mIb46Fj4OXu72grPwtWHlR3_NCCr3PSjo/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-E80UnsNVsag/TxZ-ui5lIuI/AAAAAAAACgQ/xJuLm9J5X24/s1600-h/clip_image009%25255B4%25255D.jpg"><img title="clip_image009" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image009" src="http://lh6.ggpht.com/-0kokUZJFB5o/TxZ-wFMbxRI/AAAAAAAACgY/fTaudg9ZKBE/clip_image009_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-SBhhame8syU/TxZ-wjKw1rI/AAAAAAAACgc/1Hdph38_9Es/s1600-h/clip_image010%25255B4%25255D.jpg"><img title="clip_image010" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image010" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaQpxwBpxz5rkRjMP4xRkiBR3FwJch1hpDoqMT0-670-WFBsbkpQY7bMMPcsjDxXVoIpFWQYYv2gXKXlrm7WzjV_2AcTby-g37_y-7qj0q0Dxl-qTEbN1vlsLHAdzx5QJ4KJm0RK9toZc/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-psu-uFH1vaw/TxZ-yzmtLAI/AAAAAAAACgw/mBmnySRlgKM/s1600-h/clip_image011%25255B4%25255D.jpg"><img title="clip_image011" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image011" src="http://lh5.ggpht.com/-owDQK-F1z6A/TxZ-04SfX9I/AAAAAAAACg4/zgbs4JvkMmQ/clip_image011_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHSKZN-8UHqHFOxefcdl2AegD7MGJ6-_qpVSRo3cCc238ntUhff5Sz2gQ3uqK4l9MT4yUO_Z8BhLOLi9SFrYcstBDjYpConWc-TMzEeIVJQYYwjUJ9l6gwtNYQUoTOfCdXLQTsd-tYt6g/s1600-h/clip_image012%25255B4%25255D.jpg"><img title="clip_image012" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image012" src="http://lh5.ggpht.com/-4zwmC7OJveY/TxZ-3H22OaI/AAAAAAAAChI/iwKNMJzpcYQ/clip_image012_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-FF5hk7JOjQs/TxZ-30jcBHI/AAAAAAAAChQ/Rwu1h9zLQDk/s1600-h/clip_image013%25255B4%25255D.jpg"><img title="clip_image013" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image013" src="http://lh3.ggpht.com/-14oHvj2i-u4/TxZ-5Z4bTfI/AAAAAAAAChY/UNI5mHrmFFs/clip_image013_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIt2Di2fj19SMRMtGTq0cUh2iiZdc2xBFAn6tgQDHwwoqY5gtQ0wvx9zYHi8hsY84gWU8_80dKkCnOOc-ie7oLRJ9SzTwzmc9FX3MgDCccpuakj2IsqE4gTagvwY0Drxm3Zp3MV7FpWjc/s1600-h/clip_image014%25255B4%25255D.jpg"><img title="clip_image014" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image014" src="http://lh5.ggpht.com/-Wi-9o6NJkxI/TxZ-7uScrXI/AAAAAAAACho/VZma4B3ce40/clip_image014_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-P-jdbx7kQfo/TxZ-8h9yfvI/AAAAAAAAChw/jr-uaPY-e_w/s1600-h/clip_image015%25255B4%25255D.jpg"><img title="clip_image015" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image015" src="http://lh6.ggpht.com/-hIpWAxm5eig/TxZ-96Zsf7I/AAAAAAAACh4/VHkLv4G9__E/clip_image015_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-nPPWQNktJcQ/TxZ--mm_ajI/AAAAAAAACiA/LWtGFsK9yrM/s1600-h/clip_image016%25255B4%25255D.jpg"><img title="clip_image016" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image016" src="http://lh6.ggpht.com/-cCw--KzqfTw/TxZ_A7PYK3I/AAAAAAAACiI/7AVY09aYmqw/clip_image016_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-5GzN48jpbOA/TxZ_CA9sNSI/AAAAAAAACiQ/ng6ZNSGRCag/s1600-h/clip_image017%25255B4%25255D.jpg"><img title="clip_image017" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image017" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwFTiJvRZe_UGNg0Q3ZOiUyQYYin7f1gWXNjciMAr6bvueB90lYVPyHnVmdodXa470C1KkOIkxynGt08owmE36-yfmoarcZNdP-gJhhZEiOvTXaqg3kz_sVtrlZspH8DOLr04G7SFD_xg/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-zycd_mY4pV0/TxZ_EuMIOVI/AAAAAAAACig/gFatctumJRQ/s1600-h/clip_image018%25255B4%25255D.jpg"><img title="clip_image018" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image018" src="http://lh5.ggpht.com/-01AXMMSKtQg/TxZ_Fyq7f_I/AAAAAAAACio/aVTSY9WwVAU/clip_image018_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-GHvWt2JjwI8/TxZ_G_CZyMI/AAAAAAAACiw/L4T-xg8AD1M/s1600-h/clip_image019%25255B4%25255D.jpg"><img title="clip_image019" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image019" src="http://lh4.ggpht.com/-ypidwp921jU/TxZ_H45aPNI/AAAAAAAACi4/_yCvnqLg40A/clip_image019_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-0C-Hc8skqMU/TxZ_IuYT32I/AAAAAAAACjA/Z0XAj0PFbDE/s1600-h/clip_image020%25255B4%25255D.jpg"><img title="clip_image020" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image020" src="http://lh3.ggpht.com/-ucOfBD7h2-Q/TxZ_KYz3l2I/AAAAAAAACjI/DlmSgdqZFiM/clip_image020_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-4kHuyhiZ8fA/TxZ_LGbF15I/AAAAAAAACjQ/H6Zh-ICKM90/s1600-h/clip_image021%25255B4%25255D.jpg"><img title="clip_image021" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image021" src="http://lh6.ggpht.com/-0sP6HIsEHeA/TxZ_MRFaNxI/AAAAAAAACjY/wrqyo9dFghg/clip_image021_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-hinYKOX3WJ8/TxZ_Mwi8bpI/AAAAAAAACjg/wcB9GksDxY0/s1600-h/clip_image022%25255B4%25255D.jpg"><img title="clip_image022" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image022" src="http://lh4.ggpht.com/-Wf_hYfgzfDM/TxZ_OlC3ewI/AAAAAAAACjo/OfTXiMVMihU/clip_image022_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-FTNqxnY5x3E/TxZ_PGowSOI/AAAAAAAACjw/ZM2n4ldiq0I/s1600-h/clip_image023%25255B4%25255D.jpg"><img title="clip_image023" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image023" src="http://lh6.ggpht.com/-heY6v7IumSs/TxZ_QnrxU7I/AAAAAAAACj4/55bX2qQwF0E/clip_image023_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-CQAk2r2Nfdk/TxZ_RkUYX7I/AAAAAAAACkA/rtehRJ-6LAs/s1600-h/clip_image024%25255B4%25255D.jpg"><img title="clip_image024" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image024" src="http://lh5.ggpht.com/-GfbhWZS9_4s/TxZ_SnXE08I/AAAAAAAACkI/Q3Qtd3BXjpI/clip_image024_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-5kHW2Eb4dtQ/TxZ_TXhfvLI/AAAAAAAACkM/1kifkR7Pp_g/s1600-h/clip_image025%25255B4%25255D.jpg"><img title="clip_image025" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image025" src="http://lh4.ggpht.com/-pabVhgZsf2I/TxZ_Udd4ceI/AAAAAAAACkY/rae_y9mZCVg/clip_image025_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-2_dr7vg11Ho/TxZ_VWpih3I/AAAAAAAACkg/7QxF2cDBJKE/s1600-h/clip_image026%25255B4%25255D.jpg"><img title="clip_image026" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image026" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZ7qBHHSzKvUyB9db5qmEkz3LNeStnrIm4BoA9Bj0TtA2037yxC8gmAO3DsNzScffdFzIvMnwF78jG2tLjQM4gIDR9FtMEcmQdzRd6cC8SMkwhQo3h7TV093Pw69YdKzsQlN6N59hyphenhyphen5Cw/?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4DPIVW-RkSJua4RggEIHBx_gFASMrJ94maSaQJnyUhfwGBzDG2MDMNMgTKKrJwRkxU8XQBDwnpOhIwzQKLZTo3hjK6RcZVSdgWCGF29wH_C9ZxVDRNwJJjGzBcFhkDrP0s4HG9_Wf6hw/s1600-h/clip_image027%25255B4%25255D.jpg"><img title="clip_image027" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image027" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9FZ9ltk9ZS-JP8xbXZZwstlR10fCWDvPbWrSY3mwH_v4s40dharmv5sTv2AvXP5l2v9OCy9-B1tEJ_xff4xJeHJMel223MwnB0EvGxiSjy0qX3fFmE7Y3mnTGCfrJA95lykoYs4yYMM8/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-eB0lpWOnOkM/TxZ_ZWijnwI/AAAAAAAAClA/l38dJXSSMEA/s1600-h/clip_image028%25255B4%25255D.jpg"><img title="clip_image028" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image028" src="http://lh6.ggpht.com/-EYbiKjQ0KQs/TxZ_amQRqZI/AAAAAAAAClI/uaAJ1aaWAOI/clip_image028_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-i9fwRtu4sW8/TxZ_bwlgGjI/AAAAAAAAClQ/5GA73nE1Uig/s1600-h/clip_image029%25255B4%25255D.jpg"><img title="clip_image029" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image029" src="http://lh3.ggpht.com/-OIs0nrR9Dq8/TxZ_cuEG3iI/AAAAAAAAClY/huz0MAQz-rA/clip_image029_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-zaVa4aZ_LYs/TxZ_dXQz3eI/AAAAAAAAClc/etOrbEaqM2g/s1600-h/clip_image030%25255B4%25255D.jpg"><img title="clip_image030" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image030" src="http://lh5.ggpht.com/-5sVBZ1AXmrs/TxZ_d9ufgxI/AAAAAAAAClo/LdO_StMogbI/clip_image030_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-T45uZM-7TtQ/TxZ_fqmTSXI/AAAAAAAAClw/wn9XvGN3228/s1600-h/clip_image031%25255B4%25255D.jpg"><img title="clip_image031" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image031" src="http://lh4.ggpht.com/-rKTwbh1r5iw/TxZ_g9AmiKI/AAAAAAAACl4/3syq4GmvBRM/clip_image031_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-jcRo65nH63Y/TxZ_hlwUBsI/AAAAAAAACmA/NGBBuQaEZQA/s1600-h/clip_image032%25255B4%25255D.jpg"><img title="clip_image032" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image032" src="http://lh4.ggpht.com/-LuMXmKW9Dxk/TxZ_i7xW8fI/AAAAAAAACmI/tO9HDFo7T9U/clip_image032_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-zGKSGlZ-3Jo/TxZ_jw17QbI/AAAAAAAACmQ/g56zK_v8NTE/s1600-h/clip_image033%25255B4%25255D.jpg"><img title="clip_image033" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image033" src="http://lh5.ggpht.com/-2EIFlas2PTc/TxZ_k5FTWaI/AAAAAAAACmY/wsSXsu4Ni60/clip_image033_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-p5-uxCakE0U/TxZ_l93WZ8I/AAAAAAAACmg/M02_P1Kszco/s1600-h/clip_image034%25255B4%25255D.jpg"><img title="clip_image034" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image034" src="http://lh4.ggpht.com/-fROxDFQ4AOU/TxZ_nBgxFCI/AAAAAAAACmo/Ikw0f9WRJjc/clip_image034_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgY_CYZ-I5okEeZhnamqBShb0uYRsFIXErGhac-r1iDs5SvPpPp-8g8YMaKSkR37RhZFIqKfsnzxYWfZFjGAqHZUC407X4sYeEhyx6flNjkALXgVrldTahXzMNfZeSTlCF5tNjlFMxQCCU/s1600-h/clip_image035%25255B4%25255D.jpg"><img title="clip_image035" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image035" src="http://lh6.ggpht.com/-NWlwAZ_ZAgs/TxZ_pv1N39I/AAAAAAAACm4/tkU_sYlhb9A/clip_image035_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-Tq6SCjjILQ0/TxZ_qoiS5HI/AAAAAAAACnA/ukupaT-EoYo/s1600-h/clip_image036%25255B4%25255D.jpg"><img title="clip_image036" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image036" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXLrfV3ydfaAxLw0VS3QWQf8RK5KqY8VLYdKv0sW4w1P0OWXHO1O7sCVk6euivBUEgZrglSbFnuD_VPNzfq2XDFfVvmpn1FmrQHLMS_2Mb0FDWqZtQ4Egx0iHCPWJsc3_YWxbMdPzQVwA/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-BKYIK4HQTTc/TxZ_sVEjpnI/AAAAAAAACnQ/lAqBRhWeYz0/s1600-h/clip_image037%25255B4%25255D.jpg"><img title="clip_image037" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image037" src="http://lh6.ggpht.com/-dzxtIAVRPw4/TxZ_taCGs0I/AAAAAAAACnY/dNP3Cq1UAQQ/clip_image037_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-zaJTSbxUitA/TxZ_uYzXSlI/AAAAAAAACng/vXjcYDfvwsQ/s1600-h/clip_image038%25255B4%25255D.jpg"><img title="clip_image038" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image038" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilE_A8JLZouXLGNqhZVACBz_DPyyNzonPAyarxusNTZ0oGAg7HfPqt75fyCLWAJwPxOLAuCLOo40zTlhi9m1i-1Z5LUx8jSodY3q1HYNeKWilcNmrHYS_wr4sdrmED1CQuuCIDTh-RG08/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-l7_l7Dp5Gdc/TxZ_xeE45JI/AAAAAAAACnw/piMDhf0iDTw/s1600-h/clip_image039%25255B4%25255D.jpg"><img title="clip_image039" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image039" src="http://lh5.ggpht.com/-hoxMDY-gtXg/TxZ_ypkYMcI/AAAAAAAACn4/jjLCup9dHv0/clip_image039_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-3ubAxqhHT_c/TxZ_ztp10HI/AAAAAAAACoA/2O4LAgv4pqc/s1600-h/clip_image040%25255B4%25255D.jpg"><img title="clip_image040" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image040" src="http://lh4.ggpht.com/-Cz0P9NJPtgg/TxZ_1NqB0PI/AAAAAAAACoI/ZOUQrDgqj_w/clip_image040_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-a_6zuEhjVBc/TxZ_1u-cdQI/AAAAAAAACoQ/yQJ53cbhtz4/s1600-h/clip_image041%25255B4%25255D.jpg"><img title="clip_image041" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image041" src="http://lh6.ggpht.com/-1ENLotDAyJw/TxZ_28u4yPI/AAAAAAAACoY/Ow1LTA_8ZBo/clip_image041_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvCpgJKlrU6J3_ew7NTnSr8f2VMMRxLhWhcTL0WmkwBGOqEwh7T1MvVKNFzjHj7GlBPqwIYugJboritkUJJ5M1QuZSccZpD8spTFDwq_T_K2wAn8er6Ra1TsuzXZA0asTo6jVGwpUQURg/s1600-h/clip_image042%25255B4%25255D.jpg"><img title="clip_image042" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image042" src="http://lh4.ggpht.com/-lk6DICu5ESM/TxZ_4atwJ4I/AAAAAAAACoo/_7xh6claLPM/clip_image042_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-NCW96KMzm6E/TxZ_5Yp6aLI/AAAAAAAACos/_w2nMXRoWRo/s1600-h/clip_image043%25255B4%25255D.jpg"><img title="clip_image043" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image043" src="http://lh6.ggpht.com/-G3nigRIS4Iw/TxZ_6kAtdmI/AAAAAAAACo4/3rJEHkRJ-w4/clip_image043_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-iLVXCxk0lrA/TxZ_709xvjI/AAAAAAAACpA/th5sDwecp1Q/s1600-h/clip_image044%25255B4%25255D.jpg"><img title="clip_image044" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image044" src="http://lh4.ggpht.com/-TktNl0GYfZk/TxZ_9G4xvsI/AAAAAAAACpI/mVy1uSTEef8/clip_image044_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-Vooa1sqNh2k/TxZ_-GqnA1I/AAAAAAAACpQ/mYJMIL1dKA0/s1600-h/clip_image045%25255B4%25255D.jpg"><img title="clip_image045" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image045" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgkaYRABE0WWwKzSjVZi0PuyAB06eUAVUKNaTn8yFf3k0Rpa2Bg0I7UIkV9vzlziDGybXjltESdB-SruSGfY3wZHN1KJM81o-TP6OwCbW3bFEsZzUBVGzobQ44DrcHtIBnFq7YUUDYdMpQ/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh3.ggpht.com/-rXEWC7_RVUE/TxaAAfSj_tI/AAAAAAAACpg/0YUzrmNXiKY/s1600-h/clip_image046%25255B4%25255D.jpg"><img title="clip_image046" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image046" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLsg-FjKuIbo6eRaDntypBFwO1FJpAtfjsmRKuuqp_zvSaQBhW1tYHoiviuFuxVvZuEuBhxI2F7DnxIbh_IqLBMxN9tQjWnJO61CAaUFEDqRXZIupiYc8XcXu4ocJjhTqJYMuu0chdyXY/?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-BkUjzv0hlbI/TxaAC57HSTI/AAAAAAAACpw/5nPVaD-YH6M/s1600-h/clip_image047%25255B4%25255D.jpg"><img title="clip_image047" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image047" src="http://lh3.ggpht.com/-gYZZX75w-Zc/TxaAEDVMRRI/AAAAAAAACp4/-r5QB5VRXTY/clip_image047_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh6.ggpht.com/-_AJ0hYTXuao/TxaAFCjrUNI/AAAAAAAACqA/uQsrm9yfMNU/s1600-h/clip_image048%25255B4%25255D.jpg"><img title="clip_image048" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image048" src="http://lh3.ggpht.com/-LuPrnB5Pn4U/TxaAGQKLM2I/AAAAAAAACqI/2eyQlFUqsNQ/clip_image048_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh5.ggpht.com/-0vIVwY3D7Vs/TxaAHFoCBII/AAAAAAAACqQ/g3Qf737X7m8/s1600-h/clip_image049%25255B4%25255D.jpg"><img title="clip_image049" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image049" src="http://lh6.ggpht.com/-PRt_ZCa7uRc/TxaAILZ39II/AAAAAAAACqY/h3BkDIPNHw0/clip_image049_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> <p><a href="http://lh4.ggpht.com/-JfJLmzcyfuA/TxaAI8j-VyI/AAAAAAAACqg/T7Zm8dDCcr4/s1600-h/clip_image050%25255B4%25255D.jpg"><img title="clip_image050" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="880" alt="clip_image050" src="http://lh4.ggpht.com/-09vpbFrXagw/TxaAKUNYQLI/AAAAAAAACqo/QelPQYc5fNE/clip_image050_thumb%25255B1%25255D.jpg?imgmax=800" width="679" border="0"></a> mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-14246503591026739972012-01-17T23:40:00.001-08:002012-01-17T23:40:56.177-08:00PIC microcontroller Glossary<p><b>Glossary</b> <p><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Introduction">Introduction</a> <ul> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Microcontroller">Microcontroller</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#I/O%20pin">I/O pin</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Software">Software</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Hardware">Hardware</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Simulator">Simulator</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#ICE">ICE</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#EPROM%20Emulator">EPROM Emulator</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#assembler">Assembler</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#HEX%20file">HEX file</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#List%20file">List file</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Source%20File">Source File</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Debugging">Debugging</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#ROM,%20EPROM,%20EEPROM,%20FLASH,%20RAM">ROM, EPROM, EEPROM, FLASH, RAM</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Addressing">Addressing</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#ASCII">ASCII</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Carry">Carry</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Code">Code</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Byte,%20Kilobyte,%20Megabyte">Byte, Kilobyte, Megabyte</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Flag">Flag</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Interrupt%20vector%20or%20interrupts">Interrupt vector or interrupts</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Programmer">Programmer</a> <li><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#Product">Product</a></li></ul> <p><b><a name="Introduction">Introduction</a></b> <p>Since all the fields of man's activity are regularly based on adequate and already adopted terms (through which other notions and definitions become), so in the field of microcontrollers we can single out some frequently used terms. Ideas are often connected so that correct understanding of one notion is needed in order to get acquainted with one or more of the other ideas. <p><a name="Microcontroller">Microcontroller</a><br>Microprocessor with peripherals in one electronic component.<br><a name="I/O pin">I/O pin</a><br>External microcontroller's connector pin which can be configured as input or output. In most cases I/O pin enables a microcontroller to communicate, control or read information.<br><a name="Software">Software</a><br>Information that microcontroller needs in order to be able to function. Software can not have any errors if we want the program and a device to function properly. Software can be written in different languages such as: Basic, C, pascal or assembler. Physically, that is a file on computer disc. <br><a name="Hardware">Hardware</a><br>Microcontroller, memory, supply, signal circuits and all components connected with microcontroller.<br>The other way of viewing this (especially if it's not working) is, that, hardware is something you can kick.<br><a name="Simulator">Simulator</a><br>Software package for PC which simulates the internal function of microcontroller. It is ideal for checking software routines and all the parts of the code which do not have over demanding connections with an outside world. Options are installed to watch the code, movement around the program back and forth step by step, and debugging. <br><a name="ICE">ICE</a><br>ICE (In Circuit Emulator), internal emulator, very useful part of the equipment which connects a PC instead of microcontroller on a device that is being developed. It enables software to function on the PC computer, but to appear as if a real microcontroller exists in the device. ICE enables you to move through program in real time, to see what is going on in the microcontroller and how it communicates with an outside world. <br><a name="EPROM Emulator">EPROM Emulator</a><br>EPROM Emulator is a device which does not emulate the entire microcontroller like ICE emulator, but it only emulates its memory. It is mostly used in microcontrollers that have external memory. By using it we avoid constant erasing and writing of EPROM memory. <br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/C_appendix.htm#assembler" name="assembler">Assembler</a><br>Software package which translates source code into a code which microcontroller can understand. It contains a section for discovering errors. This part is used when we debug a program from errors made when program was written. <br><a name="HEX file">HEX file</a><br>This is a file made by assembler translator when translating a source file, and has a form "understood" by microcontrollers. A continuation of the file is usually File_name.HEX where the name HEX file comes from.<br><a name="List file">List file</a><br>This is a file made by assembler translator and it contains all instructions from source file with addresses and comments programmer has written. This is a very useful file for keeping track of errors in the program. File extension is LST which is where its name comes from.<br><a name="Source File">Source File</a><br>File written in the language understood by man and assembler translator. By translating the source file, we get HEX and LIST files. <br><a name="Debugging">Debugging</a><br>Error made in writing a program, which error we are not aware of. Errors can be quite simple such as typing errors, and quite complex such as incorrect use of program language. Assembler will find most of these errors and report them to '.LST' file. Other errors will need to be searched for by trying it out and watching how device functions. <br><a name="ROM, EPROM, EEPROM, FLASH, RAM">ROM, EPROM, EEPROM, FLASH, RAM</a><br>Types of memories we meet with microcontroller use. First one can not be erased, what you write in it once, stays forever, and can not be erased. The second is erasable with UV lamp. Third one can be erased electrically, using voltage which microcontroller operates on. Fourth one is electrically erasable, but unlike EEPROM memory it does not have such a great number of cycles of writing and erasing at memory locations. Fifth one is fast, but it does not hold back the contents as the previous when there is supply shortage. Thus, program is not stored in it, but it serves for different variables and inter-results. <br><a name="Addressing">Addressing</a><br>Determines and designates certain memory locations.<br><a name="ASCII">ASCII</a><br>Short for "American Standard Code for Information Interchange". It is widely accepted type of coding where each number and letter have their eight-bit code. <br><a name="Carry">Carry</a><br>Transfer bit connected with arithmetic operations<br><a name="Code">Code</a><br>File, or section of a file which contains program instructions. <br><a name="Byte, Kilobyte, Megabyte">Byte, Kilobyte, Megabyte</a><br>Terms designating amounts of information. The basic unit is a byte, and it has 8 bits. Kilobyte has 1024 bytes, and mega byte has 1024 kilobytes. <br><a name="Flag">Flag</a><br>Bits from a status register. By their activation, programmer is informed about certain actions. Program activates its response if necessary. <br><a name="Interrupt vector or interrupts">Interrupt vector or interrupts</a><br>Location in microcontroller memory. Microcontroller takes from this location information about a section of the program that is to be executed as an answer to some event of interest to programmer and device.<br><a name="Programmer">Programmer</a><br>Device which makes it possible to write software in microcontroller memory, thus enabling the microcontroller to work independently. It consists of the hardware section usually connected with one of the ports and software section used on the computer as a program. <br><a name="Product">Product</a><br>Product development is a combination of luck and experience. Short terms, or time-limits for production should be avoided because even with most simple assignments, much time is needed to develop and improve. When creating a project, we need time, quiet, logical mind and most importantly, a thorough understanding of consumer's needs. Typical course in creating a product would have the following algorithm. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglVA9IO5wEmz_r3edIz1cvo-kCN6_oCtzfyobgL0CP6TkDoKF9d_uC6BT1yJa1kyiwh0F2Az5C0ZkSX6I-0akIq4I4Zs-URLzUcgjA_7vZKxz5MC6nbTKbVG6hE5UDt5PQ-vLaujZT3uA/s1600-h/01%25255B6%25255D.gif"><img title="01" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="707" alt="01" src="http://lh4.ggpht.com/-jgg_7aSsRQ4/TxZ3hQCEqmI/AAAAAAAACeI/FQKx5KAzE6I/01_thumb%25255B3%25255D.gif?imgmax=800" width="548" border="0"></a> mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-34690884895753608632012-01-17T23:38:00.001-08:002012-01-17T23:38:08.288-08:00PIC microcontroller instruction set<p align="justify"><b>Instruction Set</b> <p align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#Introduction">Introduction</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#Instruction%20Set%20in%20PIC16Cxx%20Microcontroller%20Family">Instruction set in PIC16Cxx microcontroller family</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#Data%20Transfer">Data Transfer</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#Arithmetic%20and%20logic">Arithmetic and logic</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#Bit%20Operations">Bit operations</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#Directing%20a%20program%20flow">Directing the program flow </a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#Instruction%20Execution%20Period">Instruction execution period</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#Word%20list">Word list</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#Instruction%20List">Instruction list</a></p> <p align="justify"><b><a name="Introduction">Introduction</a></b> <p align="justify">We have already mentioned that microcontroller is not like any other integrated circuit. When they come out of production most integrated circuits are ready to be built into devices which is not the case with microcontrollers. In order to "make" microcontroller perform a task, we have to tell it exactly what to do, or in other words we must write the program microcontroller will execute. We will describe in this chapter instructions which make up the assembler, or lower-level program language for PIC microcontrollers. <p align="justify"><a name="Instruction Set in PIC16Cxx Microcontroller Family">Instruction Set in PIC16Cxx Microcontroller Family</a> <p align="justify">Complete set which includes 35 instructions is given in the following table. A reason for such a small number of instructions lies primarily in the fact that we are talking about a RISC microcontroller whose instructions are well optimized considering the speed of work, architectural simplicity and code compactness. The only drawback is that programmer is expected to master "uncomfortable" technique of using a reduced set of 35 instructions. <p align="justify"><a name="Data Transfer">Data transfer</a> <p align="justify">Transfer of data in a microcontroller is done between work (W) register and an 'f' register that represents any location in internal RAM (regardless whether those are special or general purpose registers).<br>First three instructions (look at the following table) provide for a constant being written in W register (MOVLW is short for MOVe Literal to W), and for data to be copied from W register onto RAM and data from RAM to be copied onto W register (or on the same RAM location, at which point only the status of Z flag changes). Instruction CLRF writes constant 0 in 'f ' register, and CLRW writes constant 0 in register W. SWAPF instruction exchanges places of the 4-bit nibbles field inside a register. </p> <p align="justify"><a name="Arithmetic and logic">Arithmetic and logic</a> <p align="justify">Of all arithmetic operations, PIC like most microcontrollers supports only subtraction and addition. Flags C, DC and Z are set depending on a result of addition or subtraction, but with one exception: since subtraction is performed like addition of a negative value, C flag is inverse following a subtraction. In other words, it is set if operation is possible, and reset if larger number was subtracted from a smaller one. <br>Logic unit of PIC has capability of performing operations AND, OR, EX-OR, complementing (COMF) and rotation (RLF and RRF).<br>Instructions which rotate the register contents move bits inside a register through flag C by one space to the left (toward bit 7), or to the right (toward bit 0). Bit which "comes out" of a register is written in flag C, and value of C flag is written in a bit on the "opposite side" of the register. </p> <p align="justify"><a name="Bit Operations">Bit operations</a> <p align="justify">Instructions BCF and BSF do setting or cleaning of one bit anywhere in the memory. Even though this seems like a simple operation, it is executed so that CPU first reads the whole byte, changes one bit in it and then writes in the entire byte at the same place. <p align="justify"><a name="Directing a program flow">Directing a program flow</a> <p align="justify">Instructions GOTO, CALL and RETURN are executed the same way as on all other microcontrollers, only stack is independent of internal RAM and limited to eight levels. <br>'RETLW k' instruction is identical with RETURN instruction, except that before coming back from a subprogram a constant defined by instruction operand is written in W register. This instruction enables us to design easily the Look-up tables (lists). Mostly we use them by determining data position on our table adding it to the address at which the table begins, and then we read data from that location (which is usually found in program memory). <br>Table can be formed as a subprogram which consists of a series of 'RETLW k' instructions, where 'k' constants are members of the table. </p> <p align="justify"><a href="http://lh3.ggpht.com/-hSMF3L9S7dc/TxZ1rsdOufI/AAAAAAAACUw/d1wJVSQNXJE/s1600-h/prog1%25255B3%25255D.gif"><img title="prog1" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="158" alt="prog1" src="http://lh6.ggpht.com/-G2KF1uI5DCY/TxZ1spd5pyI/AAAAAAAACU4/zwEGmPBXthk/prog1_thumb.gif?imgmax=800" width="170" border="0"></a></p> <p align="justify">We write the position of a member of our table in W register, and using CALL instruction we call a subprogram which creates the table. First subprogram line ADDWF PCL, f adds the position of a W register member to the starting address of our table, found in PCL register, and so we get the real data address in program memory. When returning from a subprogram we will have in W register the contents of an addressed table member. In a previous example, constant 'k2' will be in W register following a return from a subprogram.<br>RETFIE (RETurn From Interrupt - Interrupt Enable) is a return from interrupt routine and differs from a RETURN only in that it automatically sets GIE (Global Interrupt Enable) bit. Upon an interrupt, this bit is automatically cleared. As interrupt begins, only the value of program counter is put at the top of a stack. No automatic storing of register values and status is provided.<br>Conditional jumps are synthesized into two instructions: BTFSC and BTFSS. Depending on a bit status in 'f' register that is being tested, instructions skip or don't skip over the next program instruction. </p> <p align="justify"><a name="Instruction Execution Period">Instruction Execution Period</a> <p align="justify">All instructions are executed in one cycle except for conditional branch instructions if condition was true, or if the contents of program counter was changed by some instruction. In that case, execution requires two instruction cycles, and the second cycle is executed as NOP (No Operation). Four oscillator clocks make up one instruction cycle. If we are using an oscillator with 4MHz frequency, the normal time for executing an instruction is 1 µs, and in case of conditional branching, execution period is 2 µs. <p align="justify"><a name="Word list">Word list</a> <p align="justify"><b>f</b> any memory location in a microcontroller<br><b>W</b> work register<br><b>b</b> bit position in 'f' register<br><b>d</b> destination bit<br><i>label</i> group of eight characters which marks the beginning of a part of the program<br><b>TOS</b> top of stack<br><b>[] </b>option<br><b><></b> bit position inside register</p> <p align="justify"><a href="http://lh6.ggpht.com/-LfSQWIfsQyY/TxZ1tbh6ukI/AAAAAAAACU8/_HnDkwzQcdA/s1600-h/table%25255B5%25255D.gif"><img title="table" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="787" alt="table" src="http://lh6.ggpht.com/-C3XvxQhEr-k/TxZ1uLxXn7I/AAAAAAAACVI/jrIFAOEmgxE/table_thumb%25255B2%25255D.gif?imgmax=800" width="651" border="0"></a></p> <p align="justify">*1 If I/O port is source operand, status on microcontroller pins is read<br>*2 If this instruction is executed on TMR register and if d=1, prescaler assigned to that timer will automatically be cleared<br>*3 If PC was modified, or test result =1, instruction was executed in two cycles.</p> <p align="justify"><a name="Instruction List">Instruction List</a> <p align="justify">Appendix contains all instructions presented separately with examples for their use. Syntax, description and its effects on status bits are given for each instruction. <ul> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.1%20Write%20constant%20in%20W%20register">A.1 MOVLW</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.2%20Copy%20W%20to%20f">A.2 MOVWF</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.3%20Copy%20f%20to%20d">A.3 MOVF</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.4%20Write%200%20in%20W">A.4 CLRW</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.5">A.5 CLRF</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.6%20Copy%20the%20nibbles%20from%20%27f%27%20to%20%27d%27%20crosswise">A.6 SWAPF</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.7%20Add%20W%20to%20a%20constant">A.7 ADDLW</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.8%20Add%20W%20to%20%27f%27">A.8 ADDWF</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.9%20Subtract%20W%20from%20a%20constant">A.9 SUBLW</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.10%20Subtract%20W%20from%20%27f%27">A.10 SUBWF</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.11%20Logic%20I%20W%20with%20constant">A.11 ANDLW</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.12%20Logic%20I%20W%20with%20f">A.12 ANDWF</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.13%20Logic%20ILI%20W%20with%20constant">A.13 IORLW</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.14%20Logic%20ILI%20W%20with%20f">A.14 IORWF</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.15%20Logic%20exclusive%20ILI%20W%20with%20constant">A.15 XORLW</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.16%20Logic%20exclusive%20ILI%20W%20with%20%27f%27">A.16 XORWF</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.17%20Increment%20%27f%27">A.17 INCF</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.18%20Decrement%20f">A.18 DECF</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.19%20Rotate%20f%20to%20the%20left%20through%20CARRY">A.19 RLF</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.20%20Rotate%20f%20to%20the%20right%20through%20CARRY">A.20 RRF</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.21%20Complement%20f">A.21 COMF</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.22%20Reset%20bit%20b%20in%20f">A.22 BCF</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.23%20Set%20bit%20b%20in%20f">A.23 BSF</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.24%20Test%20bit%20%27b%27%20in%20%27f%27,%20skip%20if%20it%20=%200%C2%A0">A.24 BTFSC</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.25%20Test%20bit%20%27b%27%20in%20%27f%27,%20skip%20if%20=1">A.25 BTFSS</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.26%20Increment%20%27f%27,%20skip%20if=0">A.26 INCFSZ</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.27%20Decrement%20f,%20skip%20if%20=%200">A.27 DECFSZ</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.28%20Jump%20to%20address">A.28 GOTO</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.29%20Call%20a%20program">A.29 CALL</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.30%20Return%20from%20a%20subprogram">A.30 RETURN</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.31%20Return%20from%20a%20subprogram%20with%20constant%20in%20W">A.31 RETLW</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.32%20Return%20from%20interrupt%20routine">A.32 RETFIE</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.33%20No%20operation">A.33 NOP</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.34%20Initialize%20watchdog%20timer">A.34 CLRWDT</a></div> <li> <div align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/A_appendix.htm#A.35%20Stand%20by%20mode">A.35 SLEEP</a></div></li></ul> <p align="justify"><a name="A.1 Write constant in W register">A.1 MOVLW Write constant in W register</a> <p align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLdU1GrARFqgHnCNWIW97XDWE3RNhOIBW34RqV5rV-TSi2yWayOtcmt6iun9xzGu-hh6KJlp4Pnu7vwKXxWmZF0NB7B3sQROoDoPIULKMpSh15S8YaVyI7Z4ELvVr2aeWDNRB9073nvRc/s1600-h/01%25255B4%25255D.gif"><img title="01" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="303" alt="01" src="http://lh5.ggpht.com/-a7i6cEGx_I0/TxZ1v6u_GCI/AAAAAAAACVU/OuW6h1fj92A/01_thumb%25255B1%25255D.gif?imgmax=800" width="672" border="0"></a></p> <p align="justify"><a name="A.2 Copy W to f">A.2 MOVWF Copy W to f</a> <p align="justify"><a href="http://lh6.ggpht.com/-d2UWWiU7lrg/TxZ1ws4VWRI/AAAAAAAACVc/XPugxU4Nsac/s1600-h/02%25255B4%25255D.gif"><img title="02" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="428" alt="02" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhi3CUD_VJ7X2gayraoPQ2RGv5pulv8Ian78DWSYrdwWDueBdbXsq4hlTp2a7hfh5maY-OOKNIt1yYrTqhZ8_-gKEkx6Pl-q0wWH5ehS2HJr08bw1quFfUCY7Z-EXpKh9nHIK20zLx40gk/?imgmax=800" width="675" border="0"></a></p> <p align="justify"><a name="A.3 Copy f to d">A.3 MOVF Copy f to d</a> <p align="justify"><a href="http://lh3.ggpht.com/-DOyEiSGRAIY/TxZ1y-VxnXI/AAAAAAAACVs/8jH4mIuyKaI/s1600-h/03%25255B4%25255D.gif"><img title="03" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="553" alt="03" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis0xUSXpWHtzM6G0muiwLABFOUJ-CiVjuxH5ylkhyGnifbVu1z-K4glNWZO8CBjpyEAqGbTo4oFo4siyV1qfy5Ycy4lwXJ0shCnlCV-J0ny9S4NL67FWz7z7OfKx4AYCErObaa_QhCNkQ/?imgmax=800" width="683" border="0"></a></p> <p align="justify"><a name="A.4 Write 0 in W">A.4 CLRW Write 0 in W</a> <p align="justify"><a href="http://lh4.ggpht.com/-p-5hx_MQ82Q/TxZ10uqTC_I/AAAAAAAACV8/drgKw1fPnDA/s1600-h/04%25255B4%25255D.gif"><img title="04" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="281" alt="04" src="http://lh3.ggpht.com/-vHQsfAANsLk/TxZ114vZzEI/AAAAAAAACWI/gc6KtZ7vWZI/04_thumb%25255B1%25255D.gif?imgmax=800" width="697" border="0"></a></p> <p align="justify"><a name="A.5">A.5 Write 0 in f</a> <p align="justify"><a href="http://lh3.ggpht.com/-C4NACuKX_RM/TxZ12omKpEI/AAAAAAAACWQ/LHBJ2ZCHetM/s1600-h/05%25255B4%25255D.gif"><img title="05" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="445" alt="05" src="http://lh6.ggpht.com/-SXdKCZbx7l8/TxZ13yBM0wI/AAAAAAAACWY/9O8M2j3ctbU/05_thumb%25255B1%25255D.gif?imgmax=800" width="706" border="0"></a></p> <p align="justify"><a name="A.6 Copy the nibbles from 'f' to 'd' crosswise">A.6 SWAPF Copy the nibbles from f to d crosswise</a> <p align="justify"><a href="http://lh6.ggpht.com/-s-4AI1ELxk4/TxZ14tP9xiI/AAAAAAAACWg/1P4bMuIQPtc/s1600-h/06%25255B4%25255D.gif"><img title="06" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="424" alt="06" src="http://lh5.ggpht.com/-2J8LphKknnA/TxZ16cTNYBI/AAAAAAAACWo/bfydRljGCoc/06_thumb%25255B1%25255D.gif?imgmax=800" width="700" border="0"></a></p> <p align="justify"><a name="A.7 Add W to a constant">A.7 ADDLW Add W to a constant</a> <p align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJZ5apF1YmHwrFHML3CLHLyrvrq60kP_BwsTf3-F9aso5tnDpKe2Tuyh27aLC1eTZC0Nw8yPcZozRuBKRLkvXzXmG_JFxDxA3KtpbL-bUvqYXxITHfGYB1PLC1TxoV314ttuCx-Q9onkM/s1600-h/07%25255B4%25255D.gif"><img title="07" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="370" alt="07" src="http://lh5.ggpht.com/-lbN4r_WpFzA/TxZ18ilguwI/AAAAAAAACW4/1ZJ1AzSjk0A/07_thumb%25255B1%25255D.gif?imgmax=800" width="702" border="0"></a></p> <p align="justify"><a name="A.8 Add W to 'f'">A.8 ADDWF Add W to f</a> <p align="justify"><a href="http://lh3.ggpht.com/-uQq4D-M2Y48/TxZ19gQy8pI/AAAAAAAACXA/yQ3E6Mb3joA/s1600-h/08%25255B4%25255D.gif"><img title="08" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="490" alt="08" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjKSHqzBQer0N2VbCRLTPh8RXqazpPIPknADvtVoYlAsY4YH9wHL1caIeK8VDvu9yZw7Y_dKBHojzbJek5488McNL17MwfbxkLwSgGzXkRP8bmTTp9rtxeghSKETOA45XaUl8XRw8U2nI8/?imgmax=800" width="694" border="0"></a></p> <p align="justify"><a name="A.9 Subtract W from a constant">A.9 SUBLW Subtract W from a constant</a> <p align="justify"><a href="http://lh5.ggpht.com/-jpbJ5ru3u0A/TxZ1_ufsNOI/AAAAAAAACXQ/Kv5xH-g4DZA/s1600-h/09%25255B4%25255D.gif"><img title="09" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="485" alt="09" src="http://lh3.ggpht.com/-AuyRD1lbkMc/TxZ2Aw4574I/AAAAAAAACXY/5PN7SUtCf9Q/09_thumb%25255B1%25255D.gif?imgmax=800" width="684" border="0"></a></p> <p align="justify"><a name="A.10 Subtract W from 'f'">A.10 SUBWF Subtract W from f</a> <p align="justify"><a href="http://lh6.ggpht.com/-pPe56cdVl7k/TxZ2BeSqqrI/AAAAAAAACXg/2zs3Jj06qeg/s1600-h/10%25255B4%25255D.gif"><img title="10" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="400" alt="10" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUJsOt4MkxrrPbWoY0EEhBF1pMXYhXFBHiRuL6pqET9AxqCYmouashjSSWE2qCjPT-srwcPS4zvgFseCSN4dCHzQCLeraOgJRtWis7osl7iIzBMvhkrnCwFes0jRVhgwoe8Z567KztVdg/?imgmax=800" width="692" border="0"></a></p> <p align="justify"><a name="A.11 Logic I W with constant">A.11 ANDLW Logic AND W with constant</a> <p align="justify"><a href="http://lh3.ggpht.com/-99Egh8IcmMw/TxZ2Dfs7ycI/AAAAAAAACXw/t3IfsaSvjR8/s1600-h/11%25255B4%25255D.gif"><img title="11" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="437" alt="11" src="http://lh3.ggpht.com/-wl73Q2ubG4E/TxZ2ErV25uI/AAAAAAAACX4/O0OrANRPyWg/11_thumb%25255B1%25255D.gif?imgmax=800" width="693" border="0"></a></p> <p align="justify"><a name="A.12 Logic I W with f">A.12 ANDWF Logic AND W with f</a> <p align="justify"><a href="http://lh3.ggpht.com/-9FWEuZspvbA/TxZ2F085KcI/AAAAAAAACX8/yA8sVDHAX0M/s1600-h/12%25255B4%25255D.gif"><img title="12" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="482" alt="12" src="http://lh3.ggpht.com/-VlFEcbOlUGw/TxZ2GzCRiBI/AAAAAAAACYI/gL_CyeURfYc/12_thumb%25255B1%25255D.gif?imgmax=800" width="703" border="0"></a></p> <p align="justify"><a name="A.13 Logic ILI W with constant">A.13 IORLW Logic OR W with constant</a> <p align="justify"><a href="http://lh3.ggpht.com/-Hex-FZiBgkw/TxZ2Hz5lBGI/AAAAAAAACYQ/OG6pCdiRzTg/s1600-h/13%25255B4%25255D.gif"><img title="13" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="407" alt="13" src="http://lh5.ggpht.com/-D-sfRoTN4Wg/TxZ2JS7t-EI/AAAAAAAACYY/p3GF80qZeX0/13_thumb%25255B1%25255D.gif?imgmax=800" width="703" border="0"></a></p> <p align="justify"><a name="A.14 Logic ILI W with f">A.14 IORWF Logic OR W with f</a> <p align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWV9lRFyp8__-SUpciTgpj2uDaquXfZKqdwPniwBjg6s1QbGFbDFJn3xpDlZUGE4q-lxQcwodHc4Fex4L9vmHZA8sJREN28DNcWGE4EKmq3zEOkhZkn8c3z9BU30gJWOTOwkLs3JVtXak/s1600-h/14%25255B4%25255D.gif"><img title="14" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="437" alt="14" src="http://lh5.ggpht.com/-xzBLC0uz32U/TxZ2K1eLseI/AAAAAAAACYo/14awaPlGec4/14_thumb%25255B1%25255D.gif?imgmax=800" width="698" border="0"></a></p> <p align="justify"><a name="A.15 Logic exclusive ILI W with constant">A.15 XORLW Logic exclusive OR W with constant</a> <p align="justify"><a href="http://lh5.ggpht.com/-T8uSB8TVbP0/TxZ2Lsjg7jI/AAAAAAAACYw/NHE8CQf7tMw/s1600-h/15%25255B4%25255D.gif"><img title="15" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="421" alt="15" src="http://lh4.ggpht.com/-k18v_w0ISzg/TxZ2Mpx_dSI/AAAAAAAACY4/Tt5WmsF3EvQ/15_thumb%25255B1%25255D.gif?imgmax=800" width="694" border="0"></a></p> <p align="justify"><a name="A.16 Logic exclusive ILI W with 'f'">A.16 XORWF Logic exclusive OR W with f</a> <p align="justify"><a href="http://lh4.ggpht.com/-FY3TpjIWYYw/TxZ2NexgOZI/AAAAAAAACY8/R6qUv0KEkWU/s1600-h/16%25255B4%25255D.gif"><img title="16" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="469" alt="16" src="http://lh3.ggpht.com/-iVl3j92H6ls/TxZ2OACUHEI/AAAAAAAACZI/uDr8DnoLDqw/16_thumb%25255B1%25255D.gif?imgmax=800" width="688" border="0"></a></p> <p align="justify"><a name="A.17 Increment 'f'">A.17 INCF Increment f</a> <p align="justify"><a href="http://lh3.ggpht.com/-ZiPw5IavHi4/TxZ2O8YpRiI/AAAAAAAACZQ/hztvISilhCg/s1600-h/17%25255B4%25255D.gif"><img title="17" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="486" alt="17" src="http://lh5.ggpht.com/-UDTINF-KxpY/TxZ2QWeNEyI/AAAAAAAACZY/xmPQzmJZtVM/17_thumb%25255B1%25255D.gif?imgmax=800" width="693" border="0"></a></p> <p align="justify"><a name="A.18 Decrement f">A.18 DECF Decrement f</a> <p align="justify"><a href="http://lh4.ggpht.com/-vNizhyjJLpQ/TxZ2Q0xSaZI/AAAAAAAACZc/uNQ_vE0tPZc/s1600-h/18%25255B4%25255D.gif"><img title="18" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="485" alt="18" src="http://lh6.ggpht.com/-JhO9M8WA7HI/TxZ2RpP5bmI/AAAAAAAACZo/lqa1VFCiJUg/18_thumb%25255B1%25255D.gif?imgmax=800" width="691" border="0"></a></p> <p align="justify"><a name="A.19 Rotate f to the left through CARRY">A.19 RLF Rotate f to the left through CARRY</a> <p align="justify"><a href="http://lh4.ggpht.com/-5N1EySX8Mbo/TxZ2Se2UUsI/AAAAAAAACZw/-abpcECxP04/s1600-h/19%25255B4%25255D.gif"><img title="19" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="486" alt="19" src="http://lh6.ggpht.com/-rBoabP9pSgQ/TxZ2TvVJ7II/AAAAAAAACZ4/HXl_Un40FXM/19_thumb%25255B1%25255D.gif?imgmax=800" width="689" border="0"></a></p> <p align="justify"><a name="A.20 Rotate f to the right through CARRY">A.20 RRF Rotate f to the right through CARRY</a> <p align="justify"><a href="http://lh5.ggpht.com/-WI-ezq8txZo/TxZ2UpFAeTI/AAAAAAAACZ8/Nu_3twGDORE/s1600-h/20%25255B5%25255D.gif"><img title="20" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="511" alt="20" src="http://lh3.ggpht.com/-CjrWJ87GmtI/TxZ2XLUgClI/AAAAAAAACaI/ZW9qs8sGm_s/20_thumb%25255B2%25255D.gif?imgmax=800" width="693" border="0"></a></p> <p align="justify"><a name="A.21 Complement f">A.21 COMF Complement f</a> <p align="justify"><a href="http://lh4.ggpht.com/-07On0txNmtk/TxZ2X0D-aHI/AAAAAAAACaQ/Z4MBa9MpRfI/s1600-h/21%25255B4%25255D.gif"><img title="21" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="459" alt="21" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSF3vw-mek9LFeHiRSi0TaI4tfH1A6nEydIA0nQ961DhvjjFxeW0Cf_d7hFdGfTL-xHrEiedBaS9hJzbgX_CLTKstK65_eBcQ7tq08iROoAZ3tEF8-HrYQcQv0W6HEWlIulk1hL4LID3w/?imgmax=800" width="693" border="0"></a></p> <p align="justify"><a name="A.22 Reset bit b in f">A.22 BCF Reset bit b in f</a> <p align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbYzCWksQPWrZ88OEs52jrgeNww8BiB9LAXj-U8n7UF6OiohV8JEjsW_nT2lEVXydL563SsJGYsseQTSmYWCzHhjfC2XlcrsSLBrgSjP9TLoenWO8D4NV5dVi_wUmoEdP7AD3CtRAabKY/s1600-h/22%25255B4%25255D.gif"><img title="22" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="420" alt="22" src="http://lh4.ggpht.com/-UY5dRpG1Cj4/TxZ2bGqJxfI/AAAAAAAACao/ZeHd-95zazo/22_thumb%25255B1%25255D.gif?imgmax=800" width="693" border="0"></a></p> <p align="justify"><a name="A.23 Set bit b in f">A.23 BSF Set bit b in f</a> <p align="justify"><a href="http://lh5.ggpht.com/-OVAOur5HU_o/TxZ2b8znyPI/AAAAAAAACas/FM5ouSjiIvQ/s1600-h/23%25255B4%25255D.gif"><img title="23" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="418" alt="23" src="http://lh6.ggpht.com/-Gw7BxZ95eNw/TxZ2c4xkJwI/AAAAAAAACa4/xEnkllLRKUs/23_thumb%25255B1%25255D.gif?imgmax=800" width="690" border="0"></a></p> <p align="justify"><a name="A.24 Test bit 'b' in 'f', skip if it = 0 ">A.24 BTFSC Test bit b in f, skip if it = 0</a> <p align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEikmUCEPgsXg8Y4hITjGAsWGTLIk9M4FXBt5iDCOKbAXtVcYxeFSAyi6EuY64HbX-7ldWNpisnDqQYYza3TmIiot0InBgRgKgQJVqC9F2Taqp3OP6KByqGgl-1FXad0K_XnpgDw0LFDUEU/s1600-h/24%25255B4%25255D.gif"><img title="24" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="457" alt="24" src="http://lh4.ggpht.com/-dLdoV8pDL7k/TxZ2ejfnoLI/AAAAAAAACbI/LbOwfEjROIM/24_thumb%25255B1%25255D.gif?imgmax=800" width="694" border="0"></a></p> <p align="justify"><a name="A.25 Test bit 'b' in 'f', skip if =1">A.25 BTFSS Test bit b in f, skip if =1</a> <p align="justify"><a href="http://lh6.ggpht.com/-Rp9N2hOLFMo/TxZ2fc8Sn-I/AAAAAAAACbQ/yGJRXqTonzA/s1600-h/25%25255B4%25255D.gif"><img title="25" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="455" alt="25" src="http://lh3.ggpht.com/-hnBKROJdFdc/TxZ2hshugFI/AAAAAAAACbY/PqR21cGav5I/25_thumb%25255B1%25255D.gif?imgmax=800" width="687" border="0"></a></p> <p align="justify"><a name="A.26 Increment 'f', skip if=0">A.26 INCFSZ Increment f, skip if=0</a> <p align="justify"><a href="http://lh5.ggpht.com/-EbHdJrDKp78/TxZ2ivqQHEI/AAAAAAAACbg/JpWB6ll896s/s1600-h/26%25255B4%25255D.gif"><img title="26" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="455" alt="26" src="http://lh5.ggpht.com/--IvsmDTs7wU/TxZ2klog6SI/AAAAAAAACbo/gm0lObTH_bk/26_thumb%25255B1%25255D.gif?imgmax=800" width="692" border="0"></a></p> <p align="justify"><a name="A.27 Decrement f, skip if = 0">A.27 DECFSZ Decrement f, skip if = 0</a> <p align="justify"><a href="http://lh3.ggpht.com/-B2Qzk35YjyA/TxZ2lkpehSI/AAAAAAAACbw/BNooKDs1NNY/s1600-h/27%25255B4%25255D.gif"><img title="27" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="457" alt="27" src="http://lh5.ggpht.com/-0NwqfxreIxM/TxZ2oML2-aI/AAAAAAAACb4/7K9pY0BraTY/27_thumb%25255B1%25255D.gif?imgmax=800" width="694" border="0"></a></p> <p align="justify"><a name="A.28 Jump to address">A.28 GOTO Jump to address</a> <p align="justify"><a href="http://lh5.ggpht.com/-sM8tbBzI23s/TxZ2o-lrgHI/AAAAAAAACcA/ejAfozV2Flk/s1600-h/28%25255B4%25255D.gif"><img title="28" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="331" alt="28" src="http://lh6.ggpht.com/-FgkRZ5onjWg/TxZ2ptcNVII/AAAAAAAACcI/c2DF7AlkRYk/28_thumb%25255B1%25255D.gif?imgmax=800" width="692" border="0"></a></p> <p align="justify"><a name="A.29 Call a program">A.29 CALL Call a program</a> <p align="justify"><a href="http://lh5.ggpht.com/-40jCuBzfzyk/TxZ2qlMQBRI/AAAAAAAACcM/v1Jlx4pqwtY/s1600-h/29%25255B4%25255D.gif"><img title="29" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="437" alt="29" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3Z8USJvaUtPCcHsOVtBG_MY4IkyonUMhiZiKZL0HO4BmV_QhN6-nvdV73aG0F_-zE61SkCZyCOwSCa5ghB0p__k1luasWm-PONM5r7GOGyaqMNbD5Mq1Jd8HWfUijVIXWN-Bzu2JCS-0/?imgmax=800" width="694" border="0"></a></p> <p align="justify"><a name="A.30 Return from a subprogram">A.30 RETURN Return from a subprogram</a> <p align="justify"><a href="http://lh4.ggpht.com/-vdUpFFyL-Vk/TxZ2sGKxz3I/AAAAAAAACcc/U4wWIOxDfCw/s1600-h/30%25255B4%25255D.gif"><img title="30" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="277" alt="30" src="http://lh5.ggpht.com/-5_xvsb_oHwE/TxZ2tKMSbKI/AAAAAAAACco/xP8IVZWokOg/30_thumb%25255B1%25255D.gif?imgmax=800" width="693" border="0"></a></p> <p align="justify"><a name="A.31 Return from a subprogram with constant in W">A.31 RETLW Return from a subprogram with constant in W</a> <p align="justify"><a href="http://lh3.ggpht.com/-_A8DFy_Kdf4/TxZ2t0WVWeI/AAAAAAAACcw/Kc3kq0WN7Zs/s1600-h/31%25255B4%25255D.gif"><img title="31" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="332" alt="31" src="http://lh3.ggpht.com/-SRiHdSHZMrE/TxZ2vHmgZ5I/AAAAAAAACc4/ochv1RGFeL4/31_thumb%25255B1%25255D.gif?imgmax=800" width="693" border="0"></a></p> <p align="justify"><a name="A.32 Return from interrupt routine">A.32 RETFIE Return from interrupt routine</a> <p align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4lLa9BZjq-JJdpoTjor2QK1WFWvumb8TDh3L63UmUU4YGARa_8YQuQeHdEELwSKkP29y1aMS85P1_kvgHFDQ0Pe3X6JzFKXPzyk1qyFeczf5LTApCFiOwE-3nJwJpuzBLYYTuO8Gk0eQ/s1600-h/32%25255B4%25255D.gif"><img title="32" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="298" alt="32" src="http://lh3.ggpht.com/-MqH8LEupH9g/TxZ2wiY2HpI/AAAAAAAACdI/NLonUZ8Px08/32_thumb%25255B1%25255D.gif?imgmax=800" width="692" border="0"></a></p> <p align="justify"><a name="A.33 No operation">A.33 NOP No operation</a> <p align="justify"><a href="http://lh5.ggpht.com/--O0Yt8SaBMs/TxZ2xkmgIrI/AAAAAAAACdQ/U8GPKW2oJZw/s1600-h/33%25255B4%25255D.gif"><img title="33" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="247" alt="33" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM5rd0so_TOQ4BvEEqf33ImpfNK4BUkbMbq7p3nHrvyIfmkM4oIhtUOfYjw8HWo34z4qja-3pdXkDwhjYT2l62KkAahRnhHan2H6PHd-VduyIsFZDXEE3lVpyUCwhY7Dm_pakCanYzd0U/?imgmax=800" width="702" border="0"></a></p> <p align="justify"><a name="A.34 Initialize watchdog timer">A.34 CLRWDT Initialize watchdog timer</a> <p align="justify"><a href="http://lh5.ggpht.com/-221p-aPS0zI/TxZ2z1kDKXI/AAAAAAAACdg/i3gNJA-LgIY/s1600-h/34%25255B5%25255D.gif"><img title="34" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="407" alt="34" src="http://lh5.ggpht.com/-bA_JEgjkWFU/TxZ21WfxS6I/AAAAAAAACdo/Hhu2NxC3SmM/34_thumb%25255B2%25255D.gif?imgmax=800" width="691" border="0"></a></p> <p align="justify"><a name="A.35 Stand by mode">A.35 SLEEP Stand by mode</a> <p align="justify"><a href="http://lh5.ggpht.com/-D6vVx304Zzk/TxZ2116XVTI/AAAAAAAACdw/v9Fau5L7eEE/s1600-h/35%25255B5%25255D.gif"><img title="35" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="367" alt="35" src="http://lh6.ggpht.com/-E3uDS9L3xc8/TxZ23RxuADI/AAAAAAAACd4/4n19cfZhnbI/35_thumb%25255B2%25255D.gif?imgmax=800" width="622" border="0"></a></p> mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-42453791024156481482012-01-17T22:56:00.001-08:002012-01-17T22:56:01.709-08:007.9 connecting LCD Display to PIC microcontroller<p><b>7.9 </b><b>LCD Display</b> <p>More microcontroller devices are using 'smart LCD' displays to output visual information. The following discussion covers the connection of a <b>Hitachi LCD display</b> to a PIC microcontroller. LCD displays designed around Hitachi's LCD HD44780 module, are inexpensive, easy to use, and it is even possible to produce a readout using the 8 x 80 pixels of the display. Hitachi LCD displays have a standard ASCII set of characters plus Japanese, Greek and mathematical symbols.<br><a href="http://lh5.ggpht.com/-VFV48E7PtBU/TxZs03cLR8I/AAAAAAAACTQ/HVbd399bNgM/s1600-h/LCD_display%25255B4%25255D.gif"><img title="LCD_display" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="222" alt="LCD_display" src="http://lh3.ggpht.com/-mxjXU8dngQA/TxZs2kmqkYI/AAAAAAAACTY/_YBHOYlZfZ4/LCD_display_thumb%25255B1%25255D.gif?imgmax=800" width="462" border="0"></a> <p><b>A 16x2 line Hitachi HD44780 display</b> <p>For a 8-bit data bus, the display requires a +5V supply plus 11 I/O lines. For a 4-bit data bus it only requires the supply lines plus seven extra lines. When the LCD display is not enabled, data lines are tri-state which means they are in a state of high impendance (as though they are disconnected) and this means they do not interfere with the operation of the microcontroller when the display is not being addressed. <br>The LCD also requires 3 "control" lines from the microcontroller. <p><b>Enable (E)</b><br>This line allows access to the display through R/W and RS lines. When this line is low, the LCD is disabled and ignores signals from R/W and RS. When (E) line is high, the LCD checks the state of the two control lines and responds accordingly. <p><b>Read/Write (R/W)</b><br>This line determines the direction of data between the LCD and microcontroller. When it is low, data is written to the LCD. When it is high, data is read from the LCD. <p><b>Register select (RS)</b><br>With the help of this line, the LCD interprets the type of data on data lines. When it is low, an instruction is being written to the LCD. When it is high, a character is being written to the LCD. <p>Logic status on control lines:<br><b>E</b> 0 Access to LCD disabled<br> 1 Access to LCD enabled<br><b>R/W</b> 0 Writing data to LCD<br> 1 Reading data from LCD<br><b>RS</b> 0 Instruction<br> 1 Character<br>Writing data to the LCD is done in several steps:<br>Set R/W bit to low <br>Set RS bit to logic 0 or 1 (instruction or character)<br>Set data to data lines (if it is writing)<br>Set E line to high <br>Set E line to low <br>Read data from data lines (if it is reading)<br>Reading data from the LCD is done in the same way, but control line R/W has to be high. When we send a high to the LCD, it will reset and wait for instructions. Typical instructions sent to LCD display after a reset are: turning on a display, turning on a cursor and writing characters from left to right. When the LCD is initialized, it is ready to continue receiving data or instructions. If it receives a character, it will write it on the display and move the cursor one space to the right. The Cursor marks the next location where a character will be written. When we want to write a string of characters, first we need to set up the starting address, and then send one character at a time. Characters that can be shown on the display are stored in data display (DD) RAM. The size of DDRAM is 80 bytes. <p>The LCD display also possesses 64 bytes of Character-Generator (CG) RAM. This memory is used for characters defined by the user. Data in CG RAM is represented as an 8-bit character bit-map. Each character takes up 8 bytes of CG RAM, so the total number of characters, which the user can define is eight. In order to read in the character bit-map to the LCD display, we must first set the CG RAM address to starting point (usually 0), and then write data to the display. The definition of a 'special' character is given in the picture. <p><a href="http://lh6.ggpht.com/-hYcEYP3Gq3I/TxZs3TgqbZI/AAAAAAAACTc/Gx8yeF5xuxc/s1600-h/32%25255B4%25255D.gif"><img title="32" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="306" alt="32" src="http://lh6.ggpht.com/-j--OsB924WQ/TxZs4BNnLxI/AAAAAAAACTk/HL_dJ_R1-QQ/32_thumb%25255B1%25255D.gif?imgmax=800" width="338" border="0"></a> <p>Before we access DD RAM after defining a special character, the program must set the DD RAM address. Writing and reading data from any LCD memory is done from the last address which was set up using set-address instruction. Once the address of DD RAM is set, a new written character will be displayed at the appropriate place on the screen. Until now we discussed the operation of writing and reading to an LCD as if it were an ordinary memory. But this is not so. The LCD controller needs 40 to 120 microseconds (uS) for writing and reading. Other operations can take up to 5 mS. During that time, the microcontroller can not access the LCD, so a program needs to know when the LCD is busy. We can solve this in two ways. <p><a href="http://lh6.ggpht.com/-D-yRZOcajGA/TxZs4rEF6TI/AAAAAAAACTw/ml9wJuX5CSc/s1600-h/33%25255B4%25255D.gif"><img title="33" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="413" alt="33" src="http://lh6.ggpht.com/-_VivyJHC4mI/TxZs5vLBw4I/AAAAAAAACT4/Mi3Za3irHX0/33_thumb%25255B1%25255D.gif?imgmax=800" width="441" border="0"></a> <p>One way is to check the BUSY bit found on data line D7. This is not the best method because LCD's can get stuck, and program will then stay forever in a loop checking the BUSY bit. The other way is to introduce a delay in the program. The delay has to be long enough for the LCD to finish the operation in process. Instructions for writing to and reading from an LCD memory are shown in the previous table.<br>At the beginning we mentioned that we needed 11 I/O lines to communicate with an LCD. However, we can communicate with an LCD through a 4-bit data bus. Thus we can reduce the total number of communication lines to seven. The wiring for connection via a 4-bit data bus is shown in the diagram below. In this example we use an LCD display with 2x16 characters, labeled LM16X212 by Japanese maker SHARP. The message 'character' is written in the first row: and two special characters '~' and '}' are displayed. In the second row we have produced the word 'mikroElektronika'. <p><a href="http://lh4.ggpht.com/-8Co9HGfZKoA/TxZs6lmLPvI/AAAAAAAACT8/tNlZcl_O8D8/s1600-h/34%25255B5%25255D.gif"><img title="34" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="352" alt="34" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg44-fpk6RR3aDaKqo6-91WbPwUZOFNjw14YU5GUIzvrkwYL4O5pcIxjSQIpYQVvTjxv3E9y0zY75HteuiCY8MrTrfOIoiF-hUf4yTuOTzoM9kUJ5Ka9nsFlQHvyOegX4XYrwtSkvKdLYA/?imgmax=800" width="638" border="0"></a> <p><b>Connecting an LCD display to a microcontroller</b> <p>File <b>lcd.inc</b> contains a group of macros for use when working with LCD displays. <p><a href="http://lh5.ggpht.com/-fpD_P8CPcak/TxZs8UqNlEI/AAAAAAAACUM/KZzK-7TdOQw/s1600-h/lcd_inc%25255B9%25255D.gif"><img title="lcd_inc" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="2256" alt="lcd_inc" src="http://lh6.ggpht.com/-XWoY0YLjQVs/TxZs9-W8FYI/AAAAAAAACUY/oABAhx_GAOs/lcd_inc_thumb%25255B6%25255D.png?imgmax=800" width="662" border="0"></a> <p><b>Using the macro for LCD support</b> <p><b>lcd</b><b>init</b><br>Macro used to initialize port connected to LCD. LCD is configured to work in 4-bit mode. <p> Example:<br>lcdinit <p>lcdtext<br>lcdtext prints the text of up to 16 characters, which is specified as a macro parameter. First parameter selects the line in which to start printing. If select is zero, text is printed from the current cursor position. <p> Example:<br>lcdtext 1, "mikroelektronika" <p>lcdtext 1, "Temperature1" ;Print the text starting from line 1, character 1 <p>lcdtext 2, "temp=" ;Print the text starting from line 2, character 1 <p>lcdtext 0, " C" ;Print C in the rest of the line 2 <p>lcdcmd<br>Sends command instructions <p>LCDCLR<br>= b'00000001'<br>;Clear display, cursor home <p>LCDCH<br>= b'00000010'<br>;Cursor home <p>LCDCL<br>= b'00000100'<br>;Move the cursor to the left <p>LCDCR<br>= b'00000110'<br>;Move the cursor to the right <p>LCDSL<br>= b'00011000'<br>;Move the content of display to the left <p>LCDSR<br>= b'00011100'<br>;Move the content of display to the right <p>LCDL1<br>= b'10000000'<br>;Select line 1 <p>LCDL2<br>= b'11000000'<br>;Select line 2 <p> Example:<br>lcdcmd LCDCH <p>lcdbyte<br>Prints one byte variable and omits leading zeros <p> Example:<br>lcdbyte Temperature <p>When working with a microcontroller the numbers are presented in a binary form. As such, they cannot be displayed on a display. That's why it is necessary to change the numbers from a binary system into a decimal system so they can be easily understood. For printing the variables lcdbyte and lcdword we have used the macros <i>digbyte</i> and <i>digword</i> which convert the numbers from binary system into a decimal system and print the result on LCD. Main program has the purpose of demonstrating use of LCD display. At the start it's necessary to declare variables LCDbuf, LCDtemp, Digtemp, Dig1, Dig2, and Dig3 used by the macros for LCD support. It is also necessary to state the port of microcontroller that LCD is connected to. Program initializes the LCD and demonstrates printing text and 8-bit variable temp. <p><a href="http://lh4.ggpht.com/-S7IeJBwjnwA/TxZs-uF3osI/AAAAAAAACUg/-VGH22Uouz0/s1600-h/lcd_asm%25255B9%25255D.gif"><img title="lcd_asm" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="1165" alt="lcd_asm" src="http://lh6.ggpht.com/-YajEZocV8u0/TxZs_5VwrbI/AAAAAAAACUo/wC1iDtSDo3E/lcd_asm_thumb%25255B6%25255D.gif?imgmax=800" width="671" border="0"></a> mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-51688939865419895872012-01-17T22:51:00.001-08:002012-01-17T22:51:51.769-08:007.8 connecting Seven-Segment Display (multiplexing) to PIC microcontrollers<p><b>7.8 Seven-Segment Display (multiplexing)</b> <p>The segments in a 7-segment display are arranged to form a single digit from 0 to F as shown in the animation: <p><a href="http://lh5.ggpht.com/-JasJ8dWuzms/TxZr7xmDRCI/AAAAAAAACSQ/74RLTrY0U58/s1600-h/7-SegDisplay%25255B5%25255D.gif"><img title="7-SegDisplay" style="display: inline" height="261" alt="7-SegDisplay" src="http://lh3.ggpht.com/--6bPIw6MJPA/TxZr8RuX56I/AAAAAAAACSU/_tdXpoAUHrI/7-SegDisplay_thumb%25255B2%25255D.gif?imgmax=800" width="193"></a> <p>We can display a multi-digit number by connecting additional displays. Even though LCD displays are more comfortable to work with, 7-segment displays are still standard in the industry. This is due to their temperature robustness, visibility and wide viewing angle. Segments are marked with non-capital letters: a, b, c, d, e, f, g and dp, where dp is the decimal point. The 8 LEDs inside each display can be arranged with a common cathode or common anode. With a common cathode display, the common cathode must be connected to the 0V rail and the LEDs are turned on with a logic one. Common anode displays must have the common anode connected to the +5V rail. The segments are turned on with a logic zero. The size of a display is measured in millimeters, the height of the digit itself (not the housing, but the digit!). Displays are available with a digit height of 7,10, 13.5, 20, or 25 millimeters. They come in different colors, including: red, orange, and green. <p>The simplest way to drive a display is via a display driver. These are available for up to 4 displays. Alternatively displays can be driven by a microcontroller and if more than one display is required, the method of driving them is called "multiplexing." <p>The main difference between the two methods is the number of "drive lines." A special driver may need only a single "clock" line and the driver chip will access all the segments and increment the display. If a single display is to be driven from a microcontroller, 7 lines will be needed plus one for the decimal point. For each additional display, only one extra line is needed. To produce a 4, 5 or 6 digit display, all the 7-segment displays are connected in parallel. The common line (the common-cathode line) is taken out separately and this line is taken low for a short period of time to turn on the display. Each display is turned on at a rate above 100 times per second, and it will appear that all the displays are turned on at the same time. As each display is turned on, the appropriate information must be delivered to it so that it will give the correct reading. Up to 6 displays can be accessed like this without the brightness of each display being affected. Each display is turned on very hard for one-sixth the time and the POV (persistence of vision) of our eye thinks the display is turned on the whole time. Therefore, the program has to ensure the proper timing, else the unpleasant blinking of display will occur. <p><a href="http://lh6.ggpht.com/-Eju97sn8mxk/TxZr80YAR3I/AAAAAAAACSc/vInMnfSwnL8/s1600-h/29%25255B4%25255D.gif"><img title="29" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="374" alt="29" src="http://lh3.ggpht.com/-67b6J5NglgM/TxZr9rY63kI/AAAAAAAACSo/2GqbSPcoEtE/29_thumb%25255B1%25255D.gif?imgmax=800" width="533" border="0"></a> <p><b>Connecting a microcontroller to 7-segment displays in multiplex mode</b> <p>Program "7seg.asm" displays decimal value of a number stored in variable D. <p>Example: <p>movlw .21 <p>movlw D<br>; number 21 will be printed on 7seg display <p>Displaying digits is carried out in multiplex mode which means that the microcontroller alternately prints ones digit and tens digit. TMR0 interrupt serves for generating a time period, so that the program enters the interrupt routine every 5ms and performs multiplexing. In the interrupt routine, first step is deciding which segment should be turned on. In case that the tens digit was previously on, it should be turned off, set the mask for printing the ones digit on 7seg display which lasts 5ms, i.e. until the next interrupt. <p>For extracting the ones digit and the tens digit, macro <i>digbyte</i> is used. It stores the hundreds digit, the tens digit, and the ones digit into variables Dig1, Dig2, and Dig3. In our case, upon macro execution, Dig1 will equal 0, Dig2 will equal 2, and Dig3 will equal 1. <p>Realization of the macro is given in the following listing: <p><a href="http://lh5.ggpht.com/-x-SXXvwfndk/TxZr-mQEIkI/AAAAAAAACSw/Bh2rj5naXk8/s1600-h/digit_inc%25255B4%25255D.gif"><img title="digit_inc" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="545" alt="digit_inc" src="http://lh4.ggpht.com/-Gk1dt6TZplg/TxZr_Mm1mHI/AAAAAAAACS4/bzR1xiCUHVo/digit_inc_thumb%25255B1%25255D.gif?imgmax=800" width="610" border="0"></a> <p>The following example shows the use of the macro in a program. Program prints a specified 2-digit number on a 7seg display in multiplex mode. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0F-gWoV0Xx8BWj3ixm19K337H2R0ERm6o-d8NThdIWJtXPcJpuPpyzzUbiChYibSDpLt9afBBEDhYGKwq5iSbl0fOYKc44VPO2sc2u3CmSQY8S0jEFHWNLjtOEcxIFf3tubgq5oNG1Ro/s1600-h/7seg_asm%25255B11%25255D.gif"><img title="7seg_asm" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="1492" alt="7seg_asm" src="http://lh6.ggpht.com/-U0THa0_fOmw/TxZsBba2V_I/AAAAAAAACTI/cfn4tRiECGA/7seg_asm_thumb%25255B8%25255D.gif?imgmax=800" width="661" border="0"></a> mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-65154906784513059652012-01-17T22:49:00.001-08:002012-01-17T22:49:55.872-08:007.7 Shift registers in microcontrollers<p align="justify"><b>7.7 Shift registers</b> <p align="justify">There are two types of shift registers: <b>input and output</b>. <b>Input shift registers</b> receive data in parallel, through 8 lines and then send it serially through two lines to a microcontroller. <b>Output shift registers</b> work in the opposite direction; they receive serial data and on a "latch" line signal, they turn it into parallel data. Shift registers are generally used to expand the number of input-output lines of a microcontroller. They are not so much in use any more though, because most modern microcontrollers have a large number of pins. However, their use with microcontrollers such as PIC16F84 is very important. <p align="justify"><b>7.7.1 Input shift register 74HC597</b> <p align="justify">Input shift registers transform parallel data into serial data and transfers it to a microcontroller. Their working is quite simple. There are four lines for the transfer of data: <b>Clock, Latch, Load and Data</b>. Data is first read from the input pins by an internal register through a 'latch' signal. Then, with a 'load' signal, data is transferred from the input latch register to the shift register, and from there it is serially transferred to a microcontroller via 'data' and 'clock' lines. <p align="justify"><a href="http://lh5.ggpht.com/-QI_vh7wlhSs/TxZrVptY75I/AAAAAAAACQM/iO4zjgA_Jfw/s1600-h/21%25255B4%25255D.gif"><img title="21" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="408" alt="21" src="http://lh4.ggpht.com/-JjuewnRXe3c/TxZrWehMN3I/AAAAAAAACQU/T2XvU9OH4Uo/21_thumb%25255B1%25255D.gif?imgmax=800" width="506" border="0"></a></p> <p align="justify">An outline of the connection of the shift register 74HC597 to a micro, is shown below. <p align="justify"><a href="http://lh4.ggpht.com/-cbZ02qcIMtQ/TxZrXPmBnLI/AAAAAAAACQc/_FRGyVd-big/s1600-h/22%25255B4%25255D.gif"><img title="22" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="385" alt="22" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRvk-fSPRF-nwkqa9l0k7kEt_oeXztxOjwABXq8gxZ7p0fvT8DAZTVYDF9gX9L9ccteF-GWAGroqaGlsPWgEpYA12z4DfFa3t2ASHjXZLhQNobQbhDCYPS3wep5tuEVLuqQU1_9loErhw/?imgmax=800" width="552" border="0"></a></p> <p align="justify">In order to simplify the main program, a macro can be used for the input shift register. Macro HC597 has two parameters:<br>HC597 macro Var, Var1<br><b>Var</b> variable where data from shift register input pins is transferred<br><b>Var1</b> loop counter<br><b>Example:</b> HC597 data, counter<br>Data from the input pins of the shift register is stored in data variable. Timer/counter variable is used as a loop counter. <br>Macro listing:</p> <p align="justify"><a href="http://lh5.ggpht.com/-dv7PZdF4x5E/TxZrY0rjzOI/AAAAAAAACQs/pdV7g2TrRds/s1600-h/hc597_inc%25255B4%25255D.gif"><img title="hc597_inc" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="516" alt="hc597_inc" src="http://lh4.ggpht.com/-FnztatHqbnY/TxZraoGPgpI/AAAAAAAACQ0/UVOgBSucQCA/hc597_inc_thumb%25255B1%25255D.gif?imgmax=800" width="575" border="0"></a></p> <p align="justify">Example of how to use the HC597 macro is given in the following program. Program receives data from a parallel input of the shift register and moves it serially into the RX variable of the microcontroller. LEDs connected to port B will indicate the result of the data input. <p align="justify"><a href="http://lh3.ggpht.com/-xxZUy50mCXo/TxZrbMZM4sI/AAAAAAAACQ4/wWGWcdR7i_0/s1600-h/hc597_asm%25255B5%25255D.gif"><img title="hc597_asm" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="783" alt="hc597_asm" src="http://lh4.ggpht.com/-1BjWewdogtk/TxZrcKnZYnI/AAAAAAAACRE/J9sMKKl0Lbs/hc597_asm_thumb%25255B2%25255D.gif?imgmax=800" width="596" border="0"></a></p> <p align="justify"><b>7.7.2 Output shift register</b> <p align="justify">Output shift registers transform serial data into parallel data. On every rising edge of the clock, the shift register reads the value from data line, stores it in temporary register, and then repeats this cycle 8 times. On a signal from 'latch' line, data is copied from the shift register to input register, thus data is transformed from serial into parallel data. <p align="justify"><a href="http://lh5.ggpht.com/-ffSifL21PaU/TxZrdJMuEcI/AAAAAAAACRI/cLj-BlWntMM/s1600-h/25%25255B4%25255D.gif"><img title="25" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="403" alt="25" src="http://lh3.ggpht.com/-dFFP21lGtdA/TxZrd7gh_HI/AAAAAAAACRU/ZtQYEhNkObM/25_thumb%25255B1%25255D.gif?imgmax=800" width="631" border="0"></a></p> <p align="justify">An outline of the 74HC595 shift register connections is shown on the diagram below: <p align="justify"><a href="http://lh3.ggpht.com/-3jsWiyycClg/TxZre-LV4GI/AAAAAAAACRY/qMVoK_YxR4g/s1600-h/26%25255B4%25255D.gif"><img title="26" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="270" alt="26" src="http://lh6.ggpht.com/-ovou50fzmno/TxZrfiUlBmI/AAAAAAAACRg/rzBuCy00yak/26_thumb%25255B1%25255D.gif?imgmax=800" width="558" border="0"></a></p> <p align="justify">Macro used in this example can be found in hc595.inc file, and is called HC595.<br>Macro HC595 has two parameters:<br>HC595 macro Var, Var1<br><b>Var</b> variable whose contents is transferred to outputs of shift register.<br><b>Var1</b> loop counter<br><b>Example:</b> HC595 Data, counter<br>The data we want to transfer is stored in data variable, and counter variable is used as a loop counter.</p> <p align="justify"><a href="http://lh3.ggpht.com/-nLeRWukIHEk/TxZrgVAzVjI/AAAAAAAACRo/kUlSuuJpB4g/s1600-h/hc595_inc%25255B5%25255D.gif"><img title="hc595_inc" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="455" alt="hc595_inc" src="http://lh5.ggpht.com/-gy3AFYsbDrs/TxZrhL8GCOI/AAAAAAAACR0/IRMD6JelPxc/hc595_inc_thumb%25255B2%25255D.gif?imgmax=800" width="606" border="0"></a></p> <p align="justify">An example of how to use the HC595 macro is given in the following program. Data from variable TX is serially transferred to shift register. LEDs connected to the parallel output of the shift register will indicate the state of the lines. In this example value 0xCB (1100 1011) is sent so that the seventh, sixth, third, first, and zero LEDs are illuminated. <p align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWQUCZq4DzmZQOY1wsV8UvE3E0thN4hMnXzRhuG0N2YYTXL_c9HnpHuLowuRNwGsisUnk3wNWEQ3-UFv3qKlRKqeOWLCbs-4FnH5-0cMVb243imlyX8_QoZIgXvtWRCF0kUn8yRcTs5h0/s1600-h/hc595_asm%25255B4%25255D.gif"></a> <p align="justify"></p> <p align="justify"><a href="http://lh6.ggpht.com/-PwhpIX1UgcQ/TxZrh5vg-bI/AAAAAAAACSE/TOuVeTip23M/s1600-h/hc595_asm%25255B6%25255D.gif"><img title="hc595_asm" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="710" alt="hc595_asm" src="http://lh5.ggpht.com/-gEG5hi_ojF8/TxZrkrMIGeI/AAAAAAAACSI/Up4_hNkocrA/hc595_asm_thumb%25255B3%25255D.gif?imgmax=800" width="591" border="0"></a></p> mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-37540599859867411922012-01-17T22:47:00.001-08:002012-01-17T22:47:30.688-08:007.6 Generating sound using PIC microcontroller<p><b>7.6 Generating sound</b> <p>In microcontroller systems, beeper is used for indicating certain occurrences, such as push of a button or an error. To have the beeper started, it needs to be delivered a string in binary code - in this way, you can create sounds according to your needs. Connecting the beeper is fairly simple: one pin is connected to the mass, and the other to the microcontroller pin through a capacitor, as shown on the following image. <p><a href="http://lh4.ggpht.com/-he1Ag-FbcSA/TxZq7-_KZ4I/AAAAAAAACPc/olqjpjNsNOM/s1600-h/18%25255B4%25255D.gif"><img title="18" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="337" alt="18" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1xD23U5AbZ1U_RqYezEqOru97-63M6_dte-AVCOIwl3qFJOxUg0W4a1f87pVKQB6peerBNAqrc1GSWGT_lljA0TyaMoBEX_gaV3sZ-Z9f-MtFu18yGFWpxQkqZdWDBUhyphenhyphenMusHUgir39U/?imgmax=800" width="531" border="0"></a> <p>As with a button, you can employ a macro that will deliver a BEEP ROUTINE into a program when needed. Macro BEEP has two arguments:<br>BEEP <b>macro</b> freq , duration:<br><b>freq:</b> frequency of the sound. The higher number produces higher frequency<br><b>duration: </b> sound duration. Higher the number, longer the sound.<br><b>Example 1:</b> BEEP 0xFF, 0x02<br>The output has the highest frequency and duration at 2 cycles per 65.3mS which gives 130.6 mS<br><b>Example2:</b> BEEP 0x90, 0x05<br>The output has a frequency of 0x90 and duration of 5 cycles per 65.3mS. It is best to determine these macro parameters through experimentation and select the sound that best suits the application.<br>The following is the BEEP Macro listing: <p><a href="http://lh6.ggpht.com/-DLgJAld-ofQ/TxZq9HcvmUI/AAAAAAAACPo/G4wmUfpsgJc/s1600-h/beep_inc%25255B5%25255D.gif"><img title="beep_inc" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="664" alt="beep_inc" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM6QdeM8Gj2s6vG_2DSDGwVrOe3LKu1uxCngR8_Lpf-VOKu06BKz2Hn3fkWHLrEGCYELgcXKkGJRwODfOTm8ulAygTZz8bTxTnJ56Lrzff54Mv_iytKxTHzcjb7H1b_FJihd3mNt69Ggk/?imgmax=800" width="532" border="0"></a> <p>The following example shows the use of a macro in a program. The program produces two melodies which are obtained by pressing T1 or T2. Some of the previously discussed macros are included in the program. <p><a href="http://lh6.ggpht.com/-vGibGH8c7dY/TxZq-8vM9NI/AAAAAAAACP4/7RIc8651esM/s1600-h/beep_asm%25255B7%25255D.gif"><img title="beep_asm" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="844" alt="beep_asm" src="http://lh6.ggpht.com/-3TiRHy8X1uY/TxZrAJkTU0I/AAAAAAAACQE/ObC6dnxmxuM/beep_asm_thumb%25255B4%25255D.gif?imgmax=800" width="564" border="0"></a> mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-29571977708710576132012-01-17T22:46:00.001-08:002012-01-17T22:46:12.258-08:007.5 Connecting Relays to PIC microcontrollers<p align="justify"><b>7.5 Relay</b> <p align="justify">The relay is an electromechanical device, which transforms an electrical signal into mechanical movement. It consists of a coil of insulated wire on a metal core, and a metal armature with one or more contacts. When a supply voltage was delivered to the coil, current would flow and a magnetic field would be produced that moves the armature to close one set of contacts and/or open another set. When power is removed from the relay, the magnetic flux in the coil collapses and produces a fairly high voltage in the opposite direction. This voltage can damage the driver transistor and thus a reverse-biased diode is connected across the coil to "short-out" the spike when it occurs. <p align="justify"><a href="http://lh6.ggpht.com/-jsV6IvOgCVM/TxZqoVA2o_I/AAAAAAAACOs/mAjDT24Bvs8/s1600-h/15%25255B5%25255D.gif"><img title="15" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="461" alt="15" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2edO-gg1nM6dSRmGYk7rASc2CrX3Ur6xmdpDIy15mWK7tbbWqizCtON0Nw9dJ9uzh8FUhiPADkkvALMpqkPAgpQwD_Mjxu3A-vK6L5JrmqvyNRgrf6ums3HtEyrF7UhwKJGI_W7l-sgE/?imgmax=800" width="599" border="0"></a></p> <p align="justify"><b>Connecting a relay to the microcontroller via transistor</b> <p align="justify">Since microcontroller cannot provide sufficient supply for a relay coil (approx. 100+mA is required; microcontroller pin can provide up to 25mA), a transistor is used for adjustment purposes, its collector circuit containing the relay coil. When a logical one is delivered to transistor base, transistor activates the relay, which then, using its contacts, connects other elements in the circuit. Purpose of the resistor at the transistor base is to keep a logical zero on base to prevent the relay from activating by mistake. This ensures that only a clean logical one on RA3 activates the relay. <p align="justify"><a href="http://lh6.ggpht.com/-SrWKiffnMdE/TxZqp7VoidI/AAAAAAAACO4/KUeJyMETU1k/s1600-h/16%25255B4%25255D.gif"><img title="16" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="465" alt="16" src="http://lh4.ggpht.com/-GIrbHwo5zEc/TxZqqsMvqlI/AAAAAAAACPE/1JrmEnlhdrA/16_thumb%25255B1%25255D.gif?imgmax=800" width="610" border="0"></a></p> <p align="justify"><b>Connecting the optocoupler and relay to a microcontroller</b> <p align="justify">A relay can also be activated via an optocoupler which at the same time amplifies the current related to the output of the microcontroller and provides a high degree of isolation. High current optocouplers usually contain a 'Darlington' output transistor to provide high output current. <p align="justify">Connecting via an optocoupler is recommended especially for microcontroller applications, where relays are used fro starting high power load, such as motors or heaters, whose voltage instability can put the microcontroller at risk. In our example, when LED is activated on some of the output port pins, the relay is started. Below is the program needed to activate the relay, and includes some of the already discussed macros. <p align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiWRUyP-T8idSImoFUeX3uEUp9rVBuso2yOCs8U7fvvI7qWXMguLRD9d4CBzj5LwKXQ5MvCfGzu4Y1zAOnWurOIJjxC67ErlPgDw3DkABt93OTeV2nXlEpXicCKsIjOnGUML8qFCKgmE0/s1600-h/relay_asm%25255B7%25255D.gif"><img title="relay_asm" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="866" alt="relay_asm" src="http://lh6.ggpht.com/-NizwqrrfqUQ/TxZqsroByWI/AAAAAAAACPU/y-flN3qlHW0/relay_asm_thumb%25255B4%25255D.gif?imgmax=800" width="600" border="0"></a></p> mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-61124891257999921762012-01-17T22:44:00.001-08:002012-01-17T22:44:44.353-08:007.4 Connecting Optocouplers PIC microcontrollers<p align="justify"><b>7.4 Optocouplers</b> <p align="justify">Optocouplers were discovered right after photo-transistors (like any other transistor, except it is stimulated by light), by combining a LED and photo-transistor in the same case. The purpose of an optocoupler is to separate two parts of a circuit. <p align="justify">This is done for a number of reasons: <ul> <li> <div align="justify">Interference<b>.</b> Typical examples are industrial units with lots of interferences which affect signals in the wires. If these interferences affected the function of control section, errors would occur and the unit would stop working.</div> <li> <div align="justify">Simultaneous separation and intensification of a signal<b>.</b> Typical examples are relays which require higher current than microcontroller pin can provide. Usually, optocoupler is used for separating microcontroller supply and relay supply.</div> <li> <div align="justify">In case of a breakdown, optocoupled part of device stays safe in its casing, reducing the repair costs.</div></li></ul> <p align="justify">Optocouplers can be used as either input or output devices. They can have additional functions such as intensification of a signal or Schmitt triggering (the output of a Schmitt trigger is either 0 or 1 - it changes slow rising and falling waveforms into definite low or high values). Optocouplers come as a single unit or in groups of two or more in one casing.<br>Each optocoupler needs two supplies in order to function. They can be used with one supply, but the voltage isolation feature, which is their primary purpose, is lost.</p> <p align="justify"><b>7.4.1 Optocoupler on an input line</b> <p align="justify">The way it works is simple: when a signal arrives, the LED within the optocoupler is turned on, and it illuminates the base of a photo-transistor within the same case. When the transistor is activated, the voltage between collector and emitter falls to 0.7V or less and the microcontroller sees this as a logic zero on its RA4 pin. <p align="justify">The example below is a simplified model of a counter, element commonly utilized in industry (it is used for counting products on a production line, determining motor speed, counting the number of revolutions of an axis, etc). We will have sensor set off the LED every time axis makes a full revolution. LED in turn will 'send' a signal by means of photo-transistor to a microcontroller input RA4 (TOCKI). As prescaler is set to 1:2 in this example, every second signal will increment TMR0. Current status of the counter is displayed on PORTB LEDs. <p align="justify"><a href="http://lh4.ggpht.com/-EX3JXF1fT0M/TxZqSVkwnfI/AAAAAAAACN8/0qF4Nje5gUM/s1600-h/12%25255B4%25255D.gif"><img title="12" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="272" alt="12" src="http://lh4.ggpht.com/-4LCyVSY55dg/TxZqTIypt_I/AAAAAAAACOE/Bu3WjdL32gM/12_thumb%25255B1%25255D.gif?imgmax=800" width="548" border="0"></a></p> <p align="justify"><b>Example of optocoupler on an input line</b> <p align="justify"><a href="http://lh3.ggpht.com/-qhkJnYqiShc/TxZqT4lh2MI/AAAAAAAACOM/RGLlB8gj1ac/s1600-h/optoin_asm%25255B4%25255D.gif"><img title="optoin_asm" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="549" alt="optoin_asm" src="http://lh5.ggpht.com/-CDjnMyAaPKo/TxZqU06zt5I/AAAAAAAACOU/E8Cd_pNI_Jw/optoin_asm_thumb%25255B1%25255D.gif?imgmax=800" width="558" border="0"></a></p> <p align="justify"><b>7.4.2 Optocoupler on an output line</b> <p align="justify">An Optocoupler can be also used to separate the output signals. If optocoupler LED is connected to microcontroller pin, logical zero on pin will activate optocoupler LED, thus activating the transistor. This will consequently switch on LED in the part of device working on 12V. Layout of this connection is shown below. <p align="justify"><a href="http://lh5.ggpht.com/-viWkOQ5VWtY/TxZqVxqHmXI/AAAAAAAACOc/htqjFqYFk4k/s1600-h/14%25255B4%25255D.gif"><img title="14" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="300" alt="14" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbh2ANKuiTaFGvfud-BH2FUAVFU22_i0_D-qabKCuHqbAqs5mMIWw3eaGYH_Z9srNODLfjdewX7sosPgZGmr2z7aEEz0EM8cJDDWdsPA0-ygsOj2g0VoohzQQ2TbURUfZlHZvByUikKNo/?imgmax=800" width="591" border="0"></a></p> <p align="justify"><b>Ex</b><b>ample of optocoupler on output line</b> <p align="justify">The program for this example is simple. By delivering a logical one to the third pin of port A, the transistor will be activated in the optocoupler, switching on the LED in the part of device working on 12V. mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-44935466596166551022012-01-17T22:43:00.001-08:002012-01-17T22:43:08.271-08:007.3 connecting buttons to PIC microcontroller pins<p align="justify"><b>7.3 </b><b>Push buttons</b> <p align="justify">Buttons are mechanical devices used to execute a break or make connection between two points. They come in different sizes and with different purposes. Buttons that are used here are also called "dip-buttons". They are soldered directly onto a printed board and are common in electronics. They have four pins (two for each contact) which give them mechanical stability. <p align="justify"><a href="http://lh6.ggpht.com/-L9Xv_hhb-Do/TxZp18lU9-I/AAAAAAAACMs/Wy4-mfATMa4/s1600-h/09%25255B4%25255D.gif"><img title="09" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="365" alt="09" src="http://lh6.ggpht.com/-WneU8FJQISI/TxZp2qbd5iI/AAAAAAAACM0/5HXQTKadYek/09_thumb%25255B1%25255D.gif?imgmax=800" width="538" border="0"></a></p> <p align="justify"><b>Example of connecting buttons to microcontroller pins</b> <p align="justify">Button function is simple. When we push a button, two contacts are joined together and connection is made. Still, it isn't all that simple. The problem lies in the nature of voltage as an electrical dimension, and in the imperfection of mechanical contacts. That is to say, before contact is made or cut off, there is a short time period when vibration (oscillation) can occur as a result of unevenness of mechanical contacts, or as a result of the different speed in pushing a button (this depends on person who pushes the button). The term given to this phenomena is called SWITCH (CONTACT) DEBOUNCE. If this is overlooked when program is written, an error can occur, or the program can produce more than one output pulse for a single button push. In order to avoid this, we can introduce a small delay when we detect the closing of a contact. This will ensure that the push of a button is interpreted as a single pulse. The debounce delay is produced in software and the length of the delay depends on the button, and the purpose of the button. The problem can be partially solved by adding a capacitor across the button, but a well-designed program is a much-better answer. The program can be adjusted until false detection is completely eliminated. Image below shows what actually happens when button is pushed. <p align="justify"><a href="http://lh5.ggpht.com/-ndl0TMGVHFk/TxZp3RB5rFI/AAAAAAAACM8/_ZKE69CPb6Q/s1600-h/deboncing%25255B4%25255D.gif"><img title="deboncing" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="407" alt="deboncing" src="http://lh5.ggpht.com/-tPfEXUFuQVo/TxZp4XaV6bI/AAAAAAAACNE/2mBKIVVEY-4/deboncing_thumb%25255B1%25255D.gif?imgmax=800" width="558" border="0"></a></p> <p align="justify">As buttons are very common element in electronics, it would be smart to have a macro for detecting the button is pushed. Macro will be called <i>button</i>. <i>Button</i> has several parameters that deserve additional explanation. <p align="justify">button <b>macro </b> port, pin, hilo, label <br><b>Port</b> is a microcontroller's port to which a button is connected. In case of a PIC16F84 microcontroller, it can be PORTA or PORTB.<br><b>Pin</b> is port's pin to which the button is connected.<br><b>HiLo</b> can be '0' or '1' which represents the state when the button is pushed.<br><b>Label</b> is a destination address for jump to a service subprogram which will handle the event (button pushed).</p> <p align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizoHGU-TED3Eqought3ExMtvHKSnlfFuNyh6XDXIKbPhrL-DXQWnTrzlvJXlC5iyTI_wYkWwIqwdTRouRlA4rPQdUBbOBxKqb2CM3MBDOmfbpjNj0_9fGdiBM5g1QV-jdWfK88p24Qrx0/s1600-h/button_inc%25255B4%25255D.gif"><img title="button_inc" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="412" alt="button_inc" src="http://lh6.ggpht.com/-R6X1NBgm-rw/TxZp6HHzGhI/AAAAAAAACNU/Ax0_myN_HAk/button_inc_thumb%25255B1%25255D.gif?imgmax=800" width="544" border="0"></a></p> <p align="justify"><b>Example 1:</b> <p align="justify">button PORTA, 3, 1, Button1 <p align="justify">Button T1 is connected to pin RA3 and to the mass across a pull-down resistor, so it generates logical one upon push. When the button is released, program jumps to the label Button1. <p align="justify"><b>Example 2:</b> <p align="justify">button PORTA, 2, 0, Button2 <p align="justify">Button T1 is connected to pin RA1 and to the mass across a pull-up resistor, so it generates logical zero upon push. When the button is released, program jumps to the label Button2. <p align="justify">The following example illustrates use of macro <i>button</i> in a program. Buttons are connected to the supply across pull-up resistors and connect to the mass when pushed. Variable <i>cnt</i> is displayed on port B LEDs;<i> cnt </i>is incremented by pushing the button RA0, and is decremented by pushing the button RA1. <p align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCNFDcmh8rj5Nz7Voe28OCvgnmGR7pOYnPtIvBpMMQJ3wZSR2gB_P7I0ALMCBCjw1SOIMH21Og7KTB4L21l447OW4blEbDJbUcahAqqUBd6xy-vL9ap_d4Nc71PPqt-3NBemjG8FMd2Ps/s1600-h/button_asm%25255B5%25255D.gif"><img title="button_asm" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="808" alt="button_asm" src="http://lh5.ggpht.com/-e3TnTGq8hEA/TxZp8OKOcsI/AAAAAAAACNk/s3--AkOgF3c/button_asm_thumb%25255B2%25255D.gif?imgmax=800" width="621" border="0"></a></p> <p align="justify">It is important to note that this kind of debouncing has certain drawbacks, mainly concerning the idle periods of microcontroller. Namely, microcontroller is in the state of waiting from the moment the button is pushed until it is released, which can be a very long time period in certain applications. if you want the program to be attending to a number of things at the same time, different approach should be used from the start. Solution is to use the interrupt routine for each push of a button, which will occur periodically with pause adequate to compensate for repeated pushes of button. <p align="justify">The idea is simple. Every 10ms, button state will be checked upon and compared to the previous input state. This comparison can detect rising or falling edge of the signal. In case that states are same, there were apparently no changes. In case of change from 0 to a 1, rising edge occurred. If succeeding 3 or 4 checks yield the same result (logical one), we can be positive that the button is pushed. <p align="justify"><a href="http://lh4.ggpht.com/-Z9Xn96B7o0c/TxZp8-q-c_I/AAAAAAAACNo/TC_AIyA7gk4/s1600-h/deboncing2%25255B5%25255D.gif"><img title="deboncing2" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="205" alt="deboncing2" src="http://lh6.ggpht.com/-lV7FN-aZNrc/TxZp-pyZVLI/AAAAAAAACN0/fHgL_cKNwzc/deboncing2_thumb%25255B2%25255D.gif?imgmax=800" width="590" border="0"></a></p> mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-86452619950024090592012-01-17T22:41:00.001-08:002012-01-17T22:41:18.022-08:007.2 Connecting LED diodes to PIC microcontroller<p align="justify"><b>7.2 LED diodes</b> <p align="justify">LEDs are surely one of the most commonly used elements in electronics. LED is an abbreviation for 'Light Emitting Diode'. When choosing a LED, several parameters should be looked at: diameter, which is usually 3 or 5 mm (millimeters), working current which is usually about 10mA (It can be as low as 2mA for LEDs with high efficiency - high light output), and color of course, which can be red or green though there are also orange, blue, yellow....<br>LEDs must be connected around the correct way, in order to emit light and the current-limiting resistor must be the correct value so that the LED is not damaged or burn out (overheated). The positive of the supply is taken to the anode, and the cathode goes to the negative or ground of the project (circuit). In order to identify each lead, the cathode is the shorter lead and the LED "bulb" usually has a cut or "flat" on the cathode side. Diodes will emit light only if current is flowing from anode to cathode. Otherwise, its PN junction is reverse biased and current won't flow. In order to connect a LED correctly, a resistor must be added in series that to limit the amount of current through the diode, so that it does not burn out. The value of the resistor is determined by the amount of current you want to flow through the LED. Maximum current flow trough LED was defined by manufacturer.</p> <p align="justify">To determine the value of the dropper-resistor, we need to know the value of the supply voltage. From this we subtract the characteristic voltage drop of a LED. This value will range from 1.2v to 1.6v depending on the color of the LED. The answer is the value of <b>Ur.</b> Using this value and the current we want to flow through the LED (0.002A to 0.01A) we can work out the value of the resistor from the formula <b>R=Ur/I</b>. <br><a href="http://lh5.ggpht.com/-RVKI2HYb4FE/TxZpe7Ovf4I/AAAAAAAACL8/4_jLO0y7yD4/s1600-h/06%25255B4%25255D.gif"><img title="06" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="374" alt="06" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYyc9pUypilPKPdcJsT6_mEHadwYbHKoclVYTIaeFVYANrg3j74j2ygM-uWGhIW12iDNRDgLZTAU3tNctvlSl4v0bWPlUbEdGrvTvTMjcwyuaI5ypaV46GO_tUENdZE0taRAusRgCPx8M/?imgmax=800" width="483" border="0"></a></p> <p align="justify">LEDs are connected to a microcontroller in two ways. One is to switch them on with logic zero, and other to switch them on with logic one. The first is called NEGATIVE logic and the other is called POSITIVE logic. The next diagram shows how to connect POSITIVE logic. Since POSITIVE logic provides a voltage of +5V to the diode and dropper resistor, it will emit light each time a pin of port B is provided with a logic 1. The other way is to connect all anodes to +5V and to deliver logical zero to cathodes. <p align="justify"><a href="http://lh3.ggpht.com/-JxzJgtBdCko/TxZpgbBLPfI/AAAAAAAACMM/Nxh98AcfPIg/s1600-h/07%25255B4%25255D.gif"><img title="07" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="534" alt="07" src="http://lh5.ggpht.com/-DKFYLGt84LY/TxZphb-pu_I/AAAAAAAACMU/tDoQrsH6qZk/07_thumb%25255B1%25255D.gif?imgmax=800" width="513" border="0"></a></p> <p align="justify"><b>Connecting LED diodes to PORTB microcontroller</b> <p align="justify">The following example initializes port B as output and alternately switches on and off LED diodes every 0.5sec. For pause we used macro <i>pausems</i>, which is defined in the file mikroel84.inc. <p align="justify"><a href="http://lh3.ggpht.com/-nj62ufGD9tc/TxZph2AxzkI/AAAAAAAACMc/ibRJsZqGqQM/s1600-h/led_asm%25255B6%25255D.gif"><img title="led_asm" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="696" alt="led_asm" src="http://lh3.ggpht.com/-9S--dG7oMy0/TxZpjKUAT2I/AAAAAAAACMk/T39tfa2uzrw/led_asm_thumb%25255B3%25255D.gif?imgmax=800" width="498" border="0"></a></p> mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-60264851222101634512012-01-17T22:39:00.001-08:002012-01-17T22:39:17.182-08:00CHAPTER 7 PIC microcontroller Examples<p><b>CHAPTER </b><b>7</b> <p><b>Examples</b> <p><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_01chapter.htm#Introduction">Introduction</a> <p><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_01chapter.htm#7.1%20Supplying%20the%20microcontroller">7.1 Supplying the microcontroller</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_02chapter.htm">7.2 LED diodes</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_03chapter.htm">7.3 Push buttons</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_04chapter.htm">7.4 Optocoupler</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_04chapter.htm">7.4.1 Optocouper on input line</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_04chapter.htm">7.4.2 Optocoupler on output line</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_05chapter.htm">7.5 Relay</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_06chapter.htm">7.6 Generating sound</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_07chapter.htm">7.7 Shift registers</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_07chapter.htm">7.7.1 Input shift register</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_07chapter.htm">7.7.2 Output shift register</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_08chapter.htm">7.8 7-seg display (multiplexing)</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_09chapter.htm">7.9 LCD display</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/7_10chapter.htm">7.10 Software SCI communication</a> <p><b><a name="Introduction">Introduction</a></b> <p>Examples given in this chapter will show you how to connect the PIC microcontroller with other peripheral components or devices when developing your own microcontroller system. Each example contains detailed description of hardware with electrical outline and comments on the program. All programs can be taken directly from the 'MikroElektronika' Internet presentation. <p><b><a name="7.1 Supplying the microcontroller">7.1 Supplying the microcontroller</a></b> <p>Generally speaking, the correct voltage supply is of utmost importance for the proper functioning of the microcontroller system. It can easily be compared to a man breathing in the air. It is more likely that a man who is breathing in fresh air will live longer than a man who's living in a polluted environment.<br>For a proper function of any microcontroller, it is necessary to provide a stable source of supply, a sure reset when you turn it on and an oscillator. According to technical specifications by the manufacturer of PIC microcontroller, supply voltage should move between 2.0V to 6.0V in all versions. The simplest solution to the source of supply is using the voltage stabilizer LM7805 which gives stable +5V on its output. One such source is shown in the picture below. <p><a href="http://lh5.ggpht.com/-cqfR4oQCrs4/TxZpDxG3-LI/AAAAAAAACLs/N6ZLhlLcM68/s1600-h/01%25255B4%25255D.gif"><img title="01" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="325" alt="01" src="http://lh3.ggpht.com/-cMtSkG0Iz_I/TxZpEn46VkI/AAAAAAAACL0/k06-mzfuT9s/01_thumb%25255B1%25255D.gif?imgmax=800" width="602" border="0"></a> <p>In order to function properly, or in order to have stable 5V at the output (pin 3), input voltage on pin 1 of LM7805 should be between 7V through 24V. Depending on current consumption of device we will use the appropriate type of voltage stabilizer LM7805. There are several versions of LM7805. For current consumption of up to 1A we should use the version in TO-220 case with the capability of additional cooling. If the total consumption is 50mA, we can use 78L05 (stabilizer version in small TO - 92 packaging for current of up to 100mA). mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-45103803490679819622012-01-17T22:37:00.001-08:002012-01-17T22:37:43.325-08:00CHAPTER 6 Examples for subsystems within microcontroller<p align="justify"><b>CHAPTER 6</b> <p align="justify"><b>Examples for subsystems within microcontroller</b> <p align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/6_chapter.htm#Introduction">Introduction</a> <p align="justify"><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/6_chapter.htm#6.1%20Writing%20to%20and%20reading%20from%20EEPROM">6.1 Writing to and reading from EEPROM</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/6_chapter.htm#6.2%20Processing%20interrupt%20caused%20by%20changes%20on%20pins%20RB4-RB7">6.2 Processing interrupt caused by changes on pins RB4-RB7</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/6_chapter.htm#6.3%20Processing%20interrupt%20caused%20by%20change%20on%20pin%20RB0">6.3 Processing interrupt caused by change on pin RB0</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/6_chapter.htm#6.4%20Processing%20interrupt%20caused%20by%20overflow%20on%20timer%20TMR0">6.4 Processing interrupt caused by overflow on timer TMR0</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/6_chapter.htm#6.5%20Processing%20interrupt%20caused%20by%20overflow%20on%20TMR0%20connected%20to%20external%20input%20%28TOCKI%29">6.5 Processing interrupt caused by overflow on TMR0 connected to external input (TOCKI)</a></p> <p align="justify"><b><a name="Introduction">Introduction</a></b> <p align="justify">Every microcontroller comprises a number of subsystems allowing for flexibility and wide range of applications. These include internal EEPROM memory, AD converters, serial or other form of communication, timers, interrupts, etc. Two most commonly utilized elements are interrupts and timers. One of these or several in combination can create a basis for useful and practical programs. <p align="justify"><b><a name="6.1 Writing to and reading from EEPROM">6.1 Writing to and reading from EEPROM</a></b> <p align="justify">Program "eeprom.asm" uses EEPROM memory for storing certain microcontroller parameters. Transfer of data between RAM and EEPROM has two steps - calling macros <i>eewrite</i> and <i>eeread</i>. Macro <i>eewrite</i> writes certain variable to a given address, while <i>eeread</i> reads the given address of EEPROM and stores the value to a variable. <p align="justify">Macro <i>eewrite</i> writes the address to EEADR register and the variable to EEDATA register. It then calls the subprogram which executes the standard procedure for initialization of writing data (setting WREN bit in EECON1 register and writing control bytes 0x55 and 0xAA to EECON2). <p align="justify"><a href="http://lh6.ggpht.com/-d1PugfR_8sM/TxZoXY8qVLI/AAAAAAAACI8/R4b3YdfCdvo/s1600-h/eeprom_inc%25255B5%25255D.gif"><img title="eeprom_inc" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="553" alt="eeprom_inc" src="http://lh6.ggpht.com/-n7soB1sVuHw/TxZoYT4O_FI/AAAAAAAACJE/iJtSAhYjpG8/eeprom_inc_thumb%25255B2%25255D.gif?imgmax=800" width="610" border="0"></a></p> <p align="justify">For data to be actually stored in EEPROM, 10ms delay is necessary. This is achieved by using macro <i>pausems</i>. In case that this pause is unacceptable for any reason, problem can be solved by using an interrupt for signaling that data is written to EEPROM. <p align="justify">eewrite<br><b>macro</b> addr, var</p> <p align="justify"><b>addr</b><br>Destination address. With PIC16F84, there are 68 bytes </p> <p align="justify">of EEPROM for a total address range of 0x00 - 0x44. <p align="justify"><b>var</b><br>Name of the variable to be stored to EPROM</p> <p align="justify">eeread<br><b>macro</b> addr, var</p> <p align="justify"><b>addr</b><br>Destination address. With PIC16F84, there are 68 bytes</p> <p align="justify">of EEPROM for a total address range of 0x00 - 0x44. <p align="justify"><b>var</b><br>Name of the variable into which data read from EPROM will be stored.</p> <p align="justify">Example: Variable <i>volume</i>, which is set via buttons RA0 and RA1, will be stored to the address 0 of EEPROM. After reboot, when the program is started, it first loads the last known value of variable <i>volume</i> from EEPROM. <p align="justify"><a href="http://lh6.ggpht.com/-hisHKqjcyBo/TxZoZCTb__I/AAAAAAAACJI/p-70JxSTpV0/s1600-h/eeprom_asm%25255B6%25255D.gif"><img title="eeprom_asm" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="1013" alt="eeprom_asm" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJmT0vgN2TMUXBxwW43cE6OMoUMJyB31j0HtILSGl7wA1daH2YHNBdkQFS8qTYLznw7AilJRkLhyphenhyphenrhNPw5cQL4ZV9zU3qhsCxDGQhyphenhyphensUOC9-RyuLg0KvnircqMzkczwEm8KfR1DBDuuSA/?imgmax=800" width="640" border="0"></a></p> <p align="justify"><b><a name="6.2 Processing interrupt caused by changes on pins RB4-RB7">6.2 Processing interrupt caused by changes on pins RB4-RB7</a></b> <p align="justify">Program "intportb.asm" illustrates how interrupt can be employed for indicating changes on pins RB4-RB7. Upon pushing any of the buttons, program enters the interrupt routine and determines which pin caused an interrupt. This program could be utilized in systems with battery power supply, where power consumption plays an important role. It is useful to set microcontroller to low consumption mode with a <i>sleep</i> instruction. Microcontroller is practically on stand-by, saving energy until the occurrence of interrupt. <p align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjsxz-QW_t-M2k8QImrnIF2mZkiNB76QeLEtIVGPLTyk6mHXacCIGcUtiDDPhkPogVPwhEB27LAS-pGv8iAZ41YIqZbuLLSvgWIg1EHULeiT_pkIhpjSokLJ3eylWslXVQObO2HecAm9JE/s1600-h/int_62%25255B5%25255D.gif"><img title="int_62" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="426" alt="int_62" src="http://lh3.ggpht.com/-NhuDGTDvs-0/TxZodJkkjqI/AAAAAAAACJk/2tApEY_8KD8/int_62_thumb%25255B2%25255D.gif?imgmax=800" width="631" border="0"></a></p> <p align="justify"><b>Example of processing interrupt caused by changes on pins RB4-RB7</b> <p align="justify"><a href="http://lh6.ggpht.com/-VfEbplNv35c/TxZoeSr2UJI/AAAAAAAACJs/PhQns7i4QpA/s1600-h/intportb_asm%25255B5%25255D.gif"><img title="intportb_asm" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="954" alt="intportb_asm" src="http://lh3.ggpht.com/-Lq0QCRsS-b8/TxZofn3OJcI/AAAAAAAACJ0/xRhLNeT8xPk/intportb_asm_thumb%25255B2%25255D.gif?imgmax=800" width="617" border="0"></a></p> <p align="justify"><b><a name="6.3 Processing interrupt caused by change on pin RB0">6.3 Processing interrupt caused by change on pin RB0</a></b> <p align="justify">Example "intrb0.asm" demonstrates use of interrupt RB0/INT. Upon falling edge of the impulse coming to RB0/INT pin, program jumps to subprogram for processing interrupt. This routine then performs a certain operation, in our case it blinks the LED diode on PORTB, 7. <p align="justify"><a href="http://lh4.ggpht.com/-gsCE-UBSk60/TxZogaBg7xI/AAAAAAAACJ8/zesYN6B1R4o/s1600-h/int_63%25255B4%25255D.gif"><img title="int_63" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="364" alt="int_63" src="http://lh5.ggpht.com/-lJFCHHabPaM/TxZoh7TXvAI/AAAAAAAACKE/R35Wr4bIll8/int_63_thumb%25255B1%25255D.gif?imgmax=800" width="629" border="0"></a></p> <p align="justify"><b>Example of processing interrupt caused by changes on pin RB0</b> <p align="justify"><a href="http://lh4.ggpht.com/-oiM2fdi5rpc/TxZoimSzU8I/AAAAAAAACKM/Hfhf4dDzl_w/s1600-h/intrb0_asm%25255B5%25255D.gif"><img title="intrb0_asm" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="780" alt="intrb0_asm" src="http://lh5.ggpht.com/-fapBE0EZH48/TxZoj0PPhQI/AAAAAAAACKU/UeYkxb8KmaE/intrb0_asm_thumb%25255B2%25255D.gif?imgmax=800" width="633" border="0"></a></p> <p align="justify"><b><a name="6.4 Processing interrupt caused by overflow on timer TMR0">6.4 Processing interrupt caused by overflow on timer TMR0</a></b> <p align="justify">Program "inttmr0.asm" illustrates how interrupt TMR0 can be employed for generating specific periods of time. Diodes on port B are switched on and off alternately every second. Interrupt is generated every 5.088ms; in interrupt routine variable <i>cnt</i> is incremented to the cap of 196, thus generating approx. 1 second pause (5.088ms*196 is actually 0.99248s). Pay attention to initialization of OPTION register which enables this mode of work for timer TMR0. <p align="justify"><a href="http://lh4.ggpht.com/-1WhAHIoq6O4/TxZokihDREI/AAAAAAAACKY/97x-1e0fTtM/s1600-h/int_64%25255B5%25255D.gif"><img title="int_64" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="650" alt="int_64" src="http://lh6.ggpht.com/-ZD6KRV88VXY/TxZoln4JB7I/AAAAAAAACKk/Qb-EAhmAclY/int_64_thumb%25255B2%25255D.gif?imgmax=800" width="640" border="0"></a></p> <p align="justify"><b>Example of processing interrupt caused by overflow on timer TMR0</b> <p align="justify"><a href="http://lh6.ggpht.com/-X5o9hRWSvYk/TxZomhKZsgI/AAAAAAAACKs/XwR2vKShFS0/s1600-h/inttmr0_asm%25255B5%25255D.gif"><img title="inttmr0_asm" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="847" alt="inttmr0_asm" src="http://lh3.ggpht.com/-Vd80xkg1cpM/TxZooPL0WiI/AAAAAAAACK0/l8tqUzdhyEs/inttmr0_asm_thumb%25255B2%25255D.gif?imgmax=800" width="542" border="0"></a></p> <p align="justify"><a href="http://lh6.ggpht.com/-lxNR3saYBeA/TxZoouHZveI/AAAAAAAACK4/_uR3uELdL5I/s1600-h/inttmr0_graph%25255B5%25255D.gif"><img title="inttmr0_graph" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="450" alt="inttmr0_graph" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVfNYRjSReGsSilDrJGzZaxCK-M1V6hGasSN4r4mxjomDvzOzecUZOfdzsqWFt9CfE-c4UAOMewqvAFKYnNi3A2olqXIjInDBsC3A1UfH9x6j7siLd58pWwOGd-IFuaQlI2-bLkbG39rw/?imgmax=800" width="551" border="0"></a></p> <p align="justify"><b><a name="6.5 Processing interrupt caused by overflow on TMR0 connected to external input (TOCKI)">6.5 Processing interrupt caused by overflow on TMR0 connected to external input (TOCKI)</a></b> <p align="justify">Counter TMR0 increments upon signal change on pin RA4/TOCKI. Prescaler is set to 4, meaning that TMR0 will be incremented on every fourth impulse. Pay attention to initialization of OPTION register which enables this mode of work for timer TMR0 (this mode is common for devices such as counters). <p align="justify"><a href="http://lh4.ggpht.com/-sNi9LeM0c1o/TxZoqN1JD2I/AAAAAAAACLI/2UpyzBWLSVU/s1600-h/int_65%25255B4%25255D.gif"><img title="int_65" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="501" alt="int_65" src="http://lh4.ggpht.com/-W6Wwy31acAg/TxZoq1d-PeI/AAAAAAAACLU/9wG3jv_jGMw/int_65_thumb%25255B1%25255D.gif?imgmax=800" width="487" border="0"></a></p> <p align="justify"><b>Example of processing interrupt caused by overflow on timer TMR0 connected to TOCKI</b> <p align="justify"><a href="http://lh5.ggpht.com/-xPkSRWBXrp8/TxZorw_XxzI/AAAAAAAACLc/3oLCJCXbdVA/s1600-h/inttmr0_a_asm%25255B8%25255D.gif"><img title="inttmr0_a_asm" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="1006" alt="inttmr0_a_asm" src="http://lh5.ggpht.com/-Feeid1-QXcY/TxZotMxKeFI/AAAAAAAACLk/wKjquYK_d5Y/inttmr0_a_asm_thumb%25255B5%25255D.gif?imgmax=800" width="635" border="0"></a></p> mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.comtag:blogger.com,1999:blog-5922120083083455839.post-91082361511378777342012-01-17T22:26:00.001-08:002012-01-17T22:26:13.796-08:00CHAPTER 5 Macros and subprograms<p><b>CHAPTER 5</b> <p><b>Macros and subprograms</b> <p><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_chapter.htm#Introduction">Introduction</a> <p><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_chapter.htm#Macros">5.1 Macros</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_chapter.htm#Subprograms">5.2 Subprograms</a><br><a href="http://www.mikroelektronika.co.yu/english/product/books/PICbook/5_chapter.htm#Macros%20used%20in%20examples">5.3 Macros used in the examples</a> <p><b><a name="Introduction">Introduction</a></b> <p>Same or similar sequence of instructions is frequently used during programming. Assembly language is very demanding. Programmer is required to take care of every single detail when writing a program, because just one incorrect instruction or label can bring about wrong results or make the program doesn't work at all. Solution to this problem is to use already tested program parts repeatedly. For this kind of programming logic, macros and subprograms are used. <p><b><a name="Macros">5.1 Macros</a></b> <p>Macro is defined with directive <b>macro </b>containing the name of macro and parameters if needed. In program, definition of macro has to be placed before the instruction line where macro is called upon. When during program execution macro is encountered, it is replaced with an appropriate set of instructions stated in the macro's definition. <p>macro_name <p><b>macro</b> par1, par2,.. <p>set of instructions <p>set of instructions <p><b>endm</b> <p>The simplest use of macro could be naming a set of repetitive instructions to avoid errors during retyping. As an example, we could use a macro for selecting a bank of SFR registers or for a global permission of interrupts. It is much easier to have a macro BANK1 in a program than having to memorize which status bit defines the mentioned bank. This is illustrated below: banks 0 and 1 are selected by setting or clearing bit 5 (RP0) of status register, while interrupts are enabled by bit 7 of INTCON register. First two macros are used for selecting a bank, while other two enable and disable interrupts. <p>bank0<br><b>macro</b><br>; Macro bank0 <p>bcf STATUS, RP0<br>; Reset RP0 bit = Bank0 <p><b>endm</b><br>; End of macro <p>bank1<br><b>macro</b><br>; Macro bank1 <p>bsf STATUS, RP0<br>; Set RP0 bit = Bank1 <p><b>endm</b><br>; End of macro <p>enableint<br><b>macro</b><br>; Interrupts are globally enabled <p>bsf INTCON, 7<br>; Set the bit <p><b>endm</b><br>; End of macro <p>disableint<br><b>macro</b><br>; Interrupts are globally disabled <p>bcf INTCON, 7<br>; Reset the bit <p><b>endm</b><br>; End of macro <p>These macros are to be saved in a special file with extension INC (abbrev. for INCLUDE file). The following image shows the file bank.inc which contains two macros, bank0 and bank1. <p> <p><i>Macros Bank0 and Bank1 are given for illustrational purposes more than practical, since directive <b>BANKSEL NameSFR</b> does the same job. Just write BANKSEL TRISB and the bank containing the TRISB register will be selected.</i> <p><a href="http://lh5.ggpht.com/-ZkzkeIXbFH8/TxZl2lV0k8I/AAAAAAAACHs/9DSr32e33gU/s1600-h/bank_inc%25255B4%25255D.gif"><img title="bank_inc" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="458" alt="bank_inc" src="http://lh4.ggpht.com/-SEmTf1CNj-Q/TxZl3QfgpFI/AAAAAAAACH0/6Kq3ehRANGg/bank_inc_thumb%25255B1%25255D.gif?imgmax=800" width="604" border="0"></a> <p>As can be seen above, first four macros do not have parameters. However, parameters can be used if needed. This will be illustrated with the following macros, used for changing direction of pins on ports. Pin is designated as input if the appropriate bit is set (with the position matching the appropriate pin of TRISB register, bank1) , otherwise it's output. <p>input<br><b>macro</b> par1, par2<br>; Macro input <p>bank1<br>; In order to access TRIS registers <p>bsf par1, par2<br>; Set the given bit - 1 = input <p>bank0<br>; Macro for selecting bank0 <p><b>endm</b><br>; End of macro <p>output<br><b>macro</b> par1, par2<br>; Macro output <p>bank1<br>; In order to access TRIS registers <p>bcf par1, par2<br>; Reset the given bit - 0 = output <p>bank0<br>; Macro for selecting bank0 <p><b>endm</b><br>; End of macro <p>Macro with parameters can be called upon in following way: <p><b>output TRISB, 7</b> ; pin RB7 is output <p>When calling macro first parameter TRISB takes place of the first parameter, <i>par1</i>, in macro's definition. Parameter 7 takes place of parameter par2, thus generating the following code: <p>output<br>TRISB, 7<br>; Macro output <p><b>bsf</b> STATUS, RP0<br>; Set RP0 bit = BANK1 <p><b>bcf</b> TRISB, 7<br>; Designate RB7 as output <p><b>bcf</b> STATUS, RP0<br>; Reset RP0 bit = BANK0 <p><b>endm</b><br>; End of macro <p>Apparently, programs that use macros are much more legible and flexible. Main drawback of macros is the amount of memory used - every time macro name is encountered in the program, the appropriate code from the definition is inserted. This doesn't necessarily have to be a problem, but be warned if you plan to use sizeable macros frequently in your program. <p>In case that macro uses labels, they have to be defined as local using the directive <b>local</b>. As an example, below is the macro for calling certain function if <i>carry</i> bit in STATUS register is set. If this is not the case, next instruction in order is executed. <p>callc<br><b>macro</b> label<br>; Macro callc <p><i>local</i><br>Exit<br>; Defining local label within macro <p><b>bnc</b> Exit<br>; If C=0 jump to Exit and exit macro <p><b>call</b> label<br>; If C=1 call subprogram at the <p>; address label outside macro <p>Exit<br>; Local label within macro <p><b>endm</b><br>; End of macro <p><b><a name="Subprograms">5.2 Subprograms</a></b> <p>Subprogram represents a set of instructions beginning with a label and ending with the instruction <i>return</i> or <i>retlw</i>. Its main advantage over macro is that this set of instructions is placed in only one location of program memory. These will be executed every time instruction <i>call subprogram_name</i> is encountered in program. Upon reaching <i>return </i>instruction<i>,</i> program execution continues at the line succeeding the one subprogram was called from. Definition of subprogram can be located anywhere in the program, regardless of the lines in which it is called. <p>Label<br>; subprogram is called with "call Label" <p>set of instructions <p>set of instructions <p>set of instructions <p><b>return</b> or <b>retlw</b> <p>With macros, use of input and output parameters is very significant. With subprograms, it is not possible to define parameters within the subprogram as can be done with macros. Still, subprogram <i>can</i> use predefined variables from the main program as its parameters. <p>Common course of events would be: defining variables, calling the subprogram that uses them, and then reading the variables which may have been changed by the subprogram. <p>The following example, <i>addition.asm</i> adds two variables, PAR1 and PAR2, and stores the result to variable RES. As 2-byte variables are in question, lower and higher byte has to be defined for each of these. The program itself is quite simple; it first adds lower bytes of variables PAR1 and PAR2, then it adds higher bytes. If two lower bytes total exceeds 255 (maximum for a byte) carry is added to variable RESH. <p> <p><i>Basic difference between macro and subprogram is that the macro stands for its definition code (sparing the programmer from additional typing) and can have its own parameters while subprogram saves memory, but cannot have its own parameters.</i> <p><a href="http://lh4.ggpht.com/-ZFwLT4u0Gto/TxZl45XaK_I/AAAAAAAACH8/2J0EBq0bgbo/s1600-h/addition%25255B5%25255D.gif"><img title="addition" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="874" alt="addition" src="http://lh6.ggpht.com/-8c9e8MsvFkc/TxZl6SpCYyI/AAAAAAAACIE/WzqWIDGq3o4/addition_thumb%25255B2%25255D.gif?imgmax=800" width="618" border="0"></a> <p><b><a name="Macros used in examples">5.3 Macros used in the examples</a></b> <p>Examples given in chapter 6 frequently use macros <i>ifbit</i>, <i>ifnotbit</i>, <i>digbyte</i>, and <i>pausems</i>, so these will be explained in detail. The most important thing is to comprehend the function of the following macros and the way to use them, without unnecessary bothering with the algorithms itself. All macros are included in the file <i>mikroel84.inc</i> for easier reference. <p><b>5.3.1 Jump to label if bit is set</b> <p>ifbit<br><b>macro</b> par1, par2, par3 <p><b>btfsc</b> par1, par2 <p><b>goto</b> par3 <p><b>endm</b> <p>Macro is called with : ifbit Register, bit, label <p><b>5.3.2 Jump to label if bit is cleared</b> <p>ifnotbit<br><b>macro</b> par1, par2, par3 <p><b>btfs</b><b>s</b> par1, par2 <p><b>goto</b> par3 <p><b>endm</b> <p>Macro is called with : ifnotbit Register, bit, label <p>Next example shows how to use a macro. Pin 0 on port A is checked and if set, program jumps to label <i>ledoff</i>, otherwise macro <i>ifnotbit</i> executes, directing the program to label <i>ledon</i>. <p><a href="http://lh4.ggpht.com/--KmLVKzWk9o/TxZl7WpwqhI/AAAAAAAACII/-snR5F71dAc/s1600-h/macrotest%25255B4%25255D.gif"><img title="macrotest" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="487" alt="macrotest" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWHzv3EhaSCgLxhnsIzuyR2S5_EWcLXVnGDNWKYdVD59IlIJo6PNqlAbVqBJ4beLhTa1NL4JH5qJYD5YSsPakHwE-qdBp7LA1JdKn07jn7uUPGTOYMo5BIGN8MNYFII6MjvRmXEEbIajM/?imgmax=800" width="623" border="0"></a> <p><b>5.3.3 Extracting ones, tens and hundreds from variable</b> <p>Typical use for this macro is displaying variables on LCD or 7seg display. <p>digbyte<br><b>macro</b> par0 <p><i>local</i> Pon0 <p><i>local</i> Exit1 <p><i>local</i> Exit2 <p><i>local</i> Positive <p><i>local</i> Negative <p><b>clrf</b> Dig1 <p><b>clrf</b> Dig2 <p><b>clrf</b> Dig3 <p>Positive <p><b>movf</b> par0, w <p><b>movwf</b> Digtemp <p><b>movlw</b> .100 <p>Pon0<br><b>incf</b> Dig1<br>;computing hundreds digit <p><b>subwf</b> Digtemp <p><b>btfsc</b> STATUS, C <p><b>goto</b> Pon0 <p><b>decf</b> Dig1, w <p><b>addwf</b> Digtemp, f <p>Exit1<br><b>movlw</b> .10<br>;computing tens digit <p><b>incf</b> Dig2, f <p><b>subwf</b> Digtemp, f <p><b>btfsc</b> STATUS, C <p><b>goto</b> Exit1 <p><b>decf</b> Dig2, f <p><b>addwf</b> Digtemp, f <p>Exit2<br><b>movf</b> Digtemp, w<br>;computing ones digit <p><b>movwf</b> Dig3 <p><b>endm</b> <p>Macro is called with : <p><b> movlw</b> .156<br>; w = 156 <p><b> movwf</b> RES<br>; RES = w <p><b> digbyte</b> RES<br>; now Dec1<-1, Dec2<-5, Dec3<-6 <p>The following example shows how to use macro <i>digbyte</i> in program. At the beginning, we have to define variables for storing the result, <i>Dig1</i>, <i>Dig2</i>, <i>Dig3</i>, as well as auxiliary variable <i>Digtemp</i>. <p><a href="http://lh5.ggpht.com/-aFD2GpYePpk/TxZl9ZNNXxI/AAAAAAAACIc/xFDmE1Lqrds/s1600-h/extract%25255B5%25255D.gif"><img title="extract" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="619" alt="extract" src="http://lh4.ggpht.com/-Lg10UZSbRrc/TxZl-cIQmYI/AAAAAAAACIk/Gi0CTmWUulw/extract_thumb%25255B2%25255D.gif?imgmax=800" width="632" border="0"></a> <p><b>5.3.4 Generating pause in miliseconds (1~65535ms)</b> <p>Purpose of this macro is to provide exact time delays in program. <p> pausems<br><b>macro</b> par1 <p><i> local</i><br>Loop1 <p><i> local</i><br>dechi <p><i> local</i><br>Delay1ms <p><i> local</i><br>Loop2 <p><i> local</i><br>End <p><b>movlw</b> high par1<br>; Higher byte of parameter 1 goes to HIcnt <p><b>movwf</b> HIcnt <p><b>movlw</b> low par1<br>; Lower byte of parameter 1 goes to LOcnt <p><b>movwf</b> LOcnt <p> Loop1 <p><b>movf</b> LOcnt, f<br>; Decrease HIcnt and LOcnt necessary <p><b>btfsc</b> STATUS, Z<br>; number of times and call subprogram Delay1ms <p><b>goto</b> dechi <p><b>call</b> Delay1ms <p><b>decf</b> LOcnt, f <p><b>goto</b> Loop1 <p> dechi <p><b>movf</b> HIcnt, f <p><b>btfsc</b> STATUS, Z <p><b>goto</b> End <p><b>call</b> Delay1ms <p><b>decf</b> HIcnt, f <p><b>decf</b> LOcnt, f <p><b>goto</b> Loop1 <p> Delay1ms:<br>; Delay1ms produces a one milisecond delay <p><b>movlw</b> .100<br>; 100*10us=1ms <p><b>movwf</b> LOOPcnt<br>; LOOPcnt<-100 <p> Loop2: <p><b>nop</b> <p><b>nop</b> <p><b>nop</b> <p><b>nop</b> <p><b>nop</b> <p><b>nop</b> <p><b>nop</b> <p><b>decfsz</b> LOOPcnt, f <p><b>goto</b> Loop2<br>; Time period necessary to execute loop Loop2 <p><b>return</b><br>; equals 10us <p> End <p><b>endm</b> <p>This macro is written for an 4MHz oscillator. For instance, with 8MHz oscillator, pause will be halved. It has very wide range of applications, from simple code such as blinking diodes to highly complicated programs that demand accurate timing. Following example demonstrates use of macro <i>pausems</i> in a program. At the beginning of the program we have to define auxiliary variables <i>HIcnt</i>, <i>LOcnt</i>, and <i>LOPcnt</i>. <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_lyyMa8ztmF_nU1jWJkSp1Ku3PyNDQaPWGpj2YkmN1rHXSZwnoUHFG72Nks2SVh2_KVI7CzgG049tB_JwkIJ4ACTYaGf07PwBVBdMOhkvHRq6syGiA9vICbvMEy-Kc9SO0wM3NWz1joE/s1600-h/ledblink%25255B6%25255D.gif"><img title="ledblink" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="664" alt="ledblink" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitrgXdYofUxzx5xEFn3aipPI5MKguQXf3jQJtr24lmsKmJX42OnR50Ze1Z8HZ8muRkiwlrga1DLs90iSeSuuawEdS7a2059hpRHGGHo12-ks7V-Etct92Y3KPfWHqBBzSnzRxTshzYwq4/?imgmax=800" width="618" border="0"></a> mechanical engineeringhttp://www.blogger.com/profile/03915677942766260946noreply@blogger.com