tag:blogger.com,1999:blog-74114043186982979912024-03-21T23:21:35.820+05:30Microcontroller ProjectsThis Blog is used to spread 8051 and PIC microcontroller projects and some simple tips..
It also links to related webpages and App NotesSiroshhttp://www.blogger.com/profile/05322973504445644007noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-7411404318698297991.post-23413194182288479382010-10-28T10:51:00.001+05:302010-10-28T10:52:09.595+05:30Free Air Frequencies of Cordless Phones<span style="font-size: small;"><span style="color: red; font-size: x-large;">I</span>n the United States, seven frequency bands have been allocated by the Federal Communications Commission for uses that include cordless phones. These are:</span><br />
<ul><li><span style="font-size: small;">1.7 MHz (1.64 MHz to 1.78 MHz & up to 5 Channels, AM System)<a class="external autonumber" href="http://electronics.howstuffworks.com/question320.htm" rel="nofollow"></a></span></li>
<li><span style="font-size: small;">43–50 MHz (Base: 43.72-46.97 MHz, Handset: 48.76-49.99 MHz, allocated in 1986 for 10 channels, and later 25 Channels, FM System)</span></li>
<li><span style="font-size: small;">900 MHz (902–928 MHz) (allocated in 1990)</span></li>
<li><span style="font-size: small;">1.9 GHz (1880–1900 MHz) (used for DECT communications outside the U.S.)</span></li>
<li><span style="font-size: small;">1.9 GHz (1920-1930 MHz) (developed in 1993 and allocated U.S. in October 2005)</span></li>
<li><span style="font-size: small;">2.4 GHz (allocated in 1998)</span></li>
<li><span style="font-size: small;">5.8 GHz (allocated in 2003 due to crowding on the 2.4 GHz band).</span></li>
</ul><span style="font-size: small;">1.7 MHz cordless phones were the earliest models available at retailers, generally identifiable by their large metal telescoping antennas. Channel selection had to be done manually by the user, and transmitted just above the AM broadcast band. These models are no longer in production, and are considered obsolete due to being very susceptible to eavesdropping and interference, especially from fluorescent lighting and automobile ignitions.</span><br />
<span style="font-size: small;">43-50 MHz cordless phones had a large installed base by the early 1990s, and featured shorter bendable antennas plus auto channel selection. Due to their popularity, an over crowding of the band led to an allocation of additional frequencies, thus manufacturers were able to sell models with 25 available channels instead of just 10 channels. Despite being less susceptible to interference, these models are no longer in production and are considered obsolete because these frequencies are easily heard on practically any radio scanner. Advanced models began to use voice inversion as a basic form of scrambling to help limit unauthorized eavesdropping.<sup class="Template-Fact" style="white-space: nowrap;" title="This claim needs references to reliable sources from July 2010"></sup></span><br />
<span style="font-size: small;">900 MHz cordless phones are still sold today and have a huge installed base. Features include even shorter antennas, up to 30 auto selecting channels, and higher resistance to interference. Available in three varieties; analog, digital, and digital spread spectrum, with most being sold today as budget analog models. Analog models are still susceptible to eavesdropping, However, older used models can still be found that are fully capable of receiving this spectrum. Digital variants can still be scanned, but are received as a digital hiss and therefore are difficult to eavesdrop upon. Digital transmission is immune to static interference but can experience signal fade (brief silence) as the phone goes out of range of the base. Digital Spread Spectrum (DSS) variants spread their signal over a range of frequencies providing more resistance to signal fade. The FCC only allows DSS model phones to transmit at the full power of 1 watt, which allows increased range over analog and digital models.<sup class="Template-Fact" style="white-space: nowrap;" title="This claim needs references to reliable sources from July 2010"></sup></span><br />
<span style="font-size: small;">Virtually all telephones sold in the US use the 900 MHz, 1.9 GHz, 2.4-GHz, or 5.8 GHz bands, though legacy phones can remain in use on the older bands. There is no specific requirement for any particular transmission mode on 900, 1.9, 2.4, and 5.8, but in practice, virtually all newer 900 MHz phones are inexpensive analog models with digital features such as DSSS and FHSS generally available only on the higher frequencies<sup class="Template-Fact" style="white-space: nowrap;" title="This claim needs references to reliable sources from July 2010"></sup></span><br />
<span style="font-size: small;">Some cordless phones advertised as 5.8 GHz actually transmit from base to phone on 5.8 GHz and transmit from phone to base on 2.4 GHz or 900 MHz, to conserve battery life inside the phone.</span><br />
<span style="font-size: small;">The recently allocated 1.9 GHz band is used by the popular DECT phone standard and is considered more secure than the other shared frequencies</span>Siroshhttp://www.blogger.com/profile/05322973504445644007noreply@blogger.com0tag:blogger.com,1999:blog-7411404318698297991.post-69134494293624765672010-10-11T20:59:00.000+05:302010-10-11T20:59:31.148+05:30Building a simple USB Charger<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px;"><div class="centerColumn" id="ezPageDefault"><div><br />
<center> <img alt="A simple USB Charger" height="333" src="http://www.probots.co.in/images/articles/usbcharger_files/Simple%20USB%20Charger.jpg" width="500" /> </center><br />
USB charging is currently the most universal method of charging an electronic device. This article details the process of construction of a cheap and simple USB charger which can be used to charge cell phones, iPods, mp3 players, cameras, etc and almost any device charges through an USB port of your computer.<br />
USB normally contains 4 lines – Vcc(+5V), Data-(D-), Data+(D+) and Gnd(Ground) . The Vcc and the Gnd line are used to power a device and the D- and D+ line are used to transfer data between the host and the device. A USB standard compliant host is expected to maintain 5V within a range of ± 0.5V and provide current of 1 unit load (I unit load = 100mA of current), unless requested for more current. To build a USB charger all you need to do is build a circuit that outputs current within the USB specification.<br />
<div style="font-size: 17px;"><b>The Power Source</b></div>Choosing a power source will be the first step in building the charger. There are quite a few options available here. One option is to use 2 AA or AAA size batteries that output 2.4V and boost up the voltage to 5V. These batteries are quite popular and easy to find and they occupy less space and contribute a lot in making the charger small and portable. But they have drawbacks – I have one such charger that really heats up within minutes of connecting it to any device and the worse still, the batteries don’t last longer than than 4-5 minutes.<br />
Another option is to use a pack of 4 Ni-Mh batteries. 4 Ni-Mh batteries output something around 5V depending on their charge. Hence, they can be connected directly to the power pins of the USB port. But the drawback is that 4 Ni-Mh batteries occupy a lot of space and they output voltage based on the amount of charge remaining in them. <br />
<div style="font-size: 14px;">Note: If you are using Ni-Mh batteries I would suggest you to use batteries of capacity greater than 2000 mAh. Ni-Mh batteries, though rated at 1.2V, output something around 1.4V when fully charged and 1V when fully drained. This variation is most for Ni-Mh batteries of low capacity(less than 1000 mAh ) and least for batteries of high capacity(greater than 1500mAh). A 2000mAh battery will output 1.3V when fully charged and 1.1V when fully drained.</div>Another popular power source is a 9V battery. The advantage is it is easily available and cheap. The drawback though is - you will have to regulate the 9V to 5V and only then supply it to the device.<br />
For my charger, I will be making use of a 9V battery and also provide an option for connecting 4 Ni-Mh battery pack to be used as the source.<br />
<br />
<div style="font-size: 17px;"><b>Voltage Regulation</b></div>For voltage regulation, the popular linear LM7805 regulator can be used because – it outputs a constant of 5V, is widely available and comes cheap. The only problem is that there will be a lot of energy wastage if the 7805 is used. The 7805 regulates voltage by converting the input voltage to 5V and the rest to heat. In the process of charging a USB device at 5V by providing it a current of 100 mA, the 7805 will be wasting 0.1*(9 - 5)W =0.4W and have efficiency of( 5V/9V) 55% !(In reality the efficiency is much more because the 9V battery will provide 9V only for the first few minutes and then slowly over time drop down its output voltage to nearly 6.8V before draining completely).<br />
But still I went ahead with using the 7805 because I wanted my charger to be a simple and cheap (efficiency was quite low in my list of priorities). Actually charging any battery with another battery is itself not efficient because you will have wasted energy in charging your source battery and again will be wasting some more energy when charging your USB device’s battery through the source battery!<br />
<br />
<div style="font-size: 17px;"><b>What about the D- and the D+ lines?</b></div>Just providing a 5V across the Vcc and Gnd lines will charge almost most USB device but it is not the best way of charging the device. By just providing a 5V across Vcc and Gnd lines and leaving the D- and D+ lines unconnected (technically called floating) will charge the device at only 100 mA. Charging a battery at 100 mA is a slow process. Hence, we have to tell the device that it has been connected to a charger and that the charger can provide more current. Unfortunately, there is no standard way of doing this and what works for one device does not work for another. For most devices, connecting the D- and D+ lines to 5V through a 100K resistor works. For, charging iPods, the D- line has to connected to 5V through a 10K resistor and the D+ line has to be connected to Gnd through a 10K resistor.<br />
<br />
<div style="font-size: 17px;"><b>The Circuit</b></div>Here is the circuit for charging any USB device – <br />
<center> <img alt="A simple USB Charger" height="274" src="http://www.probots.co.in/images/articles/usbcharger_files/USB%20Charger%20Circuit.jpg" width="570" /> </center><br />
Here is the circuit for charging an iPod – <br />
<center> <img alt="A simple USB iPod Charger" height="274" src="http://www.probots.co.in/images/articles/usbcharger_files/USB%20iPod%20Charger%20Circuit.jpg" width="570" /> </center><br />
<br />
<div style="font-size: 17px;"><b>Construction </b></div>The pictures of the charger I built is shown below (I added a 8mm High Brightness White LED to the board as I had a little space left on the board and didn’t want to waste the space). <br />
<center> <img alt="A simple USB Charger" height="353" src="http://www.probots.co.in/images/articles/usbcharger_files/USB%20Charger.jpg" width="500" /> </center><br />
<br />
<center> <img alt="A simple USB Charger" height="167" src="http://www.probots.co.in/images/articles/usbcharger_files/USB%20Charger%20PCB.jpg" width="495" /> </center><br />
You will have to attach a heat sink to the 7805 if you want to charge your device with more than 500 mA of current. Optionally, you can place a 0.1uF capacitor across the power pins of the USB connector as close to it as possible to reduce any noise in the power lines.</div></div></span></span>Siroshhttp://www.blogger.com/profile/05322973504445644007noreply@blogger.com2tag:blogger.com,1999:blog-7411404318698297991.post-90903166724016325492010-09-25T06:10:00.000+05:302010-09-25T06:17:30.552+05:30Processing explanation of Ultrasonic Range Meter<ul style="direction: ltr; margin-bottom: 0in; margin-left: 0.0208in; margin-top: 0in; unicode-bidi: embed;"><div style="font-family: Calibri; font-size: 10pt; margin: 0in;"><span style="color: red; font-size: large;">T</span>his range meter detects a reflected wave from the object after sending out a ultrasonic pulse.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">By measuring the time which returns after emitting a sound wave, a distance to the object is measured.</div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcqofSt2Sr5ZMhpUQoEkbV-6Pi8jFIE-FNIEgH4jjV2X56xBozxMcnw1uDeLsxz5EJzJhuq4oTxD75WHqZy2PXFXxEYypiNh5Q39Gzb2dc8uTTrHhd3jiR5pzJb60_939kWcTdKhn-vIfI/s1600/1.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcqofSt2Sr5ZMhpUQoEkbV-6Pi8jFIE-FNIEgH4jjV2X56xBozxMcnw1uDeLsxz5EJzJhuq4oTxD75WHqZy2PXFXxEYypiNh5Q39Gzb2dc8uTTrHhd3jiR5pzJb60_939kWcTdKhn-vIfI/s1600/1.gif" /></a></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">The operation of the following figure is repeatedly executed.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">LED display processing is executed in parallel with this operation.</div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 13.5pt; margin: 0in;">Label definition</div><div style="font-family: Calibri; margin: 0in;"><span style="font-size: 10pt;">;**************** Label Definition ********************</span><span style="font-size: 11pt;"></span><span style="font-size: 10pt;"><span> </span>cblock<span> </span>h'20'</span><span style="font-size: 11pt;"></span><span style="font-size: 10pt;">s_count<span> </span>;Send-out pulse count adr</span><span style="font-size: 11pt;"></span></div><div style="margin: 0in;"><img height="1" src="file:///C:/DOCUME%7E1/SIVARA%7E1/LOCALS%7E1/Temp/msohtmlclip1/01/clip_image004.gif" width="100" /></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">endc</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">I used CBLOCK directive for the definition of the workarea.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">When using this directive, workareas which were defined between CBLOCK and ENDC are automatically allocated in the order from the address which was specified by the operand of CBLOCK. It is convenient because it is possible to prevent the double allocation of the area. To confirm an allocated address, you confirm it by the assembly result.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in 0in 0in 0.375in;"></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">Lighting-up segment data for 7 segments LED are designated by EQU.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">The data from 0 to 9 is used for digital display. However, the 10th is used for the detection error display.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">At first, I make light up only center segment. But I turned off all segments because the display was confusing. </div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">The 11th is used for the interruption error display. It is for the debugging.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;"></div><div style="font-family: Calibri; font-size: 13.5pt; margin: 0in;">Environment designating and others</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">As for <a href="http://www.piclist.com/images/www/hobby_elec/e_pic6_55.htm#2">LIST and INCLUDE directive</a> and <a href="http://www.piclist.com/images/www/hobby_elec/e_pic6_55.htm#4">Program start</a>, refer to "<a href="http://www.piclist.com/images/www/hobby_elec/e_pic6_55.htm">Light controller</a>".</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in 0in 0in 0.375in;"></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">The following specification is done as configuration word.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in 0in 0in 0.375in;"></div><div style="direction: ltr;"> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border: 0pt solid rgb(163, 163, 163); direction: ltr; margin-left: 0.3333in;" valign="top"><tbody><tr> <td style="border-width: 0pt; padding: 4pt; vertical-align: top; width: 1.209in;"> <div style="font-family: Calibri; font-size: 10pt; margin: 0in;">Oscillator</div></td> <td style="border-width: 0pt; padding: 4pt; vertical-align: top; width: 0.6673in;"> <div style="font-family: Calibri; font-size: 10pt; margin: 0in;">:</div></td> <td style="border-width: 0pt; padding: 4pt; vertical-align: top; width: 4.4826in;"> <div style="font-family: Calibri; font-size: 10pt; margin: 0in;">HS</div></td> </tr><tr> <td style="border-width: 0pt; padding: 4pt; vertical-align: top; width: 1.209in;"> <div style="font-family: Calibri; font-size: 10pt; margin: 0in;">Watchdog Timer</div></td> <td style="border-width: 0pt; padding: 4pt; vertical-align: top; width: 0.6673in;"> <div style="font-family: Calibri; font-size: 10pt; margin: 0in;">:</div></td> <td style="border-width: 0pt; padding: 4pt; vertical-align: top; width: 4.4826in;"> <div style="font-family: Calibri; font-size: 10pt; margin: 0in;">OFF</div></td> </tr><tr> <td style="border-width: 0pt; padding: 4pt; vertical-align: top; width: 1.209in;"> <div style="font-family: Calibri; font-size: 10pt; margin: 0in;">Power-up Timer</div></td> <td style="border-width: 0pt; padding: 4pt; vertical-align: top; width: 0.6673in;"> <div style="font-family: Calibri; font-size: 10pt; margin: 0in;">:</div></td> <td style="border-width: 0pt; padding: 4pt; vertical-align: top; width: 4.4826in;"> <div style="font-family: Calibri; font-size: 10pt; margin: 0in;">enabled</div></td> </tr><tr> <td style="border-width: 0pt; padding: 4pt; vertical-align: top; width: 1.209in;"> <div style="font-family: Calibri; font-size: 10pt; margin: 0in;">Low Voltage ICSP </div></td> <td style="border-width: 0pt; padding: 4pt; vertical-align: top; width: 0.6673in;"> <div style="font-family: Calibri; font-size: 10pt; margin: 0in;">:</div></td> <td style="border-width: 0pt; padding: 4pt; vertical-align: top; width: 4.4826in;"> <div style="font-family: Calibri; font-size: 10pt; margin: 0in;">OFF</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">(RB3 can not be used for the input/output port when not making this OFF).</div></td> </tr></tbody></table></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">The result is 3F72h.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 13.5pt; margin: 0in;">Initialization process</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">;****************<span> </span>Initial Process<span> </span>*********************</div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in 0in 0in 0.375in;">Port initialization</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">Because the RA0/AN0 port is used for input of A/D converter, it is set to input mode. Other A ports are set to the output. All B ports are set to output because it is used for the LED segment control.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">RC2/CCP1 of C port is set to the input mode because it is used for input of capture.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in 0in 0in 0.375in;"></div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in 0in 0in 0.375in;">Ultrasonic transmission period timer(TMR0) initialization</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">The transmission period of the ultrasonic is controlled using timer0. Because timer0 is a timer with byte, the count value is up to 256. However, it is making count 65535 by setting the prescaler to 256. (256 x 256 = 65535) This time, because it is using 4 MHz for the oscillator, 1 count is 1 microsecond. (1/(4 x 106))x4=10-6 seconds</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">So, the time-out time of timer0 is about 65 milliseconds.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in 0in 0in 0.375in;"></div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in 0in 0in 0.375in;">Capture mode initialization</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">Timer1 is used for capture. Timer1 is initialized.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">At the time of the initialization, it makes CCP1 OFF to prevent from a malfunction.</div><div style="margin: 0in 0in 0in 0.375in;"></div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in 0in 0in 0.375in;">A/D converter initialization</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">Channel 0 is set as the converter input. Because the clock to use this time is 4 MHz, Fosc/8 is set to A/D conversion clock.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">Because the higher rank side of the A/D converted result are used, the storage of the result is made right justification (ADFM=0).</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">Because A porta are used for the output of the digit specification of the LED, ports except RA0/AN0 are made digital specification.</div><div style="margin: 0in 0in 0in 0.375in;"></div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in 0in 0in 0.375in;">LED display period timer(TMR2) initialization</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">Display data for 7 segments LED are set to workarea. The initial value of the display is "the error code".</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">The time-out of timer2 is about 10 milliseconds.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">The interruption eable bits of the capture and timer2 are set.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in 0in 0in 0.375in;"></div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in 0in 0in 0.375in;">Interruption initialization</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">It makes timer0 interruption, peripheral device interruption, global interruption possible.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">The interruption of the capture and timer2 doesn't occur when not making peripheral device interruption possible.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">By this process, interruption operation is started.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in 0in 0in 0.375in;"></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">When the initialization process ends, the interruption is waited for. It executes same address repeatedly.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 13.5pt; margin: 0in;">Interruption process</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">;***************<span> </span>Interruption Process<span> </span>*****************</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">Capture interruption, timer2 interruption, timer0 interruption are checked. The kind of the interruption is judged by each interruption flag. After that, it jumps to the corresponding interruption process.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">When the kind of the interruption is unsettled, processing is stopped. To confirm illegal interruption with the actual circuit, an in-circuit simulator is needed. There is a way of resetting but it isn't improved because it does the same operation even if it resets.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">A global interruption enable bit (the GIE bit) is automatically cleared when the interruption occurs. So, the interruption never occurs while processing in the interruption.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 13.5pt; margin: 0in;">Illegal interruption process</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">;*************** Illegal interruption *****************</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5i79W9lcDFUz2tM9WSnY9k_J94KJgffcubbmFRBjrPJdRX003HThyphenhyphenO86mvMSoz-KbPP7s_BHWAOT71ufnJNZt1_bFHoxess3t4zttjAUAy8ohj76M3oKy6Ri6tVZhPADHvu0_89ZWVX__/s1600/Untitled+picture.gif" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5i79W9lcDFUz2tM9WSnY9k_J94KJgffcubbmFRBjrPJdRX003HThyphenhyphenO86mvMSoz-KbPP7s_BHWAOT71ufnJNZt1_bFHoxess3t4zttjAUAy8ohj76M3oKy6Ri6tVZhPADHvu0_89ZWVX__/s200/Untitled+picture.gif" width="165" /></a></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">It displays an interruption error to the LED when the illegal interruption occurs. </div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">This process is the process for debugging and is usable with the other checking, too.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 13.5pt; margin: 0in;">Interruption ending process</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">;************<span> </span>END of Interruption Process **************</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">As for the software this time, all processing is done by the interruption except the initialization processing. The common registers(W register, Status register) are not used in the interrupted process (Main process). So, the saving and resaving process for them isn't need.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">In the interruption ending process, GIE bit is set by RETFIE instruction to enable interruption.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 13.5pt; margin: 0in;">Ultrasonic pulse sending-out process</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">;***************<span> </span>Pulse send-out Process ****************</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">In the pulse sending-out process, the following process is done.</div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in 0in 0in 0.375in;"></div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in 0in 0in 0.375in;">Clear the interruption display</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">The interruption flag of TMR0 is cleared. When not clearing this flag, the interruption occurs at once when interruption processing is ended without waiting a regular time-out.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">I clear the count area of timer0 because of the sure operation.</div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in 0in 0in 0.375in;">Check the detection error</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">When the detection of the reflected wave isn't done from the pulse sending-out in the last time until the pulse sending-out this time, it means measurement impossible and display is turned off. The previous data is displayed in the measurement impossible condition when not doing this process and the mistake occurs to the measurement.</div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in 0in 0in 0.375in;">Stop the reflected wave detector</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">Immediately after letting out a transmission pulse, the influence occurs to the receiver circuit and there is possibility to do wrong detection. To prevent from this, the operation of the reflected wave detector is stopped. The RA4 port is an open type and an external resistor is needed. So, I used RA5.</div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in 0in 0in 0.375in;">Start the capture operation</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">The count area of timer1 and the contents of the capture register are cleared. the rising edge detection mode capture is set and a capture interruption enable bit is set. And an interruption flag is cleared because of the sure operation.</div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in 0in 0in 0.375in;">Send-out the 40KHz pulse</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">The 40KHz pulse is the pulse which has 12.5 µ-sec as ON time and 12.5 µ-sec as OFF time in 1 cycle.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">Because 4-MHz clock is used at the circuit this time, the instruction execution time is 1 microsecond. So, correct 40KHz can not be sent out. When doing ON, OFF respectively with the 12 µ-sec, it is 41.7KHz. In case of 13 µ-sec, it is 38.5KHz. This time is adjusted by changing the number of the steps in the pulse sending-out processing.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">It is 0.5 milliseconds when sending out 20 pulses. (20pulses x 0.025milliseconds/pulse)</div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in 0in 0in 0.375in;">Take-in the display revision data</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">To make operate A/D converter, the GO bit of the ADCON0 register is set. When switching the input channel of A/D converter, after switching the input, about 20 microseconds waiting time is needed. This time, because the input channel is fixed on 0, waiting time isn't necessary. The completion of the A/D conversion is judged by the checking the GO bit. When GO bit is cleared, the conversion is completion. The upper 3 bits is picked up and add 54 as the conversion value.</div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in 0in 0in 0.375in;">Error detection prevention</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">A detector is stopped until the influence ends to the receiver after sending out a pulse. I set this time to about 1 millisecond. When few influences occur, it is to be OK even if it is shorter. When many influences occur, it is necessary to make longer.</div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in 0in 0in 0.375in;">Start the reflected wave detection</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">After the wrong detection prevention time elapse, it is made a enable condition in the reflected wave detection.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 13.5pt; margin: 0in;">Capture interruption process</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">;******************<span> </span>Capture Process ********************</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">In the capture interruption process, the following process is done.</div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in 0in 0in 0.375in;">Clear the interruption display</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">Capture interruption flag is cleared.</div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in 0in 0in 0.375in;">Distance conversion processing</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">The count value of the timer0 which was stopped by the capture operation is proportional to the propagation time of the sound wave. It isn't possible to use for the display just as it is. In the processing this time, division by some value is done and is converted into the distance numerical value.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">For example, I will explaine in case to have been reflected from the 1-m distance.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">In the time that the sound wave goes and returns in 1 m, it is 2m/343m/sec=5831 microseconds in case of 20°C. Because the clock of timer0 is 1µ-sec/count, the value of the timer0 when a capture is done is 5831. It is to be OK if using 58 as the divisor to make display this value as 100(It displays 1 m). The value to take in by the A/D converter is used for a divisor. So, when the temperature is different, the display can be revised if changing the input voltage to the A/D converter. But, because it is changed in the digital, it isn't possible to do fine adjustment.</div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in 0in 0in 0.375in;">Display setting processing</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">Because the type of distance value which is converted is binary, it can not be displayed on the LED just as it is.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">Binary number is converted into the decimal number and is set to each workarea(100th, 10th, 1st).</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.75in;">When 100th digit exceeds 9, it makes error display.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 13.5pt; margin: 0in;">LED display process</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">;****************<span> </span>LED display control<span> </span>*****************</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">This is the process to display the distance numerical value which was gotten by the capture to the LED.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">One LED is controlled at each period. So, only 1 digit is displayed at the same time.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in 0in 0in 0.375in;">Display is done every 10 milliseconds using timer2. When the display flickers, you should make the set value of timer2 more little and it quickens a period.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div></ul>Siroshhttp://www.blogger.com/profile/05322973504445644007noreply@blogger.com0tag:blogger.com,1999:blog-7411404318698297991.post-91312678432337720322010-09-25T06:05:00.000+05:302010-09-25T06:17:30.556+05:30Circuit explanation for Ultrasonic Range Meter<ul style="direction: ltr; margin-bottom: 0in; margin-left: 0.0534in; margin-top: 0in; unicode-bidi: embed;"><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 13.5pt; margin: 0in;">Receiver circuit</div><div class="separator" style="clear: both; text-align: center;"></div><div style="margin: 0in 0in 0in 0.375in;"></div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in;">Signal amplification circuit</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHjBs3w_VGCWdg6wSa6nazymGRkr02DannWOD8RmLeV2c_1ocLZ45j6DFMHYUchqqt1Soax8qyiyHLm3Md_wq66Jb2UAqpeEPiCkCnZvThQ6d1bSjgntYbcyhbtUZf-crn06JmkZCB8CEF/s1600/1.gif" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHjBs3w_VGCWdg6wSa6nazymGRkr02DannWOD8RmLeV2c_1ocLZ45j6DFMHYUchqqt1Soax8qyiyHLm3Md_wq66Jb2UAqpeEPiCkCnZvThQ6d1bSjgntYbcyhbtUZf-crn06JmkZCB8CEF/s1600/1.gif" /></a>The ultrasonic signal which was received with the reception sensor is amplified by 1000 times(60dB) of voltage with the operational amplifier with two stages. It is 100 times at the first stage (40dB) and 10 times (20dB) at the next stage.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">As for the dB (decibel), refer to "<a href="http://www.piclist.com/images/www/hobby_elec/e_logarithm.htm#1">Logarithm Table</a>".</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">Generally, the positive and the negative power supply are used for the operational amplifier. The circuit this time works with the single power supply of +9 V. Therefore, for the positive input of the operational amplifiers, the half of the power supply voltage is appied as the bias voltage. Then the alternating current signal can be amplified on 4.5V central voltage. When using the operational amplifier with the negative feedback, the voltage of the positive input terminal and the voltage of the negative input terminal become equal approximately. This is called virtual grounding. So, by this bias voltage, the side of the positive and the side of the negative of the alternating current signal can be equally amplified. When not using this bias voltage, the distortion causes the alternating current signal. This technique is often used when using the operational amplifier which needs two kinds of powers in the single power.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">As for the operation of the operational amplifier, refer to "<a href="http://www.piclist.com/images/www/hobby_elec/e_ckt16_2.htm#4">Operation explanation of the triangular wave oscillator</a>".</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in;">Detection circuit</div><div style="margin: 0in 0in 0in 1.125in;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGG53Eq6LbQ8W1iIUnVX61MkhT5ZaFS9_il0ZUyucvaSv56Hxu-GoiwzD5d3E8z9HXuYfaPey5H69oyh_DFJ7Wv7w7weSTyQgGRWNN5UVEird6t1whll-2ZUr09oTI5pe-9eFfPMG_uN8p/s1600/2.gif" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGG53Eq6LbQ8W1iIUnVX61MkhT5ZaFS9_il0ZUyucvaSv56Hxu-GoiwzD5d3E8z9HXuYfaPey5H69oyh_DFJ7Wv7w7weSTyQgGRWNN5UVEird6t1whll-2ZUr09oTI5pe-9eFfPMG_uN8p/s1600/2.gif" /></a></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">The detection is done to detect the received ultrasonic signal. This is the half-wave rectification circuit with Shottky barrier diodes. The DC voltage according to the level of the detection signal is output to the capacitor behind the diode. The Shottky barrier diodes are used because the high frequency characteristic is good.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">As for the Shottky barrier diode, refer to "<a href="http://www.piclist.com/images/www/hobby_elec/e_diode.htm#diode4">Diodes</a>".</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in;">Signal detector</div><div style="margin: 0in 0in 0in 1.125in;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUHmjUUX64m-YATLQB8pMauHoBoPqNFdJiFKrNuU2ebVI_8cG8zOkE46aNvh3uIBkgNqQZETd-zR9GRcjZjuRWrwF1GnfmUNJCpE7rCWgE-ruZM704Pit8ikpG728m4Adi4p6X-cRsSe8U/s1600/3.gif" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiUHmjUUX64m-YATLQB8pMauHoBoPqNFdJiFKrNuU2ebVI_8cG8zOkE46aNvh3uIBkgNqQZETd-zR9GRcjZjuRWrwF1GnfmUNJCpE7rCWgE-ruZM704Pit8ikpG728m4Adi4p6X-cRsSe8U/s1600/3.gif" /></a></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">This circuit is the circuit which detects the ultrasonic which returned from the measurement object. The output of the detection circuit is detected using the comparator. At the circuit this time, the operational amplifier of the single power supply is used instead of the comparator. The operational amplifier amplifies and outputs the difference between the positive input and the negative input.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">In case of the operational amplifier which doesn't have the negative feedback, the output becomes the saturation state by a little input voltage. Generally, the operational amplifier has over 10000 times of mu factors. So, when the positive input becomes higher a little than the negative input, the difference is tens of thousands of times amplified and the output becomes the same as the power supply almost.(It is the saturation state) Oppositely, when the positive input becomes lower a little than the negative input, the difference is tens of thousands of times amplified and the output becomes 0 V almost.(It is in the OFF condition) This operation is the same as the operation of the comparator. However, because the inner circuit of the comparator is different from the operational amplifier, the comparator can not be used as the operational amplifier.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">At the circuit this time, the output of the detection circuit is connected with the positive input of the signal detector and the voltage of the negative input is made constant.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="direction: ltr;"> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border: 0pt solid rgb(163, 163, 163); direction: ltr;" valign="top"><tbody><tr> <td style="border-width: 0pt; padding: 4pt; vertical-align: top; width: 0.6673in;"> <div style="color: green; font-family: Calibri; font-size: 13.5pt; font-weight: bold; margin: 0in;">Vrf</div></td> <td style="border-width: 0pt; padding: 4pt; vertical-align: top; width: 2.2062in;"> <div style="font-family: Calibri; font-size: 10pt; margin: 0in;">= ( Rb x Vcc )/( Ra + Rb )</div></td> </tr><tr> <td style="border-width: 0pt; padding: 4pt; vertical-align: top; width: 0.6673in;"> <div style="font-family: Calibri; font-size: 11pt; margin: 0in;"><br /></div></td> <td style="border-width: 0pt; padding: 4pt; vertical-align: top; width: 2.2062in;"> <div style="font-family: Calibri; font-size: 10pt; margin: 0in;">= ( 47K-ohm x 9V )/( 1M-ohm + 47K-ohm )</div></td> </tr><tr> <td style="border-width: 0pt; padding: 4pt; vertical-align: top; width: 0.6673in;"> <div style="font-family: Calibri; font-size: 11pt; margin: 0in;"><br /></div></td> <td style="border-width: 0pt; padding: 4pt; vertical-align: top; width: 2.2062in;"> <div style="font-family: Calibri; margin: 0in;"><span style="font-size: 10pt;">=</span><span style="font-size: 11pt;"> </span><span style="color: green; font-size: 13.5pt; font-weight: bold;">0.4V</span></div></td> </tr></tbody></table></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">So, when the rectified ultrasonic signal becomes more than 0.4 V, the output of the signal detector becomes the H level (Approximately 9V).</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">This output is lowered with the resistor to make fit with the input of signal holding circuit (TTL:0V to 5V).</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDnNRnb-8UFmiUDgENY_QhUpHFN1hyphenhyphencg5oCjQGqrgLqgoLXw49aFPUVCPPa8DTeaa3vaRMD3Qx3KFWv7mRLFS5BshaY9JcKQptGh635_RLUbnnisckufx4SlJczF1r6jksUFqM1FT_Z6xG/s1600/4.gif" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDnNRnb-8UFmiUDgENY_QhUpHFN1hyphenhyphencg5oCjQGqrgLqgoLXw49aFPUVCPPa8DTeaa3vaRMD3Qx3KFWv7mRLFS5BshaY9JcKQptGh635_RLUbnnisckufx4SlJczF1r6jksUFqM1FT_Z6xG/s320/4.gif" width="215" /></a> </div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 10pt; font-weight: bold; margin: 0in;">Signal holding circuit</div><div style="margin: 0in 0in 0in 0.75in;"></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">This is the holding circuit of detected signal. SR ( Set and Reset ) flip-flop is used. For the details of SR-FF, refer to "<a href="http://www.piclist.com/images/www/hobby_elec/e_ckt10_6.htm#1">The operation explanation of the D-type flip-flop</a>".</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">The detector is made to be not operate in the constant time(About 1.5 milliseconds) after sending out a transmission pulse to prevent from the wrong detection which is due to the influence of the transmission pulse. This operation is controlled with the software of PIC.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">When using the capture feature of PIC, this circuit isn't indispensable. Capture operation is done by the change of the capture input in the once. The reason why I am using this circuit is to confirm signal detection operation within the reflected signal detection time(About 65 milliseconds). When sending out next ultrasonic pulse, the output of this circuit is checked. And when the output is L level, an error display is done because the reflected signal could not be detected.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 13.5pt; margin: 0in;">Transmitter circuit</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFHAwOC4SHnkxaBd1U1d3tMeBwhOTRhzMEstVR98QfMyLr9FMiRryZhCXV9pvy5ObhT9pPiqg9x0DrgesXB6jeSZo_ROu7zse0rOtrUeheqWNFQHMh1xpWbFEEEjy0CwTNR_BWWEYbJHrJ/s1600/5.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFHAwOC4SHnkxaBd1U1d3tMeBwhOTRhzMEstVR98QfMyLr9FMiRryZhCXV9pvy5ObhT9pPiqg9x0DrgesXB6jeSZo_ROu7zse0rOtrUeheqWNFQHMh1xpWbFEEEjy0CwTNR_BWWEYbJHrJ/s1600/5.gif" /></a></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">The inverter is used for the drive of the ultrasonic sensor. The two inverters are connected in parallel because of the transmission electric power increase.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">The phase with the voltage to apply to the positive terminal and the negative terminal of the sensor has been 180 degrees shifted. Because it is cutting the direct current with the capacitor, about twice of voltage of the inverter output are appied to the sensor.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">The power supply voltage of this drive circuit is +9V. It is converting voltage with the transistor to make control at the operating voltage of PIC(+5V). Because C-MOS inverters are used, it is possible to do ON/OFF at high speed comparatively.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhysY83zD7DoQbWkQ_S7S1_VO-0wrbSVxZV2IKJcTo3UWW_VvYJNNIWPBvNvft-Ak5jf4_pZhxNXEgSub-xROEKYTGV-bZbBczNHw0E7vXCkLB1QidWNR3W_ffbaQ-dQ4lARJvWeIqWrNq/s1600/6.gif" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhhysY83zD7DoQbWkQ_S7S1_VO-0wrbSVxZV2IKJcTo3UWW_VvYJNNIWPBvNvft-Ak5jf4_pZhxNXEgSub-xROEKYTGV-bZbBczNHw0E7vXCkLB1QidWNR3W_ffbaQ-dQ4lARJvWeIqWrNq/s1600/6.gif" /></a></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 13.5pt; margin: 0in;">7 segment LED display circuit</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">Three 7 segment LEDs are used for 3-digit display. As for the lighting-up of the LED, 1 digit is displayed in the order with the software of PIC.</div><div style="font-family: Calibri; margin: 0in;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0_bT835OkHrVDgC35P2hDJmVXnMzShsp9FVa9bkw27z7l4jaVMOBiEf7Ro6nNdy49aZ-mBobG6zrSD4PsnCGpSs0FjieNTFILsn3RNf3INxjXe9rr87l9717g4WO_m2PLZPvV4VwuDxql/s1600/7.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0_bT835OkHrVDgC35P2hDJmVXnMzShsp9FVa9bkw27z7l4jaVMOBiEf7Ro6nNdy49aZ-mBobG6zrSD4PsnCGpSs0FjieNTFILsn3RNf3INxjXe9rr87l9717g4WO_m2PLZPvV4VwuDxql/s1600/7.gif" /></a><span style="font-size: 10pt;">At the circuit this time, I make light up it when the terminal of PIC is L level. So, </span><span style="color: red; font-size: 12pt;">ANODE COMMON </span><span style="font-size: 10pt;">type is used as the LED. The anode common type is the type which the side of the positive(Anode) of the LED is connected inside. It lights up when grounding(L level) a cathode in the segment to want to make light up.</span></div><div style="font-family: Calibri; margin: 0in;"><span style="font-size: 10pt;">As the 7 segment LED, the others have a cathode common type. When you buy them, the specification of the type should be checked.</span><span style="font-size: 11pt;"> </span></div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div class="separator" style="clear: both; text-align: center;"></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 13.5pt; margin: 0in;">Temperature revision voltage generating circuit</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-RuERIpv2WbnAv0uGeDwEj16lnxOxSE8CWrIDUnOGt3CZ8Tc7KMRgzm1PFKtEy1kU9KVho5j_JAC1AcD8iWJe7Gq1o65RfpCws3m96lLZYVTrjVM7rpv7wdTi9jOSgj22dYtuweCoO-wD/s1600/8.gif" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-RuERIpv2WbnAv0uGeDwEj16lnxOxSE8CWrIDUnOGt3CZ8Tc7KMRgzm1PFKtEy1kU9KVho5j_JAC1AcD8iWJe7Gq1o65RfpCws3m96lLZYVTrjVM7rpv7wdTi9jOSgj22dYtuweCoO-wD/s1600/8.gif" /></a> </div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">The sound wave propagation speed in air is changed by the temperature. At 0°C, it is 331.5m/sec. At 40°C, it is 355.5m/sec.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">For the details of the propagation speed, refer to "<a href="http://www.piclist.com/images/www/hobby_elec/e_srm1_4.htm#4">The sound wave propagation speed in the air</a>".</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">This range meter calculates a distance by dividing the propagation time which was measured by the capture feature.</div><div class="separator" style="clear: both; text-align: center;"></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">I will explain that it does the case of the distance measurement of 1m in the 0°C environment as for the example. The time which the sound wave takes to go and return is 2m/331.5m/sec = 0.006033 seconds = 6.033 milliseconds. The contents of the counter by the capture feature is 6033 within 1 microsecond.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">For the conversion of this to distance (cm), it divides by <span style="color: red;">60</span>. It is 6033/60=100.55. The following of the decimal point is cut off. It becomes a measurement error.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">This conversion value (60) depends on the temperature. It isn't related with the distance to measure. In case of 9 m, it is 54298/60=904.9. The conversion error becomes big when the distance becomes long. This is because it isn't possible to do conversion below the decimal point.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">In case of 40°C, it is 2m/355.5m/sec = 5625 microseconds and the conversion value is <span style="color: red;">56</span>.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">The conversion value should be changed by the ambient temperature.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">At this range meter, a conversion value is generated using the A/D conversion feature. The A/D converter converts input voltage into the 10-bit digital data. This time, I am using upper 3 bits. So, the A/D conversion result from 0V to 5V is the value from 0 to 7. And 54 is added to this value.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">Then, the conversion value range is from 54 to 61.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 13.5pt; margin: 0in;">Resonator</div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">I used 4-MHz resonator.</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqULMHI_M6j8jC4-OE_2v1hfmuPNtVpFv5pwVwYQXO6tnH4m2ddzy1GHGdfRc4nvAM20PuSIR2ravgElRVSk1QVs8gSU5MEBgpFTH0tKfHIPgnNWW4KZ46ntIWu48RQR1whMpY452DXggn/s1600/9.gif" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqULMHI_M6j8jC4-OE_2v1hfmuPNtVpFv5pwVwYQXO6tnH4m2ddzy1GHGdfRc4nvAM20PuSIR2ravgElRVSk1QVs8gSU5MEBgpFTH0tKfHIPgnNWW4KZ46ntIWu48RQR1whMpY452DXggn/s1600/9.gif" /></a></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">I used 4 MHz in the relation of the timer in the count time. When using 4-MHz clock, it is 1 microsecond per count for the counter count up time. Timer1 to use for capture is a maximum of 65535 counts(16 bits). So, a maximum of 65.535 milliseconds count is made.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">The propagation speed of the sound in air is 343 m/second in case of 20°C. In the time which goes and returns in the 10-m distance, it is 20m/343m/sec = 0.0583 seconds (58.3 milliseconds). As the range meter this time, it is an exactly good value.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWCtTnxsdrYO4Y2Dtkn9eCguA-RZRuNzc945dH8fL_nkt2BpFYK9iMv6bj7RZ9QEjRKuGWEvE5_wxzYsY82EW3L2ikKg-cQYjUTEl_Jy_lryzZMC_A4FWvPfOvS-JUzG4wwdvdVBaDe0pS/s1600/10.gif" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWCtTnxsdrYO4Y2Dtkn9eCguA-RZRuNzc945dH8fL_nkt2BpFYK9iMv6bj7RZ9QEjRKuGWEvE5_wxzYsY82EW3L2ikKg-cQYjUTEl_Jy_lryzZMC_A4FWvPfOvS-JUzG4wwdvdVBaDe0pS/s1600/10.gif" /></a></div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 13.5pt; margin: 0in;">Power supply circuit</div><div style="margin: 0in;"></div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">The voltage of +5V and +9V are made with +12V power supply using the 3 terminal regulator.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">+9V are used for the transmitter and the receiver. 100-mA type is used because few needed electric currents.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">In other circuit, +5V is used. +5V voltage is used for the lighting-up of LEDs, because they are controlled by PIC. The about 10-mA electric current per segment flows through the LED. So, it becomes about 80 mA when all segments(eight) light up.</div><div style="font-family: Calibri; font-size: 10pt; margin: 0in;">Because few electric currents of the other IC occur, I think that you can use a 100-mA type, too. I used a 1A type for the safety.</div><div style="font-family: Calibri; font-size: 11pt; margin: 0in;"></div></ul>Siroshhttp://www.blogger.com/profile/05322973504445644007noreply@blogger.com0tag:blogger.com,1999:blog-7411404318698297991.post-24841636879674976082010-09-25T05:56:00.000+05:302010-09-25T06:17:30.560+05:30Ultrasonic Range Meter (Circuit Diagram)<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKN9g76IV7NsbaZDr-m9g4oJXRmgVRI9y4u7Y3enDiaNVWXLRNLAdaKtg-9O29Xu2Sz1czTiUrr4Y460qEyX64EhqfOWKbncyOaiShXz8cViL-q_n-YTDjqkbUkc62S75jQQmLoQpCZL8e/s1600/Untitled+picture.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKN9g76IV7NsbaZDr-m9g4oJXRmgVRI9y4u7Y3enDiaNVWXLRNLAdaKtg-9O29Xu2Sz1czTiUrr4Y460qEyX64EhqfOWKbncyOaiShXz8cViL-q_n-YTDjqkbUkc62S75jQQmLoQpCZL8e/s1600/Untitled+picture.gif" /></a></div>Siroshhttp://www.blogger.com/profile/05322973504445644007noreply@blogger.com1tag:blogger.com,1999:blog-7411404318698297991.post-2576757096790252962010-08-26T19:07:00.000+05:302010-08-26T19:07:04.443+05:30Speaker Driver {Special Companies}<div class="separator" style="clear: both; text-align: center;"><a href="http://www.madisound.com/images/HiVi-Research-Logo.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="78" src="http://www.madisound.com/images/HiVi-Research-Logo.gif" width="500" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div style="font: normal normal normal 13px/16px Verdana, Geneva, Arial, Helvetica, sans-serif;">HiVi is a leading manufacturer of stereophile quality audio systems. Employing some of the worlds’ finest electro-acoustical technicians and craftsmen, the company established state-of-the art R+D facilities in Toronto, Canada in 1994 and was fueled by early successes with innovative driver designs. In 1997, HiVi merged with highly-regarded speaker manufacturer Swans Speaker Systems and opened corporate offices in Monterey Park, California. Respected audio designer Frank Hale, former president of Swans, continues to serve today as Chief Designer for HiVi Speaker Systems.</div><div style="font: normal normal normal 13px/16px Verdana, Geneva, Arial, Helvetica, sans-serif;">HiVi’s proprietary driver technologies including Planar Ribbon Tweeters are employed by many of the audio industry’s top brands. With focused re-investment in research and development, HiVi continues to advance the art and science of electro-acoustical engineering. The merger with Swans provided the opportunity for complete system research and design.</div><div style="font: normal normal normal 13px/16px Verdana, Geneva, Arial, Helvetica, sans-serif;">HiVi’s range of drivers and complete speaker systems have been established in niche European, Asian and North American markets for more than a decade. HiVi wholly owns 300 retail stores across Asia, with direct retail presence in an additional 700 locations. With critical success has come substantial growth, and HiVi’s markets continue to expand globally. The HiVi product range has also grown to serve these markets to include high-quality car audio systems, custom home installation speakers and multi-media systems along with home theater systems and drivers.</div><div style="font: normal normal normal 13px/16px Verdana, Geneva, Arial, Helvetica, sans-serif;">HiVi founder and president Hong Bo Yao continues to drive the company to new heights. Ongoing research and development programs continue to produce innovative products and technologies - raising the bar on what is possible in high-quality audio reproduction. HiVi is capitalizing on these technologies and extending product offerings successfully into new markets and new categories - converting listeners to audiophiles with uncompromised excellence.</div><h5 align="center" style="font: normal normal normal 13px/17px Tahoma, Arial, sans-serif; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 7px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"></h5>Siroshhttp://www.blogger.com/profile/05322973504445644007noreply@blogger.com0tag:blogger.com,1999:blog-7411404318698297991.post-61052607785579382002010-06-08T06:52:00.002+05:302010-06-08T06:52:46.870+05:30PHASE SEQUENCE DETECTOR {CIRCUIT LOGIC}<div class="MsoNormal" style="text-align: justify;"><br />
</div><div class="MsoNormal" style="text-align: justify;"><span lang="RU">In a three-phase system, three circuit conductors carry three alternating currents (of the same frequency) which reach their instantaneous peak values at different times. Taking one conductor as the reference, the other two currents are delayed in time by one-third and two-thirds of one cycle of the electrical current. </span></div><div class="MsoNormal" style="text-align: justify;"><span lang="RU">The circuit logic is based on this phase difference. The first supply line, line L1, is taken as reference and is called R phase. Now the microprocessor checks which line reaches its peak value next, L2 or L3. If it’s L2 second line is called Y phase and the sequence is RYB. If it’s L3 then third line is Y phase and the phase sequence is RBY. </span></div>Siroshhttp://www.blogger.com/profile/05322973504445644007noreply@blogger.com1tag:blogger.com,1999:blog-7411404318698297991.post-6130573371895182342010-06-05T21:08:00.000+05:302010-06-05T21:08:26.290+05:30PHASE SEQUENCE DETECTOR {Abstract}<blockquote><span class="Apple-style-span" style="font-size: x-large;">T</span>he instrument presented here, the <span class="Apple-style-span" style="background-color: yellow;"><b><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">PHASE SEQUENCE DETECTOR WITH MOTOR ROTATION SELECTOR</span></b></span> permits the electrical contractor or industrial maintenance electrician to permanently connect and tape the terminals of the motor being installed, without having to first energize the motor by a temporary hookup from a power source, if available, to determine motor rotation.</blockquote><blockquote> Therefore, this relay instrument eliminates the need for temporary connections that can be time consuming, costly and quite hazardous, particularly where many large, high-voltage motors are involved. Also, certain types of drives should never be rotated in the wrong direction. In such cases, the temporary hookup or trial method, having a fifty-fifty chance of being wrong, can do serious harm. </blockquote>Siroshhttp://www.blogger.com/profile/05322973504445644007noreply@blogger.com0tag:blogger.com,1999:blog-7411404318698297991.post-37472706993373009922010-05-31T05:47:00.001+05:302010-05-31T06:43:30.139+05:30Basic Visible and Infrared Light Detectors<ul style="direction: ltr; margin-bottom: 0in; margin-left: .0201in; margin-top: 0in; unicode-bidi: embed;"><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"> This page features basic, visible light photo-detector circuits that can be used to detect trains or other light blocking objects.</span></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> The sensors used for these circuits are silicon phototransistors or Cadmium Sulfide (CdS) photocells. Both of these sensors allow less current to flow when they are dark. (Phototransistors change their 'conductance' while photocells change their resistance depending on the intensity of the light falling on them.)</blockquote></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> The phototransistor or photocell would normally be placed between the rails in the circuits on this page.</blockquote></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> The Photo-detectors on this page use LM339 (Quad) or LM393 (Dual) voltage comparator, integrated circuits to detect the change in voltage across the sensor. </blockquote></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> All of the circuits on this page are configured to have the LED's turn on when the sensor element is dark (covered by a train.) The LED's can also be made to turn off when a train is detected. This will be explained in the NOTES sections of this page.</blockquote></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> The supply voltage for the circuits is specified as regulated 12 volts DC but this can be changed if needed. In some cases the values of some resistors may have to be adjusted to compensate.</blockquote></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm0L0kXJHShtEuaCfC7PlA9NSStgkc1WDkmcKpqyauGMX54DmxxnQZ4A0jyhtZoatlyphEdh6ohdgxHfqNbaW9WYKZ8MQSVE0yp5jC2Uf4gZsznTWR5MeRPcNvlv_xJ9Ykz0_bqGZbOic/s1600/Untitled+picture.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm0L0kXJHShtEuaCfC7PlA9NSStgkc1WDkmcKpqyauGMX54DmxxnQZ4A0jyhtZoatlyphEdh6ohdgxHfqNbaW9WYKZ8MQSVE0yp5jC2Uf4gZsznTWR5MeRPcNvlv_xJ9Ykz0_bqGZbOic/s320/Untitled+picture.gif" /></span></a></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"> </span></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"> </span> </div><div style="font-size: 18pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"><span class="Apple-style-span" style="font-weight: normal;">- Section 1 -</span></span></div><div style="font-size: 20pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">Visible Light Photo-Detector Circuits</span></div><div style="font-size: 18pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">Basic Phototransistor Detector</span></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> In this circuit, when the light falling on the phototransistor (Q1) is blocked, its conductance will decrease and the voltage across Q1 will rise. When the voltage rises above 1/2 of the supply voltage the output of the comparator will turn ON and the LED will be lit.</blockquote></div><div style="margin: 0in;"></div><div style="font-size: 16pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">Basic Phototransistor Detector</span></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> The only critical part of this circuit is the value of resistor R1 which in most cases can be 470K ohms but may have to be increase if the room is dark or decreased if the room is well lit.</blockquote></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> Increasing the value of R1 will cause the sensitivity of the sensor to decrease. This may be necessary when the light falling on the cell is not very strong or shadows can affect the phototransistor.</blockquote></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> There are a number of phototransistors sizes and case styles. The smaller cases will be easier to hide but connecting wires may be more difficult.</blockquote></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWbE9K3iURfkz6L30iqoPHaWQetNSMjiBTg75GtrJN7-Q5y1SbjNXK0V_pZ_I-GKKbXKCpvEKZvVi_ezRCy3BdfZ5PPw8NV1wsxQEsGoEYv-86cOdViSQ8jC0_yZ8JnGmEBKqN91UXedQ/s1600/Untitled+picture1.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWbE9K3iURfkz6L30iqoPHaWQetNSMjiBTg75GtrJN7-Q5y1SbjNXK0V_pZ_I-GKKbXKCpvEKZvVi_ezRCy3BdfZ5PPw8NV1wsxQEsGoEYv-86cOdViSQ8jC0_yZ8JnGmEBKqN91UXedQ/s320/Untitled+picture1.gif" /></span></a></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"> </span></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"> </span> </div><div style="font-size: 18pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">Basic CdS Photocell Detector</span></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> In this circuit, when the light falling on the photocell (PC 1) is blocked, its resistance will increase and the voltage across PC 1 will rise. When the voltage rises above 1/2 of the supply voltage the output of the comparator will turn ON and the LED will be lit.</blockquote></div><div style="margin: 0in;"></div><div style="font-size: 16pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">Basic Photocell Detector</span></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> Due to wide variations in CdS photocells it is usually best to install the cell and then measure its resistance under normal lighting conditions. A resistor with a value that is approximately 3 to 5 times the measured resistance of the cell is then selected for R1. For example; If the cell resistance is measured at 400 ohms then a 1200 to 2200 ohms resistor would be used.</blockquote></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> Increasing the value of R1 will cause the sensitivity of the sensor to decrease. This may be necessary when the light falling on the cell is not very strong or shadows can affect the photocell.</blockquote></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> This circuit can be adapted for use in dark areas by placing a small light above the photocell.<span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"> </span></blockquote></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"> </span> </div><div style="font-size: 18pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">- Section 2 -</span></div><div style="font-size: 20pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">Infrared Light Photo-Detector Circuit</span></div><div style="font-size: 18pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">Basic Phototransistor Detector</span></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> In this circuit the light falling on the phototransistor will be from an Infrared Light Emitting Diode (IrLED) but otherwise it is the same as the phototransistor circuit shown above.</blockquote></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> When the light falling on the phototransistor (Q1) is blocked, its conductance will decrease and the voltage across Q1 will rise. When the voltage rises above 1/2 of the supply voltage the output of the comparator will turn ON and the LED will be lit.</blockquote></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSpaNfg5dtv8VhAqyArKVslB2lVIXgC2_pBnwXg45-qmhZLl26UIXSqeCkBnJ64a9yp2ZExVZ2LICXzUSlQtb5FBaB0LPJqlkhDmFeAYni8-779NgLllPJs9EKoKbIB8KhI3XRKMZFxPE/s1600/Untitled+picture2.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSpaNfg5dtv8VhAqyArKVslB2lVIXgC2_pBnwXg45-qmhZLl26UIXSqeCkBnJ64a9yp2ZExVZ2LICXzUSlQtb5FBaB0LPJqlkhDmFeAYni8-779NgLllPJs9EKoKbIB8KhI3XRKMZFxPE/s320/Untitled+picture2.gif" /></span></a></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"> </span></div><div style="margin: 0in;"></div><div style="font-size: 16pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><i><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">Basic Infrared Detector</span></i></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"> </span></div><div style="font-size: 16pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">Is The IR LED Working?</span></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> Infrared light is not visible to the naked eye, however, a digital camera can be used to view the IR light if it does not have an IR blocking filter on the lens.</blockquote></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> The image may not be very bright but close-up or in a darkened area the light should be visible on the camera's display screen.</blockquote></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"> </span> </div><div style="font-size: 18pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">- Section 3 -</span></div><div style="font-size: 20pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">A Practical Quad Photo-Detector Circuit</span></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> The next circuit is for a practical 4 photo-detector circuit using an LM339 Quad comparator IC. Although phototransistors are shown, photocells could also be used with the corresponding change in values for resistors R1 through R4.</blockquote></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> This circuit can also be used for infrared detector circuits as shown above.</blockquote></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYy0xYwgOlz_aTqK2dchSzzGtZpnQTIkvVUbY9oGRCWuZGpz6gLtMGOLSgESGWnA-QRYI5c3qh-U7hZ-oWwh1ZLKl9lE9YgsU5c907izZT_mc4ZVzu8XMmsjRYOqWDcIYiEOoXmhUkklQ/s1600/Untitled+picture3.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYy0xYwgOlz_aTqK2dchSzzGtZpnQTIkvVUbY9oGRCWuZGpz6gLtMGOLSgESGWnA-QRYI5c3qh-U7hZ-oWwh1ZLKl9lE9YgsU5c907izZT_mc4ZVzu8XMmsjRYOqWDcIYiEOoXmhUkklQ/s320/Untitled+picture3.gif" /></span></a></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"> </span></div><div style="margin: 0in;"></div><div style="font-size: 16pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">Quad Photocell Detector</span></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> The values for resistors R7 through R10 can also be changed depending on the required LED current. </blockquote></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> A printed circuit board with 8 comparator type photo-detectors can be seen at this link. 8 Photo-Detector Circuit Board</blockquote></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"> </span> </div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> This High Impedance Test Voltmeter circuit can also be used for testing phototransistors installations.</blockquote></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"> </span> </div><div style="font-size: 18pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">Phototransistor Detector Relay Driver</span></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> By adding a PNP transistor to the basic detector circuit larger currents can be controlled. In this example a small relay is operated by the detector.</blockquote></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxv9Pfvl0AO4jVrM_TwE1riJPu_ydef7tdAszfk-g5BNFFfLozGyUulmFxTCb4HpMboLs8pFpteJyLGPBSiD61yg8ipraWOkOKOlG_-Lzkr8PvLPXPc3dHr4Lzparpi9M5InOqedzWkj8/s1600/Untitled+picture4.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxv9Pfvl0AO4jVrM_TwE1riJPu_ydef7tdAszfk-g5BNFFfLozGyUulmFxTCb4HpMboLs8pFpteJyLGPBSiD61yg8ipraWOkOKOlG_-Lzkr8PvLPXPc3dHr4Lzparpi9M5InOqedzWkj8/s320/Untitled+picture4.gif" /></span></a></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"> </span></div><div style="margin: 0in;"></div><div style="font-size: 16pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">Relay Driver</span></div><div style="font-size: 18pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">Using Multiple Phototransistors</span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9eqs-tJX2VWnskWRq0beRR5SnPmTcbd_fCPTK_IpjZV4OXbwkSbncvY8QOiwtmq1GDDByn5fXJyuzpBWX1eDqORQghgmCX6cmWnkb67hnhDZXeX5ws4m4uRG0y6Xv-v5vWFTH36j6eBo/s1600/Untitled+picture5.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9eqs-tJX2VWnskWRq0beRR5SnPmTcbd_fCPTK_IpjZV4OXbwkSbncvY8QOiwtmq1GDDByn5fXJyuzpBWX1eDqORQghgmCX6cmWnkb67hnhDZXeX5ws4m4uRG0y6Xv-v5vWFTH36j6eBo/s400/Untitled+picture5.gif" width="227" /></span></a></div><div style="font-size: 18pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"> </span></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> More than one phototransitor can be connected to a single voltage comparator. This would allow transistors to be placed along a section of track to indicate when a train is anywhere in that section.</blockquote></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> As long as the train is long enough to cover two sensors the circuit will continuously detect the train.</blockquote></div><div style="margin: 0in;"></div><div style="font-size: 16pt; font-weight: bold; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">Multiple Sensors</span></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><blockquote> Circuit 2 on the schematic is simpler but the phototransistors must have better lighting than Circuit 1 to get good results.</blockquote></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"> </span> </div><div style="margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><a href="http://www.national.com/ds/LM/LM339.pdf"><span style="font-size: 12pt; font-weight: bold;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">LM339 Data sheet - National Semiconductor (.pdf)</span></span></a></div><div style="margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span style="font-size: 12pt; font-weight: bold;"><a href="http://www.national.com/ds/LM/LM393.pdf"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">LM393 Data sheet - National Semiconductor (.pdf)</span></a></span></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif; font-size: x-large;"><span class="Apple-style-span" style="font-size: 24px;"><b><span class="Apple-style-span" style="font-size: medium;"><span class="Apple-style-span" style="font-size: 15px; font-weight: normal;"> </span></span></b></span></span></div><div style="font-size: 11pt; margin-bottom: 0in; margin-left: 0in; margin-right: 0in; margin-top: 0in;"></div></ul>Siroshhttp://www.blogger.com/profile/05322973504445644007noreply@blogger.com0tag:blogger.com,1999:blog-7411404318698297991.post-49965128891033414502010-05-23T06:47:00.000+05:302010-05-23T06:47:59.854+05:30Development Board For PIC & 8051<span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px; line-height: normal;">We are making a new development board for PIC.</span></span><div><span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px; line-height: normal;"><br />
</span></span></div><div><span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px; line-height: normal;">It's divided into more parts.</span></span></div><div><ol><li><span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px; line-height: normal;">Main board or Microcontroller Board</span></span></li>
<li><span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px; line-height: normal;">Real Time Clock board</span></span></li>
<li><span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px; line-height: normal;">Relay Board</span></span></li>
<li><span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px; line-height: normal;">Stepper Motor Interfacing mode</span></span></li>
<li><span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px; line-height: normal;">4*4 Keypad</span></span></li>
<li><span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px; line-height: normal;">LCD interfacing</span></span></li>
<li><span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px; line-height: normal;">16 digit "7-Segment interfacing</span></span></li>
<li><span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px; line-height: normal;">Simple status LED board</span></span></li>
<li><span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px; line-height: normal;">Temperature controller board</span></span></li>
<li><span class="Apple-style-span" style="font-family: Arial; font-size: small;"><span class="Apple-style-span" style="font-size: 13px; line-height: normal;">I2C Communication board</span></span></li>
</ol></div>Siroshhttp://www.blogger.com/profile/05322973504445644007noreply@blogger.com0tag:blogger.com,1999:blog-7411404318698297991.post-32665357286958792192010-05-21T06:49:00.000+05:302010-05-21T06:49:54.177+05:30Introduction to C and the PIC Microcontroller<div style="color: black; font-family: "Times New Roman"; font-size: 10.0pt; font-style: italic; font-weight: bold; margin: 0in;"><s>Real-World Interfacing</s></div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;"><br />
</div><div style="color: black; font-size: 11.0pt; margin: 0in;"><span style="font-family: "Times New Roman";">In this lab you will be introduced to the programming language </span><span style="font-family: "Times New Roman"; font-style: italic;">C</span><span style="font-family: "Times New Roman";">, and the </span><span style="font-family: "Times New Roman"; font-style: italic;">PIC16F873</span><span style="font-family: "Times New Roman";">, a popular and very widely used </span><span style="font-family: symbol;">m-</span><span style="font-family: "Times New Roman";">controller (read </span><span style="font-family: "Times New Roman"; font-style: italic;">micro-controller</span><span style="font-family: "Times New Roman";">). </span><span style="font-family: symbol;">m</span><span style="font-family: "Times New Roman";">-controllers find use in devices that needs some intelligence but not a huge amount of processing power (eg, fancy graphical interfaces, massive computing needs). You can find these devices in cars (engine control, anti-lock brakes...), in appliances, etc... There are many ways to program these devices, but you will be using C to program the PIC to perform some fairly simple tasks. C is often used with </span><span style="font-family: symbol;">m</span><span style="font-family: "Times New Roman";">-controllers because of its small size, high speed, and the access it allows to the real-world. This week you will get a short introduction to C as well as a brief look at some of the capabilities of the PIC.</span></div><div style="font-family: "Times New Roman"; margin: 0in;"><span style="color: black; font-size: 11.0pt;">A good resource for help with the PIC programmed with the CCS C-compiler is given at </span><a href="http://www.ccsinfo.com/forum/"><span style="font-size: 12.0pt;">http://www.ccsinfo.com/forum/</span></a><span style="color: black; font-size: 12.0pt;">.</span></div><div style="font-size: 11.0pt; margin: 0in;"><span style="color: black; font-family: "Times New Roman";">The PIC microcontroller comes in a wide range of variants. You can check them out in data books that are in the lab, or at the </span><a href="http://www.microchip.com/"><span style="font-family: "Times New Roman";">MicroChip web site</span></a><span style="color: black; font-family: "Times New Roman";">. A </span><span style="color: black; font-family: symbol;">m</span><span style="color: black; font-family: "Times New Roman";">-controller is distinguished from a </span><span style="color: black; font-family: symbol;">m</span><span style="color: black; font-family: "Times New Roman";">-processor in that it has many capabilities useful for real-world interfacing built into the chip. The PIC has a RISC-based Harvard architecture with separate memory for data and program. The one we will be using is the PIC16F873 (</span><a href="http://ww1.microchip.com/downloads/en/DeviceDoc/30292c.pdf"><span style="font-family: "Times New Roman";">link to data sheet</span></a><span style="color: black; font-family: "Times New Roman";">) It has an on-board RAM (Random Access Memory), EPROM (Erasable Programmable Read Only Memory), an oscillator, a couple of timers, and several Input/Output (I/O) pins, serial ports and 8 channel A/D convertor (if you don’t know what all of those things are don’t worry; suffice it to say there can be an impressive array of peripherals built into the chip). However, the </span><span style="color: black; font-family: symbol;">m</span><span style="color: black; font-family: "Times New Roman";">-controller is less computationally capable than most </span><span style="color: black; font-family: symbol;">m</span><span style="color: black; font-family: "Times New Roman";">-processors due to the fact that they are used for simple control applications rather than spreadsheets and elaborate calculations. As an example, the PIC16F873 has 4096 words of memory for program, and only 192 bytes of RAM, and can only operate with clocks up to 20 MHz on 8 bits of data (compared to megabytes of RAM, Speeds of a GHZ or more and 32 or even 64 bits of data for many desktop systems). It also has no facilities for floating point numbers... A pinout of the PIC16F873 is shown below.</span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGaXPqWsN0Gsd_hvWSqCAtw8iBC8wvn-eZ2EQMP3wDXT9DHNYdWhdIsZr0mlA03JXY99ALv_vvRCL9u2cxmJgohZJnftmZMhdAtqdxf7Ab4Ea24Xks8Q2X4xnNPg2140vxepY7BCzK7i4/s1600/PIC16F873.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="235" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGaXPqWsN0Gsd_hvWSqCAtw8iBC8wvn-eZ2EQMP3wDXT9DHNYdWhdIsZr0mlA03JXY99ALv_vvRCL9u2cxmJgohZJnftmZMhdAtqdxf7Ab4Ea24Xks8Q2X4xnNPg2140vxepY7BCzK7i4/s400/PIC16F873.gif" width="400" /></a></div><div style="font-size: 11.0pt; margin: 0in;"><span style="color: black; font-family: "Times New Roman";"><br />
</span></div><div style="font-size: 11.0pt; margin: 0in;"><span style="color: black; font-family: "Times New Roman";"><br />
</span></div><div style="margin: 0in;"></div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">There are several pins that are used to power the device. Many of the other pins have multiple uses depending on how the device is programmed. </div><div style="color: black; font-size: 11.0pt; margin: 0in;"><span style="font-family: "Times New Roman";">This week, and the next, you will be using a </span><span style="font-family: symbol;">m</span><span style="font-family: "Times New Roman";">-controller in the lab. These laboratories will serve as a brief introduction to the processor and to programming in C.</span></div><div style="color: black; font-family: "Times New Roman"; font-size: 12.0pt; font-weight: bold; margin: 0in;"><br />
</div><div style="color: magenta; font-family: "Times New Roman"; font-size: 18.0pt; font-weight: bold; margin-left: .375in; margin: 0in;">Getting started with C.</div><div style="color: #800040; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">A simple C program</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">A very simple C program is shown below.</div><div style="color: green; font-family: "courier new"; font-size: 11.0pt; margin-left: 1.125in; margin: 0in;">/*simple.c -- sets a pin low, then high*/</div><div style="color: green; font-family: "courier new"; font-size: 11.0pt; margin-left: 1.125in; margin: 0in;">#INCLUDE <16F873.h><br />
#USE DELAY (CLOCK=4000000)</div><div style="color: green; font-size: 11.0pt; margin-left: 1.125in; margin: 0in;"><span style="font-family: "courier new";">void main() {<br />
<br />
</span><span style="font-family: "Times New Roman";"> output_low(pin_C1);<br />
output_high(pin_C1);</span><span style="font-family: "courier new";"><br />
}</span></div><div style="font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;"><span style="color: black;">This program has many common features of C programs. The first line is a comment that is ignored by the compiler. It is simply there to document what the program code does. A comment is anything that occurs between a "/*" and the subsequent "*/". The next line is a "directive". All directives begin with a "#" and are used to convey information to the compiler. The directive in this program tells the compiler to include a header file ("16F873.h") which is necessary when using the microcontroller’s input and output capabilities. The next two directives tell it how to configure the device, and how fast it goes. The next line tells the compiler that this is the "main" program, and that everything between the opening brace, {, and the matching closing brace, , constitutes the main program. The main program itself is only two lines. The first line (not a comment) is a call to the "output_low" function, which sets output pin pin_C1 low, and a call to output_high, which sets it high. . Note that </span><span style="color: red; font-style: italic;">after every program statement there is a semi-colon</span><span style="color: black; font-style: italic;">.</span><span style="color: black;"> This is </span><span style="color: magenta; font-weight: bold;">very</span><span style="color: black;"> important.</span></div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;"><br />
</div><div style="color: #800040; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Variables</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">Almost all programs will use variables which are simply units of information stored in the computers memory. The standard C language has a wide variety of variable types available, however the dialect we will be using is more restricted. The version of C that we will be using has a quite unstandard set of variable types that are suited to its architecture.</div><div style="direction: ltr;"> <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-color: #A3A3A3; border-style: solid; border-width: 1pt; direction: ltr; margin-left: .3333in;" valign="top"><tbody>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Type Specifier</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Size</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Range</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">unsigned</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">8 bit unsigned</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">0 to 255</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">unsigned int</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">int</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">char</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">int8</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">long</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">16 bit unsigned</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">0 to 65535</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">long int</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">int16</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">signed</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">8 bit signed</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">-128 to 127</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">signed int</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">signed int8</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">signed long</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">16 bit signed</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">-32768 </div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">to 32767</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">signed int8</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">int32</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">32 bit unsigned</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">4*109</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">signed int32</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">32 bit signed</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">±2*109</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">float</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">32 bit floating point</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">±0.5*2-128 to 1-(2-15)*2128</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">short</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">one bit</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">0 to 1</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">short int</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.1715in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">int1</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.434in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.7979in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> </tr>
</tbody></table></div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">The program below shows how variables are used.</div><div style="color: green; font-family: "courier new"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">#INCLUDE <16F873.h><br />
#USE DELAY (CLOCK=4000000)</div><div style="margin-left: .75in; margin: 0in;"><span style="color: green; font-family: "courier new"; font-size: 11.0pt;">void main() {<br />
</span><span style="color: #008040; font-family: courier; font-size: 12.0pt;"><span style="mso-spacerun: yes;"> </span>char i, j, k; /* declare characters */</span></div><div style="color: #008040; margin-left: .75in; margin: 0in;"><span style="font-family: courier; font-size: 12.0pt;"><span style="mso-spacerun: yes;"> </span>i=2;<br />
<span style="mso-spacerun: yes;"> </span>j=3;<br />
<span style="mso-spacerun: yes;"> </span>k=i+j;<br />
</span><span style="font-family: "Times New Roman"; font-size: 11.0pt;">}</span></div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">Again we have a fairly simple program that shows many different features of C. Note the semicolon after every program statement. We declare 3 char’s, "i", "j" and "k". A char is simply an 8 bit variable. You should use chars whenever possible because the PIC is designed to work on data 8 bits at a time.</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;"><br />
</div><div style="color: #800040; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Numerical manipulations</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">C has a variety of built in operations for performing math. These are listed below along with an example where a=0x03, and b=0x11:</div><div style="direction: ltr;"> <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-color: #A3A3A3; border-style: solid; border-width: 1pt; direction: ltr; margin-left: .3333in;" valign="top"><tbody>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.4868in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.425in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Name of Operand</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Symbol</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Example</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.6854in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Result a=0x03 b=0x11</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.4868in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Binary Operators (Two Operands)</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.425in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Addition</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">+</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">a+b</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.6854in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">0x14</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.4868in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.425in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Subtraction</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">-</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">b-a</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.6854in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">0x0E</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.4868in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.425in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Multiplication</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">*</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">a*b</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.6854in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">0x33</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.4868in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.425in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Division</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">/</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">b/a</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.6854in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">0x05</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.4868in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.425in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Modulus</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">(remainder)</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">%</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">b%a</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.6854in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">0x02</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.4868in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.425in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Bitwise and</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">&</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">b&a</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.6854in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">0x01</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.4868in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.425in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Bitwise or</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">|</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">b|a</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.6854in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">0x13</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.4868in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.425in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Bitwise xor</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">^</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">b^a</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.6854in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">0x12</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.4868in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.425in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Shift right</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">>></div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">b>>a</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.6854in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">0x02</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.4868in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.425in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Shift left</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;"><<</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">b<<a href=""></a></div><a href=""> </a></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.6854in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">0x88</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.4868in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Unary Operators (One Operand)</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.425in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">increment</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">++</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">++a</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.6854in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">0x04</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.4868in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.425in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">decrement</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">--</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">--a</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.6854in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">0x03</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.4868in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.425in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">negate</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">-</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">-a</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.6854in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">-0x03</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.4868in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.425in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">logical complement</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">~</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">~a</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.6854in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">0xFC</div></td> </tr>
</tbody></table></div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: 2.25in; margin: 0in;"><br />
</div><div style="color: #800040; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Logical Expressions</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">In addition ot manipulating numbers, C is also capable of handling logical expressions. When using these expressions TRUE is taken to be anything that is not zero, and FALSE is always equal to zero. Again, a=0x03, and b=0x11:</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">Binary operators (two operands)</div><div style="direction: ltr;"> <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-color: #A3A3A3; border-style: solid; border-width: 1pt; direction: ltr; margin-left: .3333in;" valign="top"><tbody>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.2486in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.5097in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in; text-align: right;">Name of Operand</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Symbol</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Example</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.2291in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Result </div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">a=0x03 b=0x11</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.2486in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Binary Operators</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.5097in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Greater than</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">></div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">a>b</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.2291in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">FALSE</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.2486in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.5097in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Less than</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;"><</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">a<b></b></div><b> </b></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.2291in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">TRUE</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.2486in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.5097in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Equal</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">==</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">a==b</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.2291in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">FALSE</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.2486in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.5097in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Greater than or equal</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">>=</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">a>=b</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.2291in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">FALSE</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.2486in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.5097in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Less than or equal</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;"><=</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">a<=b</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.2291in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">TRUE</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.2486in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.5097in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Not equal</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">!=</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">a!=b</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.2291in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">TRUE</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.2486in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.5097in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Logical AND</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">&&</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">a&&b</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.2291in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">TRUE</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.2486in;"> <div style="font-family: Calibri; font-size: 11.0pt; margin: 0in;"><br />
</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.5097in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Logical OR</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">||</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">a||b</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.2291in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">TRUE</div></td> </tr>
<tr> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.2486in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Unary operators (one operand)</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.5097in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">Logical complement</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .7173in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">!</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .802in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">!a</div></td> <td style="border-color: #A3A3A3; border-style: solid; border-width: 1pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.2291in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;">FALSE</div></td> </tr>
</tbody></table></div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: 2.625in; margin: 0in;"><br />
</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;"><br />
</div><div style="font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;"><span style="color: #800040; font-weight: bold;">Manipulating addresses</span><span style="color: black;"> (somewhat advanced topic, may be skipped)</span></div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">There are two operators used for manipulating addresses and you have already been briefly introduced to one of them, the indirection operator, *. The other one is the address operator &. If you have an address k, the value stored at that address is *k. If you have a variable j, the address of the variable is given by &j. Therefore it is obvious that *(&j)=j.</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;"><br />
</div><div style="color: #800040; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">I/O (Input/Output) Ports</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">It is possible with with a PIC to interact with the real world. This is done thourgh the use of I/O ports. The PIC16F873 has 3 I/O ports, labeled "a", "b" and "c". We will use Port A for analog input, though it has other uses. Ports B and C will be used for digital I/O. On the schematic the pins are labeled RB0 through RB7, but the compiler refers to them as pin_B0 through pin_B7. Likewise for port C. The pins can be used for either input or output. </div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">Your circuit has the pushbutton switch connected to RB0, and the LED's to pins RC0 through RC7.</div><div style="color: #800040; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin-left: .375in; margin: 0in;">Digital Output</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">There are several functions that are used for output from the PIC. A full listing is in the PCB manual. Four commonly used functions are:</div><ul style="direction: ltr; margin-bottom: 0in; margin-left: 1.5in; margin-top: 0in; unicode-bidi: embed;" type="disc"><li style="color: maroon; margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="color: maroon; font-family: "courier new"; font-size: 10.0pt;">Output_high(</span><span style="color: maroon; font-family: "courier new"; font-size: 10.0pt; font-style: italic;">pin</span><span style="color: maroon; font-family: "courier new"; font-size: 10.0pt;">)<br />
</span><span style="color: black; font-family: "Times New Roman"; font-size: 11.0pt;">Sets the specified pin to a logic 1 (about 5 volts).</span></li>
<li style="color: maroon; margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="color: maroon; font-family: "courier new"; font-size: 10.0pt;">Output_low(</span><span style="color: maroon; font-family: "courier new"; font-size: 10.0pt; font-style: italic;">pin</span><span style="color: maroon; font-family: "courier new"; font-size: 10.0pt;">)<br />
</span><span style="color: black; font-family: "Times New Roman"; font-size: 11.0pt;">Sets the specified pin to a logic 0 (about 0 volts)</span></li>
<li style="color: maroon; margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="color: maroon; font-family: "courier new"; font-size: 10.0pt;">Output_float(</span><span style="color: maroon; font-family: "courier new"; font-size: 10.0pt; font-style: italic;">pin</span><span style="color: maroon; font-family: "courier new"; font-size: 10.0pt;">)<br />
</span><span style="color: black; font-family: "Times New Roman"; font-size: 11.0pt;">Sets the specified pin to a high-impedance (or tri-state) state. In this state it is as if the pin has no connections to the chip. Current can neither go in or out of the pin.</span></li>
<li style="color: maroon; margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="color: maroon; font-family: "courier new"; font-size: 10.0pt;">Output_bit(</span><span style="color: maroon; font-family: "courier new"; font-size: 10.0pt; font-style: italic;">pin</span><span style="color: maroon; font-family: "courier new"; font-size: 10.0pt;">, </span><span style="color: maroon; font-family: "courier new"; font-size: 10.0pt; font-style: italic;">value</span><span style="color: maroon; font-family: "courier new"; font-size: 10.0pt;">)<br />
</span><span style="color: black; font-family: "Times New Roman"; font-size: 11.0pt;">This function sets the specified pin to the specified value (which must be 0 or 1).</span></li>
</ul><div style="color: #800040; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin-left: .375in; margin: 0in;">Digital Input</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">There is only one input function you will need for the PIC.</div><ul style="direction: ltr; margin-bottom: 0in; margin-left: 1.5in; margin-top: 0in; unicode-bidi: embed;" type="disc"><li style="color: maroon; margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="color: maroon; font-family: "courier new"; font-size: 10.0pt;">Input(</span><span style="color: maroon; font-family: "courier new"; font-size: 10.0pt; font-style: italic;">pin</span><span style="color: maroon; font-family: "courier new"; font-size: 10.0pt;">)<br />
</span><span style="color: black; font-family: "Times New Roman"; font-size: 11.0pt;">Reads the value on a specified pin. The value is returned in a short int. A proper use of the function would be something like:<br />
<br />
</span><span style="color: #008040; font-family: "courier new"; font-size: 10.0pt;"> while( !input(pin_B0)) { ... }<br />
<br />
</span><span style="color: black; font-family: "Times New Roman"; font-size: 11.0pt;">which would repeat the commands in the braces as long as RB0 was low.</span></li>
</ul><div style="color: #800040; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">"High level" I/O</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">If the PIC is connected to the PIC C development software via the debugger it is possible to do some higher level input and output. These interactions take place via the debugger's "Monitor" window.</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">You specify that IO is to take place through the debugger by properly defining serial connections (usually in your codes header file):</div><div style="color: #008040; font-family: "Courier New"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">#use rs232(DEBUGGER)</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">You can then print to the monitor window by using "putc()" which sends a character to the monitor window, "puts()" which sends a string, or "printf()" which sends a formatted string. The "printf()" command is most useful, but also the most complicated (and takes the most memory).</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">The syntax of printf is the following:</div><div style="font-family: Calibri; font-size: 11.0pt; margin-left: .375in; margin: 0in;"><br />
</div><div style="color: #008040; font-family: "Courier New"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">printf(format-string, [arg_1] , ... , [arg_N] )</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">This is best illustrated by some examples.</div><div style="margin-left: .375in; margin: 0in;"><a href="http://www.swarthmore.edu/NatSci/echeeve1/Ref/C%20for%20PIC/C_Intro.html#TOC54"><span style="font-family: "Times New Roman"; font-size: 12.0pt; font-weight: bold;">P</span><span style="font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold;">rinting Examples</span></a></div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;"><span style="font-weight: bold;">Example 1: Printing a message.</span> The following statement prints a text string to the screen.</div><div style="font-family: Calibri; font-size: 11.0pt; margin-left: .375in; margin: 0in;"><br />
</div><div style="color: #008040; font-family: "Courier New"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">printf("Hello, world!\n");</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">In this example, the format string is simply printed to the screen.</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">The character \n at the end of the string signifies <span style="font-style: italic;">end-of-line</span>. When an end-of-line character is printed, the LCD screen will be cleared when a subsequent character is printed. Thus, most printf statements are terminated by a \n.</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;"><span style="font-weight: bold;">Example 2: Printing a number.</span> The following statement prints the value of the integer variable x with a brief message.</div><div style="font-family: Calibri; font-size: 11.0pt; margin-left: .375in; margin: 0in;"><br />
</div><div style="color: #008040; font-family: "Courier New"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">printf("Value is %d\n", x);</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">The special form %d is used to format the printing of an integer in decimal format.</div><div style="font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;"><span style="color: black; font-weight: bold;">Example 3: Printing a character.</span><span style="color: black;"> The following statement prints the ascii equivalent of the integer variable x with a brief message. Here is an </span><a href="http://www.cs.mun.ca/~michael/c/ascii-table.html">ascii table</a><span style="color: black;">.</span></div><div style="font-family: Calibri; font-size: 11.0pt; margin-left: .375in; margin: 0in;"><br />
</div><div style="color: #008040; font-family: "Courier New"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">printf("Value is %d, ascii = %c\n", x, x);</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;"><span style="font-weight: bold;">Example 4: Printing a number in binary.</span> The following statement prints the value of the integer variable x as a binary number.</div><div style="font-family: Calibri; font-size: 11.0pt; margin-left: .375in; margin: 0in;"><br />
</div><div style="color: #008040; font-family: "Courier New"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">printf("Value is %b\n", x);</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">The special form %b is used to format the printing of an integer in binary format. Only the <span style="font-style: italic;">low byte</span> of the number is printed.</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;"><span style="font-weight: bold;">Example 5: Printing a floating point number.</span> The following statement prints the value of the floating point variable n as a floating point number.</div><div style="font-family: Calibri; font-size: 11.0pt; margin-left: .375in; margin: 0in;"><br />
</div><div style="color: #008040; font-family: "Courier New"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">printf("Value is %f\n", n);</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">The special form %f is used to format the printing of floating point number.</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin-left: .375in; margin: 0in;">Example 6: Printing two numbers in hexadecimal format.</div><div style="font-family: Calibri; font-size: 11.0pt; margin-left: .375in; margin: 0in;"><br />
</div><div style="color: #008040; font-family: "Courier New"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">printf("A=%x<span style="mso-spacerun: yes;"> </span>B=%x\n", a, b);</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">The form %x formats an integer to print in hexadecimal.</div><div style="margin-left: .375in; margin: 0in;"><a href="http://www.swarthmore.edu/NatSci/echeeve1/Ref/C%20for%20PIC/C_Intro.html#TOC55"><span style="font-family: "Times New Roman"; font-size: 12.0pt; font-weight: bold;">Formatting Command Summary</span></a></div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: 1.125in; margin: 0in;">%d</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: 1.5in; margin: 0in;">Type: int Description: decimal number</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: 1.125in; margin: 0in;">%x</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: 1.5in; margin: 0in;">Type: int Description: hexadecimal number</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: 1.125in; margin: 0in;">%b</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: 1.5in; margin: 0in;">Type: int Description: low byte as binary number</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: 1.125in; margin: 0in;">%c</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: 1.5in; margin: 0in;">Type: int Description: low byte as ASCII character</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: 1.125in; margin: 0in;">%f</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: 1.5in; margin: 0in;">Type: float Description: floating point number</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: 1.125in; margin: 0in;">%s</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: 1.5in; margin: 0in;">Type: char array Description: char array (string)</div><div style="direction: ltr;"> <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-color: #A3A3A3; border-style: solid; border-width: 0pt; direction: ltr; margin-left: 1.4583in;" valign="top"><tbody>
<tr> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.443in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Format Command</div></td> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .9159in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Data Type</div></td> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.1034in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Description</div></td> </tr>
<tr> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.443in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">%d</div></td> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .9159in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">int</div></td> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.1034in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">decimal number</div></td> </tr>
<tr> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.443in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">%x</div></td> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .9159in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">int</div></td> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.1034in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">hexadecimal number</div></td> </tr>
<tr> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.443in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">%b</div></td> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .9159in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">int</div></td> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.1034in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">low byte as binary number</div></td> </tr>
<tr> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.443in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">%c</div></td> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .9159in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">int</div></td> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.1034in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">low byte as ASCII character</div></td> </tr>
<tr> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.443in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">%f</div></td> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .9159in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">float</div></td> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.1034in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">floating point number</div></td> </tr>
<tr> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 1.443in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">%s</div></td> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: .9159in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">char array</div></td> <td style="border-width: 0pt; padding: 4pt 4pt 4pt 4pt; vertical-align: top; width: 2.1034in;"> <div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">char array (string)</div></td> </tr>
</tbody></table></div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;"><br />
</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">Your circuit has the pushbutton switch connected to RB0, and the LED's to pins RC0 through RC7.</div><div style="color: #800040; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin-left: .375in; margin: 0in;">Input</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">Unfortunately, you can only receive input from the keyboard one character at a time using the getc() command. Be aware:</div><ul style="direction: ltr; margin-bottom: 0in; margin-left: 1.5in; margin-top: 0in; unicode-bidi: embed;" type="disc"><li style="color: black; margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="font-family: "Times New Roman"; font-size: 11.0pt;">getc() returns the ascii equivalent of the character entered into the keyboard.</span></li>
<li style="color: black; margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="font-family: "Times New Roman"; font-size: 11.0pt;">the keyboard I/O is implemented in software on the PIC. That means, it won't receive input from the keyboard unless it is explicitly looking for it. Therefore, your program must stop in order to look for input from the keyboard. (Hardware communications could receive a character in the background, without requiring software support).</span></li>
</ul><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">As an example, the following code gets the ascii value in k, converts to a number, and prints the number.</div><div style="color: green; font-family: "Courier New"; font-size: 11.0pt; margin-left: 1.125in; margin: 0in;">k=getc(); %Get ascii value of keyboard input.</div><div style="color: green; font-family: "Courier New"; font-size: 11.0pt; margin-left: 1.125in; margin: 0in;">k=k-'0'; %Subtract value of '0' to convert to number.</div><div style="color: green; font-family: "Courier New"; font-size: 11.0pt; margin-left: 1.125in; margin: 0in;">printf(" ... k=%d\n",k); %print the number.</div><div style="color: #800040; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Control of Flow</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">What you have learned up to this point has been useful but is of limited utility because it does not allow for decision making capabilities by the computer. C has a variety of mechanisms to control the flow of a program. These are listed below:</div><div style="color: purple; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin-left: .375in; margin: 0in;">The if...then construct</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">if (logical expression) {</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;"> ...statements...</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">}</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">If the logical expression is true then evaluate the statements between the braces. The following code sets RC1 if a is even.</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">if ((a%2) == 0) {</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;"> Output_high(pin_C1);</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">}</div><div style="color: purple; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin-left: .375in; margin: 0in;">The if...then...else construct</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">if (logical expression) {</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;"> ...if statements...</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">}</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">else {</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;"> ...else statements...</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">}</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">If the logical expression is true then evaluate the "if" statements between the braces, otherwise execute the "else" statements. The following code decides if a number if is even or odd.</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">if ((a%2) == 0) {</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;"> Output_high(pin_C1);</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">}</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">else {</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;"> Output_low(pin_C1);</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">}</div><div style="color: purple; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin-left: .375in; margin: 0in;">The while loop</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">while (logical expression) {<br />
<span style="mso-spacerun: yes;"> </span>...statements...<br />
}</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">While the logical expression is true, the statments (of which there is an arbitrary number) between the braces is executed. The following code cycles through the even numbers from 0 to 9 (the variables must have been declared elsewhere in the program).</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">a=0;<br />
while (a<10) {<br />
<span style="mso-spacerun: yes;"> </span>...statements...<br />
<span style="mso-spacerun: yes;"> </span>a=a+2;<br />
} </div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;"><br />
</div><div style="color: purple; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin-left: .375in; margin: 0in;">The for loop</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">for (initial condition; logical expression; change loop counter variable) {</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;"> ...statements...</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">}</div><div style="font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .75in; margin: 0in;"><span style="color: black;">Set the initial condition, then while the logical expression is true execute the statement between the braces while changing the loop counter as specified once at the end of each loop. This code segment is functionally equivalent to the one for the "</span><a href="http://www.swarthmore.edu/NatSci/echeeve1/Ref/C%20for%20PIC/C_Intro.html#The while loop">while</a><span style="color: black;">" loop.</span></div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">for (a=0; a<10; a=a+2) {</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;"> ...statements...</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">}</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin: 0in;"><br />
</div><div style="color: purple; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin-left: .375in; margin: 0in;">The case...switch construct</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .75in; margin: 0in;">Case..switch is used in place of a series of "if...else" clauses when a variable can take on several values. The "default" clause at the bottom takes care of any cases not covered explicitly.</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">switch (variable) {</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;"> case val1: ...statements 1...</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;"> break;</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;"> case val2: ...statements 2...</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;"> break;</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;"> case val3: ...statements 3...</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;"> break;</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;"> default: ...statements default...</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;"> break;</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: 1.125in; margin: 0in;">}</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;"><br />
</div><div style="color: #800040; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Functions</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">Often a series of instruction must be repeated over and over again. Instead of repeating the same operations repetitively it is useful to use a function that performs the repetitive operations. For instance to set a value on RC1 and then read from RB0 and set RC0 to that value, and returning the value of RB0 you might use a function called "RB0toRC0". (Note: this program isn't meant to be particularly useful, but to introduce the syntax for function declaration, and use).</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: .75in; margin: 0in;">/*simpleFunc.c -- to demonstrate function calls*/</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: .75in; margin: 0in;">#INCLUDE <16F873.h><br />
#USE DELAY (CLOCK=4000000)</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: .75in; margin: 0in;">short int RB0toRC0(RC1val)<br />
short int RC1val;<br />
{<br />
<span style="mso-spacerun: yes;"> </span>Output_bit(pin_C1, RC1val);<span style="mso-spacerun: yes;"> </span>/*Set RC1 to the specified value*/<br />
<span style="mso-spacerun: yes;"> </span>if (input(pin_B0)) {<span style="mso-spacerun: yes;"> </span>/*Read RB0*/<span style="mso-spacerun: yes;"> </span><br />
<span style="mso-spacerun: yes;"> </span>Output_high(pin_C0);<span style="mso-spacerun: yes;"> </span>/*If RB0 is high, RC0 set high*/<br />
<span style="mso-spacerun: yes;"> </span>} <br />
<span style="mso-spacerun: yes;"> </span>else {<br />
<span style="mso-spacerun: yes;"> </span>Output_low(pin_C0);<span style="mso-spacerun: yes;"> </span>/*else set RC0 low*/<br />
<span style="mso-spacerun: yes;"> </span>}<br />
<span style="mso-spacerun: yes;"> </span>return(input(pin_B0));<span style="mso-spacerun: yes;"> </span>/*Return RB0*/<br />
}<br />
</div><div style="color: #008040; font-family: "courier new"; font-size: 10.0pt; margin-left: .75in; margin: 0in;">void main() {<br />
<span style="mso-spacerun: yes;"> </span>short int b;<br />
<br />
<span style="mso-spacerun: yes;"> </span>b=RB0toRC0(1);<br />
<span style="mso-spacerun: yes;"> </span>b=RB0toRC0(0);<br />
}</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">This program introduces some new constructs. The most obvious is the function "RB0toRC0" which is at the top. The first line of the function declares that the function returns a short int, and has one argument. The type of the argument is given before the function's opening brace. The body of the function (between the braces) outputs a value to RC1, and reads from RB0 and echos to RC1. The last line tells that compiler to return the value of RB0 to the calling function.</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">The function is called in the main program with different arguments. The first call would set RC1 high, and return the current value of RB0 to the variable "b". The next line would set RC1 low, and return the value of RB0 to the variable "b".</div><div style="color: #800040; font-family: "Times New Roman"; font-size: 11.0pt; font-weight: bold; margin: 0in;">Wrapping up</div><div style="color: black; font-family: "Times New Roman"; font-size: 11.0pt; margin-left: .375in; margin: 0in;">You should now know enough to do some fairly simple things with the microcontroller. This has been a very brief introduction to C and did not even begin to touch the richness available with the language. If you would like to know more look in the manuals in the lab, or some of the books in the library.</div><div style="font-family: Calibri; font-size: 11.0pt; margin-left: .375in; margin: 0in;"><br />
</div>Siroshhttp://www.blogger.com/profile/05322973504445644007noreply@blogger.com0tag:blogger.com,1999:blog-7411404318698297991.post-46678695837739959052010-05-21T06:44:00.001+05:302010-05-21T06:44:46.003+05:302 km FM transmitter<div style="color: #333333; font-family: Georgia; font-size: 9.75pt; font-weight: bold; margin: 0in;"><span class="Apple-style-span" style="background-color: cyan;">Description</span></div><div style="color: #333333; font-family: Georgia; font-size: 9.75pt; font-weight: bold; margin: 0in;"><br />
</div><div style="color: #333333; font-family: Georgia; font-size: 9.75pt; margin: 0in;">With a matching antenna, the FM transmitter circuit shown here can transmit signals up to a range of 2 kilo metres. The transistor Q1 and Q2 forms a classic high sensitive preamplifier stage. The audio signal to be transmitted is coupled to the base of Q1 through capacitor C2. R1, R3, R4, R6, R5 and R9 are the biasing resistors for the preamplifier stage comprising of Q1 and Q2. Transistor Q3 performs the collective job of oscillator, mixer and final power amplifier.C9 and L1 forms the tank circuit which is essential for creating oscillations. Inductor L2 couples the FM signal to the antenna.</div><div style="color: #333333; font-family: Georgia; font-size: 9.75pt; margin: 0in;"><br />
</div><div style="color: #333333; font-family: Georgia; font-size: 9.75pt; font-weight: bold; margin: 0in;"><span class="Apple-style-span" style="background-color: #ead1dc;">Circuit diagram</span></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiF2YzJNHtJSwHB9LfuwxxXwNY8AO5vlnUu_6at0XCSqERCQ9nNFgLqcwNAXD1mUQvHB5gZ41m1pTNE-IlrzKuBYuXILOi-8FlHMVnp0kt48TY5Xb-d1MGrd2qebIyz1a7Vk8PSRDIj3aY/s1600/Untitled+picture.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="171" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiF2YzJNHtJSwHB9LfuwxxXwNY8AO5vlnUu_6at0XCSqERCQ9nNFgLqcwNAXD1mUQvHB5gZ41m1pTNE-IlrzKuBYuXILOi-8FlHMVnp0kt48TY5Xb-d1MGrd2qebIyz1a7Vk8PSRDIj3aY/s400/Untitled+picture.png" width="400" /></a></div><div style="color: #333333; font-family: Georgia; font-size: 9.75pt; font-weight: bold; margin: 0in;"><br />
</div><div style="margin: 0in;"></div><div style="color: #333333; font-family: Georgia; font-size: 9.75pt; font-weight: bold; margin: 0in;"><span class="Apple-style-span" style="background-color: #d9d2e9;">Notes.</span></div><ul style="direction: ltr; margin-bottom: 0in; margin-left: .75in; margin-top: 0in; unicode-bidi: embed;" type="disc"><li style="color: black; margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="font-family: Arial; font-size: 9pt;">Assemble the circuit on a good quality PCB.</span></li>
<li style="color: black; margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="font-family: Arial; font-size: 9pt;">The circuit can be powered from anything between 9 to 24V DC.</span></li>
<li style="color: black; margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="font-family: Arial; font-size: 9pt;">Inductor L3 can be a VK220J type RFC.</span></li>
<li style="color: black; margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="font-family: Arial; font-size: 9pt;">For L1 make 3 turns of 1mm enamelled copper wire on a 10mm diameter plastic former. On the same core make 2 turns of 1 mm enamelled copper wire close to L3 and that will be L2.</span></li>
<li style="color: black; margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="font-family: Arial; font-size: 9pt;">Frequency can be adjusted by varying C9.</span></li>
<li style="color: black; margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="font-family: Arial; font-size: 9pt;">R9 can be used to adjust the gain.</span></li>
<li style="color: black; margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="font-family: Arial; font-size: 9pt;">For optimum performance, value of C8 must be also adjusted.</span></li>
<li style="color: black; margin-bottom: 0; margin-top: 0; vertical-align: middle;"><span style="font-family: Arial; font-size: 9pt;">Using a battery for powering the circuit will reduce noise.</span></li>
</ul>Siroshhttp://www.blogger.com/profile/05322973504445644007noreply@blogger.com0tag:blogger.com,1999:blog-7411404318698297991.post-47352072380574551472010-05-21T06:35:00.001+05:302010-05-21T06:39:50.739+05:30Using the 74xx47 BCD to Seven-segment display<h1 align="CENTER"><span class="Apple-style-span" style="font-size: x-large;"><span class="Apple-style-span" style="background-color: #fff2cc;"><span class="Apple-style-span" style="font-family: 'Trebuchet MS', sans-serif;">Using the 74xx47 BCD to Seven-segment display</span></span></span></h1>The 74xx47 chip is used to drive 7 segment display. You must use the 74xx47 with a <b>common anode 7-segment display</b> (e.g. Kingbright part number SA03). The input to the 74xx47 is a binary number <b>DCBA</b> where D is 8s, C is 4s, B is 2s and A is 1s. The inputs DCBA often come from a binary counter.The display is only sensible if the binary number is between DCBA=0000 (0) and DCBA=1001 (9); this is called Binary Coded Decimal or BCD for short. If the number is larger than 9 you get a strange output on the display. Try this out by moving your mouse over the truth table.<br />
The inputs <img src="http://www.davidswinscoe.com/electronics/components/7447/BI.gif" />/<img src="http://www.davidswinscoe.com/electronics/components/7447/RBO.gif" />, <img src="http://www.davidswinscoe.com/electronics/components/7447/RBI.gif" /> and <img src="http://www.davidswinscoe.com/electronics/components/7447/LT.gif" /> are usually connected to 5v<br />
<img src="http://www.davidswinscoe.com/electronics/components/7447/74xx47.gif" /><br />
<h2>Simple use</h2><ol><li>Connect V<sub>cc</sub> [pin 16], <img src="http://www.davidswinscoe.com/electronics/components/7447/LT.gif" /> [pin 3], <img src="http://www.davidswinscoe.com/electronics/components/7447/BI.gif" />/<img src="http://www.davidswinscoe.com/electronics/components/7447/RBO.gif" /> [pin 4] and <img src="http://www.davidswinscoe.com/electronics/components/7447/RBI.gif" /> [pin 5] to 5v.</li>
<li>Connect Gnd [pin 8] to 0v.</li>
<li>connect DCBA [pins 1, 2, 6 and 7] to DCBA on your counter.</li>
<li>Connect <img src="http://www.davidswinscoe.com/electronics/components/7447/a.gif" /> <img src="http://www.davidswinscoe.com/electronics/components/7447/b.gif" /> <img src="http://www.davidswinscoe.com/electronics/components/7447/c.gif" /> <img src="http://www.davidswinscoe.com/electronics/components/7447/d.gif" valign="top" /> <img src="http://www.davidswinscoe.com/electronics/components/7447/e.gif" /> <img src="http://www.davidswinscoe.com/electronics/components/7447/f.gif" /> <img src="http://www.davidswinscoe.com/electronics/components/7447/g.gif" /> [pins 9-15] to abcdefg on the common anode 7-segment display.</li>
</ol><table align="CENTER" border="5" cellspacing="1" cols="15"><tbody>
<tr><th align="CENTER" colspan="7">Inputs</th><th align="CENTER" colspan="8">Outputs</th></tr>
<tr><th>D</th><th>C</th><th>B</th><th>A</th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/BI.gif" />/<img src="http://www.davidswinscoe.com/electronics/components/7447/RBO.gif" /></th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/RBI.gif" /></th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/LT.gif" /></th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/a.gif" /></th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/b.gif" /></th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/c.gif" /></th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/d.gif" /></th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/e.gif" /></th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/f.gif" /></th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/g.gif" /></th><th>Display</th></tr>
<tr id="line0" style="color: black;"><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td rowspan="19"><img name="image1" src="http://www.davidswinscoe.com/electronics/components/7447/7segb11.gif" /></td></tr>
<tr id="line1"><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td></tr>
<tr id="line2"><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td></tr>
<tr id="line3"><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td></tr>
<tr id="line4"><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td></tr>
<tr id="line5"><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td></tr>
<tr id="line6"><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td></tr>
<tr id="line7"><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td></tr>
<tr id="line8" style="color: black;"><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td></tr>
<tr id="line9" style="color: black;"><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td></tr>
<tr id="line10" style="color: black;"><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td></tr>
<tr id="line11" style="color: red;"><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td></tr>
<tr id="line12" style="color: black;"><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td></tr>
<tr id="line13"><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td></tr>
<tr id="line14"><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td></tr>
<tr id="line15"><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td></tr>
</tbody></table><h2>Advanced use</h2><img src="http://www.davidswinscoe.com/electronics/components/7447/LT.gif" /> stands for Lamp Test. When <img src="http://www.davidswinscoe.com/electronics/components/7447/LT.gif" /> is low all the segments on the 7-seg display are lit regardless of DCBA. <a href="http://www.davidswinscoe.com/electronics/components/7447/BI.gif" imageanchor="1"><img border="0" src="http://www.davidswinscoe.com/electronics/components/7447/BI.gif" /></a> stands for Blanking Input. When <img src="http://www.davidswinscoe.com/electronics/components/7447/BI.gif" /> is low the display is blank so all the segments on the 7seg display are off regardless of DCBA.<br />
<img src="http://www.davidswinscoe.com/electronics/components/7447/RBI.gif" /> stands for Ripple Blanking Input. When <img src="http://www.davidswinscoe.com/electronics/components/7447/RBI.gif" /> is low and DCBA=0000 the display is blank otherwise the number is displayed on the display. This is used to remove leading zeroes from a number (e.g. diplay 89 instead of 089). To use with more than one display connect <img src="http://www.davidswinscoe.com/electronics/components/7447/RBO.gif" /> (Ripple Blanking Output) from most significant 74xx47 to the <img src="http://www.davidswinscoe.com/electronics/components/7447/RBI.gif" /> of the next 74xx47.<br />
Connect <img src="http://www.davidswinscoe.com/electronics/components/7447/RBI.gif" /> of the least significant 74xx47 to 5v unless you want the diplay to turn off when the number is 0.<br />
<table align="CENTER" border="5" cellspacing="1" cols="15"><tbody>
<tr><th align="CENTER" colspan="7">Inputs</th><th align="CENTER" colspan="8">Outputs</th></tr>
<tr><th>D</th><th>C</th><th>B</th><th>A</th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/BI.gif" />/<img src="http://www.davidswinscoe.com/electronics/components/7447/RBO.gif" /></th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/RBI.gif" /></th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/LT.gif" /></th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/a.gif" /></th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/b.gif" /></th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/c.gif" /></th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/d.gif" /></th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/e.gif" /></th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/f.gif" /></th><th><img src="http://www.davidswinscoe.com/electronics/components/7447/g.gif" /></th><th>Display</th></tr>
<tr id="line16" style="color: red;"><td align="CENTER">X</td><td align="CENTER">X</td><td align="CENTER">X</td><td align="CENTER">X</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td rowspan="19"><img name="image2" src="http://www.davidswinscoe.com/electronics/components/7447/7segb15.gif" /></td></tr>
<tr id="line17" style="color: black;"><td align="CENTER">X</td><td align="CENTER">X</td><td align="CENTER">X</td><td align="CENTER">X</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td></tr>
<tr id="line18" style="color: black;"><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td></tr>
<tr id="line19"><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td></tr>
<tr id="line20"><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td></tr>
<tr id="line21"><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td></tr>
<tr id="line22"><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td></tr>
<tr id="line23"><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td></tr>
<tr id="line24"><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td></tr>
<tr id="line25"><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td></tr>
<tr id="line26"><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td></tr>
<tr id="line27"><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td></tr>
<tr id="line28"><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td></tr>
<tr id="line29"><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td></tr>
<tr id="line30"><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td></tr>
<tr id="line31"><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td></tr>
<tr id="line32"><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td><td align="CENTER">0</td></tr>
<tr id="line33"><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">0</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td><td align="CENTER">1</td></tr>
</tbody></table>Siroshhttp://www.blogger.com/profile/05322973504445644007noreply@blogger.com0tag:blogger.com,1999:blog-7411404318698297991.post-92143650042813020902010-05-21T06:24:00.000+05:302010-05-21T06:24:53.359+05:30Description<div style="text-align: center;"><span class="Apple-style-span" style="color: red;"><span class="Apple-style-span" style="font-size: x-large;">This Blog is used to spread </span><b><span class="Apple-style-span" style="background-color: yellow;"><span class="Apple-style-span" style="font-size: x-large;">8</span></span><span class="Apple-style-span" style="color: #e06666;"><span class="Apple-style-span" style="background-color: yellow;"><span class="Apple-style-span" style="font-size: x-large;">0</span></span></span><span class="Apple-style-span" style="background-color: yellow;"><span class="Apple-style-span" style="font-size: x-large;">51</span></span></b><span class="Apple-style-span" style="font-size: x-large;"> and </span><b><span class="Apple-style-span" style="background-color: yellow;"><span class="Apple-style-span" style="font-size: x-large;">PIC</span></span></b><span class="Apple-style-span" style="font-size: x-large;"> micro controller projects and some <span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;">simple tips</span>..</span></span></div><div style="text-align: center;"><span class="Apple-style-span" style="color: red;"><span class="Apple-style-span" style="font-size: x-large;">It also links to related web pages and <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">App Notes</span></span></span></div>Siroshhttp://www.blogger.com/profile/05322973504445644007noreply@blogger.com0tag:blogger.com,1999:blog-7411404318698297991.post-39190181208379676482010-05-20T19:07:00.001+05:302010-05-20T19:07:59.854+05:30Welcome to my new blogHai Friends<div><br /></div><div>Welcome to my new blog site for 8051 and PIC project and programming,</div>Siroshhttp://www.blogger.com/profile/05322973504445644007noreply@blogger.com0