<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2873049276340993950</id><updated>2012-02-16T14:52:45.177+07:00</updated><category term='4X3 matrix keypad'/><category term='microcontroller'/><category term='Dual channel at89S52-based frequency counter'/><category term='error'/><category term='clock'/><category term='7-segment common anode'/><category term='99 MHz frequency counter'/><category term='timer for counter'/><category term='generator'/><title type='text'>Microcontroller for better live</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>40</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-354807322192319419</id><published>2011-04-12T11:18:00.003+07:00</published><updated>2011-05-05T10:52:12.651+07:00</updated><title type='text'>Measure true-RMS of Voltage and Current Grid</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Improvement of power quality is one attempt to increase the efficiency of electrical energy. One effort is by monitoring the amount of voltage and current RMS grid. The use of measuring devices such as voltmeters and ammeters used to sometimes do not give accurate results. Some measuring devices (including some digital measuring instrument) only measure the average value of which is calibrated to indicate RMS value. Determination of the true RMS value for a variety of waveforms to be done by using a true-RMS digital measuring instrument.&lt;br /&gt;The use of digital measuring instrument gives the consequences of rising prices of measuring instruments must be purchased. So for the purposes of measuring RMS voltage value with a certain specification and accuracy should be used in microcontroller-based measuring instrument that we can make. For the purposes of the laboratory and further development, the instruments should be able to determine the RMS value for the wave of contaminated several harmonic components.&lt;br /&gt;Implementation of voltage and current measurement based on microcontroller is done in order to the effort of monitoring and improving the quality of electric power. Thus the results of application of this research should have a great opportunity to develop a system of monitoring and improving the quality of electric power.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;&lt;br /&gt;&lt;span class="short_text" id="result_box" lang="en"&gt;&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;How it works&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span class="short_text" id="result_box" lang="en"&gt;&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;To be able to&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;measure the&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;RMS&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;value&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;we&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;must&lt;/span&gt;&lt;span class="" title="Klik untuk terjemahan alternatif"&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span class="" id="result_box" lang="en"&gt;&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;1&lt;/span&gt;&lt;span title="Klik untuk terjemahan alternatif"&gt;.&lt;/span&gt; &lt;a href="http://microforbetterlive.blogspot.com/2010/09/frequency-measurement.html"&gt;&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;determine the&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;frequency&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;signal&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;2&lt;/span&gt;&lt;span title="Klik untuk terjemahan alternatif"&gt;.&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;determine the&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;sampling&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;count&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;per&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;signal&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;period&lt;/span&gt;&lt;br /&gt;&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;3&lt;/span&gt;&lt;span title="Klik untuk terjemahan alternatif"&gt;.&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;sampling&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;the&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;signal&lt;/span&gt;&lt;br /&gt;&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;4&lt;/span&gt;&lt;span title="Klik untuk terjemahan alternatif"&gt;.&lt;/span&gt; &lt;a href="http://microforbetterlive.blogspot.com/2010/07/calculate-true-rms-value_20.html"&gt;&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;calculate the&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;RMS&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;value&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span class="" id="result_box" lang="en"&gt;&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;5&lt;/span&gt;&lt;span class="" title="Klik untuk terjemahan alternatif"&gt;.&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;RMS&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;value of&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;the display&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;update&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;periodically&lt;/span&gt; &lt;span class="hps atn" title="Klik untuk terjemahan alternatif"&gt;(&lt;/span&gt;&lt;span title="Klik untuk terjemahan alternatif"&gt;the period&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;can&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;be improved&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;with&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;precision&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;algorithm&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;for&lt;/span&gt; &lt;a href="http://microforbetterlive.blogspot.com/2010/07/precision-frequency-generator.html"&gt;&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;precision&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;frequency&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;generator&lt;/span&gt;&lt;/a&gt;&lt;span class="" title="Klik untuk terjemahan alternatif"&gt;)&lt;/span&gt;&lt;span class="" title="Klik untuk terjemahan alternatif"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class="" id="result_box" lang="en"&gt;&lt;span title="Klik untuk terjemahan alternatif"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="" id="result_box" lang="en"&gt;&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span class="" id="result_box" lang="en"&gt;&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="short_text" id="result_box" lang="en"&gt;&lt;span class="" title="Klik untuk terjemahan alternatif"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;System Block Diagram&lt;/b&gt;&lt;br /&gt;System for measuring RMS voltage and current values are made based block diagram in Figure 1. Input signal for this system are the voltage and current on a grid. Detection of voltage and current do not use voltage and current sensors. &lt;/span&gt;&lt;span class="" id="result_box" lang="en" style="font-size: small;"&gt;&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;Most&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;applications&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;using&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;current&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;and&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;voltage&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;sensors&lt;/span&gt;&lt;span title="Klik untuk terjemahan alternatif"&gt;.&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;However,&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;the use of&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;both&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;sensors&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;will&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;result in&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;the&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;current&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;and&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;voltage&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;signals&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;can not be&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;analyzed&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;again&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;for&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;other purposes&lt;/span&gt;&lt;span class="" title="Klik untuk terjemahan alternatif"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt; &amp;nbsp;&lt;a href="http://3.bp.blogspot.com/-53bi624GwMI/TaPQOBltmNI/AAAAAAAAAG4/TFz10jlY890/s1600/diagram+block.jpg" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-53bi624GwMI/TaPQOBltmNI/AAAAAAAAAG4/TFz10jlY890/s1600/diagram+block.jpg" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size: small;"&gt;Figure 1&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;Sampling Voltage and Current&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="" id="result_box" lang="en" style="font-size: small;"&gt;&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;One&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;period of&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;the voltage&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;sampled&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;64&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;times&lt;/span&gt;&lt;span title="Klik untuk terjemahan alternatif"&gt;, so&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;for&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;a&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;period of&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;electric current&lt;/span&gt;&lt;span class="" title="Klik untuk terjemahan alternatif"&gt;.&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;So here it&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;is necessary&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;an algorithm&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;to&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;determine the&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;period&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;and&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;frequency of&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;electric&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;voltage&lt;/span&gt;&lt;span class="" title="Klik untuk terjemahan alternatif"&gt;. &lt;/span&gt;&lt;/span&gt;&lt;span class="" id="result_box" lang="en" style="font-size: small;"&gt;&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;Voltages&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;and&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;currents&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;have the&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;same&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;frequency&lt;/span&gt;&lt;span title="Klik untuk terjemahan alternatif"&gt;,&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;but &lt;a href="http://www.blogger.com/goog_56407030"&gt;the&lt;/a&gt;&lt;/span&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage.html"&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;determination&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;is&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;made&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;​​on the&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;frequency of&lt;/span&gt;&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;the voltage&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;signal&lt;/span&gt;&lt;/a&gt; &lt;span class="" title="Klik untuk terjemahan alternatif"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt; Sampling the voltage and current signals performed alternately as Figure 4. Thus the frequency of samples to be f = 128 × f_grid. Figure 4 is an example of sampling the grid voltage of 255 volts and the current with 500 mA amplitude of the fundamental components that contaminated by 3rd and 5th harmonic and electric current lag 11.25 degrees. Signal fed to pin ADC0 voltage and current signals fed to the ADC1 pin.&lt;br /&gt;&amp;nbsp;&lt;a href="http://2.bp.blogspot.com/-Ivw4T7EyYMs/TaPQucdOTwI/AAAAAAAAAG8/QC1FrGRqlqE/s1600/Sampling.jpg" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-Ivw4T7EyYMs/TaPQucdOTwI/AAAAAAAAAG8/QC1FrGRqlqE/s1600/Sampling.jpg" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size: small;"&gt;Figure 2 &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;Selection bits ADC Data Used&lt;/b&gt;&lt;br /&gt;Although the ADC has a maximum resolution of 10 bits. &lt;span class="" id="result_box" lang="en"&gt;&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;In&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;this study&lt;/span&gt;&lt;span title="Klik untuk terjemahan alternatif"&gt;,&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;we&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;use the&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;ADC&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;with a&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;resolution of&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;8 bits&lt;/span&gt;&lt;span title="Klik untuk terjemahan alternatif"&gt;.&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;Use of&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;10&lt;/span&gt;&lt;span title="Klik untuk terjemahan alternatif"&gt;-bit&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;resolution&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;will certainly&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;provide&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;a higher&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;accuracy&lt;/span&gt;&lt;span class="" title="Klik untuk terjemahan alternatif"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt; Instantaneous voltage and current represented by the 8 bit register ADCH of 10 bit ADC data samples that have been arranged left-adjust as Figure 3.&lt;br /&gt;&amp;nbsp;&lt;a href="http://4.bp.blogspot.com/-kOvdgQdH838/TaPRHVjSqhI/AAAAAAAAAHE/QvpDaoRovhY/s1600/Bit+used.jpg" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-kOvdgQdH838/TaPRHVjSqhI/AAAAAAAAAHE/QvpDaoRovhY/s1600/Bit+used.jpg" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size: small;"&gt;Figure 3&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;The system uses 8-bit ADC and sample frequency of 64 times the fundamental frequency of grid voltage. Measurement error caused by quantization error is reduced by using the oversampling and 2.5 VDC offset addition method.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;The Result&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span class="" id="result_box" lang="en"&gt;&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;We have&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;been&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;able to measure the&lt;/span&gt; true-&lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;RMS&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;of voltage&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;from&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;10&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;to&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;250&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;volts&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;and&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;true-RMS&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;of currents&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;of&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;50mA&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;to&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;1&lt;/span&gt; &lt;span class="hps" title="Klik untuk terjemahan alternatif"&gt;A. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;Absolute error value of RMS voltage measurement below 0.5% for the range of voltage from 160 volts to 250 volts. And absolute error value of RMS current measurement below 4% for the range of currents from 200 mA to 1 A for currents slightly contaminated harmonic components. With a few suggestions for improvement, this system can be developed into the next research of the power quality measurement based on microcontroller.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/07/purpose-of-this-blog.html"&gt;click here for more information&lt;/a&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-354807322192319419?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/354807322192319419/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2011/04/measure-true-rms-of-voltage-and-current.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/354807322192319419'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/354807322192319419'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2011/04/measure-true-rms-of-voltage-and-current.html' title='Measure true-RMS of Voltage and Current Grid'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-53bi624GwMI/TaPQOBltmNI/AAAAAAAAAG4/TFz10jlY890/s72-c/diagram+block.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-3184568605019344405</id><published>2010-12-01T09:11:00.004+07:00</published><updated>2010-12-01T09:22:54.316+07:00</updated><title type='text'>Automatic Power Factor Correction Systems</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt; The power factor is one of the problems in electric power quality improvement. In many cases, low power factor causes the waste of electrical energy. In large commercial and industrial sectors, usually used in a centralized system of capacitors in a room for power factor correction. However, changes in the electric power consumed by electrical equipment operated at any time require changes in the capacity of capacitors which must compensate for the inductive nature of the electrical equipment is being operated. A value system that can provide appropriate capacity of capacitors to improve power factor is needed on systems with dynamic changes in electrical load.&lt;br /&gt;Ideally, all customers of electric energy should have a good power factor (close to the value 1) to reduce the cost of electrical energy production. However, power factor corrections should be done the right way for any equipment used. This raises a new problem: how to design a power factor correction systems that can be used for all electrical equipment used. And how for power factor correction systems can also be operated for a variety of electrical load, so it does not need to be plugged at any existing electrical equipment. With this system, the expected power factor can be fixed easily and the system can be used for every electricity customer. With the corrected power factor, the electricity companies no longer must be generated electrical energy that is greater than the needs of customers.&lt;br /&gt;Power factor is one parameter determining the quality of electric power. A good quality electrical power will increase efficiency in the electricity system. With the same production at the customer side, the total electrical energy consumed by customers will be reduced. This will be followed by a decrease in the voltage loss in the distribution system, thus decreasing the voltage drop on the customer side. On the generation of electrical energy, without reducing the electrical energy dollars are sold, the total energy generated will be smaller so that the operational costs of electricity generation will be reduced. With the increased efficiency of electric power, rising power demand next few years can still be supplied by the current generator, so the electricity deficit in this country for a while can be forgotten and needs additional power plant may be delayed.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/using-atmega8535-avr-microcontroller.html"&gt;Using ATmega8535 AVR Microcontroller&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/heaviest-electrical-loads-for-system.html"&gt; Heaviest Electrical Loads for the System&amp;nbsp;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/modeling-using-matlab.html"&gt;Modeling using MATLAB&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/performance-of-apfc.html"&gt; The Performance of the APFC&lt;/a&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-3184568605019344405?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/3184568605019344405/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/12/automatic-power-factor-correction.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/3184568605019344405'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/3184568605019344405'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/12/automatic-power-factor-correction.html' title='Automatic Power Factor Correction Systems'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-4622423977107139407</id><published>2010-12-01T09:10:00.010+07:00</published><updated>2010-12-01T09:49:11.109+07:00</updated><title type='text'>Using ATmega8535 AVR Microcontroller</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;APFC system uses AVR microcontroller family as the main component that has an internal ADC. ATmega8535 microcontroller is used here. To be able to record voltage and current signals, we use a voltage-to-voltage converter and current-to-voltage. A signal conditioning is used to make the both output signal voltage of the converter in accordance with the characteristics of the ADC inputs. This system uses a capacitor bank (C-bank), which consists of four capacitors. These capacitors are used for power factor correction.&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_Xf1TLp5Ejns/TPW3HsZaODI/AAAAAAAAAGs/NOivzJtt8iI/s1600/APFC1.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="291" src="http://4.bp.blogspot.com/_Xf1TLp5Ejns/TPW3HsZaODI/AAAAAAAAAGs/NOivzJtt8iI/s640/APFC1.JPG" width="640" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;span id="goog_55972877"&gt;&lt;/span&gt;&lt;span id="goog_55972878"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/automatic-power-factor-correction.html"&gt;The need for Automatic Power Factor Correction (APFC) Systems&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/heaviest-electrical-loads-for-system.html"&gt;  Heaviest Electrical Loads for the System &lt;/a&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/heaviest-electrical-loads-for-system.html"&gt; &amp;nbsp;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/modeling-using-matlab.html"&gt;Modeling  using MATLAB&lt;/a&gt;&lt;span id="goog_174014030"&gt;&lt;/span&gt;&lt;span id="goog_174014031"&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/performance-of-apfc.html"&gt;  The Performance of the APFC&lt;/a&gt;&lt;/span&gt; &lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-4622423977107139407?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/4622423977107139407/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/12/using-atmega8535-avr-microcontroller.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/4622423977107139407'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/4622423977107139407'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/12/using-atmega8535-avr-microcontroller.html' title='Using ATmega8535 AVR Microcontroller'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_Xf1TLp5Ejns/TPW3HsZaODI/AAAAAAAAAGs/NOivzJtt8iI/s72-c/APFC1.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-1806168201963453458</id><published>2010-12-01T09:10:00.007+07:00</published><updated>2010-12-01T09:27:03.340+07:00</updated><title type='text'>Heaviest Electrical Loads for the System</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;For this system, the greater the power used, effort should be made for power factor correction is also more severe. Capacitor capacity value should be used for power factor correction will be even greater.&lt;br /&gt;At the same apparent power, the lower the power factor, power factor correction efforts are also increasingly heavy. Attempts to raise the power factor will require a capacitor with larger capacity as well. Low power factor due to the large value of phase difference between voltage and current.&lt;br /&gt;Heaviest electrical loads for the system occurs when the load has largest apparent power and smallest power factor. All capacitors in the C-bank should be able to correct this condition so that the value of power factor becomes one.&lt;br /&gt;Modeling using MATLAB&lt;br /&gt;This model is created using Simulink in MATLAB version 6.5.1. Models of automatic power factor correction systems can be seen in the following figure. This model consists of several subsystems and the S-Function. This system is also equipped with input devices that can retrieve data from a file and the output device (data logger), which can save data to multiple variables in a workspace that can be saved to a file for further processing. Listing program written in C language.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/automatic-power-factor-correction.html"&gt;&lt;span&gt;The  need for Automatic Power Factor Correction (APFC) Systems&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/using-atmega8535-avr-microcontroller.html"&gt;Using  ATmega8535 AVR Microcontroller&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/heaviest-electrical-loads-for-system.html"&gt;  &lt;/a&gt;&lt;span&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/modeling-using-matlab.html"&gt;Modeling  using MATLAB&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/performance-of-apfc.html"&gt;  The Performance of the APFC&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;  &lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-1806168201963453458?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/1806168201963453458/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/12/heaviest-electrical-loads-for-system.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/1806168201963453458'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/1806168201963453458'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/12/heaviest-electrical-loads-for-system.html' title='Heaviest Electrical Loads for the System'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-3840198484645558964</id><published>2010-12-01T09:09:00.005+07:00</published><updated>2010-12-01T09:28:36.417+07:00</updated><title type='text'>Modeling using MATLAB</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;This model is created using Simulink in MATLAB version 6.5.1. Models of automatic power factor correction systems can be seen in the following figure. This model consists of several subsystems and the S-Function. This system is also equipped with input devices that can retrieve data from a file and the output device (data logger), which can save data to multiple variables in a workspace that can be saved to a file for further processing. Listing program written in C language.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/automatic-power-factor-correction.html"&gt;The  need for Automatic Power Factor Correction (APFC) Systems&lt;/a&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/using-atmega8535-avr-microcontroller.html"&gt;Using  ATmega8535 AVR Microcontroller&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/heaviest-electrical-loads-for-system.html"&gt;  Heaviest Electrical Loads for the System&amp;nbsp;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/performance-of-apfc.html"&gt;  The Performance of the APFC&lt;/a&gt;&lt;/span&gt;  &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-3840198484645558964?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/3840198484645558964/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/12/modeling-using-matlab.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/3840198484645558964'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/3840198484645558964'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/12/modeling-using-matlab.html' title='Modeling using MATLAB'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-2567219153056210535</id><published>2010-12-01T09:08:00.001+07:00</published><updated>2010-12-01T09:27:16.076+07:00</updated><title type='text'>The Performance of the APFC</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Assuming the capacitor value of automatic power factor correction systems can be any, or in other words the number of variations of the value of the capacitor capacity is infinite, the higher the apparent power of load or the lower the power factor of load, power factor correction efforts will be heavier and value output power factor can still be worth far below one.&lt;br /&gt;But with the limited number of variations in the value of the capacitor capacity, as long as the maximum limits of correction, the higher the load apparent power, power factor corrected values would be guaranteed getting closer to one and have a fairly small fluctuations.&lt;br /&gt;In order to achieve the value of power factor as close to one, the determination of the total capacity of capacitors in the C-bank should be based on the largest electrical load that happens, both electrical load with the greatest apparent power and the smallest power factor, and not based on installed power capacity.&lt;br /&gt;In conditions with heavier loads than specified, the system will perform power factor correction by using all of available capacitors and there is the possibility of power factor corrected still much smaller than one.&lt;br /&gt;With the same power factor value, the lower the load apparent power, power factor corrected values will be more varied and this value can be far below the value of one. The low power factor at low power will not be harmful because the reactive current that occurred only a little.&lt;br /&gt;The model has been developed can be implemented into a prototype of automatic power factor correction that can be used for many consumers.&lt;br /&gt;For overall power factor correction, should be considered the harmonic components. This research can proceed with efforts to correcting harmonic component.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/automatic-power-factor-correction.html"&gt;&lt;span&gt;The  need for Automatic Power Factor Correction (APFC) Systems&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/using-atmega8535-avr-microcontroller.html"&gt;Using  ATmega8535 AVR Microcontroller&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/heaviest-electrical-loads-for-system.html"&gt;  Heaviest Electrical Loads for the System&amp;nbsp;&lt;/a&gt;&lt;br /&gt;&lt;span&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/12/modeling-using-matlab.html"&gt;Modeling  using MATLAB&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-2567219153056210535?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/2567219153056210535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/12/performance-of-apfc.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2567219153056210535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2567219153056210535'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/12/performance-of-apfc.html' title='The Performance of the APFC'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-2937066075405053965</id><published>2010-09-22T09:50:00.008+07:00</published><updated>2010-10-13T13:40:36.468+07:00</updated><title type='text'>Measure the Frequency of Grid Voltage and Phase Difference between Current of Load and Grid Voltage</title><content type='html'>&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Voltage range&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 40 V ~ 280 V (Vrms)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt; Current range&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 0 ~ 200 mA&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;Frequency&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 35Hz ~ 70Hz&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;Phase differnece : 0° ~ 90&lt;/span&gt;&lt;span style="font-size: small;"&gt;° (lead or lag)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Voltage grid should be is 50Hz or 60Hz. But in reality the frequency of the grid are sometimes shifted slightly, so be below or above &lt;/span&gt;&lt;span style="font-size: small;"&gt;50Hz or 60Hz&lt;/span&gt;&lt;span style="font-size: small;"&gt;. The stability of the voltage frequency is one indicator of the quality of electrical voltage.&lt;/span&gt;&lt;span style="font-size: small;"&gt; The stability of the power grid's frequency is a health indicator of the grid's ability to respond to changes in supply and demand of electricity. Although there are other grid characteristics that can be measured,&lt;br /&gt;frequency is less affected by local disturbances than other attributes like voltage and current.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; As we develop more energy resources, these resources need to be integrated efficiently and cost effectively with our existing energy infrastructure – the power grids. Alternating Current, or AC, power generators need to be synchronized to provide optimal service and electric energy supply. When we consume electricity, we place a load on the power grid. We can develop smart appliances that can measure the grid's frequency and the health of the grid's power supply; then respond appropriately by scheduling or reducing load to help maintain grid stability.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Most of the electrical load current draw currents that have a different phase with the voltage supplied to him. Current on inductive load is lagging behind the voltage. Current on incandescent sometimes precedes the voltage of grid. Fact, the current in the electrical load that use of switching power supply is extremely precede the voltage.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In order to achieve maximum efficiency in electricity usage, the phase angle between the currents must be equal to the voltage, in other words, the current must be in phase with voltage. Real power comparison of voltage multiplied by current is called the power factor.&lt;br /&gt;Ideally, power factor of load is to be one.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Measuring instrument of real power and power factor both analog and digital has been widely available. However, a measurement to the phase difference between voltage and current flowing in the grid is still rarely found. The need for these measuring devices in the lab sometimes still constrained. This paper describes the results of the implementation of the ATmega8535 microcontroller as a major component of the device for measure the frequency of the grid voltage and measure the phase difference between voltage and current flowing in the load. Furthermore, the expected applications can be developed for the measurement of the values of voltage and current RMS, power and power factor, even down to the power analyzer&amp;nbsp; based microcontroller. &lt;/span&gt;&lt;span class="" id="result_box" lang="en" style="font-size: small;"&gt;&lt;span title=""&gt;Programs in this microcontroller can be applied to several other AVR microcontroller series if this program will not be developed further.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage-and.html"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;The Need for Phase Difference Measuring Instrument&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage.html"&gt;&lt;span style="font-size: small;"&gt;Measure the Frequency of Grid Voltage rather than Measure the Frequency of Current&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/voltage-and-current-converter.html"&gt;&lt;span style="font-size: small;"&gt;Voltage and Current Converter&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/signal-conditioning.html"&gt;&lt;span style="font-size: small;"&gt;The Signal Conditioning&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/use-of-microcontroller-adc.html"&gt;&lt;span style="font-size: small;"&gt;The use of the microcontroller ADC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/frequency-measurement.html"&gt;&lt;span style="font-size: small;"&gt;Frequency Measurement&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/phase-difference-measurement.html"&gt;&lt;span style="font-size: small;"&gt;Phase Difference Measurement&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/output-display-format.html"&gt;&lt;span style="font-size: small;"&gt;Output Display Format&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/07/purpose-of-this-blog.html"&gt;click here for more information&lt;/a&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-2937066075405053965?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2937066075405053965'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2937066075405053965'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage-and.html' title='Measure the Frequency of Grid Voltage and Phase Difference between Current of Load and Grid Voltage'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-2201388648441168925</id><published>2010-09-22T09:49:00.004+07:00</published><updated>2010-10-13T13:37:09.351+07:00</updated><title type='text'>Measure the Frequency of Grid Voltage rather than Measure the Frequency of Current</title><content type='html'>&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The fundamental frequency of the current flowing to a load will be the same to the fundamental frequency of the voltage supplied to it. Due to the current usually have more harmonic components than voltage, frequency measurement easier done on the voltage supplied to it.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The frequency of the grid voltage in Indonesia is 50 Hz, whereas in some other countries is 60 Hz. To reduce the calculation errors caused by harmonic components, frequency range of the measurement values can be restricted so that the harmonic frequencies will be ignored. To increase accuracy, measurements of the frequency value for the low frequency signal, is done by first measuring the value of the period, and not by counting the occurrence of waves. Nevertheless, the accuracy of the measurement result is displayed in the format of three digits such as the frequency measuring instruments for grid voltage.&lt;br /&gt;best to avoid using voltage and current sensors&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Detection of voltage and current values does not use a voltage and current sensor. Generally, the voltage and current signal was converted to DC voltage signals by a sensor and then fed to the ADC input. But this will make the voltage and current cannot be analyzed further more.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;In this application, the value of alternating voltage which has been normalized is fed directly to the ADC input of the microcontroller. Current can be detected by the ADC after converted into a voltage.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage-and.html"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;The Need for Phase Difference Measuring Instrument&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage.html"&gt;&lt;span style="font-size: small;"&gt;Measure the Frequency of Grid Voltage rather than Measure the Frequency of Current&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/voltage-and-current-converter.html"&gt;&lt;span style="font-size: small;"&gt;Voltage and Current Converter&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/signal-conditioning.html"&gt;&lt;span style="font-size: small;"&gt;The Signal Conditioning&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/use-of-microcontroller-adc.html"&gt;&lt;span style="font-size: small;"&gt;The use of the microcontroller ADC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/frequency-measurement.html"&gt;&lt;span style="font-size: small;"&gt;Frequency Measurement&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/phase-difference-measurement.html"&gt;&lt;span style="font-size: small;"&gt;Phase Difference Measurement&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/output-display-format.html"&gt;&lt;span style="font-size: small;"&gt;Output Display Format&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-2201388648441168925?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/2201388648441168925/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2201388648441168925'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2201388648441168925'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage.html' title='Measure the Frequency of Grid Voltage rather than Measure the Frequency of Current'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-1348948038594838370</id><published>2010-09-22T09:46:00.008+07:00</published><updated>2010-10-13T13:57:55.692+07:00</updated><title type='text'>Voltage and Current Converter</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Voltage-to-Voltage Converter:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;u&gt;Input&lt;/u&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;u&gt;Output&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;Vrms&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 ~ 280V&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.57 ~ 1.77V with 5VDC offset or&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;Vpp &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 0 ~ 400V&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.80 ~ 5.00V with 5VDC offset&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;Current-to-Voltage Converter:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;u&gt;Input&lt;/u&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;u&gt;Output&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;Irms&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0 ~ 500mA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0.00 ~ 1.77V with 5VDC offset&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In order for the grid voltage and current flowing in the load can be read by the ADC microcontroller, voltage signal are converted using a voltage-to-voltage converter that is step-down transformer. While the current signal converted using current-to-voltage converter that is a step-up transformer which has very low inductance at primary coil and high inductance at secondary coil. For this purpose, we can use the adapter transformer. In this case, I_out and I_in fed to the low voltage coil and we get v0 and ground from high voltage coil as Figure 1.&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_Xf1TLp5Ejns/TJlt4UmRRkI/AAAAAAAAAGg/h8RSUhIWBMQ/s1600/Block+Diagram.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="156" src="http://2.bp.blogspot.com/_Xf1TLp5Ejns/TJlt4UmRRkI/AAAAAAAAAGg/h8RSUhIWBMQ/s400/Block+Diagram.jpg" width="400" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;Figure 1 &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;At the ADC input of microcontroller, we found clipper diode that can be utilized as a main component to build a zero cross detector that can be used to measure the period of input voltage. But in this study, the input voltage that is usually sinusoidal form will be entered as a whole, so that in future this system can be developed for the calculation of RMS values and power.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage-and.html"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;The Need for Phase Difference Measuring Instrument&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage.html"&gt;&lt;span style="font-size: small;"&gt;Measure the Frequency of Grid Voltage rather than Measure the Frequency of Current&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/signal-conditioning.html"&gt;&lt;span style="font-size: small;"&gt;The Signal Conditioning&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/use-of-microcontroller-adc.html"&gt;&lt;span style="font-size: small;"&gt;The use of the microcontroller ADC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/frequency-measurement.html"&gt;&lt;span style="font-size: small;"&gt;Frequency Measurement&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/phase-difference-measurement.html"&gt;&lt;span style="font-size: small;"&gt;Phase Difference Measurement&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/output-display-format.html"&gt;Output Display Format&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-1348948038594838370?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/1348948038594838370/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/09/voltage-and-current-converter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/1348948038594838370'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/1348948038594838370'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/09/voltage-and-current-converter.html' title='Voltage and Current Converter'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_Xf1TLp5Ejns/TJlt4UmRRkI/AAAAAAAAAGg/h8RSUhIWBMQ/s72-c/Block+Diagram.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-6575036280541619264</id><published>2010-09-22T09:40:00.007+07:00</published><updated>2010-10-13T14:02:20.402+07:00</updated><title type='text'>The Signal Conditioning</title><content type='html'>&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; v0 and v1 fed into the Signal_Conditioning block to have normalized so that the maximum voltage is Vpp = 5V. In this block, we add 2.5 V DC offset voltage to both signal so they have a voltage range of 0 to 5 V according to the ADC limits. &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The phase shift will occur while converting grid voltage to low voltage and converting current to voltage. To compensate them, on the block Signal_Conditioning, there is the phase shifting circuit that will adjust the phase again. This circuit also functions as a first-orde high-pass-filter. These filters are used to reduce the amplitude values of harmonic components which might make the calculation value of the frequency and phase difference to be wrong.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The output of this block is a voltage signal v0' that it’s shape like the grid voltage, and voltage signals v1' it’s shape like the current grid. Phase shift between v0' and v1' equal to the phase shift between voltage and current grid.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage-and.html"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;The Need for Phase Difference Measuring Instrument&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage.html"&gt;&lt;span style="font-size: small;"&gt;Measure the Frequency of Grid Voltage rather than Measure the Frequency of Current&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/voltage-and-current-converter.html"&gt;&lt;span style="font-size: small;"&gt;Voltage and Current Converter&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/signal-conditioning.html"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/a&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/use-of-microcontroller-adc.html"&gt;&lt;span style="font-size: small;"&gt;The use of the microcontroller ADC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/frequency-measurement.html"&gt;&lt;span style="font-size: small;"&gt;Frequency Measurement&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/phase-difference-measurement.html"&gt;&lt;span style="font-size: small;"&gt;Phase Difference Measurement&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/output-display-format.html"&gt;Output Display Format&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-6575036280541619264?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/6575036280541619264/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/09/signal-conditioning.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/6575036280541619264'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/6575036280541619264'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/09/signal-conditioning.html' title='The Signal Conditioning'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-2095067680188363673</id><published>2010-09-22T09:38:00.004+07:00</published><updated>2010-10-13T14:04:53.803+07:00</updated><title type='text'>The use of the microcontroller ADC</title><content type='html'>&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; v0' fed to the input channel 0 of the ADC, while v1' fed to the second channel of the ADC input. Another channel ADC inputs are connected to the Ground to reduce the effects of cross-talk between the two entries. Voltage signal v0’ which represent the grid voltage and signal voltage v1’ which represent the load current, sampled by the ADC of microcontroller.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The higher the ADC clock, so sampling process will be faster, but tend to diminish the accuracy of the ADC. In order to obtain fast conversion time but the accuracy of eight bits, then the ADC is run with prescaler = 16. This means that the ADC is run using a clock frequency of 691 kHz. Time to do a conversion or the conversion period (tc) is 14 times the clock period or about 20 microseconds. At 50 Hz input signal, sampling the voltage signal at intervals of 20 microseconds will provide a maximum error 0.1%&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage-and.html"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;The Need for Phase Difference Measuring Instrument&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage.html"&gt;&lt;span style="font-size: small;"&gt;Measure the Frequency of Grid Voltage rather than Measure the Frequency of Current&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/voltage-and-current-converter.html"&gt;&lt;span style="font-size: small;"&gt;Voltage and Current Converter&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/signal-conditioning.html"&gt;&lt;span style="font-size: small;"&gt;The Signal Conditioning&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/use-of-microcontroller-adc.html"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/a&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/frequency-measurement.html"&gt;&lt;span style="font-size: small;"&gt;Frequency Measurement&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/phase-difference-measurement.html"&gt;&lt;span style="font-size: small;"&gt;Phase Difference Measurement&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/output-display-format.html"&gt;Output Display Format&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-2095067680188363673?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/2095067680188363673/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/09/use-of-microcontroller-adc.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2095067680188363673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2095067680188363673'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/09/use-of-microcontroller-adc.html' title='The use of the microcontroller ADC'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-2278777003685017063</id><published>2010-09-22T09:36:00.005+07:00</published><updated>2010-10-13T14:09:56.026+07:00</updated><title type='text'>Frequency Measurement</title><content type='html'>&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; font-family: Arial,Helvetica,sans-serif; text-align: center;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: Arial,Helvetica,sans-serif; text-align: center;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: Arial,Helvetica,sans-serif; text-align: center;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://1.bp.blogspot.com/_Xf1TLp5Ejns/TJlriBjJo9I/AAAAAAAAAGY/eCmnWptcCvA/s1600/Frequency+measurement.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Measurement of the frequency of the grid voltage is done by first measuring the time between two successive foot of the mountain, as Figure 2. At the time of the grid voltage moves up above 2.5 V, a timer is run in normal mode. And when the value of grid voltage moves up on the 2.5 V anymore, timer 1 is stopped.&amp;nbsp; Timer 1 run during Δt1.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif; text-align: center;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://1.bp.blogspot.com/_Xf1TLp5Ejns/TJlriBjJo9I/AAAAAAAAAGY/eCmnWptcCvA/s1600/Frequency+measurement.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="256" src="http://1.bp.blogspot.com/_Xf1TLp5Ejns/TJlriBjJo9I/AAAAAAAAAGY/eCmnWptcCvA/s320/Frequency+measurement.gif" width="320" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;Figure 2&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Timer 1 is 16-bit timers. This timer is operated with prescaler = 8. Time for counting one digit is tT1 = 0.723 microsecond. The result of count is 16 bit hexadecimal value stored in a register TCNT1 that formed by pairing 8-bit registers TCNT1H and TCNT1L.&lt;br /&gt;For 50 Hz input signal, the counting result is 6C00h. To avoid detection of the harmonic frequency, the frequency restricted from 35 Hz to 70 Hz. So that, the valid value of TCNT1 is from 9A49h until 4D24h. Maximum error of this counting is 0.004%.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage-and.html"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;The Need for Phase Difference Measuring Instrument&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage.html"&gt;&lt;span style="font-size: small;"&gt;Measure the Frequency of Grid Voltage rather than Measure the Frequency of Current&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/voltage-and-current-converter.html"&gt;&lt;span style="font-size: small;"&gt;Voltage and Current Converter&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/signal-conditioning.html"&gt;&lt;span style="font-size: small;"&gt;The Signal Conditioning&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/use-of-microcontroller-adc.html"&gt;&lt;span style="font-size: small;"&gt;The use of the microcontroller ADC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/frequency-measurement.html"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/a&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/phase-difference-measurement.html"&gt;&lt;span style="font-size: small;"&gt;Phase Difference Measurement&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/output-display-format.html"&gt;Output Display Format&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-2278777003685017063?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/2278777003685017063/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/09/frequency-measurement.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2278777003685017063'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2278777003685017063'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/09/frequency-measurement.html' title='Frequency Measurement'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TJlriBjJo9I/AAAAAAAAAGY/eCmnWptcCvA/s72-c/Frequency+measurement.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-5798078821159343602</id><published>2010-09-22T09:34:00.013+07:00</published><updated>2010-10-13T14:13:39.285+07:00</updated><title type='text'>Phase Difference Measurement</title><content type='html'>&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; After the timer 1 is stopped, the value TCNT1 immediately saved to memory. Furthermore, the timer run again for detecting the phase difference. This timer is run in CTC mode (Clear Timer on Compare Match), which means the timer will be reset when the count equals to the OCR1 register value. OCR1 value assigned half of the value of the first count results as Equation 1.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;a href="http://3.bp.blogspot.com/_Xf1TLp5Ejns/TJln2ms5_jI/AAAAAAAAAFg/F529vYl3OKQ/s1600/Phase+difference+fromula.gif" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_Xf1TLp5Ejns/TJln2ms5_jI/AAAAAAAAAFg/F529vYl3OKQ/s1600/Phase+difference+fromula.gif" /&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Eq. 1)&lt;br /&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; This timer will be stopped again when the voltage value v1' move to rise above 2.5 V as Figure 3. To be able to detect v1’, just after the timer run again, the ADC input multiplexer is changed to channel 2.&amp;nbsp; This timer will count for the duration of time °Δt2. In theory, the phase difference (θ) for the case that the current lags behind the grid voltage is calculated using Equation 2.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;a href="http://1.bp.blogspot.com/_Xf1TLp5Ejns/TJlowSQEUGI/AAAAAAAAAFo/SgFwd9p8o_E/s1600/Phase+difference+fromula+at+program.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_Xf1TLp5Ejns/TJlowSQEUGI/AAAAAAAAAFo/SgFwd9p8o_E/s320/Phase+difference+fromula+at+program.gif" /&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Eq. 2)&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_Xf1TLp5Ejns/TJlpEV8L2tI/AAAAAAAAAFw/Nq_eYh3ybgg/s1600/Current+lag.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="260" src="http://4.bp.blogspot.com/_Xf1TLp5Ejns/TJlpEV8L2tI/AAAAAAAAAFw/Nq_eYh3ybgg/s320/Current+lag.gif" width="320" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Figure 3&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In&amp;nbsp; the program, TCNT11 is the result of a count by the timer during t1, TCNT12 is the result of a count by the timer during t2, and calculating the phase angle difference following the Equation 3.&lt;/span&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp; &lt;/span&gt;&lt;br /&gt;&lt;a href="http://3.bp.blogspot.com/_Xf1TLp5Ejns/TJlpbwX0QMI/AAAAAAAAAF4/JvfaS-cVvDw/s1600/Phase+difference+formula+at+program1.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_Xf1TLp5Ejns/TJlpbwX0QMI/AAAAAAAAAF4/JvfaS-cVvDw/s320/Phase+difference+formula+at+program1.gif" /&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; (Eq. 3)&lt;br /&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The equation above can not be applied to cases that current precedes the grid voltage. In this case, the timer run until at v1' move falls below 2.5 V as Figure 4. Calculating the phase difference following the Equation 4.&lt;br /&gt;&lt;/span&gt;&lt;a href="http://2.bp.blogspot.com/_Xf1TLp5Ejns/TJlp2D0WaFI/AAAAAAAAAGA/bI23-1iSGuk/s1600/phase+difference+current+preceeding+voltage.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_Xf1TLp5Ejns/TJlp2D0WaFI/AAAAAAAAAGA/bI23-1iSGuk/s320/phase+difference+current+preceeding+voltage.gif" /&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Eq. 4)&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_Xf1TLp5Ejns/TJlqE7_O0wI/AAAAAAAAAGI/SKsXgGv1er0/s1600/current+prerceeding+voltage.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="254" src="http://1.bp.blogspot.com/_Xf1TLp5Ejns/TJlqE7_O0wI/AAAAAAAAAGI/SKsXgGv1er0/s320/current+prerceeding+voltage.gif" width="320" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt; Figure 4&lt;/span&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_Xf1TLp5Ejns/TJlqE7_O0wI/AAAAAAAAAGI/SKsXgGv1er0/s1600/current+prerceeding+voltage.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;br /&gt;&lt;/a&gt;&lt;a href="http://1.bp.blogspot.com/_Xf1TLp5Ejns/TJlqW5PSlgI/AAAAAAAAAGQ/-x2tLiTGqks/s1600/phase+difference+current+preceeding+voltage+%282%29.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In&amp;nbsp; the program, TCNT11 is the result of a count by the timer during t1, TCNT12 is the result of a count by the timer during t2, and calculating the phase angle difference following the Equation 5.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://1.bp.blogspot.com/_Xf1TLp5Ejns/TJlqW5PSlgI/AAAAAAAAAGQ/-x2tLiTGqks/s1600/phase+difference+current+preceeding+voltage+%282%29.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_Xf1TLp5Ejns/TJlqW5PSlgI/AAAAAAAAAGQ/-x2tLiTGqks/s320/phase+difference+current+preceeding+voltage+%282%29.gif" /&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Eq. 5)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Since the equation for calculating the phase difference in the case where the current lagging against grid voltage and currents precede the grid voltage is different, then there must be an algorithm that can check the occurrence of such current. For that, after the timer is run a second time, the microcontroller immediately check the voltage at v1'. If &lt;/span&gt;&lt;span style="font-size: small;"&gt;Δ&lt;/span&gt;&lt;span style="font-size: small;"&gt;t2 starts with the value of voltage is less than 2.5 V as Figure 3, the current lags behind voltage considered.&amp;nbsp; Phase difference calculation was done using Equation 3. However, if &lt;/span&gt;&lt;span style="font-size: small;"&gt;Δ&lt;/span&gt;&lt;span style="font-size: small;"&gt;t2 begins with a voltage value equal to or greater than 2.5 V as Figure 4, it is considered current precedes the voltage. Phase difference calculation was done using Equation 5.&lt;br /&gt;Special cases the use of Equation 5 occurs when the current in phase with voltage.&amp;nbsp; This case resembles the illustration in Figure 4, voltage value slightly more than 2.5 V. In this case, the value of Δt2 will be equal to Δt1/2, so that according to Equation 5, the value of phase difference θ = 0.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage-and.html"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;The Need for Phase Difference Measuring Instrument&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage.html"&gt;&lt;span style="font-size: small;"&gt;Measure the Frequency of Grid Voltage rather than Measure the Frequency of Current&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/voltage-and-current-converter.html"&gt;&lt;span style="font-size: small;"&gt;Voltage and Current Converter&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/signal-conditioning.html"&gt;&lt;span style="font-size: small;"&gt;The Signal Conditioning&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/use-of-microcontroller-adc.html"&gt;&lt;span style="font-size: small;"&gt;The use of the microcontroller ADC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/frequency-measurement.html"&gt;&lt;span style="font-size: small;"&gt;Frequency Measurement&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/output-display-format.html"&gt;Output Display Format&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-5798078821159343602?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/5798078821159343602/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/09/phase-difference-measurement.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/5798078821159343602'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/5798078821159343602'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/09/phase-difference-measurement.html' title='Phase Difference Measurement'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_Xf1TLp5Ejns/TJln2ms5_jI/AAAAAAAAAFg/F529vYl3OKQ/s72-c/Phase+difference+fromula.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-733620516852271650</id><published>2010-09-22T09:34:00.012+07:00</published><updated>2010-10-13T14:10:13.091+07:00</updated><title type='text'>Output Display Format</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Microcontroller operated with clock frequencies fcpu = 11.0592 MHz. With this frequency, we can set up communication with the computer using USART for different variations of the bit rate with 0% error. In this study, the frequency and phase difference value is stored in the log files using Hyperterminal.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Maximum errors caused by the ADC is 0.1%. While the error caused by the timer can be ignored because it is much more smaller than the error caused by the ADC. So that the value of the frequency of the grid voltage and the value of the phase difference between voltage and current can be displayed in the format of three digits. The value of the frequency range from 35.0 Hz to 70.0 Hz can be displayed with format XX.X Hz, whereas the phase difference value with a range from 0 to 90° shown enough with the format XX°. View the output can be coupled with information that the electric current is in phase, lagging behind the voltage or preceding against to the grid voltage.&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage-and.html"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;The Need for Phase Difference Measuring Instrument&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/measure-frequency-of-grid-voltage.html"&gt;&lt;span style="font-size: small;"&gt;Measure the Frequency of Grid Voltage rather than Measure the Frequency of Current&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/voltage-and-current-converter.html"&gt;&lt;span style="font-size: small;"&gt;Voltage and Current Converter&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/signal-conditioning.html"&gt;&lt;span style="font-size: small;"&gt;The Signal Conditioning&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/use-of-microcontroller-adc.html"&gt;&lt;span style="font-size: small;"&gt;The use of the microcontroller ADC&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/frequency-measurement.html"&gt;&lt;span style="font-size: small;"&gt;Frequency Measurement&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/09/phase-difference-measurement.html"&gt;&lt;span style="font-size: small;"&gt;Phase Difference Measurement&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="short_text" id="result_box" lang="en"&gt;&lt;span title=""&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/07/purpose-of-this-blog.html"&gt;click here for more information&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-733620516852271650?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/733620516852271650/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/09/output-display-format.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/733620516852271650'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/733620516852271650'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/09/output-display-format.html' title='Output Display Format'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-7394126217928011873</id><published>2010-07-30T11:07:00.007+07:00</published><updated>2011-05-25T09:45:23.670+07:00</updated><title type='text'>Calculate True RMS Value (2)</title><content type='html'>&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;This program is an extension of &lt;a href="http://microforbetterlive.blogspot.com/2010/07/calculate-true-rms-value_20.html"&gt;the previous program&lt;/a&gt;. This program will calculate the true-RMS value of voltage at the input ADC0 and ADC1 as much as 10 times a second. Thus, data from both input sampling will be updated every 100ms. To make the appropriate updates 10 times per second, we use the timer 0. This timer is &lt;/span&gt;&lt;span style="font-size: small;"&gt;precision &lt;/span&gt;&lt;span style="font-size: small;"&gt;operated (like we operate &lt;a href="http://microforbetterlive.blogspot.com/2010/07/precision-frequency-generator.html"&gt;the precision frequency generator&lt;/a&gt;) to schedule the sampling process so that all sampling process on both inputs will take place at intervals 100ms. Every 100ms portc2 will become high. This activity is regulated by timer0. High logic of that port will activy sampling subroutines. After the sampling process completed, portc2 will be low again. &lt;br /&gt;To observe the accuracy sampling schedule, users can measure the output frequency of this port. This port emits a clock signal with frequency of 10Hz. During the sampling process, this port will be high. This high logic duration (t&lt;span style="font-size: xx-small;"&gt;H&lt;/span&gt;) is the sampling period, i.e. 20ms. Users can check the accuracy of this port to determine the sampling duration.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt; Note that sampling duration must equel to the voltage period.&lt;br /&gt;Clock signal duty cycle in this port describes the load time of the microcontroller. The higher clock signal duty cycle, the higher the load time of the microcontroller. If the duty cycle is low, we still can insert other subroutines to run on the sidelines of the overall sampling process. These subroutines will fill the remaining time until the hose is fully loaded, that is 100ms. In fact, although the duty cycle approaching 100% (microcontroller load time already high), we were still able to insert other subroutines to be executed when the CPU waiting for the completion of the ADC conversion. &lt;br /&gt;In this program, the one period of voltage (50Hz) was sampled 64 times. This means, each of the input signal would be sampled with a frequency of 64X50Hz = 3200Hz. This program sampled two inputs. So, the total frequency of sampling is 2X3200 Hz = 6400Hz. This means that the sampling process should happen every 156.25 microseconds. The sampling period is set by a timer 1 had been made in precision.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;See also &lt;/span&gt;&lt;a href="http://microforbetterlive.blogspot.com/2011/04/measure-true-rms-of-voltage-and-current.html"&gt;Measure true-RMS of Voltage and Current Grid&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/07/purpose-of-this-blog.html"&gt;Download .asm and hex code&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;How to extend this work forward? &lt;br /&gt;We can display true-RMS value to the LCD, or &lt;a href="http://microforbetterlive.blogspot.com/2010/07/data-logger-to-pc-via-serial-port.html"&gt;send the data to a PC via the serial port&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;We can also increase the sampling frequency or use full resolution of ADC.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-7394126217928011873?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/7394126217928011873/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/calculate-true-rms-value-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/7394126217928011873'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/7394126217928011873'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/calculate-true-rms-value-2.html' title='Calculate True RMS Value (2)'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-3966127651002657402</id><published>2010-07-29T10:15:00.007+07:00</published><updated>2011-04-13T08:39:46.018+07:00</updated><title type='text'>Precision Frequency Generator</title><content type='html'>&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif; text-align: left;"&gt;&lt;span style="font-size: small;"&gt;Frequency generator usually has certain accuracy. Analog frequency generator typically has a relatively low accuracy. Errors that arise sometimes still above 1%, while digital frequency generator typically has higher accuracy with the error below 0.05%.&lt;a href="http://www.blogger.com/goog_1075521473"&gt;&lt;br /&gt;&lt;/a&gt; Many applications of frequency generator are created using the AVR microcontroller to build AVR-based frequency generator. But most have low accuracy. AVR can be operated as frequency generator by using a timer. CTC (Clear Timer on Compare) mode is usually used for this purpose. Theoretically, the output frequency f&lt;span style="font-size: xx-small;"&gt;OCn&lt;/span&gt; of a timer will fulfill the following equation.&lt;/span&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_Xf1TLp5Ejns/TFEgbOeoQQI/AAAAAAAAAEs/kQg4iXmw8OU/s1600/image002.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt; &lt;img border="0" src="http://4.bp.blogspot.com/_Xf1TLp5Ejns/TFEgbOeoQQI/AAAAAAAAAEs/kQg4iXmw8OU/s320/image002.gif" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt; Where N is the prescaler value and OCRn is the match compare register. These equations will yield values that are not high accuracy. For example, we use the timer 0 to generate the frequency of 10Hz. There are several options for the value of N and OCRn.&lt;br /&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; N&amp;nbsp;&amp;nbsp;&amp;nbsp; OCRn (dec)&amp;nbsp;&amp;nbsp;&amp;nbsp; OCRn (hex)&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&amp;nbsp;&amp;nbsp;&amp;nbsp; 69119&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10DFF&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 64&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8639&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 21BF&lt;br /&gt;&amp;nbsp; 256&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 2159&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 86F&lt;br /&gt;1024&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 539&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; 21B&lt;br /&gt;&lt;br /&gt;By looking at OCRn value in the table above, the generation of these frequencies is only possible with prescaler equal to 64, or 256 or 1024 and must use 16-bit timer, which timer 1. This is a conventional way.&lt;br /&gt;With a prescaler 64, or 256 or 1024, we can use 8-bit timer, which is &lt;/span&gt;&lt;span style="font-size: small;"&gt;timer &lt;/span&gt;&lt;span style="font-size: small;"&gt;0 or 2. This may occur in large applications where the timer 1 is used to trigger another subroutine. With 8-bit timer we just need to fill the low byte of OCRn to OCR0 or OCR2 register. Furthermore, we run the timer as many as M times, where M is the high byte of OCRn value.&lt;br /&gt;For example, to generate a clock with a frequency of 10Hz, the prescaler value can be filled 64, the value OCR0 = BFh and timer 0 is repeated as many times 21h.&lt;br /&gt;But after a try, sometimes inaccurate output frequency 10Hz could be occured. For that, we need to do calibration. The trick is to shift the value OCRn. By increasing the OCRn value, the frequency will be lower; and by decreasing the OCRn value, the frequency will be higher. Ideally, the increase or decrease the output frequency value is as small as possible. But the time for single-digit increase of TCNTn (t) cannot be small as possible. It depends to prescaler which is used as the following table.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; N&amp;nbsp;&amp;nbsp;&amp;nbsp; t (us)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; 0,72 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 64&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 5,79 &lt;br /&gt;&amp;nbsp; 256&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 23,15 &lt;br /&gt;1024&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 92,59 &lt;br /&gt;&lt;br /&gt;To fix it, shift the OCRn &lt;/span&gt;&lt;span style="font-size: small;"&gt;value &lt;/span&gt;&lt;span style="font-size: small;"&gt;on the last count. Another example, for the generation of 5Hz frequency, we can operate the timer 0 with CTC &lt;/span&gt;&lt;span style="font-size: small;"&gt;mode and prescaler=64&lt;/span&gt;&lt;span style="font-size: small;"&gt;. In theory OCR0 value = 255. After the timer 0 count as much as 67 times, the value OCR0 changed to 128. With the simulation in AVR Studio, we get the output frequency to 5.0003 Hz. The value of these can be calibrated by decreasing the value of OCR0 be 127 so that the value of output frequency is 5.0000 Hz. Output frequency will have a maximum error of 0.01%.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/07/purpose-of-this-blog.html"&gt;Download .asm and hex code&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt; Does the error still can be reduced? Of course we still can! &lt;br /&gt;We still use the prescaler = 64. With prescaler = 8, the error rate can be reduced. &lt;br /&gt;But for now it might not need to do ....&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;What this routine can be applied for?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt; &lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;We have applied it for:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;- To fix sampling periode for &lt;a href="http://microforbetterlive.blogspot.com/2010/07/calculate-true-rms-value-2.html"&gt;True RMS Calculation&lt;/a&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;- To fix the periode of interval of &lt;a href="http://microforbetterlive.blogspot.com/2010/07/data-logger-to-pc-via-serial-port.html"&gt;sending data via serial port&lt;/a&gt;.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-3966127651002657402?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/3966127651002657402/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/precision-frequency-generator.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/3966127651002657402'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/3966127651002657402'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/precision-frequency-generator.html' title='Precision Frequency Generator'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_Xf1TLp5Ejns/TFEgbOeoQQI/AAAAAAAAAEs/kQg4iXmw8OU/s72-c/image002.gif' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-2309641262735872749</id><published>2010-07-27T14:21:00.003+07:00</published><updated>2010-08-02T09:09:23.283+07:00</updated><title type='text'>Data Logger to PC via Serial Port</title><content type='html'>&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;A data logger is an electronic device that is used to record the value measured over time. It is simply plug into a serial port on your PC. By connecting suitable sensors, data logger can be used as acquisition products that can be used to measure temperature, pressure, relative humidity, light, resistance, current, power, speed, vibration... in fact, anything that you need to measure. The output data from data logger is a periodic stream in simple text or hexadecimal with customized data format we need. Simply capture the data to a text file and then import it into Excel to produce tables and charts over time.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;If the data sent to the PC is a text data, you can use HyperTerminal to receive the data. Some control characters like tabs and carriage returns can be used here. For this purpose, the data which is usually a binary or hexadecimal numbers must be converted into ASCII format. Here you can use the binary &lt;/span&gt;&lt;span style="font-size: small;"&gt;/ hexadecimal &lt;/span&gt;&lt;span style="font-size: small;"&gt;to ASCII &lt;/span&gt;&lt;span style="font-size: small;"&gt;data converter . &lt;br /&gt;In order to obtain higher transmission speeds, the data sent should still use binary or hexadecimal format. To receive this data, we should use receiver that can receive binary or hexadecimal data. We can make this program with programming tools such as Delphi, Visual Basic or Visual C. If necessary, the program can convert binary / hex to ASCII.&lt;br /&gt;In the application we build, data from microcontroller ATmega8535 was sent to the PC using a serial transmission. This data is fed to PC via serial port. Data emited from TXD pin (PD1) of microcontroller. In the future, we must also be able to receive data from the PC. Such data can be received through the RXD pin (PD0) microcontroller. Of data to and from the microcontroller using TTL level, while data from and to the PC serial port using RS-232 level. To interface between the microcontroller and a serial port, we can use the CMOS / TTL - RS-232 converter, for example is MAX-232. &lt;br /&gt;We can determine the speed of data to be sent. Here we use the speed of 9600bps. Because a single ASCII characters using 8-bit data format, then we can send about 1000 ASCII characters per second. The speed of data and data length can be changed. In this application, the microcontroller is operated at a clock frequency of 11.0592 MHz. On this frequency, some variation in the data transmission speeds will have 0% error. &lt;br /&gt;The data that we send do not have to be continuous. Here, we will send data every 100ms. Data that we send are ASCII characters that located at memory location pointed to by the index_start until index_end constant. Such data will be sent 10 times per second. This data transfer speed is usually quite adequate for a data logger. However, if necessary, we can increase the speed. &lt;br /&gt;In some applications like data logger, it may take time high accuracy in data transmission speed. A precision data logger can send appropriate data 10 times per second which means exactly 100 times per 10 seconds or right 36 000 times per hour. We can make the data transmission speed precisly. We can use 8-bit timer for this purpose. This is similar to building a &lt;a href="http://microforbetterlive.blogspot.com/2010/07/precision-frequency-generator.html"&gt;precision frequency generator&lt;/a&gt;. Further discussion of this matter, you can &lt;a href="http://microforbetterlive.blogspot.com/2010/07/precision-frequency-generator.html"&gt;click here&lt;/a&gt;. &lt;br /&gt;This application can be combined with other applications that shown in this blog. By integrating the application with a &lt;a href="http://microforbetterlive.blogspot.com/2010/07/calculate-true-rms-value_20.html"&gt;True RMS meter&lt;/a&gt;, we can build a True RMS meter with data logger to a PC. By integrating these applications with the &lt;a href="http://microforbetterlive.blogspot.com/2010/07/calculate-phase-difference-between.html"&gt;phase difference meter&lt;/a&gt;, we can build the phase difference meter with data logger to a PC. And &lt;/span&gt;&lt;span style="font-size: small;"&gt;by integrating these applications with the &lt;a href="http://microforbetterlive.blogspot.com/2010/06/read-compass-sensor.html"&gt;compass tracker&lt;/a&gt;, we can build the &lt;/span&gt;&lt;span style="font-size: small;"&gt;compass tracker &lt;/span&gt;&lt;span style="font-size: small;"&gt;with data logger to a PC.&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-2309641262735872749?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/2309641262735872749/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/data-logger-to-pc-via-serial-port.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2309641262735872749'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2309641262735872749'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/data-logger-to-pc-via-serial-port.html' title='Data Logger to PC via Serial Port'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-7942009484489639691</id><published>2010-07-27T14:16:00.002+07:00</published><updated>2010-07-27T14:16:59.641+07:00</updated><title type='text'>32-bit Square Root</title><content type='html'>&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;&lt;/span&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;This subroutine will calculate a square value of 32-bit value at r5:r4:r3:r2. Result is 16-bit at r17:r16 and will be rounded to nearest integer (0.5 rounds up). &lt;br /&gt;Cycles include call &amp;amp; return: 271 - 316.&lt;br /&gt;&lt;br /&gt;R17:R16 = sqrt(R5:R4:R3:R2)&lt;br /&gt;&lt;br /&gt;sqrt32:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; push&amp;nbsp; R18&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; push&amp;nbsp; R19&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldi&amp;nbsp;&amp;nbsp; R19,0xc0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clr&amp;nbsp;&amp;nbsp; R18&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldi&amp;nbsp;&amp;nbsp; R17,0x40&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sub&amp;nbsp;&amp;nbsp; R16,R16 &lt;br /&gt;&lt;br /&gt;_sq32_1:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs&amp;nbsp; _sq32_2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cp&amp;nbsp;&amp;nbsp;&amp;nbsp; R4,R16&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpc&amp;nbsp;&amp;nbsp; R5,R17&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs&amp;nbsp; _sq32_3&lt;br /&gt;&lt;br /&gt;_sq32_2:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sub&amp;nbsp;&amp;nbsp; R4,R16&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sbc&amp;nbsp;&amp;nbsp; R5,R17&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; or&amp;nbsp;&amp;nbsp;&amp;nbsp; R16,R18&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; or&amp;nbsp;&amp;nbsp;&amp;nbsp; R17,R19&lt;br /&gt;&lt;br /&gt;_sq32_3:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lsr&amp;nbsp;&amp;nbsp; R19&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ror&amp;nbsp;&amp;nbsp; R18&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; eor&amp;nbsp;&amp;nbsp; R17,R19&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; eor&amp;nbsp;&amp;nbsp; R16,R18&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp; R2&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp; R3&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp; R4&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp; R5&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sbrs&amp;nbsp; R2,0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rjmp&amp;nbsp; _sq32_1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs&amp;nbsp; _sq32_4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cp&amp;nbsp;&amp;nbsp;&amp;nbsp; R16,R4&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpc&amp;nbsp;&amp;nbsp; R17,R5&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcc&amp;nbsp; _sq32_5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;_sq32_4:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sbc&amp;nbsp;&amp;nbsp; R3,R19&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sbc&amp;nbsp;&amp;nbsp; R4,R16&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sbc&amp;nbsp;&amp;nbsp; R5,R17&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; inc&amp;nbsp;&amp;nbsp; R16&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;_sq32_5:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lsl&amp;nbsp;&amp;nbsp; R3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp; R4&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp; R5&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs&amp;nbsp; _sq32_6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cp&amp;nbsp;&amp;nbsp;&amp;nbsp; R16,R4&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpc&amp;nbsp;&amp;nbsp; R17,R5&lt;br /&gt;&lt;br /&gt;_sq32_6:&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; adc&amp;nbsp;&amp;nbsp; R16,R19&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; adc&amp;nbsp;&amp;nbsp; R17,R19&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pop&amp;nbsp;&amp;nbsp; R19&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pop&amp;nbsp;&amp;nbsp; R18&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-7942009484489639691?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/7942009484489639691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/7942009484489639691'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/32-bit-square-root.html' title='32-bit Square Root'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-1267127869633888539</id><published>2010-07-27T08:57:00.005+07:00</published><updated>2011-05-25T08:54:31.317+07:00</updated><title type='text'>The Purpose of This Blog</title><content type='html'>&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The aim of this blog was to exchange our experiences in make use of microcontroller to facilitate our life. We used the 8051 and AVR microcontroller family. Your involvement was really hoped in giving the comment, the suggestion, the question and criticism for the development of applications that has we got up. This blog contain basic application. Several applications could be united with the other application to form the implement microcontroller-based digital measurement, such as: AC/DC Digital Voltmeter, True RMS Voltmeter, Apparent and True Power meter, Power Factor Meter, etc. All of them can use LCD to display the output value, and have data logger to log data to PC via serial port.&lt;br /&gt;All of the application presented in this blog has been tested with best of my knowledge to make it error-free, but no warranty they are no mistake if they applied in the different environment, like quality of each component. Please send report to me if you find any error.&lt;br /&gt;We also had several versions of each application presented in blog this. They had several differences, like: the clock speed, accuracy, sampling period, memory location and so on. Each of their variation could be have different schematic diagram.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;Most of our applications using assembler programming language. The language is much faster than the C language Assembler language also would have a hex code that is much smaller, so it can be executed by the AVR microcontroller, which mostly have SRAM just below 4 kbytes. &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; All of the application is tested with best of my knowledge to make it error-free, but no warranty they are no mistake. Try it at your own risk!  &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt; &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: #0b5394; font-size: large;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;Further Information &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; What we show here is an overview of our application. More detailed explanation of this application which includes detailed specifications, result and accuracy, usability, electronic scheme, and program listings are also available.&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;We also have several analyses of them. &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;If you need it, please send a written request via the email below. Also please mention your profession and your goals using the application.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;&lt;a href="mailto:freddykurniawan@yahoo.com"&gt;freddykurniawan@yahoo.com&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-1267127869633888539?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/1267127869633888539'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/1267127869633888539'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/purpose-of-this-blog.html' title='The Purpose of This Blog'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-776034924415289522</id><published>2010-07-27T08:47:00.000+07:00</published><updated>2010-07-27T08:47:47.698+07:00</updated><title type='text'>Multiply 16-bit by 16-bit</title><content type='html'>&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;&lt;/span&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;This subroutine will multiply 16-bit value at r23:r22 with 16-bit value at r21:r20. Result is 16-bit at r17:r16.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (r23:r22)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (r21:r20)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; -----------X&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (r17:r16)&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;r17:r16 = r23:r22 * r21:r20&lt;br /&gt;Register usage: r0, r1&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;mul16by16:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mul r22, r20 ; al * bl&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; movw r17:r16, r1:r0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mul r23, r20 ; ah * bl&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; add r17, r0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mul r21, r22 ; bh * al&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; add r17, r0&lt;br /&gt;ret&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-776034924415289522?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/776034924415289522'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/776034924415289522'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/multiply-16-bit-by-16-bit.html' title='Multiply 16-bit by 16-bit'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-2461783819698461279</id><published>2010-07-22T10:22:00.001+07:00</published><updated>2010-07-23T10:31:26.744+07:00</updated><title type='text'>16-bit Square Root</title><content type='html'>&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;This subroutine will calculate a square value of 16-bit value at r3:r2. Result is 16-bit at r17:r16 and will be rounded to &lt;/span&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;nearest integer (0.5 rounds up). The value at R3:R2 will be changed.&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;Cycles include call &amp;amp; return: 95 - 102.&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;R17:R16 = sqrt(R3:R2)&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;sqrt16:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldi&amp;nbsp;&amp;nbsp; R17,0xc0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldi&amp;nbsp;&amp;nbsp; R16,0x40&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;sqrt16_1:&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs&amp;nbsp; sqrt16_2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cp&amp;nbsp;&amp;nbsp;&amp;nbsp; R3,R16&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs&amp;nbsp; sqrt16_3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;sqrt16_2:&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sub&amp;nbsp;&amp;nbsp; R3,R16&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; or&amp;nbsp;&amp;nbsp;&amp;nbsp; R16,R17&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;sqrt16_3:&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lsr&amp;nbsp;&amp;nbsp; R17&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lsl&amp;nbsp;&amp;nbsp; R2&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp; R3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; eor&amp;nbsp;&amp;nbsp; R16,R17&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; andi&amp;nbsp; R17,0xfe&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brne&amp;nbsp; sqrt16_1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs&amp;nbsp; sqrt16_4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cp&amp;nbsp;&amp;nbsp;&amp;nbsp; R16,R3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcc&amp;nbsp; sqrt16_5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;sqrt16_4:&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sbc&amp;nbsp;&amp;nbsp; R2,R17&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sbc&amp;nbsp;&amp;nbsp; R3,R16&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; inc&amp;nbsp;&amp;nbsp; R16&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;sqrt16_5:&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lsl&amp;nbsp;&amp;nbsp; R2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp; R3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs&amp;nbsp; sqrt16_6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cp&amp;nbsp;&amp;nbsp;&amp;nbsp; R16,R3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;sqrt16_6:&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; adc&amp;nbsp;&amp;nbsp; R16,R17&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-2461783819698461279?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/2461783819698461279/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/16-bit-square-root.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2461783819698461279'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2461783819698461279'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/16-bit-square-root.html' title='16-bit Square Root'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-7167748894753514590</id><published>2010-07-21T11:06:00.001+07:00</published><updated>2010-07-21T11:13:27.009+07:00</updated><title type='text'>Divide 32-bit by 32-bit</title><content type='html'>&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;This subroutine will divide 32-bit value at r19:r18:r17:R16 with 32-bit value at r23:r22:r21:R20. Result is 32-bit at &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;r19:r18:r17:R16 and remainder is at r19:r18:r17:R16.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;This routine uses r27:r26:r25:r24 as temporary registers.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (r19:r18:r17:R16)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (r23:r22:r21:R20)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; -----------------:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (r19:r18:r17:R16)&amp;nbsp;&amp;nbsp;&amp;nbsp; remainder: (r23:r22:r21:R20)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;div32by32:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clr&amp;nbsp;&amp;nbsp;&amp;nbsp; r25&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tst&amp;nbsp;&amp;nbsp;&amp;nbsp; r23&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; breq&amp;nbsp;&amp;nbsp;&amp;nbsp; udi10&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldi&amp;nbsp;&amp;nbsp;&amp;nbsp; r24, 8&lt;br /&gt;udi1:&amp;nbsp;&amp;nbsp;&amp;nbsp; lsl&amp;nbsp;&amp;nbsp;&amp;nbsp; r16&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp; r17&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp; r18&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp; r19&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp; r25&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cp&amp;nbsp;&amp;nbsp;&amp;nbsp; r17, r20&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpc&amp;nbsp;&amp;nbsp;&amp;nbsp; r18, r21&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpc&amp;nbsp;&amp;nbsp;&amp;nbsp; r19, r22&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpc&amp;nbsp;&amp;nbsp;&amp;nbsp; r25, r23&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs&amp;nbsp;&amp;nbsp;&amp;nbsp; udi2&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sub&amp;nbsp;&amp;nbsp;&amp;nbsp; r17, r20&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sbc&amp;nbsp;&amp;nbsp;&amp;nbsp; r18, r21&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sbc&amp;nbsp;&amp;nbsp;&amp;nbsp; r19, r22&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sbc&amp;nbsp;&amp;nbsp;&amp;nbsp; r25, r23&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; inc&amp;nbsp;&amp;nbsp;&amp;nbsp; r16&lt;br /&gt;udi2:&amp;nbsp;&amp;nbsp;&amp;nbsp; dec&amp;nbsp;&amp;nbsp;&amp;nbsp; r24&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brne&amp;nbsp;&amp;nbsp;&amp;nbsp; udi1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp; r20, r17&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clr&amp;nbsp;&amp;nbsp;&amp;nbsp; r17&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp; r21, r18&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clr&amp;nbsp;&amp;nbsp;&amp;nbsp; r18&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp; r22, r19&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clr&amp;nbsp;&amp;nbsp;&amp;nbsp; r19&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp; r23, r25&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret&lt;br /&gt;&lt;br /&gt;udi10:&amp;nbsp;&amp;nbsp;&amp;nbsp; tst&amp;nbsp;&amp;nbsp;&amp;nbsp; r22&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; breq&amp;nbsp;&amp;nbsp;&amp;nbsp; udi20&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldi&amp;nbsp;&amp;nbsp;&amp;nbsp; r24, 16&lt;br /&gt;udi11:&amp;nbsp;&amp;nbsp;&amp;nbsp; lsl&amp;nbsp;&amp;nbsp;&amp;nbsp; r16&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp; r17&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp; r18&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp; r19&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp; r25&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs&amp;nbsp;&amp;nbsp;&amp;nbsp; udi12&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cp&amp;nbsp;&amp;nbsp;&amp;nbsp; r18, r20&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpc&amp;nbsp;&amp;nbsp;&amp;nbsp; r19, r21&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpc&amp;nbsp;&amp;nbsp;&amp;nbsp; r25, r22&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs&amp;nbsp;&amp;nbsp;&amp;nbsp; udi13&lt;br /&gt;udi12:&amp;nbsp;&amp;nbsp;&amp;nbsp; sub&amp;nbsp;&amp;nbsp;&amp;nbsp; r18, r20&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sbc&amp;nbsp;&amp;nbsp;&amp;nbsp; r19, r21&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sbc&amp;nbsp;&amp;nbsp;&amp;nbsp; r25, r22&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; inc&amp;nbsp;&amp;nbsp;&amp;nbsp; r16&lt;br /&gt;udi13:&amp;nbsp;&amp;nbsp;&amp;nbsp; dec&amp;nbsp;&amp;nbsp;&amp;nbsp; r24&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brne&amp;nbsp;&amp;nbsp;&amp;nbsp; udi11&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp; r20, r18&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clr&amp;nbsp;&amp;nbsp;&amp;nbsp; r18&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp; r21, r19&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clr&amp;nbsp;&amp;nbsp;&amp;nbsp; r19&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp; r22, r25&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret&lt;br /&gt;&lt;br /&gt;udi20:&amp;nbsp;&amp;nbsp;&amp;nbsp; tst&amp;nbsp;&amp;nbsp;&amp;nbsp; r21&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; breq&amp;nbsp;&amp;nbsp;&amp;nbsp; udi30&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldi&amp;nbsp;&amp;nbsp;&amp;nbsp; r24, 24&lt;br /&gt;udi21:&amp;nbsp;&amp;nbsp;&amp;nbsp; lsl&amp;nbsp;&amp;nbsp;&amp;nbsp; r16&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp; r17&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp; r18&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp; r19&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp; r25&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs&amp;nbsp;&amp;nbsp;&amp;nbsp; udi22&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cp&amp;nbsp;&amp;nbsp;&amp;nbsp; r19, r20&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpc&amp;nbsp;&amp;nbsp;&amp;nbsp; r25, r21&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs&amp;nbsp;&amp;nbsp;&amp;nbsp; udi23&lt;br /&gt;udi22:&amp;nbsp;&amp;nbsp;&amp;nbsp; sub&amp;nbsp;&amp;nbsp;&amp;nbsp; r19, r20&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sbc&amp;nbsp;&amp;nbsp;&amp;nbsp; r25, r21&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; inc&amp;nbsp;&amp;nbsp;&amp;nbsp; r16&lt;br /&gt;udi23:&amp;nbsp;&amp;nbsp;&amp;nbsp; dec&amp;nbsp;&amp;nbsp;&amp;nbsp; r24&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brne&amp;nbsp;&amp;nbsp;&amp;nbsp; udi21&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp; r20, r19&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clr&amp;nbsp;&amp;nbsp;&amp;nbsp; r19&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp; r21, r25&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret&lt;br /&gt;&lt;br /&gt;udi30:&amp;nbsp;&amp;nbsp;&amp;nbsp; ldi&amp;nbsp;&amp;nbsp;&amp;nbsp; r24, 32&lt;br /&gt;udi31:&amp;nbsp;&amp;nbsp;&amp;nbsp; lsl&amp;nbsp;&amp;nbsp;&amp;nbsp; r16&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp; r17&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp; r18&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp; r19&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp; r25&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs&amp;nbsp;&amp;nbsp;&amp;nbsp; udi32&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cp&amp;nbsp;&amp;nbsp;&amp;nbsp; r25, r20&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs&amp;nbsp;&amp;nbsp;&amp;nbsp; udi33&lt;br /&gt;udi32:&amp;nbsp;&amp;nbsp;&amp;nbsp; sub&amp;nbsp;&amp;nbsp;&amp;nbsp; r25, r20&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; inc&amp;nbsp;&amp;nbsp;&amp;nbsp; r16&lt;br /&gt;udi33:&amp;nbsp;&amp;nbsp;&amp;nbsp; dec&amp;nbsp;&amp;nbsp;&amp;nbsp; r24&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brne&amp;nbsp;&amp;nbsp;&amp;nbsp; udi31&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp; r20, r25&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-7167748894753514590?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/7167748894753514590/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/divide-32-bit-by-32-bit.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/7167748894753514590'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/7167748894753514590'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/divide-32-bit-by-32-bit.html' title='Divide 32-bit by 32-bit'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-6701645802553689579</id><published>2010-07-20T11:13:00.013+07:00</published><updated>2011-05-25T09:47:53.031+07:00</updated><title type='text'>Calculate True RMS Value</title><content type='html'>&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;The RMS (Root Mean Square) value of a set of values (or a continuous-time waveform) is the square root of the arithmetic mean (average) of the squares of the original values (or the square of the function that defines the continuous waveform). The RMS over all time of a periodic function is equal to the RMS of one period of the function. The RMS value of a continuous function or signal can be approximated by taking the RMS of a series of equally spaced samples. Additionally, the RMS value of various waveforms can also be determined without calculus.&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; Measuring the true RMS value of a waveform is not easy. Inexpensive AC voltmeters simply rectify the waveform (by passing it through a diode, for example), measure an average value of the rectified waveform, and apply a correction factor (assuming a sine wave). Such meters, therefore, are only accurate for sinusoidal waveforms. They do NOT accurately measure any other waveform shape. So-called “True” RMS meters in the past have depended on some sort of power measurement to derive the correct RMS value. Now that calculation power is so much more economically available, meters can analyze a waveform’s shape and actually mathematically calculate the correct RMS value. In general, if an AC meter does not explicitly say it gives a “true” RMS reading, you can assume that it is accurate only for a sinusoidal waveform.&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; To calculate true RMS, we must do the following equation.&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;a href="http://4.bp.blogspot.com/_Xf1TLp5Ejns/TEZ-IsGx8XI/AAAAAAAAAEk/fMmHoKBzPQg/s1600/image001.png" style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;img src="http://4.bp.blogspot.com/_Xf1TLp5Ejns/TEZ-IsGx8XI/AAAAAAAAAEk/fMmHoKBzPQg/s320/image001.png" /&gt;&lt;/a&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;That equation can be used for any periodic waveform, such as a sinusoidal or saw tooth waveform, allowing us to calculate the mean power delivered into a specified load. To do that, we must follow several steps.&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; 1. Take the waveform and divide it into a “large” number of individual increments.&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; 2. For each sample, square the voltage value.&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; 3. Sum these squared values over all samples and then calculate their mean value.&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; 4. Take the square root of this mean.&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;It is also possible to calculate the RMS power of a signal. By analogy with RMS voltage and RMS current, RMS power is the square root of the mean of the square of the power over some specified time period. This quantity, which would be expressed in units of watts (RMS), has no physical significance. However, the term "RMS power" is sometimes used in the audio industry as a synonym for "mean power" or "average power".&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;This application use ATmega8535 AVR microcontroller to sample two lines voltage that fed to channel 0 and 1 of its ADC. We use 3.2 kHz of frequency sampling generated by timer 1. So, at 50Hz power line input, we get 64 samples per period. Each sample saved at SRAM then multiplied and summed. After we calculate the mean, then a special routine will calculate the square root to find the RMS value of each voltage.&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; &lt;/span&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;The maximum voltage can be applied to ADC input is 2.5 Vpp with +2.5 VDC offset. For 2.5 V DC or -2.5 V DC input, the output display must show the 2.50 value. To do this, we multiply the result by 100/512. So to calibrate the calculation, the above equation can be changed to:&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;a href="http://1.bp.blogspot.com/_Xf1TLp5Ejns/TEZ9exBdyzI/AAAAAAAAAEc/0khxVajKr74/s1600/image003.png" style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;img src="http://1.bp.blogspot.com/_Xf1TLp5Ejns/TEZ9exBdyzI/AAAAAAAAAEc/0khxVajKr74/s320/image003.png" /&gt;&lt;/a&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;The rms value of v0 and v1 in 8-bit hexadecimal and 3-character ASCII (X.XX volt) format are stored in following location:&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;       Hexadecimal          ASCII&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; v0       v0_rms      v0_rms_ASCII&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; v1       v1_rms      v1_rms_ASCII&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;The 1*64 elements array represents v0 during one period is stored at v0_data_index_start to v0_data_index_start+64; and the 1*64 elements array represents v0 during one period is stored at from v1_data_index_start to v1_data_index_start+64. They can be &lt;a href="http://microforbetterlive.blogspot.com/2010/07/data-logger-to-pc-via-serial-port.html"&gt;sent to PC via serial port (USART)&lt;/a&gt;. From them, we can build a graph represents two voltages in one period like a PC-oscilloscope that show two channels waveform.&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; Please fetch them carefully, and make sure all data have been updated.&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; Note:&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; The result has 0.78% accuracy, so we must be care about the least significant digit; the result is suggested less than 2.25 digit format.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;See also &lt;/span&gt;&lt;a href="http://microforbetterlive.blogspot.com/2011/04/measure-true-rms-of-voltage-and-current.html"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;Measure true-RMS of Voltage and Current Grid&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;  &lt;br /&gt;&lt;div style="color: black; font-family: Arial,Helvetica,sans-serif;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/07/purpose-of-this-blog.html"&gt;&lt;span style="font-size: small;"&gt;Download .asm and hex code&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="color: black;"&gt;&lt;span style="font-size: small;"&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;br style="color: black; font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="color: black; font-family: Arial,Helvetica,sans-serif;"&gt;What’s next? &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="color: black;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="color: black;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;You can make a precise period &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/07/calculate-true-rms-value-2.html"&gt;of sampling and schedule when it happen...&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="color: black;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/07/data-logger-to-pc-via-serial-port.html"&gt;You can send the data to PC like data logger....&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="color: black;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="color: black;"&gt;&lt;span style="font-size: small;"&gt;What shall we do to make it more accurate? We can make it more accurate by making the sampling interval more precision (like &lt;a href="http://microforbetterlive.blogspot.com/2010/07/precision-frequency-generator.html"&gt;making precision frequency generator&lt;/a&gt;).&lt;/span&gt;&lt;/div&gt;&lt;div style="color: black;"&gt;&lt;span style="font-size: small;"&gt;We could increase the sampling frequency or increase the data length of data from 8-bit to 10 or 12 bit.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/07/purpose-of-this-blog.html"&gt;click here for more information&lt;/a&gt; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-6701645802553689579?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/6701645802553689579/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/calculate-true-rms-value_20.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/6701645802553689579'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/6701645802553689579'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/calculate-true-rms-value_20.html' title='Calculate True RMS Value'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_Xf1TLp5Ejns/TEZ-IsGx8XI/AAAAAAAAAEk/fMmHoKBzPQg/s72-c/image001.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-1142494183268310888</id><published>2010-07-20T11:03:00.002+07:00</published><updated>2010-07-21T11:07:59.052+07:00</updated><title type='text'>Divide 24-bit by 24-bit</title><content type='html'>&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;This subroutine will divide 24-bit value at r20:r19:r18 with 24-bit value at r23:r22:r21. Result is 24-bit at r20:r19:r18 and remainder is 24-bit at r2:r1:r0.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (r20:r19:r18)&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (r23:r22:r21)&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; -------------:&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (r20:r19:r18)&amp;nbsp;&amp;nbsp;&amp;nbsp; remainder: (r2:r1:r0)&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;div24by24:&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r0&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r1&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r2&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldi&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r16,24&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lsl&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r18&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r19&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r20&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r0&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r1&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r2&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cp&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; r0,r21&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r1,r22&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r2,r23&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs&amp;nbsp;&amp;nbsp;&amp;nbsp; PC+5&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; inc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r18&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sub&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r0,r21&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sbc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r1,r22&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sbc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r2,r23&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dec&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r16&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brne&amp;nbsp;&amp;nbsp;&amp;nbsp; PC-15&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-1142494183268310888?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/1142494183268310888'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/1142494183268310888'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/divide-24-bit-by-24-bit.html' title='Divide 24-bit by 24-bit'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-2108655489540303198</id><published>2010-07-20T10:56:00.002+07:00</published><updated>2010-07-21T11:09:20.781+07:00</updated><title type='text'>Divide 16-bit by 16-bit</title><content type='html'>This subroutine will divide 16-bit value at r19:r18 with 16-bit value at r21:r20. Result is 16-bit at r19:r18 and remainder is 16-bit at r1:r0.&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (r19:r18)&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (r21:r20)&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --------- :&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (r19:r18)&amp;nbsp;&amp;nbsp;&amp;nbsp; mod&amp;nbsp;&amp;nbsp;&amp;nbsp; (r1:r0)&lt;/div&gt;&lt;br /&gt;&lt;div style="font-family: inherit;"&gt;div16by16:&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r19,r3&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r18,r2&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldi&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r22,0x0d&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldi&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r21,0x80&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rcall&amp;nbsp;&amp;nbsp; div16by16&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r18,r2&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r19,r3&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r20,r4&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r0&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r1&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ldi&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r16,16&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lsl&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r18&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r19&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r0&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r1&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cp&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; r0,r21&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cpc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r1,r22&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs&amp;nbsp;&amp;nbsp;&amp;nbsp; PC+4&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; inc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r18&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sub&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r0,r21&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sbc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r1,r22&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dec&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r16&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brne&amp;nbsp;&amp;nbsp;&amp;nbsp; PC-11&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-2108655489540303198?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2108655489540303198'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2108655489540303198'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/divide-16-bit-by-16-bit.html' title='Divide 16-bit by 16-bit'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-2155561587237667380</id><published>2010-07-20T10:51:00.001+07:00</published><updated>2010-07-20T11:08:34.251+07:00</updated><title type='text'>Multiply 16-bit by 8-bit</title><content type='html'>This subroutine will multiply 16-bit value at r19:r18 with 8-bit value at r20. Result is 24-bit at r4:r3:r2.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; (r19:r18)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; (r20)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;---------- X&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;(r4:r3:r2)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;mul16by8:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;mul &amp;nbsp;&amp;nbsp; &amp;nbsp;r18,r20 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;mov &amp;nbsp;&amp;nbsp; &amp;nbsp;r2,R0 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;mov &amp;nbsp;&amp;nbsp; &amp;nbsp;r3,R1&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;mul &amp;nbsp;&amp;nbsp; &amp;nbsp;r19,r20 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;mov &amp;nbsp;&amp;nbsp; &amp;nbsp;r4,R1 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;add &amp;nbsp;&amp;nbsp; &amp;nbsp;r3,R0 &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;brcc &amp;nbsp;&amp;nbsp; NoInc &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;inc &amp;nbsp;&amp;nbsp; &amp;nbsp;r4&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;NoInc:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;ret&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-2155561587237667380?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2155561587237667380'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2155561587237667380'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/multiply-16-bit-by-8-bit.html' title='Multiply 16-bit by 8-bit'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-6841320328088306876</id><published>2010-07-20T10:44:00.002+07:00</published><updated>2010-07-21T11:08:46.307+07:00</updated><title type='text'>Divide 16-bit by 8-bit</title><content type='html'>&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;This subroutine will divide 16-bit value at r1:r0 with 8-bit value at r3. Result is 16-bit at r5:r4&lt;/span&gt;.&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;(r1:r0)&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; (r3)&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --------- :&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;(r5:r4)&lt;/div&gt;&lt;br /&gt;&lt;div style="font-family: inherit;"&gt;div16by8:&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;div8:&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clr &amp;nbsp;&amp;nbsp;&amp;nbsp; r2 &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clr &amp;nbsp;&amp;nbsp;&amp;nbsp; r5&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clr &amp;nbsp;&amp;nbsp;&amp;nbsp; r4&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; inc &amp;nbsp;&amp;nbsp;&amp;nbsp; r4&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;div8a:&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol &amp;nbsp;&amp;nbsp;&amp;nbsp; r0 &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol &amp;nbsp;&amp;nbsp;&amp;nbsp; r1 &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol &amp;nbsp;&amp;nbsp;&amp;nbsp; r2&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs &amp;nbsp;&amp;nbsp; div8b &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cp &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r2,r3 &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcs &amp;nbsp;&amp;nbsp; div8c&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;div8b:&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sub &amp;nbsp;&amp;nbsp;&amp;nbsp; r2,r3&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sec&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rjmp &amp;nbsp;&amp;nbsp; div8d&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;div8c:&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; clc&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;div8d:&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol &amp;nbsp;&amp;nbsp;&amp;nbsp; r4&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rol &amp;nbsp;&amp;nbsp;&amp;nbsp; r5&lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; brcc &amp;nbsp;&amp;nbsp; div8a&amp;nbsp; &lt;/div&gt;&lt;div style="font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-6841320328088306876?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/6841320328088306876'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/6841320328088306876'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/divide-16-bit-by-8-bit.html' title='Divide 16-bit by 8-bit'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-730654317317263683</id><published>2010-07-13T11:46:00.006+07:00</published><updated>2010-08-12T09:21:36.920+07:00</updated><title type='text'>Calculate Phase Difference between Voltage and Current</title><content type='html'>&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;When capacitors or inductors are involved in an AC circuit, the current and voltage do not peak at the same time. The fraction of a period difference between the peaks expressed in degrees is said to be the phase difference. The phase difference is &amp;lt;= 90 degrees. It is customary to use the angle by which the voltage leads the current. This leads to a positive phase for inductive circuits since current lags the voltage in an inductive circuit. The phase is negative for a capacitive circuit since the current leads the voltage. &lt;/span&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: Arial,Helvetica,sans-serif; text-align: center;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://1.bp.blogspot.com/_Xf1TLp5Ejns/TDvoWpaBOxI/AAAAAAAAAEI/hp7TxnClfw0/s1600/phas.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_Xf1TLp5Ejns/TDvoWpaBOxI/AAAAAAAAAEI/hp7TxnClfw0/s320/phas.gif" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;This application was effectively used for 50Hz or 60Hz power line. This use&amp;nbsp; Zero Cross Detector to detect the rising edge of voltage and current. The square wave represent the voltage fed to INT0 (port D pin 2) and the square wave represent the current fed to ICP1 (port D pin 6). When the first of rising edge of the first wave at INT0 occurs, timer 1 will active. This timer starts to count the period of the wave. When the rising edge of the wave at ICP1 occurs, the Input Capture Unit of microcontroller actives and saves the value of ICR1 register. And, when the next rising edge of the wave at INT0 occurs, it will stop the Timer 1. This will followed by running a special routine to measure the frequency of the voltage and the phase different between voltage and current.&lt;br /&gt;This application can measure the frequency of signal (act as frequency meter), measure duration between two clock pulses (act as period meter), and measure phase difference between voltage and current. The results were saved in a specific memory location that will be described below. You can send them to LCD display or to PC while data logger. The development of this application to specific purpose application is become new really enabled and has been done.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt; The frequency of the signal in hexadecimal format can be read at the location referred by Frequency_voltage. This 2-byte value will represent the frequency multiplied by ten. The frequency in ASCII format can be read at the location referred by Frequency_voltage_ASCII. This 3-character represents the frequency in XX.X Hz format.&lt;br /&gt;The phase difference angle between voltage and current in hexadecimal format can be read at the location referred by Phase_different_angle. The phase difference angle in ASCII format can be read at the location referred by Phase_different_angle_ASCII. This 3-character represents the frequency in degree.&lt;br /&gt;In the future, from this application, we can build an AVR-microcontroller-based power factor measurement.&lt;/span&gt;&lt;br /&gt;&lt;div style="color: black;"&gt;&lt;span style="font-size: small;"&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style="color: black;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="color: black;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://www.4shared.com/file/gz9K5Fu5/Phase_difference.html"&gt;Download .asm and hex code&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="color: black;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;&lt;span style="color: black;"&gt;What’s next? &lt;/span&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/07/data-logger-to-pc-via-serial-port.html" style="color: black;"&gt;You can send the data to PC like data logger....&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-730654317317263683?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/730654317317263683/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/calculate-phase-difference-between.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/730654317317263683'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/730654317317263683'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/07/calculate-phase-difference-between.html' title='Calculate Phase Difference between Voltage and Current'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TDvoWpaBOxI/AAAAAAAAAEI/hp7TxnClfw0/s72-c/phas.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-968741499676029582</id><published>2010-06-30T14:37:00.009+07:00</published><updated>2010-10-05T14:27:06.402+07:00</updated><title type='text'>Read PWM signal from CMPS03 Compass Sensor Module</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;The CMPS03 compass module has been specifically designed for use in robots as an aid to navigation. A PWM signal is available on pin 4. The PWM signal is a pulse width modulated signal with the positive width of the pulse representing the angle. The pulse width varies from 1mS (0°) to 36.99mS (359.9°) – in other words 100uS/° with a +1mS offset. The signal goes low for 65mS between pulses, so the cycle time is 65mS + the pulse width - i.e. 66ms-102ms. The pulse is generated by a 16 bit timer in the processor giving a 1uS resolution; however I would not recommend measuring this to anything better than 0.1° (10uS). Make sure you connect the I2C pins, SCL and SDA, to the 5v supply if you are using the PWM, as there are no pull-up resistors on these pins.&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; font-family: Arial,Helvetica,sans-serif; text-align: center;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://2.bp.blogspot.com/_Xf1TLp5Ejns/TCrzwBUtjCI/AAAAAAAAAEA/dGdQndlgrEk/s1600/Compass.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_Xf1TLp5Ejns/TCrzwBUtjCI/AAAAAAAAAEA/dGdQndlgrEk/s320/Compass.jpg" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;This program will read PWM signal from CPMS03 Compass Module and convert it to an angle. The PWM signal from pin 4 of compass module fed to port C pin 2 of ATmega8535 microcontroller. Note that we use 11.0592MHz clock frequency.&lt;br /&gt;This program uses timer0 to measure the positive width of PWM pulse. At the positive-going-transition of PWM signal, timer0 goes on; and at the negative-going-transition of PWM signal, timer0 goes off. With prescaler=8, the timer will need 0.72338us per step counting. The timer will count 1382.4 (0x567) if the positive width of the pulse is 1ms. This value will be represented as 0 degree. And the timer will count 51148.8 (0xc7cc) if the positive width of the pulse is 37ms. This value will be represented as 360 degree.&lt;/span&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif; font-size: small;"&gt;The angle in 16-bit hexadecimal format can be read at the address of Compass_raw_loc of SRAM. This varies from 0 (0x0000) to 360 (0x0168). And the angle in 3-characters ASCII format can be read at the address of Compass_loc of SRAM. This varies from ‘000’ to ‘360’.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://www.4shared.com/file/lOjDkp8T/Compass_PWM.html"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;Download Program&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;What’s next? &lt;a href="http://microforbetterlive.blogspot.com/2010/07/data-logger-to-pc-via-serial-port.html"&gt;You can send the data to PC like data logger....&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/07/purpose-of-this-blog.html"&gt;click here for more information&lt;/a&gt;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-968741499676029582?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/968741499676029582/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/06/read-compass-sensor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/968741499676029582'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/968741499676029582'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/06/read-compass-sensor.html' title='Read PWM signal from CMPS03 Compass Sensor Module'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_Xf1TLp5Ejns/TCrzwBUtjCI/AAAAAAAAAEA/dGdQndlgrEk/s72-c/Compass.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-2444211844986414774</id><published>2010-06-08T09:18:00.007+07:00</published><updated>2010-10-05T14:26:13.856+07:00</updated><title type='text'>Drive an ESC with PWM from AVR Microcontroller</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;A brushless DC motor (BLDC) is an AC synchronous electric motor that from a modeling perspective looks very similar to a DC motor. Sometimes the difference is explained as an electronically controlled commutation system, instead of a mechanical commutation system, although this is misleading, as physically the two motors are completely different…&lt;br /&gt;Brushless DC motor controllers are much more complicated than brushed motor controllers. They have to convert the DC from the battery into phased AC (usually three phase) in order to produce the changing magnetic field.&lt;br /&gt;DC ESCs in the broader sense are PWM controllers for electric motors. An electronic speed control or ESC is an electronic circuit with the purpose to vary an electric motor's speed, its direction and possibly also to act as a dynamic brake. The ESC generally accepts a nominal 50 Hz PWM servo input signal whose pulse width varies from 1ms to 2ms. When supplied with a 1 ms width pulse at 50Hz, the ESC responds by turning off the DC motor attached to its output. A 1.5ms pulse-width input signal results in a 50% duty cycle output signal that drives the motor at approximately half-speed. When presented with 2.0ms input signal, the motor runs at full speed due to the 100% duty cycle (on constantly) output.&lt;br /&gt;The correct phase varies with the motor rotation, which is to be taken into account by the ESC: Usually, back EMF from the motor is used to detect this rotation, but variations exist that use magnetic or optical detectors. Computer-programmable speed controls generally have user-specified options which allows setting low voltage cut-off limits, timing, acceleration, braking and direction of rotation. Reversing the motor's direction may also be accomplished by switching any two of the three leads from the ESC to the motor.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;Why use an AVR microcontroller?&lt;br /&gt;In the AVR, the timer/counter 1 is used to generate PWM signals. This signal emitted from OC1A pin of ATmega8535 microcontroller and fed to an ESC to drive two brushless DC motors. The width of the PWM pulse was defined by the value of OCR1A. The maximum value of this register will set the motor at low voltage cut-off limits. This value was defined by OCR1_HIGH. And the minimum value of this register will set the motor run at highest speed. This value was defined by OCR1_LOW. &lt;br /&gt;To speed up motor, you can use a command or make port C pin 2 high; and to slow down motor, you can use a command or make port C pin 3 high.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;The development of this application to specific purpose application is become new really enabled and has been done. &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://www.4shared.com/file/z8Px1zSy/drive_esc.html"&gt;Download Program&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2010/07/purpose-of-this-blog.html"&gt;click here for more information&lt;/a&gt; &lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-2444211844986414774?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/2444211844986414774/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2010/06/drive-esc-with-pwm-from-avr.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2444211844986414774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2444211844986414774'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2010/06/drive-esc-with-pwm-from-avr.html' title='Drive an ESC with PWM from AVR Microcontroller'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-8183971730789147843</id><published>2009-09-14T10:31:00.007+07:00</published><updated>2010-07-26T08:29:28.217+07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='99 MHz frequency counter'/><title type='text'>99 MHz Frequency Counter</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;This dual-channel frequency counter work based on &lt;a href="http://microforbetterlive.blogspot.com/2009/07/dual-channel-920-khz-frequency-counter_8765.html"&gt;920 kHz microcontroller-based frequency counter&lt;/a&gt;. First channel has 99 MHz upper limit of frequency, and the second channel has 920 kHz upper limit of frequency. For the beginner, you can read the &lt;a href="http://microforbetterlive.blogspot.com/2009/06/microcontroller-based-2-channel.html"&gt;basic operation of this frequency counter&lt;/a&gt; and &lt;a href="http://microforbetterlive.blogspot.com/2009/07/dual-channel-920-khz-frequency-counter_8765.html"&gt;learn our old project&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;We have extended the upper limit of maximum frequency that can be counted by adding 74HC393 divider. This CMOS IC is a dual 4-bit binary ripple counter. The operation of each half of this device is the same as the 393 series except no external connection are required.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;To maintenance of the accuracy of counting, we cut the upper limit of frequency range feed to timer 0 of AT89S52 microcontroller that can be counted at 900 kHz. By using the all the flip-flop of 74HC393, we can build 8-bit counter. This must be a counter with modulus of 256. But 74HC393 have a maximum clock input frequency of 99 MHz. So, to maximize the accuracy, we only operate this device as 3-bit and 4-bit counter. Counter 0 was operated as 3-bit counter and counter 1 operated as 4-bit counter.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;The range of incoming frequency was divided by three.&lt;/span&gt;&lt;/div&gt;&lt;ol style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;Low Frequency (LF): 0 Hz ~ 899,999 Hz. This incoming frequency can feed through T0 pin of microcontroller. To display the value of incoming frequency is the same of our old project.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;Medium Frequency (MF): 900,000 Hz ~ 7,199,999 Hz. This incoming frequency must feed to T0 pin of microcontroller via a 3-bit counter/divider. To display the value of incoming frequency, the number of pulse that was counted by timer 0 must be multiplied by eight. To maintenance the accuracy, we cut the least significant digit of display. The display format is X,XXX.XX kHz.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;High Frequency (HF): 7,200,000 Hz ~ 99 MHz. This incoming frequency must feed to T0 pin of microcontroller via a 3-bit and 4-bit counter/divider. To display the value of incoming frequency, the number of pulse that was counted by timer 0 must be multiplied by 128. To maintenance the accuracy, we cut the two least significant digits of display. The display format is XX,XXX.X kHz. To display the frequency between 99 MHz and 100 MHz is still on experiment.&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;It’s not convenient for user to select a switch to match between the incoming frequency and those three ranges above.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;So, we make an &lt;a href="http://microforbetterlive.blogspot.com/2009/08/open-collector-as-selector.html"&gt;auto-select subroutine program&lt;/a&gt; to automatic select the best range that will be used. This subroutine will drive the some &lt;a href="http://microforbetterlive.blogspot.com/2009/08/open-collector-as-selector.html"&gt;open-collector configurations&lt;/a&gt; of counter output that builds five switches. So we only connect the probe to feed the incoming frequency, wait 1 second, and read the display.&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-8183971730789147843?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/8183971730789147843/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2009/09/99-mhz-frequency-counter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/8183971730789147843'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/8183971730789147843'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2009/09/99-mhz-frequency-counter.html' title='99 MHz Frequency Counter'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-1069935123676722706</id><published>2009-08-26T14:01:00.007+07:00</published><updated>2009-09-14T12:19:26.740+07:00</updated><title type='text'>Open-Collector as Selector</title><content type='html'>We use the open-collector configuration to make five digital switches like figure below. The range of incoming pulse is 1 Hz to 99 MHz. By adding the 74HC393 frequency divider, we get the output that its frequency range is 1 Hz to 900 kHz. This is done because the frequency range for incoming pulse that can feed to timer 0 of microcontroller is 920 kHz.&lt;br /&gt;We have three states. Each state has its frequency range.&lt;br /&gt;1.    High Frequency State.&lt;br /&gt;This state sets HFPin, so the incoming pulse (f) can feed to CP1 (Clock Pulse of counter 1). This state also sets HFPin1, so the output frequency of counter 0 feed to CP0 (Clock Pulse of counter 0). The incoming pulse was isolated to CP0 by resetting MFPin. Next the output frequency of counter 0 was emitted from Q2-0 to timer 0. To do this, we set HMFPin and reset LFPin.&lt;br /&gt;2.    Medium Frequency State.&lt;br /&gt;This state resets HFPin and sets MFPin, so incoming pulse feed to CP0 . The 3-bit counter/divider works and emits the pulse at Q2-0.&lt;br /&gt;3.    Low Frequency State.&lt;br /&gt;This state sets the LFPin and resets the others. The incoming pulse feed through to timer 0.&lt;br /&gt;The schematic diagram is the same as &lt;a href="http://microforbetterlive.blogspot.com/2009/07/dual-channel-920-khz-frequency-counter_29.html"&gt;the schematic diagram of dual channel 920 kHz Frequency Counter project&lt;/a&gt;, but before counter 0 pin (P3.4), we must add this divider.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_Xf1TLp5Ejns/Sq3Rh_r-sWI/AAAAAAAAAD4/anngydQaCCA/s1600-h/74HC393+as+freq+divider.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 320px;" src="http://1.bp.blogspot.com/_Xf1TLp5Ejns/Sq3Rh_r-sWI/AAAAAAAAAD4/anngydQaCCA/s400/74HC393+as+freq+divider.gif" alt="" id="BLOGGER_PHOTO_ID_5381187511739396450" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Auto-select Subroutine Program&lt;/span&gt;&lt;br /&gt;When counting the incoming pulse (by timer 0) was running, counter/divider that was activated must proper with the incoming frequency. To do this, the Auto-select Subroutine Program will be run before the counting process. This subroutine will determine the counter/divider that must be activated.&lt;br /&gt;This subroutine works as follow.&lt;br /&gt;1.    Check if incoming pulse is high frequency.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Activate HF state: set HFPin, HFPin1, HMFPin; and reset MFPin, LFPin (See table bellow). This will enable output of the 3-bit and 4-bit counter/divider.&lt;/li&gt;&lt;li&gt;Count incoming pulse during 20 ms intervals.&lt;/li&gt;&lt;li&gt;If result is grater than 56,250, the incoming pulse must be high frequency, go to step 4.&lt;/li&gt;&lt;/ul&gt;2.    Check if incoming pulse is medium frequency.&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Activate MF state: set MFPin, HMFPin; and reset HFPin, HFPin1, LFPin. This will enable output of the 3-bit counter/divider but disable the other.&lt;/li&gt;&lt;li&gt;Count incoming pulse during 20 ms intervals.&lt;/li&gt;&lt;li&gt;If result is grater than 112,500, the incoming pulse must be medium frequency. So, and go to step 4.&lt;/li&gt;&lt;/ul&gt;3.    Activate LF state: set LFPin and reset the others. This will disable all output of all counter/divider.&lt;br /&gt;4.    Count incoming pulse during 1 s intervals.&lt;br /&gt;&lt;br /&gt;            &lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aaaaa&lt;/span&gt;HFPin  HFPin1  MFPin  HMFPin  LFPin&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aaaaa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;P0.1 &lt;span style="color: rgb(255, 255, 255);"&gt;aa&lt;/span&gt;  P0.2        &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;P0.3 &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    P0.4      &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;P0.5&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;HF       &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aaaaa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;1 &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aaaaa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    1                 &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aaaaa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;0             &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aaaaa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;1      &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aaaaa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;MF &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aaaaa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;0 &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aaaaa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;    0      &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aaaaa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;1               &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aaaaa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;1               &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aaaaa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;0&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;LF       &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;a&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;0     &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aaaaa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;0                 &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aaaaa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;0     &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aaaaa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;0               &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="color: rgb(255, 255, 255);"&gt;aaaaa&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:courier new;"&gt;1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;To do four step above we make some subroutine: PreDelay20ms to prepare timer 2 for delay 20 ms, PreCount20msT0 to count the incoming pulse of timer 0 during 20 ms intervals, CheckIfHF to check if incoming pulse is high frequency, CheckIfMF to check if incoming pulse is medium frequency, CountF to count incoming frequency during 1 s interval, CountHFFrequency to divide the incoming high frequency by 128 and prepare it for display, CountMFFrequency to divide the incoming medium frequency by eight and prepare it for display.&lt;br /&gt;The listing program can be downloaded &lt;a href="http://www.4shared.com/file/132469064/e260393a/FC_online.html"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-1069935123676722706?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/1069935123676722706/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2009/08/open-collector-as-selector.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/1069935123676722706'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/1069935123676722706'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2009/08/open-collector-as-selector.html' title='Open-Collector as Selector'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_Xf1TLp5Ejns/Sq3Rh_r-sWI/AAAAAAAAAD4/anngydQaCCA/s72-c/74HC393+as+freq+divider.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-5475431808163974654</id><published>2009-07-29T09:11:00.025+07:00</published><updated>2010-07-26T08:28:28.798+07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Dual channel at89S52-based frequency counter'/><title type='text'>Dual Channel 920 kHz Frequency Counter</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;This is the listing program of Dual Channel 920 kHz Frequency Counter. The basic operation of this dual channel 920 kHz AT89S52-based frequency counter can be found &lt;a href="http://microforbetterlive.blogspot.com/2009/06/microcontroller-based-2-channel.html"&gt;here&lt;/a&gt;. &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Note that this program involve some subroutines as follow:&lt;/span&gt;&lt;/div&gt;&lt;ol style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;CmdWrtStart,CmdWrt, DataWrt&lt;br /&gt;This subroutine will display a character on LCD and others facilities to display some properties like initiate LCD, clear screen, go to home, and write some characters.&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;HexToBcd&lt;br /&gt;This subroutine will convert 20-bits hexadesimal number at tripple of register R1 R2 R3 to 8-digits BCD number at quadruple of register R4 R5 R6 R7. The BCD data can be displayed on LCD. May be only some lowest data that required to display.&lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;span style="font-size: small;"&gt;DisplayDigit&lt;br /&gt;A subroutine to display 6-digits is enough for displaying digital data accuratly.DisplayDigitThis subroutine will display 6-digits on LCD. Zero will be replaced by space until we find non-zero number. Input data must be BCD format and located at triplle of register R5 R6 R7.&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;This is the schematic diagram of the frequency counter. The buffer should be TTL/CMOS with Schmitt trigger like 74LS14 or 74LS19 or its family. The basic operation of this dual channel 920 kHz AT89S52-based frequency counter can be found &lt;a href="http://microforbetterlive.blogspot.com/2009/06/microcontroller-based-2-channel.html"&gt;here&lt;/a&gt;.&lt;a href="http://3.bp.blogspot.com/_Xf1TLp5Ejns/SnJg_1pTcKI/AAAAAAAAADg/GfNiR_s6AGU/s1600-h/FC.gif" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5364456756000026786" src="http://3.bp.blogspot.com/_Xf1TLp5Ejns/SnJg_1pTcKI/AAAAAAAAADg/GfNiR_s6AGU/s400/FC.gif" style="cursor: pointer; display: block; height: 298px; margin: 0px auto 10px; text-align: center; width: 402px;" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;a href="http://www.4shared.com/file/132482412/2b7a9b74/FC0.html"&gt;Listing Program.&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;This application can be extended to build &lt;a href="http://microforbetterlive.blogspot.com/2009/09/99-mhz-frequency-counter.html"&gt;frequency meter that can measure up to 99 MHz of frequency&lt;/a&gt;. &lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-5475431808163974654?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/5475431808163974654/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2009/07/dual-channel-920-khz-frequency-counter_8765.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/5475431808163974654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/5475431808163974654'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2009/07/dual-channel-920-khz-frequency-counter_8765.html' title='Dual Channel 920 kHz Frequency Counter'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_Xf1TLp5Ejns/SnJg_1pTcKI/AAAAAAAAADg/GfNiR_s6AGU/s72-c/FC.gif' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-8696483654809427394</id><published>2009-06-29T11:33:00.006+07:00</published><updated>2010-07-26T08:25:28.025+07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Dual channel at89S52-based frequency counter'/><title type='text'>Microcontroller-based 2 Channel Frequency-Meter</title><content type='html'>&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small; font-weight: bold;"&gt;Our Goal&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: small;"&gt;This project is to make frequency counter/frequency meter that can measure the frequency of incoming analog signal. This project has two input leads. Up to now, this application can measure the frequency of both leads from 0 Hz to 920 kHz with six digit display. We have calibrated this project with fabrication-made frequency counter. This project has only 0.01 % error. So if we measure a frequency above 100kHz, the error may be happen below 20 Hz. And if we measure the a frequency between 10kHz and 100kHz, the last digit may be toggle between two values.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;By adding prescaler, we hope the range of frequency that can be measured can be increase to 100 MHz. And by some additional methods, we also hope the accuracy of measurements of lower frequency can be greatly increased so we can display the frequency from 1.0 Hz to 100 MHz. To do this, we will need to perform some mathematical operations. We rely on an AT89S52 microcontroller (8051 family) to perform them in this project.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;We try to use minimal component so the price of this project not so expensive. The main component is an AT89S52 microcontroller and a LCD display. The only one advantage of AT89S52 than AT89S51&amp;nbsp; that we use is there is one additional 16-bit timer called timer 2.&amp;nbsp;&lt;/span&gt;&lt;style&gt;!--  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal  {mso-style-parent:"";  margin:0cm;  margin-bottom:.0001pt;  mso-pagination:widow-orphan;  font-size:12.0pt;  font-family:"Times New Roman";  mso-fareast-font-family:"Times New Roman";  mso-ansi-language:IN;  mso-no-proof:yes;} @page Section1  {size:612.0pt 792.0pt;  margin:72.0pt 90.0pt 72.0pt 90.0pt;  mso-header-margin:36.0pt;  mso-footer-margin:36.0pt;  mso-paper-source:0;} div.Section1  {page:Section1;} -&lt;/style&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small; font-weight: bold;"&gt;Target Specifications:&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Channel Input: 2&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Frequency range: 1.0Hz ~ 35MHz (auto-scale)&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Display: 6-Digit LCD&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Gate time: 0.1s ~ 1s&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Error: less than 0.01%&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Input sensitivity: minimum 0.1V&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Power consumption: less than 1W&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;DC Power Supply Input: 4.5V ~ 5.5V&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;We make open discussion forum, so all of you can contribute to this forum to share our ability.&lt;/span&gt;&lt;span style="font-size: small; font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;Overview &lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;A processor is one of main components of frequency counter. It must has ability to count and then perform arithmetic operations. To reduce price of the frequency counter become more competitive, then this research is used a microcontroller as substitute for a processor. This paper presents the design of frequency counter based on AT89S52 that it has three independent timers.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;This Frequency Counter, based on &lt;a href="http://microforbetterlive.blogspot.com/2009/05/program-for-counter.html"&gt;counter program&lt;/a&gt;, can measure up to 920 kHz of incoming frequency. This will be enough to trace and debug most of circuits, to adjust 555 timers frequency and perform all kind of frequency measurements in Digital circuits. This device has 0.01% error, so it can display up to 5 digits at frequency above 100 kHz.&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span lang="EN-GB"&gt; The upper limit of frequency can be extended up to 256 MHz by adding a frequency divider. The analysis of the accuracy of measuring presented in this article can support to determine the number of digit to display.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;To understand the basic of operation of this project, recall the simplest definition of frequency: the number of occurrences within a given time period. What we are trying to do is to count the number of electric pulses during a time of one second. To do this, we need a counter. The counters count the high-to-low transition of incoming pulses. A timer stop that after 1000 milliseconds.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small; font-weight: bold;"&gt;Counter Methods&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;This frequency counter work by using a counter which accumulates the number of events occurring within a specific period of time. After a preset period, that is 1 second, the value in the counter is transferred to a memory and the counter is reset to zero. After that, microcontroller runs a subroutine to prepare to display and a subroutine to display some character that representing a value of incoming frequency.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;If the event being measured repeats itself with sufficient stability and the frequency is considerably lower than that of the clock oscillator being used, the resolution of the measurement can be greatly improved by measuring the time required for an entire number of cycles, rather than counting the number of entire cycles observed for a pre-set duration (often referred to as the reciprocal technique). The second method can be used for measure the incoming frequency below 1kHz effectively. The accuracy for this can be improved so I can display the one tenth of frequency.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small; font-weight: bold;"&gt;Using T0 and T1 of AT89S52 as Counter&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;In this application we use 2 timers that operate as mode 1 counter. They are Counter 0 and Counter 1, and can be independently configured to operate in a variety of modes as a an event counter. When operating as a counter, the counter runs for a programmed length of time, then issues an interrupt request. They counts negative transitions on an external pin. After a preset number of counts, the counter issues an interrupt request.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;In this application we use 2 timers that operate as mode 1 counter. They are Counter 0 and Counter 1, and can be independently configured to operate in a variety of modes as an event counter. The timer register counts the negative transitions on the Tx external input pin. The external input is sampled every peripheral cycle. When&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;the sample is high in one cycle and low in the next one, the counter is incremented.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Since it takes 2 cycles (12 peripheral clock periods) to recognize a negative transition, the maximum count rate is FPER/12, i.e. FOSC/24 in standard mode or FOSC/ 12 in X2 mode. Because we use standard mode at 24 MHz clock operation, theoretically the maximum count rate is 1 MHz. In fact, the count rate can not exceed 920 kHz.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small; font-weight: bold;"&gt;Two Input Channels&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;We use two input channels. The first input directly fed to the T0 (P3.4) pin of the AT89S52, and the other fed to T1 (P3.5). In order to make any kind of measurements on some circuits, the ground of the measurement device and the ground of the all circuits being tested must be connected together. The incoming signal must be match to TTL level. But in the future, by adding a signal conditioning, we hope all type of analog signal can be fed to this device. The signal conditioning must take off any DC offset from the signal and then convert it into a square wave.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;Counter 0 counts the incoming clock pulse at T0 (P3.4) and Counter 1 counts the incoming clock pulse at T1 (P3.5). By resetting all counter before running, they count 0000h~FFFFh. After a value of FFFFh of counts, the counter issues an interrupt request. At the each of interrupt vector of their interrupt, we put some commands to increase a value that is an accumulator of each of overflow event of each counter.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small; font-weight: bold;"&gt;Timer 2 In Auto-Reload Mode&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;The interval of 1 second is held by timer 2 that acts as auto-reload mode. The auto-reload mode functions just like Timer 0 and Timer 1 in auto-reload mode, except that the Timer 2 auto-reload mode performs a full 16-bit reload (recall that Timer 0 and Timer 1 only have 8-bit reload values). When a reload occurs, the value of TH2 will be reloaded with the value contained in RCAP2H and the value of TL2 will be reloaded with the value contained in RCAP2L.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;To operate Timer 2 in auto-reload mode, the CP/RL2 bit (T2CON.0) must be clear. In this mode, Timer 2 (TH2/TL2) will be reloaded with the reload value (RCAP2H/RCAP2L) whenever Timer 2 overflows; that is to say, whenever Timer 2 overflows from FFFFh back to 0000h. An overflow of Timer 2 will cause the TF2 bit to be set, which will cause an interrupt to be triggered, if Timer 2 interrupt is enabled. Note that TF2 will not be set on an overflow condition if either RCLK or TCLK (T2CON.5 or T2CON.4) are set.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;By setting RCAP2H and RCAP2L to 3CB0h, timer 2 runs for 50 ms. Timer 2 runs 40 times, so we get 1 second delay.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;We use &lt;a href="http://www.kmitl.ac.th/%7Ekswichit/IspPgm30a/ISP-Pgm30a.html"&gt;ISP Flash Microcontroller Programmer Ver 3.0a&lt;/a&gt; to burning the hex code. Listing program can be found at &lt;a href="http://microforbetterlive.blogspot.com/2009/07/dual-channel-920-khz-frequency-counter_8765.html"&gt;here&lt;/a&gt;. Look &lt;a href="http://microforbetterlive.blogspot.com/2009/07/dual-channel-920-khz-frequency-counter_29.html"&gt;schematic diagram&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small; font-weight: bold;"&gt;2X16 LCD Display&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;We choose 2X16 LCD for display. The LCD display is “lighter” than 7-segment LED display. The second display much more &lt;a href="http://microforbetterlive.blogspot.com/2009/05/displaying-2-digits-to-7-segment-led.html"&gt;needs microcontroller attention to scan some LED&lt;/a&gt;. The attention may be could be reduced by replacing subroutine for scanning with some driver like 74LS46/7. But its need more complex circuit for it.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Arial,Helvetica,sans-serif;"&gt;&lt;span style="font-size: small;"&gt;&lt;a href="http://microforbetterlive.blogspot.com/2009/07/dual-channel-920-khz-frequency-counter_8765.html"&gt;Here the frequency meter application&lt;/a&gt;. &lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-8696483654809427394?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/8696483654809427394/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2009/06/microcontroller-based-2-channel.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/8696483654809427394'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/8696483654809427394'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2009/06/microcontroller-based-2-channel.html' title='Microcontroller-based 2 Channel Frequency-Meter'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-2570823306782757818</id><published>2009-05-15T14:56:00.005+07:00</published><updated>2010-07-23T11:00:46.871+07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='4X3 matrix keypad'/><title type='text'>Access 4X3 Matrix-Keypad</title><content type='html'>A &lt;a href="http://microforbetterlive.blogspot.com/2009/04/keypad.html"&gt;keypad&lt;/a&gt; is the most widely used input devices of a microcontroller. In order to use it effectively, we need a basic understanding of them. In this section, we discuss keyboard fundamentals, along with key press and key detection mechanisms, Then we show how a keyboard is interfaced to an AT89S51 microcontroller.&lt;br /&gt;&lt;br /&gt;At the lowest level, keyboards are organized in a matrix of rows and columns. The CPU accesses both rows and column through ports; therefore, with a port of microcontroller, a 4X3 matrix of keys can be connected. When a key pressed, a row and column make a connection; otherwise, there is no connection between row and column.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Scanning and Identifying the Key Pressed&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Figure1 shows a 4X3 matrix connected to port 1. The rows (R1 through R4) are connected to an output port and the columns (C1 through C3) are connected to an input port. Note that, we only use 7 pins of port 1.&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/_Xf1TLp5Ejns/SlwpCzeIkWI/AAAAAAAAADA/CW7D4cL_-g0/s1600-h/image007.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5358202784817123682" src="http://2.bp.blogspot.com/_Xf1TLp5Ejns/SlwpCzeIkWI/AAAAAAAAADA/CW7D4cL_-g0/s400/image007.jpg" style="cursor: pointer; display: block; height: 268px; margin: 0px auto 10px; text-align: center; width: 333px;" /&gt;&lt;/a&gt;Figure 1 A 4X3 matrix connected to port 1.&lt;/div&gt;&lt;br /&gt;To detect a pressed key, first, the microcontroller set pin 0 through 7 of port 1 and initiate the variable ‘Digit’ to zero. The value of ‘Digit’ represents the digit of key pressed.&lt;br /&gt;Then it sends 0111 to R1 R2 R3 R4 and it reads the columns. If the data read from the columns is C1 C2 C3 =111, no key has been pressed and the process continues to next step.&lt;br /&gt;If the data read from the columns is C1 C2 C3 =011, this means that a key in the R1 row and C1 column has been pressed. That is ‘1’.&lt;br /&gt;In the subroutine ‘CheckColumn’, the value of ‘Digit’ is increased. The value of ‘Digit’ represents the key pressed. Before leave this subroutine, microcontroller set ‘KeyPressed’ to indicate there is a key pressed.&lt;br /&gt;If the data read from the columns is C1 C2 C3 =101, this means that a key in the R1 row and C2 column has been pressed. That is ‘2’. Table 1 represents the meaning of each combination of data received at C1 C2 C3.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_Xf1TLp5Ejns/SlwpLIpVseI/AAAAAAAAADI/Ym5w2qyUltU/s1600-h/image008.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5358202927940219362" src="http://4.bp.blogspot.com/_Xf1TLp5Ejns/SlwpLIpVseI/AAAAAAAAADI/Ym5w2qyUltU/s400/image008.jpg" style="cursor: pointer; display: block; height: 400px; margin: 0px auto 10px; text-align: center; width: 362px;" /&gt;&lt;/a&gt;Table 1 The meaning of each combination of data received at C1 C2 C3&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;Someone can not press two key at the same time. There is time different between press a key with another key. ‘KeyPressed’ indicates there is a key pressed in this time. Before leave the entire subroutine, if ‘KeyPressed’ has been set, the microcontroller set the variable ‘KeyAlreadyPressed’. This variable will not be cleared until this subroutine detect that there is no key pressed. So, if press more than two key, only the first key will be read.&lt;br /&gt;To see if any key is pressed, the columns are scanned over and over in an infinite loop until one of them has a 0 on it. The listing below is only for example. In fact, it’s no efficient if we scan the keypad without any intervals of time. We usually use the intervals time for scanning more than 10 ms. This interval can be generated by timer.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.4shared.com/file/132489881/bdaa0fe2/Keypad.html"&gt;Listing Program.&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-2570823306782757818?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/2570823306782757818/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2009/05/access-4x3-keypad.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2570823306782757818'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/2570823306782757818'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2009/05/access-4x3-keypad.html' title='Access 4X3 Matrix-Keypad'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_Xf1TLp5Ejns/SlwpCzeIkWI/AAAAAAAAADA/CW7D4cL_-g0/s72-c/image007.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-9045156364796767051</id><published>2009-05-15T14:53:00.002+07:00</published><updated>2009-09-14T14:14:34.787+07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='timer for counter'/><title type='text'>Program for counter</title><content type='html'>Sometimes we need a counter to count an event at digital scope. Counter can be made by JK flip-flop. There are some integrated chip contains two or more JK flip-flop that can be operated as a counter. A flip-flop can act as one bit counter. So, if we need 4 bit counter, that can count 0 to 16, we need four flip-flops.&lt;br /&gt;A programmable counter can be made by a microcontroller. AT89S51 have two timers that can be operated as independent counter. To do this, we must set c/t bit at TMOD register. This sample will operate timer 0 as mode 2 counter. By loading 155des at TL0 and TH0, timer 0 act as 100des counter.&lt;br /&gt;A &lt;a href="http://microforbetterlive.blogspot.com/2009/06/microcontroller-based-2-channel.html"&gt;simple frequency counter&lt;/a&gt; can be made by this counter.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_Xf1TLp5Ejns/SkmOpc9APmI/AAAAAAAAABg/96B5Jx_qJIg/s1600-h/TMOD.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 76px;" src="http://1.bp.blogspot.com/_Xf1TLp5Ejns/SkmOpc9APmI/AAAAAAAAABg/96B5Jx_qJIg/s320/TMOD.JPG" alt="" id="BLOGGER_PHOTO_ID_5352966474904387170" border="0" /&gt;&lt;/a&gt;This is the sample program for counting negative edge of input clock at T0 (p3.4). The number of clock will displayed at 2 digit of 7-segment LED common anode.&lt;br /&gt;This program also acts as frequency divider. The clock frequency will be divided by 100 and emitted to P3.2. Press INT0 for pause and INT0 again to resume.&lt;span style=";font-family:courier new;font-size:85%;"  &gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.4shared.com/file/132487608/e6ee6777/Counter.html"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-family: georgia;"&gt;Here is the listing program.&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-9045156364796767051?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://microforbetterlive.blogspot.com/feeds/9045156364796767051/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://microforbetterlive.blogspot.com/2009/05/program-for-counter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/9045156364796767051'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/9045156364796767051'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2009/05/program-for-counter.html' title='Program for counter'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_Xf1TLp5Ejns/SkmOpc9APmI/AAAAAAAAABg/96B5Jx_qJIg/s72-c/TMOD.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-5372219894312651342</id><published>2009-05-15T14:45:00.002+07:00</published><updated>2009-09-15T09:35:50.737+07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='7-segment common anode'/><title type='text'>Displaying 2 digits to 7-segment LED</title><content type='html'>&lt;p class="MsoNormal" style=""&gt;&lt;span lang="IN"&gt;The 2 digit 7-segment display can seem a little complicated. The main idea for this system is to connect both 7-segment cells together in parallel, but in the same time, only one that be powered.&lt;br /&gt;Here is the simple sequence to show the ones at the right cell and tens at the left cell.&lt;br /&gt;1.    Sends data ‘ones’ though the ‘PortLED’.&lt;br /&gt;2.    Energizes the right cell while left cell is off by resetting P1.0.&lt;br /&gt;3.    Wait for a short time delay. In this project, we paused for 8.192 ms that was setted by interrupt from timer 1.&lt;br /&gt;4.    Sends data ‘tens’ though the ‘PortLED’.&lt;br /&gt;5.    Energizes the left cell while right cell is off by setting P1.0.&lt;br /&gt;6.    Wait for 8.192 ms too.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style=""&gt;&lt;span lang="IN"&gt;&lt;/span&gt;&lt;/p&gt;&lt;a href="http://www.4shared.com/file/132699560/2c5e0912/Display2Digit7Segment.html"&gt;Here &lt;/a&gt;is a sample program for displaying 00~99 to 7-Segment LED common anode.Each digit activated by multiplexing every 8128 ms.&lt;br /&gt;The ones will increment in 1 second.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;p class="Gambar" style="page-break-after: avoid;"&gt;&lt;span lang="IN"&gt;&lt;!--[if gte vml 1]&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" spt="75" preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt;  &lt;v:stroke joinstyle="miter"&gt;  &lt;v:formulas&gt;   &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt;   &lt;v:f eqn="sum @0 1 0"&gt;   &lt;v:f eqn="sum 0 0 @1"&gt;   &lt;v:f eqn="prod @2 1 2"&gt;   &lt;v:f eqn="prod @3 21600 pixelWidth"&gt;   &lt;v:f eqn="prod @3 21600 pixelHeight"&gt;   &lt;v:f eqn="sum @0 0 1"&gt;   &lt;v:f eqn="prod @6 1 2"&gt;   &lt;v:f eqn="prod @7 21600 pixelWidth"&gt;   &lt;v:f eqn="sum @8 21600 0"&gt;   &lt;v:f eqn="prod @7 21600 pixelHeight"&gt;   &lt;v:f eqn="sum @10 21600 0"&gt;  &lt;/v:formulas&gt;  &lt;v:path extrusionok="f" gradientshapeok="t" connecttype="rect"&gt;  &lt;o:lock ext="edit" aspectratio="t"&gt; &lt;/v:shapetype&gt;&lt;v:shape id="_x0000_i1025" type="#_x0000_t75" style="'width:326.4pt;"&gt;  &lt;v:imagedata src="file:///C:\DOCUME~1\TEKNIK~1\LOCALS~1\Temp\msohtml1\01\clip_image001.png" title="" cropleft="13438f"&gt; &lt;/v:shape&gt;&lt;![endif]--&gt;&lt;!--[if !vml]--&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-5372219894312651342?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/5372219894312651342'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/5372219894312651342'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2009/05/displaying-2-digits-to-7-segment-led.html' title='Displaying 2 digits to 7-segment LED'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-816590922133219362</id><published>2009-04-24T14:05:00.000+07:00</published><updated>2009-07-09T12:54:06.804+07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='microcontroller'/><category scheme='http://www.blogger.com/atom/ns#' term='clock'/><category scheme='http://www.blogger.com/atom/ns#' term='error'/><category scheme='http://www.blogger.com/atom/ns#' term='generator'/><title type='text'>Microcontroller as a frequency generator</title><content type='html'>Many electronic experiences require clock generator. In common, analog clock generator can build clock signal with 5 % error, and digital clock generator can build it with 0.1 % error. Microcontroller-based clock signal generator has crystal accuracy. The useful frequency range that can be generated is between 1 Hz and 1 MHz when the microcontroller operating at a 24 MHz clock frequency. The 1 MHz frequency output can be generated with continuing to execute a one-cycle-instruction to complement the pin output. To generate a specific frequency below 1 MHz, the other instruction(s) such as no-operation can be inserted to delay the next instruction. The maximum error of 0.1 % can be generated at frequency output below 2 kHz and the maximum error of 1 % at frequency below 20 kHz. The selected frequency signal with 0.1 % or less error also can be generated for frequency below 1 MHz.&lt;br /&gt;The main principle of  microcontroller-based clock generator is toggling a output pin with specific time interval.&lt;br /&gt;Here is a sample program for toggling pin 0 through 7 of port 0 with delay routine.&lt;br /&gt;&lt;span style="font-family: courier new;font-family:courier new;font-size:85%;"  &gt;$MOD51&lt;br /&gt;           Org  0h&lt;br /&gt;Start:      Mov   P1,#00001111B&lt;br /&gt;           call  Delay&lt;br /&gt;           Mov   P1,#11110000B&lt;br /&gt;           call  Delay&lt;br /&gt;           Jmp   Start&lt;br /&gt;;------------------- Delay sub routine -------------------&lt;br /&gt;Delay:      Mov   R0,#0FFh      ;R0=FF (Hex)&lt;br /&gt;Delay1:     Mov   R1,#0FFh      ;R1=FF (hex)&lt;br /&gt;Delay2:     nop                 ;no operation&lt;br /&gt;           nop&lt;br /&gt;           nop&lt;br /&gt;           Djnz  R1,Delay2   &lt;br /&gt;           Djnz  R0,Delay1   &lt;br /&gt;           Ret               &lt;br /&gt;           End&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:Courier New;"&gt;&lt;/span&gt;&lt;br /&gt;Here is a sample program will source the clock with its periode 6 ms.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;font-size:85%;"&gt;$mod51&lt;br /&gt;           MOV   P1,#0h&lt;br /&gt;Repeat:     CPL   P1.0&lt;br /&gt;           JMP   Repeat&lt;br /&gt;END&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-816590922133219362?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/816590922133219362'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/816590922133219362'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2009/04/microcontroller-as-frequency-generator.html' title='Microcontroller as a frequency generator'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-4311589554393393753</id><published>2009-04-22T11:40:00.001+07:00</published><updated>2009-07-28T13:11:43.855+07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='4X3 matrix keypad'/><title type='text'>Keypad</title><content type='html'>&lt;span&gt;&lt;span&gt;A keypad is a set of buttons arranged in a block which usually bear digits and other symbols but not a complete set of alphabetical letters. If it mostly contains numbers then it can also be called a numeric keypad. Keypads are found on many alphanumeric keyboards and on other devices such as calculators, combination locks and telephones which require largely numeric input.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_Xf1TLp5Ejns/SlWDr4ajyfI/AAAAAAAAAB4/-bpQ4aIofdk/s1600-h/image001.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 149px; height: 172px;" src="http://2.bp.blogspot.com/_Xf1TLp5Ejns/SlWDr4ajyfI/AAAAAAAAAB4/-bpQ4aIofdk/s320/image001.jpg" alt="" id="BLOGGER_PHOTO_ID_5356332121728469490" border="0" /&gt;&lt;/a&gt;&lt;span&gt;&lt;span&gt;Figure 1 A 4X3 matrix keypad   &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span&gt;&lt;span&gt;A computer keyboard usually contains a small numeric keypad with a calculator-style arrangement of buttons duplicating the numeric and arithmetic keys on the main keyboard to allow efficient entry of numerical data. This number pad (commonly abbreviated to "numpad") is usually positioned on the right side of the keyboard because most people are right-handed.   Many laptop computers have special function keys which turn part of the alphabetical keyboard into a numerical keypad as there is insufficient space to allow a separate keypad to be built into the laptop's chassis. Separate plug-in keypads can be purchased.&lt;br /&gt;By convention, the keys on calculator-style keypads are arranged such that 123 is on the bottom row. In contrast, a telephone keypad has the 123 keys at the top. It also has buttons labelled * (star) and # (octothorpe, number sign, "pound" or "hash") either side of the zero. Most of the keys also bear letters which have had several auxiliary uses, such as remembering area codes or whole telephone numbers.   The keypad of a calculator contains the digits 0 through 9, together with the four arithmetic operations, the decimal point and other more advanced functions.   Keypads are a part of mobile phones that are replaceable and sit on a sensor board. Some multimedia mobile phones have a small joystick which has a cap to match the keypad.   Keypads are also a feature of some combination locks. This type of lock is often used on doors, such as that found at the main entrance to some offices.&lt;br /&gt;There are some type(s) of keypad: 4X3, 4X4, etc. Each type of those sould be accessed with different manner. Microcontroller must use I/O port to source and sink current to achieve data in which keypad pressed.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Constructing a Matrix Keypad&lt;/span&gt;&lt;br /&gt;Martix keypads are well known for their simple architecture and ease of interfacing with any microcontroller. In this part of tutorial we will learn how to interface a 4x4 matrix keypad with AVR and 8051 microcontroller. Also we will see how to program then in Assembly and C.&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_Xf1TLp5Ejns/SlWElBHAwtI/AAAAAAAAACQ/Gufwxi0WPQY/s1600-h/image003.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 167px; height: 162px;" src="http://4.bp.blogspot.com/_Xf1TLp5Ejns/SlWElBHAwtI/AAAAAAAAACQ/Gufwxi0WPQY/s320/image003.gif" alt="" id="BLOGGER_PHOTO_ID_5356333103314944722" border="0" /&gt;&lt;/a&gt;&lt;span&gt;&lt;span&gt;Figure 3 Keypad Switch&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;span&gt;&lt;span&gt;Constuction of a keypad is really simple. As per the outline shown in the figure below we have four rows and four columns. In between each overlapping row and column line there is a key. Now our keypad is ready, all we have to do is connect the rows and columns to a port of microcontroller and program the controller to read the input.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Scanning a Matrix Keypad&lt;/span&gt;&lt;br /&gt;There are many methods depending on how you connect your keypad with your controller, but the basic logic is same. We make the coloums as i/p and we drive the rows making them o/p, this whole procedure of reading the keyboard is called scanning.&lt;br /&gt;In order to detect which key is pressed from the matrix, we make row lines low one by one and read the coloums. Lets say we first make Row1 low, then read the columns. If any of the key in row1 is pressed will make the corrosponding column as low i.e if second key is pressed in Row1, then column2 will give low. So we come to know that key 2 of Row1 is pressed. This is how scanning is done.&lt;br /&gt;So to scan the keypad completely, we need to make rows low one by one and read the columns. If any of the button is pressed in a row, it will take the corrosponding column to a low state which tells us that a key is pressed in that row. If button 1 of a row is pressed then Column 1 will become low, if button 2 then column2 and so on...&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-4311589554393393753?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/4311589554393393753'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/4311589554393393753'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2009/04/keypad.html' title='Keypad'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_Xf1TLp5Ejns/SlWDr4ajyfI/AAAAAAAAAB4/-bpQ4aIofdk/s72-c/image001.jpg' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-2873049276340993950.post-8190238784227287701</id><published>2009-04-22T11:27:00.001+07:00</published><updated>2009-07-28T13:12:13.906+07:00</updated><title type='text'>Overview of microcontroller</title><content type='html'>&lt;!-- dtl_id=7553 //--&gt;                          &lt;p  style="font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt;       A microcontroller is a miniature of computer. &lt;/span&gt;It has                                                   CPU,                                                   ROM,                                                   RAM,                          I/O port and timer all embedded on single chip, some                          times its contain                                                   ADC,                                                  DAC                          and                                                   analogue comparator. It's also known as IBP                          ("itty-bitty processors").&lt;span style=";font-family:Arial;font-size:10;color:navy;"   &gt; &lt;/span&gt;&lt;span style="font-size:100%;"&gt;All computers -- whether we are talking about a personal &lt;span&gt;&lt;span&gt;desktop computer&lt;/span&gt;&lt;/span&gt; or a large mainframe computer or a microcontroller -- have several things in common:  &lt;/span&gt;&lt;/p&gt; &lt;ul  style="font-family:arial;"&gt; &lt;li&gt;&lt;span style="font-size:100%;"&gt;All computers have a &lt;a href="http://electronics.howstuffworks.com/microprocessor.htm"&gt;&lt;/a&gt;&lt;/span&gt;CPU     &lt;span style="font-size:100%;"&gt;(central processing unit) that executes programs. If you are sitting at a desktop computer right now reading this article, the CPU in that machine is executing a program that implements the Web browser that is displaying this page. &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;The CPU loads the program from somewhere. On your desktop machine, the browser program is loaded from the &lt;a href="http://electronics.howstuffworks.com/hard-disk.htm"&gt;&lt;/a&gt;&lt;/span&gt;hard disk&lt;span style="font-size:100%;"&gt;.      &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;The computer has some&lt;/span&gt; RAM&lt;span style="font-size:100%;"&gt; (random-access memory) where it can store "variables."      &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;And the computer has some input and output devices so it can talk to people. On your desktop machine, the&lt;/span&gt; keyboard a&lt;span style="font-size:100%;"&gt;nd &lt;/span&gt;mouse&lt;span style="font-size:100%;"&gt; are input devices and the &lt;/span&gt;monitor&lt;span style="font-size:100%;"&gt; and &lt;/span&gt;printer are output devices. A hard disk is an I/O device -- it handles both input and output. &lt;/li&gt; &lt;/ul&gt;  &lt;p  style="font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt; The desktop computer you are using is a "general purpose computer" that can run any of thousands of programs. Microcontrollers are "special purpose computers." Microcontrollers do one thing well. There are a number of other common characteristics that define microcontrollers. If a computer matches a majority of these characteristics, then you can call it a "microcontroller": &lt;/span&gt;&lt;/p&gt; &lt;ul  style="font-family:arial;"&gt; &lt;li&gt;&lt;span style="font-size:100%;"&gt;Microcontrollers are "&lt;strong&gt;embedded&lt;/strong&gt;" inside some other device (often a consumer product) so that they can control the features or actions of the product. Another name for a microcontroller, therefore, is "embedded controller." &lt;/span&gt;&lt;p&gt; &lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt;Microcontrollers are &lt;strong&gt;dedicated&lt;/strong&gt; to one task and run one specific program. The program is stored in &lt;/span&gt;ROM&lt;span style="font-size:100%;"&gt; (read-only memory) and generally does not change.     &lt;/span&gt;&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;Microcontrollers are often &lt;strong&gt;low-power devices&lt;/strong&gt;. A desktop computer is almost always plugged into a wall socket and might consume 50 watts of electricity. A battery-operated microcontroller might consume 50 milliwatts. &lt;/span&gt;&lt;p&gt; &lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;A microcontroller has a &lt;strong&gt;dedicated input device&lt;/strong&gt; and often (but not always) has a small &lt;strong&gt;LED or LCD display for output&lt;/strong&gt;. A microcontroller also takes input from the device it is controlling and controls the device by sending signals to different components in the device. &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt; For example, the microcontroller inside a TV takes input from the &lt;/span&gt;remote control&lt;span style="font-size:100%;"&gt; and displays output on the TV screen. The controller controls the channel selector, the &lt;/span&gt;speaker system and certain adjustments on the picture tube electronics such as tint and brightness. The engine controller&lt;span style="font-size:100%;"&gt; in a car takes input from sensors such as the oxygen and knock sensors and controls things like fuel mix and spark plug timing. A &lt;/span&gt;microwave oven&lt;span style="font-size:100%;"&gt; controller takes input from a keypad, displays output on an LCD display and controls a &lt;/span&gt;relay&lt;span style="font-size:100%;"&gt; that turns the microwave generator on and off.     &lt;/span&gt;&lt;/p&gt;&lt;p&gt; &lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;A microcontroller is often &lt;strong&gt;small and low cost&lt;/strong&gt;. The components are chosen to minimize size and to be as inexpensive as possible.     &lt;/span&gt;&lt;p&gt; &lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;A microcontroller is often, but not always, &lt;strong&gt;ruggedized&lt;/strong&gt; in some way.     &lt;/span&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt; The microcontroller controlling a car's engine, for example, has to work in temperature extremes that a normal computer generally cannot handle. A car's microcontroller in Alaska has to work fine in -30 degree F (-34 C) weather, while the same microcontroller in Nevada might be operating at 120 degrees F (49 C). When you add the heat naturally generated by the &lt;/span&gt;engine&lt;span style="font-size:100%;"&gt;, the temperature can go as high as 150 or 180 degrees F (65-80 C) in the engine compartment.     &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:100%;"&gt; On the other hand, a microcontroller embedded inside a VCR hasn't been ruggedized at all.     &lt;/span&gt;&lt;/p&gt;&lt;/li&gt; &lt;/ul&gt; &lt;p  style="font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt; The actual &lt;strong&gt;processor&lt;/strong&gt; used to implement a microcontroller can vary widely. For example, the cell phone shown on &lt;/span&gt;Inside a Digital Cell Phone&lt;span style="font-size:100%;"&gt; contains a &lt;/span&gt;Z-80 processor&lt;span style="font-size:100%;"&gt;. The Z-80 is an 8-bit &lt;/span&gt;microprocessor&lt;span style="font-size:100%;"&gt; developed in the 1970s and originally used in home computers of the time. The Garmin GPS shown in &lt;/span&gt;How GPS Receivers Work&lt;span style="font-size:100%;"&gt; contains a low-power version of the Intel 80386, I am told. The 80386 was originally used in desktop computers. &lt;/span&gt;&lt;/p&gt; &lt;p  style="font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt; In many products, such as microwave ovens, the demand on the CPU is fairly low and price is an important consideration. In these cases, manufacturers turn to &lt;strong&gt;dedicated microcontroller chips&lt;/strong&gt; -- chips that were originally designed to be low-cost, small, low-power, embedded CPUs. The Motorola 6811 and &lt;/span&gt;Intel 8051&lt;span style="font-size:100%;"&gt; are both good examples of such chips. There is also a line of popular controllers called "PIC microcontrollers" created by a company called &lt;/span&gt;Microchip&lt;span style="font-size:100%;"&gt;. By today's standards, these CPUs are incredibly minimalistic; but they are extremely inexpensive when purchased in large quantities and can often meet the needs of a device's designer with just one chip. &lt;/span&gt;&lt;/p&gt; &lt;p  style="font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt; A typical low-end microcontroller chip might have 1,000 &lt;/span&gt;bytes&lt;span style="font-size:100%;"&gt; of ROM and 20 bytes of RAM on the chip, along with eight I/0 pins. In large quantities, the cost of these chips can sometimes be just pennies. You certainly are never going to run Microsoft Word on such a chip -- Microsoft Word requires perhaps 30 megabytes of RAM and a processor that can run millions of instructions per second. But then, you don't need Microsoft Word to control a microwave oven, either. With a microcontroller, you have one specific task you are trying to accomplish, and low-cost, low-power performance is what is important.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2873049276340993950-8190238784227287701?l=microforbetterlive.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/8190238784227287701'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2873049276340993950/posts/default/8190238784227287701'/><link rel='alternate' type='text/html' href='http://microforbetterlive.blogspot.com/2009/04/overview-of-microcontroller.html' title='Overview of microcontroller'/><author><name>Freddy</name><uri>http://www.blogger.com/profile/07998798527600294261</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_Xf1TLp5Ejns/TFEgxEGRBvI/AAAAAAAAAE4/8HQ7ufWmpWE/S220/Freddy+2X3+4X6.jpg'/></author></entry></feed>
