<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>SulhanSetiawan.com &#187; Microcontroller Learning</title> <atom:link href="http://www.sulhansetiawan.com/tag/microcontroller-learning/feed" rel="self" type="application/rss+xml" /><link>http://www.sulhansetiawan.com</link> <description></description> <lastBuildDate>Sun, 05 Feb 2012 17:08:53 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>SSMaker, tool for creating seven segment constant</title><link>http://www.sulhansetiawan.com/ssmaker</link> <comments>http://www.sulhansetiawan.com/ssmaker#comments</comments> <pubDate>Sat, 26 Jun 2010 09:36:50 +0000</pubDate> <dc:creator>Sulhan</dc:creator> <category><![CDATA[IDE (Integrated Development Environment)]]></category> <category><![CDATA[Microcontroller]]></category> <category><![CDATA[All]]></category> <category><![CDATA[Microcontroller Learning]]></category> <category><![CDATA[Microcontroller IDE]]></category><guid isPermaLink="false">http://sulhansetiawan.com/?p=1017</guid> <description><![CDATA[SSMaker.exe is a program to help make a lighting table of seven segment. Click on the segment to be switched on or off. After that, the table to form the light will be instantly displayed. Lights are represented by the value bit 0. To make the light represented by the value bit 1, check the [...]]]></description> <content:encoded><![CDATA[<div class="wp-caption aligncenter" style="width: 214px"><img title="SSMaker.exe" src="http://resource.sulhansetiawan.com/img/SSMaker.PNG" alt="SSMaker.exe" width="204" height="286" /><p class="wp-caption-text">SSMaker.exe</p></div><p>SSMaker.exe is a program to help make a lighting table of seven segment.</p><p>Click on the segment to be switched on or off. After that, the table to form the light will be instantly displayed. Lights are represented by the value bit 0. To make the light represented by the value bit 1, check the <strong>Active High</strong>.</p><div class="wp-caption aligncenter" style="width: 422px"><img title="SSMaker.exe" src="http://resource.sulhansetiawan.com/img/SSMaker5.PNG" alt="SSMaker5.exe" width="204" height="286" /> <img title="SSMaker.exe" src="http://resource.sulhansetiawan.com/img/SSMaker5A.PNG" alt="SSMaker5A.exe" width="204" height="286" /><p class="wp-caption-text">Constants for the number 5 is 92H (light = 0) or 6DH (light = 1)</p></div><p>By default, bit 0 is for segment A, bit 1 is for the segment b, and so on. But you also can change the order. Of course this arrangement tailored to the hardware. To determine the bits to its segments, right click on the segment to be determined its bit, then from pupop menu that appears, choose the number of bits.</p><div class="wp-caption aligncenter" style="width: 214px"><img title="SSMaker.exe" src="http://resource.sulhansetiawan.com/img/SSMakerBit.PNG" alt="SSMaker.exe" width="204" height="286" /><p class="wp-caption-text">Right-click on a segment for selecting bits for the segment.</p></div><p>If we use the bits that are being used by another segment, the segment which bits are used will be made to not connected to any bit. Signs that the segment is not connected to the bit is the segment which is marked with the letter X.</p><p>This program is a package of <a href="http://sulhansetiawan.com/microcontroller-project">Microcontroller Project</a></p> ]]></content:encoded> <wfw:commentRss>http://www.sulhansetiawan.com/ssmaker/feed</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>Running Text on LED Matrix</title><link>http://www.sulhansetiawan.com/teks-berjalan-pada-matriks-led</link> <comments>http://www.sulhansetiawan.com/teks-berjalan-pada-matriks-led#comments</comments> <pubDate>Tue, 02 Mar 2010 10:57:32 +0000</pubDate> <dc:creator>Sulhan</dc:creator> <category><![CDATA[Experiments]]></category> <category><![CDATA[All]]></category> <category><![CDATA[Microcontroller Learning]]></category> <category><![CDATA[LED matrix]]></category> <category><![CDATA[Microcontroller]]></category> <category><![CDATA[Moving Sign]]></category> <category><![CDATA[Simulation]]></category> <category><![CDATA[Running Text]]></category><guid isPermaLink="false">http://sulhansetiawan.com/teks-berjalan-pada-matriks-led</guid> <description><![CDATA[In the example in Showing images on LED matrix using simulator, the note is displayed as an image. First we create a text image, then we create a constant from the text image. After that it displayed as an image. Displaying text in this way is only appropriate if the text to be displayed is [...]]]></description> <content:encoded><![CDATA[<p style="TEXT-ALIGN: center"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="494" height="178" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="menu" value="false" /><param name="quality" value="medium" /><param name="scale" value="exactfit" /><param name="src" value="http://resource.sulhansetiawan.com/swf/MXLED-2.swf" /><embed type="application/x-shockwave-flash" width="494" height="178" src="http://resource.sulhansetiawan.com/swf/MXLED-2.swf" menu="false" scale="exactfit" quality="medium"></embed></object></p><p>In the example in <a href="http://sulhansetiawan.com/menampilkan-gambar-pada-led-matriks-menggunakan-simulator">Showing images on LED matrix using simulator</a>, the note is displayed as an image. First we create a text image, then we create a constant from the text image. After that it displayed as an image.</p><p>Displaying text in this way is only appropriate if the text to be displayed is short. In addition, the displayed text will not be changed anymore. If the note to be displayed is a long text, or text that is displayed will be changed, then there is a better way than that way.</p><p>A better way is as follows: First, we create a character constant. In the example here, we make a character constant of 8 rows x 5 columns character size. The character constant was created using Karakter.bmp that you can edit to fit your desires.</p><p>Once we get a constant character, by compile the Karakter.bmp using <a title="ImgTable.zip" href="http://sulhansetiawan.com/mikrokontroler/ImgTable.zip"><strong>ImgTable.exe</strong></a>, then every time we will display the text, we do it by reading the text character-by-character. Each character is read, then displayed by looking at the character table. In this way, we can display any article and can be changed while the program is running. Of course you have to create a procedure to change the text to be displayed if you want to replace it.</p><p>Unfortunately <a title="the program listing" href="http://sulhansetiawan.com/microsource/RunningText.zip"><strong>the program listing</strong></a> only writen in assembly language. So, if you prefer to use the C language, please do the conversion yourself <img src='http://www.sulhansetiawan.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p>If you want to try the example program using MXLED, do the simulator settings as in <a href="http://sulhansetiawan.com/menampilkan-gambar-pada-led-matriks-menggunakan-simulator">Showing images on LED matrix using simulator</a></p><p>Good luck <img src='http://www.sulhansetiawan.com/wp-includes/images/smilies/icon_exclaim.gif' alt=':!:' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://www.sulhansetiawan.com/teks-berjalan-pada-matriks-led/feed</wfw:commentRss> <slash:comments>64</slash:comments> </item> <item><title>Microcontroller tutorial</title><link>http://www.sulhansetiawan.com/tutorial-belajar-mikrokontroler</link> <comments>http://www.sulhansetiawan.com/tutorial-belajar-mikrokontroler#comments</comments> <pubDate>Fri, 20 Feb 2009 13:55:31 +0000</pubDate> <dc:creator>Sexytaris</dc:creator> <category><![CDATA[Microcontroller books]]></category> <category><![CDATA[All]]></category> <category><![CDATA[Microcontroller Learning]]></category> <category><![CDATA[Microcontroller]]></category><guid isPermaLink="false">http://sulhansetiawan.com/?p=564</guid> <description><![CDATA[Compared to some time ago, now the microcontroller chips price is relatively inexpensive. Even to simply make the running lights, microcontroller electable. But apparently cheap price does not necessarily make the fans of electronics using a microcontroller in the design. Instead of nothing, but because they can not programm it! What trick to use? It [...]]]></description> <content:encoded><![CDATA[<p>Compared to some time ago, now the microcontroller chips price is relatively inexpensive. Even to simply make the running lights, microcontroller electable. But apparently cheap price does not necessarily make the fans of electronics using a microcontroller in the design. Instead of nothing, but because they can not programm it!</p><h4>What trick to use?</h4><p>It must be admitted that designing microcontroller based system does require a fairly complex science base. So many people give up before trying. They were puzzled by a vicious cycle, where to start?</p><p>Importantly, you need lots of practice, both theory and practice. Therefore, you should first prepare the tools and materials, ie minimal microcontroller system (consisting of a microcontroller chip, resistors, capacitors, and crystals), downloader, and Integrated System Environment (IDE).</p><p>The components you can buy in electronics stores. Downloader you can make yourself or buy. IDE you can get <a title="IDE mikrokontroler" href="http://sulhansetiawan.com/category/mikrokontroler/integrated-development-environment">here</a>. Do not forget, have the <a title="Easy and Fun Learning Microcontroller" href="http://sulhansetiawan.com/mudah-dan-menyenangkan-belajar-mikrokontroler">Easy and Fun Learning Microcontroller</a> book beside you <img src='http://www.sulhansetiawan.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /></p><p>Indeed, to be an expert, it took quite a long time. But, to only to be able to use a microcontroller, one or two days is enough! Start with the simplest, gradually continue to rise to complex. Later, if you feel stuck facing a complicated problem, make the problem becomes simple. If you are facing a big problem, make the problem becomes small. If you encounter a difficult chapter, do not force yourself. Believe me, another time you can certainly understand it.</p><h4>What microcontroller to use?</h4><p>Once you master one type of microcontroller, it will be easy for you to move to other types of microcontrollers. So, no matter what microcontroller to use, but its programming techniques.</p><p>AT89S51 or AT89S2051 from MCS-51 family can be a good choice. This easy-cost microcontroller-rousing. You will not be too sad if you make it destroyed. Instead, you&#8217;ll be very happy if you can master the science of microcontroller with low-cost.</p><h4>What language to use?</h4><p>There are many choices of programming languages. There are suggestion to use high-level programming language first, such as Basic, Pascal, C, and others. However, the best programming language that will really make you understand the microcontroller is the assembly that this language requires you to make the instructions carefully.</p><p>Happy learning!</p> ]]></content:encoded> <wfw:commentRss>http://www.sulhansetiawan.com/tutorial-belajar-mikrokontroler/feed</wfw:commentRss> <slash:comments>51</slash:comments> </item> <item><title>Questions about &#8220;Mudah dan Menyenangkan Belajar Mikrokontroler&#8221; book</title><link>http://www.sulhansetiawan.com/pertanyaan-seputar-buku-mudah-dan-menyenangkan-belajar-mikrokontroler</link> <comments>http://www.sulhansetiawan.com/pertanyaan-seputar-buku-mudah-dan-menyenangkan-belajar-mikrokontroler#comments</comments> <pubDate>Sat, 31 Jan 2009 23:47:50 +0000</pubDate> <dc:creator>Sulhan</dc:creator> <category><![CDATA[Microcontroller books]]></category> <category><![CDATA[All]]></category> <category><![CDATA[Microcontroller Learning]]></category> <category><![CDATA[Microcontroller]]></category><guid isPermaLink="false">http://sulhansetiawan.com/?p=469</guid> <description><![CDATA[A book reader Mudah dan Menyenangkan Belajar Mikrokontroler asked as follows: In the program listing of digital clock with button (p. 91), please explain more about the use and calculation of Timer 0 Mode 2 so as to produce an accurate timer of 1 second. Please explain more about the workings of the listing of [...]]]></description> <content:encoded><![CDATA[<p style="text-align: center;"><a href="http://resource.sulhansetiawan.com/img/BkMdhMnynangknTnyKnp.jpg"><img class="aligncenter" title="BkMdhMnynangknTnyKnp" src="http://resource.sulhansetiawan.com/img/BkMdhMnynangknTnyKnp.jpg" alt="" width="73" height="97" /></a></p><p>A book reader <a title="Mudah dan Menyenangkan Belajar Mikrokontroler" href="http://www.sulhansetiawan.com/buku/mudah-dan-menyenangkan-belajar-mikrokontroler/">Mudah dan Menyenangkan Belajar Mikrokontroler</a> asked as follows:</p><p><a name="Top"></a></p><ol style="text-align: justify;"><li style="text-align: justify;"><a href="#1">In the program listing of digital clock with button (p. 91), please explain more about the use and calculation of Timer 0 Mode 2 so as to produce an accurate timer of 1 second.</a></li><li style="text-align: justify;"><a href="#2">Please explain more about the workings of the listing of button data retrieval (p. 119).</a></li><li style="text-align: justify;"><a href="#3">How do I use a variable declaration in listing with <span class='notrnaslate'>*.M51</span> extension such: <span class='notrnaslate'>~byte, ~bit, ~word, and ~array?</span></a></li><li style="text-align: justify;"><a href="#4">How to use the tool: <span class='notrnaslate'>Virtual LCD, Tombol, MXLED</span>, in the simulator?</a></li><li style="text-align: justify;"><a href="#5">Well, the next question may not relate to the book, but still about a microcontroller. How to make one button so it has two functions? For example we put the button at P3.0. If pressed once it will execute subprogram A and if pressed twice it will execute subprogram B.</a></li><li style="text-align: justify;"><a href="#6">Mas, I tried to make the clock circuit on PCB and I filled it with the &#8220;debouncing 2.HEX&#8221; program. The result was running perfectly. But when the minutes or hours modifier button was pressed, the value on 7 segment did not changed directly but wait until the program completing one minutes. How to make changes instantly?</a></li></ol><p>And here&#8217;s the answer:</p><ol><a name="1"></a></p><li style="text-align: justify;"><h4>Timer 1 sec accurate.</h4><p>Actually, the information in the book is clear enough. First, the crystal used was 11.0592 MHz. Thus the speed of the machine cycle is 921.6 KHz (11.0592 MHz/12). Second, TH0 filled #0, which means timer0 interrupt will be called every 256 cycles of the machine. Remember that TH=256-interval or interval=256-TH. Thus the calling interval is 256 machine cycles.</p><p>From both the data above we can calculate the speed of the calling of timer0 interrupt is 3600Hz (921.6 KHz/256). Now, to obtain a second, we must divide this interval again by 3600. So we do this in two steps, which is divided by 225 (3600/225 = 16), then we can simply divide the result by 16 to obtain a frequency of 1Hz. However, because we need to set the frequency to 2Hz to make the blink of the point, then we do not divide by 16 but by 8.</p><p>1Hz frequency is obtained with a flip-flop which is a 2 divider. Flip-flop is obtained by using the cpl command on a flag (Bendera1Detik). Hopefully quite clear.</p><p><a href="#Top">Back to top</a></li><p><a name="2"></a></p><li style="text-align: justify;"><h4>Techniques to retrieve button data by debouncing.</h4><p>Pieces of the program will retrieve multiple keys concurrently and has been carried out debouncing. So we can use any key and do not have to worry about bounce. How to use it is just call the procedure, ie &#8220;AmbilTombol&#8221;.</p><p>After a call to this procedure, Acc will contain the button data. For example, if the button mounted on the bit0 and bit1, then after calling this procedure, A will contain 0 if no keys are pressed, 1 if the button on bit0 is pressed, 2 if the button on bit1 is pressed, and 3 if both buttons are pressed.</p><p>Of course, the resulting value depends on where the buttons are mounted. Just look at the value of bits. Bit0 is 1 and bit1 is 2. About how it happens, try to look at the included flowchart. Learn the flowchart carefully. Hopefully quite clear.</p><p><a href="#Top">Back to top</a></li><p><a name="3"></a></p><li style="text-align: justify;"><h4>Memory allocation for variables with a technique that easy to make any modification.</h4><p><span class='notrnaslate'><b>~byte, ~bit, ~word,</b></span> and <span class='notrnaslate'><b>~array</b></span> variable are the relatively easy way to set the location of memory compared with the set of memory locations in a way such as:</p><pre class='notranslate'>  Buffer  <b>equ</b> 8  <i>;4 byte</i>
  Angka   <b>equ</b> 12
  Puluhan <b>equ</b> 13
  Satuan  <b>equ</b> 14</pre><p>It would be easier if we use:</p><pre class='notranslate'>  <b>~Array</b> 4 Buffer
  <b>~byte</b> Angka Puluhan Satuan</pre><p>With the second way, we will put the <span class='notrnaslate'>Buffer</span> at location 8, the <span class='notrnaslate'>Angka</span> at 12 locations, <span class='notrnaslate'>Puluhan</span> on the location 13, and <span class='notrnaslate'>Satuan</span> on the location 14. And automatically there will be a constant that holds the highest position of the memory location that is not used. In this position should be stored for stack initiation. The constant is named SaveStack. Thus, we can initiate the stack with:</p><pre class='notranslate'>  <b>mov SP</b>,#SaveStack</pre><p>and it would have the same meaning with:</p><pre class='notranslate'>  <b>mov SP</b>,#14</pre><p>because the highest location used is 14.</p><p>If we use the first way and we want to change the memory requirement for the buffer to be only 2 bytes, we will set it to:</p><pre class='notranslate'>  Buffer  <b>equ</b> 8
  Angka   <b>equ</b> 10
  Puluhan <b>equ</b> 11
  Satuan  <b>equ</b> 12</pre><p>and the stack initiation becomes:</p><pre class='notranslate'>  <b>mov SP</b>,#12</pre><p>Well, we have to change all the numbers in its memory location setting. But if we use the second way, then we simply replace the number 4 to 2 in the <b class='notrnaslate'>~array</b> declaration such as:</p><pre class='notranslate'>  <b>~Array</b> 2 Buffer
  <b>~byte</b> Angka Puluhan Satuan</pre><p>or because the Buffer only requires 2 bytes, then we can replace it with the <b class='notrnaslate'>~word</b> type such as:</p><pre class='notranslate'>  <b>~word</b> Buffer
  <b>~byte</b> Angka Puluhan Satuan</pre><p>Note that we only change the <span class='notrnaslate'>Buffer</span> declaration and no other parts that we change.</p><p>While the variable <b class='notrnaslate'>~bit</b> is a 1-bit variable that is placed on location 20H.0 to 3FH.7.</p><p>Placement of all these variables will always find a lowest location that is still unused starting from address 8 (the default) or can be moved to a specific position using <b class='notrnaslate'>~basequ</b>.</p><p>And the explanation about this is already in the appendix of the book. Hopefully quite clear.</p><p><a href="#Top">Back to top</a></li><p><a name="4"></a></p><li style="text-align: justify;"><h4>&#8220;Virtual LCD&#8221; (LCD simulation), &#8220;MXLED&#8221; (LED Matrix simulation), and <span class='notrnaslate'>&#8220;Tombol&#8221;</span> (Button simulation using keyboard).</h4><ul><li style="text-align: justify;">&#8220;Virtual LCD&#8221; can be used for experiments that require a lot of character display. This simulation can be linked with the real circuit using a serial connection. See Chapter 19 of &#8220;Easy and Fun Learning Microcontroller&#8221;. However, these simulations can also be used from the simulator with &#8220;Link Message&#8221;. To do this, select used Com to &#8220;Message&#8221;. If data about the keyboard keystrokes are sent to the simulator via the serial communication (received in SBUF), the &#8220;Message to send&#8221; must be filled by 1035. Whereas if the data desired to be received by the port, then the &#8220;Message to send&#8221; is 1034 and &#8220;lParam to send&#8221; filled with the port number, ie 0, 1, 2, or 3. Besides, &#8220;Handle&#8221; should point to the active simulator. We can use the &#8220;Capture Handle&#8221; then click on the window of the target simulator. In addition to settings on the &#8220;Virtual LCD&#8221;, simulator port must also be adjusted. If the simulator wants to send data to the &#8220;Virtual LCD&#8221; through a serial communication simulations, the Com should use the &#8220;Message&#8221; and set &#8220;Handle&#8221; to point to the desired &#8220;Virtual LCD&#8221; with &#8220;Message to send&#8221; in the form WM_USER (1024). Meanwhile, if the simulator was about to send its data through a port, then we have to set the port to use &#8220;Link Message&#8221; directed to the &#8220;Virtual LCD&#8221;.</li><li style="text-align: justify;">&#8220;MXLED&#8221; is a LED matrix simulation. This simulation also receive data through the &#8220;Link Message&#8221; from the port settings on the simulator. Because the explanation rather long, so I put in a separate post that is in the <a href="http://www.sulhansetiawan.com/mikrokontroler/experiment/menampilkan-gambar-pada-led-matriks-menggunakan-simulator/">Showing Images on LED Matrix using Simulator.</a></li><li style="text-align: justify;">For <span class='notrnaslate'>&#8220;Tombol&#8221;</span>, if the port settings on the simulator using the &#8220;Link Message&#8221;, then the keyboard keystrokes on the <span class='notrnaslate'>&#8220;Tombol&#8221;</span> will be sent to the simulator. <span class='notrnaslate'>&#8220;Tombol&#8221;</span> itself does not require setting, because automatically it will find the current simulator.</li></ul><p><a href="#Top">Back to top</a></li><p><a name="5"></a></p><li style="text-align: justify;"><h4>One button for many functions.</h4><p>Such buttons programming requires a fairly precission timing. The first is to check whether the button is pressed or not. If yes, then the process of button detection began.</p><p>The detection of this button is basically the same as other debouncing techniques, ie wait until the button is released again, but if the button has been released does not directly assume that the button has been released. There is a minimum time so that the button has been released is really considered to has been released. If time is not reached, then the next keystrokes will still be considered as part of previous keystrokes.</p><p>Now if the button is eligible to be considered to has been released, meaning that the minimum waiting time (timeout debouncing) exceeded. Program does not directly perform a certain action but simply increase the variable that stating the number of keystrokes, then wait the next keystroke again. This is done by creating a flag stating that the program is waiting for more key presses. This waiting period we now call the &#8220;next press timeout&#8221;. If the button is pressed again before the waiting time is exceeded, then the keystroke will only increase the calculation of the amount of keystrokes. The program will only process the button press data only when &#8220;next press timeout&#8221; is exceeded.</p><p>You can download the <a title="SatuTombol.zip 3,03KB" href="http://resource.sulhansetiawan.com/microsource/SatuTombol.zip">example program</a> which is a two-digit counter 0-99. Port0 used to transmit data segment, port1 to control digits, while Port3.0 used as a button. To increase the count, we must press the button once. As for decrease the count, we must press the button twice quickly. We can also directly reach a value of 99 by pressing the button four times quickly. As for the immediate return to 0, then we must press the button three times quickly.</p><p>From this example, we can use one button for a lot of actions. But remember, if you create a program and there is a function executed by pressing the button quickly to ten times, can certainly be uncomfortable in their use <img src='http://www.sulhansetiawan.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /></p><p><a href="#Top">Back to top</a></li><p><a name="6"></a></p><li style="text-align: justify;"><h4>Revised example program of digital clock with buttons with debouncing.</em></h4><p>After I recheck, there are something missing and some were wrong. Should the <span class='notrnaslate'>MainLoop</span> structure is like:</p><pre class='notranslate'>              <b>mov   R4</b>,#NoMode     <i>;R4 =status mode</i>
   MainLoop0: <b>acall</b> IsiBuffer
   MainLoop:  <b>acall</b> AmbilTombol</pre><p>And each finished making changes to the data either minutes or hours, then the jump is toward MainLoop0 and not to the <span class='notrnaslate'>MainLoop</span>. In addition, the constants for key presses should be:</p><pre class='notranslate'>   S1ditekan   <b>equ</b>   00010000b <i>;original =00001000b</i>
   S2ditekan   <b>equ</b>   00100000b <i>;original =00010000b</i>
   S1S2ditekan <b>equ</b>   00110000b <i>;original =00011000b</i></pre><p>And the button filtering on &#8220;AmbilTombol&#8221; should:</p><pre class='notranslate'>   AmbilTombol_:
               <b>mov   A</b>,P3
               <b>cpl   a</b>            <i>;data inversion</i>
               <b>anl   A</b>,#00110000b <i>;original =00011000b</i>
               <b>ret</b></pre><p>These errors resulted in a mistaken reading of the buttons because the buttons position are at P3.4 and P3.5 instead of P3.3 and P3.4. But I have made a revised version with a little addition so that when the status mode is on ModeJam, then the hours digit will be blinking. Similarly, when the status mode is on ModeMenit, then the minutes digit will also be blinking. Thus the user knows what will happen if the button is pressed. Revised program listing can be downloaded <a title="Debouncing2rev.zip 1,53KB" href="http://resource.sulhansetiawan.com/microsource/Debouncing2rev.zip">here</a>.</p><p><a href="#Top">Back to top</a></li></ol><p>Which can be downloaded from this post:</p><ol><li><a title="SatuTombol.zip 3,03KB" href="http://resource.sulhansetiawan.com/microsource/SatuTombol.zip">Examples of one button many function programs</a></li><li><a title="Debouncing2rev.zip 1,53KB" href="http://resource.sulhansetiawan.com/microsource/Debouncing2rev.zip">&#8220;Debouncing 2&#8243; program revision</a></li></ol> ]]></content:encoded> <wfw:commentRss>http://www.sulhansetiawan.com/pertanyaan-seputar-buku-mudah-dan-menyenangkan-belajar-mikrokontroler/feed</wfw:commentRss> <slash:comments>34</slash:comments> </item> <item><title>Using MXLED.EXE for LED matrix simulation</title><link>http://www.sulhansetiawan.com/menggunakan-mxledexe-untuk-simulasi-matriks-led</link> <comments>http://www.sulhansetiawan.com/menggunakan-mxledexe-untuk-simulasi-matriks-led#comments</comments> <pubDate>Sat, 31 Jan 2009 23:37:14 +0000</pubDate> <dc:creator>Sulhan</dc:creator> <category><![CDATA[All]]></category> <category><![CDATA[Simulator]]></category> <category><![CDATA[Microcontroller Learning]]></category> <category><![CDATA[LED matrix]]></category> <category><![CDATA[Microcontroller]]></category> <category><![CDATA[Simulation]]></category><guid isPermaLink="false">http://sulhansetiawan.com/?p=467</guid> <description><![CDATA[MXLED controlled using two ports, a port as a data port and another as a control port. Both the data port and control port are received as a WM_USER message at the wParam. To determine that the received signal is a data or control, MXLED will look at the lParam. If lParam = 2, then [...]]]></description> <content:encoded><![CDATA[<p>MXLED controlled using two ports, a port as a data port and another as a control port. Both the data port and control port are received as a WM_USER message at the wParam. To determine that the received signal is a data or control, MXLED will look at the lParam. If lParam = 2, then the received signal is a signal to the data. Whereas if lParam = 1, then the received signal is a control signal.</p><p>There are six sizes provided by MXLED, ie 8 × 16, 8 × 32, 8 × 48, 16 × 16, 16 × 32, and 16 × 48. For each size there are two choices of orientation, ie landscape and portrait.</p><p>Control signals only use bit.0 and bit.1. Bit.0 used to reset the counter, while bit.1 used to increase the counter.</p><p>Data signal used to determine which LED where lit and LED where off. For each time, there were only eight LED that are controlled, which LED on the current column. To determine which columns is active, we use a counter. At the time counter is reset, then the column 0 is active. then if we provide the clock signal, the signal on bit.1, then the active column will move to column 1. Then if given the clock signal again, the active column will be column 2. and so on.</p><p>There are two choices of the clock signal, ie the L to H transition or the H to L transition.</p><p>The arrangement of the columns of LEDs depends on the size and orientation. For landscape orientation, then the left column is a lower column and the right column is a higher column. This applies to the size of 8x. As for the size of 16x, then the LED array is divided into two blocks of rows. The first column number of the second row block is the column number of the last column of the first row block plus 1.</p><p>More details are as follows:</p><pre class='notrnaslate'>16 x 16

Row 0..7 : 0  1  2  ......15

Row 8..15: 16 17 18 ......31

16 x 32

Row 0..7 : 0  1  2  ......31

Row 8..15: 32 33 34 ......63

16 x 48

Row 0..7 : 0  1  2  ......47

Row 8..15: 48 49 50 ......95
</pre><p>For each block row, bit.0 will control the LED at the top, while bit.7 will control the LED at the bottom.</p><p>For portrait orientation, we divide the LED into a column or a block of columns and rows. Counter will determine which row is active. Top row is row 0, and will be active if the reset signal is activated. The active row increase along with the clock signal acquisition.</p><p>For the 8x size, column 0 is the leftmost column and activated by bit.0. Whereas column 7 is the rightmost column and activated by bit.7</p><p>Rule for the 16x size could be analogous to the position of landscape orientation.</p><p>MXLED simulated on the system to work like a real matrix. If we managed to change the active row or column  slowly, then it can be seen only eight moving lights jumping around. However, if the changes is fast enough, then the lit changes of the LED will be seen steady not blinking. So the simulation MXLED will feel like a real LED matrix.</p><p>You can see examples of the use of this MXLED in the example <a href="http://www.sulhansetiawan.com/menampilkan-gambar-pada-led-matriks-menggunakan-simulator">Showing Images on LED Matrix using Simulator</a></p></p> ]]></content:encoded> <wfw:commentRss>http://www.sulhansetiawan.com/menggunakan-mxledexe-untuk-simulasi-matriks-led/feed</wfw:commentRss> <slash:comments>35</slash:comments> </item> <item><title>Showing Images on LED Matrix using Simulator</title><link>http://www.sulhansetiawan.com/menampilkan-gambar-pada-led-matriks-menggunakan-simulator</link> <comments>http://www.sulhansetiawan.com/menampilkan-gambar-pada-led-matriks-menggunakan-simulator#comments</comments> <pubDate>Tue, 04 Nov 2008 06:59:46 +0000</pubDate> <dc:creator>Sulhan</dc:creator> <category><![CDATA[Experiments]]></category> <category><![CDATA[All]]></category> <category><![CDATA[Microcontroller Learning]]></category> <category><![CDATA[LED matrix]]></category> <category><![CDATA[Microcontroller]]></category> <category><![CDATA[Moving Sign]]></category> <category><![CDATA[Simulation]]></category><guid isPermaLink="false">http://sulhansetiawan.com/?p=257</guid> <description><![CDATA[Controlling the LED matrix is actually almost the same as controlling seven segment. The difference is that the LEDs of seven segment are organized into seven sections which could form the figures. While the LED matrix, LEDs are arranged into a matrix that can be referenced by column and row. The columns on the LED [...]]]></description> <content:encoded><![CDATA[<p style="text-align: center;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="494" height="178" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="menu" value="false" /><param name="quality" value="high" /><param name="src" value="http://resource.sulhansetiawan.com/swf/MXLED.swf" /><param name="vspace" value="10" /><param name="hspace" value="10" /><embed type="application/x-shockwave-flash" width="494" height="178" src="http://resource.sulhansetiawan.com/swf/MXLED.swf" hspace="10" vspace="10" quality="high" menu="false"></embed></object></p><p>Controlling the LED matrix is actually almost the same as controlling seven segment. The difference is that the LEDs of seven segment are organized into seven sections which could form the figures. While the LED matrix, LEDs are arranged into a matrix that can be referenced by column and row. The columns on the LED matrix can be equated with the digits on the seven segment. While the lines on the LED matrix can be equated with LED a through LED g plus a decimal point LED on seven segment. Thus between the seven segment and LED matrix is basically the same, especially if the number of rows are only eight.</p><p>Then how to display images on the LED matrix? Yes basically the same as displaying the numbers on the seven segment. If you are already familiar with how to display data on the seven segment display using the buffer as is done in discussion about seven segment in the <strong><a title="Easy and Fun Learning Microcontroller" href="http://www.sulhansetiawan.com/mudah-dan-menyenangkan-belajar-mikrokontroler/">Easy and Fun Learning Microcontroller</a></strong> book, in which to display data on the seven segment, all we have to do is fill the display buffers, then to display image on the LED matrix, all we need to do is also just fill data on corresponding display buffers.</p><p>In the picture above, the size of the LED matrix that we use is 8 rows x 32 columns. This size is equivalent to seven segment which the number of digits are 32 digits. Thus basically we need a total of 32 bytes of display buffers. The LEDs on the top line we associate with bit 0 of port and successively LEDs on the lines below to bit 1, bit 2, and so on until bit 7. To make a LED lit on a particular line, then we need only fill the correlated bits with 0 or 1 depending on the configuration of the matrix that we use, active low or active high. For ease of understanding, we usually use active high so to lit the LED on the top line then we have to make the bit 0 to has the value of 1.</p><p>As an example, consider the logo below. The logo size is 32 x 32. Therefore, the logo may not be displayed on the LED matrix with the size of 32 x 8 at once. To display it, we have to split the logo into four parts. After that we have to show four parts one by one.</p><p>To the left of the logo there is a number from 0 to 7 and repeated up to four times. While above the logo are the numbers from 0 to 31. These figures will show us how to display the parts of the logo on the LED matrix. The figure above the logo shows the buffer index, while the figure at left of the logo shows the bit position. Thus, to show the first part of the logo (the top), then the buffer [0] must be filled with data 11111111b, buffer [1] = 00000001b, buffer [10] = 00011001b, and so on.</p><pre style="TEXT-ALIGN: center" class='notranslate'>  0.        1.        2.        3.
  01234567890123456789012345678901<span style="color:red;">
0 ©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©
1 © .............................©
2 ©..........©©©©..©©©©..........©
3 ©........©©©©©©..©©©©©©........©
4 ©......©©©©©©©©..©©©©©©©©......©
5 ©.....©©©©...©©..©©...©©©©.....©
6 ©....©©©.....©©..©©.....©©©....©
7 ©...©©©......©©..©©......©©©...©</span><span style="color:brown;">
0 ©..©©©.......©©..©©.......©©©..©
1 ©..©©........©©..©©........©©..©
2 ©.©©©............©©............©
3 ©.©©.............©©............©
4 ©.©©©©©©©©©©©©©..©©©©©©©©©©©©©.©
5 ©.©©©©©©©©©©©©©..©©©©©©©©©©©©©.©
6 ©............©©.............©©.©
7 ©............©©............©©©.©</span><span style="color:green;">
0 ©..©©........©©..©©........©©..©
1 ©..©©©.......©©..©©.......©©©..©
2 ©...©©©......©©..©©......©©©...©
3 ©....©©©.....©©..©©.....©©©....©
4 ©.....©©©©...©©..©©...©©©©.....©
5 ©......©©©©©©©©..©©©©©©©©......©
6 ©........©©©©©©..©©©©©©........©
7 ©..........©©©©..©©©©..........©</span><span style="color:blue;">
0 ©..............................©
1 ©..©©©.©..©..©©..©...©.©..©©©©.©
2 ©.©....©..©.©..©.©©..©.©.©.....©
3 ©.©....©©©©.©©©©.©.©.©....©©©..©
4 ©.©....©..©.©..©.©..©©.......©.©
5 ©..©©©.©..©.©..©.©...©...©©©©..©
6 ©..............................©
7 ©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©©</span>
The Logo.</pre><p>To be able to fill these data to the buffer with ease, then we can create an image data table. This technique is similar to how to show the variation of Running LED on exercise 5 of the <strong><a title="Easy and Fun Learning Microcontroller" href="http://www.sulhansetiawan.com/mudah-dan-menyenangkan-belajar-mikrokontroler/">Easy and Fun Learning Microcontroller</a></strong> book or on the <strong><a title="Running LED simulation on Microcontroller" href="http://www.sulhansetiawan.com/simulasi-led">LED Simulation</a></strong> article. Each image table has the same size with the size of the buffer. And for the case of the logo above, we need four 32 bytes size image tables.</p><p>Like on the Running LED exercise, the work of preparing the table is a tedious job and requires precision. But you should not be discouraged if you want to make the table of the large and complicated image because you can use the aid program <a title="ImgTable.zip" href="http://resource.sulhansetiawan.com/mikrokontroler/ImgTable.zip"><strong>ImgTable.exe</strong></a>. The program will help you to convert bmp format images into an image table that we can use it in the program using either the M51 format or using the SDCC format. So to get an image table, you simply create an image using MSPaint, and then do the conversion using ImgTable.exe.</p><p>ImgTable.exe can do the conversion from bmp file with a monochrome format up to 24 bits format. But because the table will be used to lit the LED which of course is equivalent to a monochrome format, the 24 bits format would be first converted by ImgTable.exe into the monochrome format. Therefore, it is better if you save the images you create with monochrome format to save on file size.</p><p>Rules applied by ImgTable is that the pixels that are black will be converted into 1, while the white pixels into 0. For colors other than black and white, then the three basic color elements will be summed first, then divided by three. After that, if the value is closer to the black will be interpreted as black, and if it is closer to white will be interpreted as white.</p><p>Table creation sequence is from left to right and from top to bottom. From top to bottom means every eight pixels will be taken as one byte. For example, an image with a size of 32 x 32, it will be four tables with the size of 32 bytes. The first table stores the data of the coordinates (0,0) to (31,7) by the rule that the upper left pixel is (0,0) and the lower right pixel is (31.31). The second table is (0,8) to (31,15). So forth.</p><p>In this example, all tables store the entire image data appropriately because the high of the image size is a multiples of eight. If the size of the image is not a multiples of eight, then the final table will have the remaining bits. For example if the image size is 32 (width) x 33 (height), then the number of tables are five tables with size of 32 bytes. And the last table only use bit 0. While bit 1 to bit 7 will be filled with 0.</p><p>Return to the LED matrix, we must display the four parts of the logo one by one. But if we display them alternately, then the shape of the logo will not be seen clearly. We will only see the incomplete images that appear alternately. Therefore we have to show by shifting it up or down. However, we have created tables that contains the data of the image blocks. So we can not retrieve data from the image coordinates (0,1) to (31,8) directly. For that, we need one more buffer with the same size as the first buffer. If we call the first buffer as the display buffer, then we call the second buffer as hidden buffer because it was not for displaying data to the LED matrix. This buffer is only used as an aid in manipulating the display data.</p><p>In case we want to shift the image up, then we can describe the arrangement as if the buffer is as follows:</p><pre style="TEXT-ALIGN: center" class='notranslate'>01245...
abcde...
Numbers = the display buffer, alfabets = hidden buffer.</pre><p>The first time, we fill the display buffer with data 0, so that all the LEDs will be turned off. Then we put the first image block table on hidden buffer. After that do a bit shifting between a and 0, b and 1, c and 2, and so on. Do these shifts of up to eight times, which means that all parts of the image block has been on display buffer. And before doing the ninth shift, we must place the second image block into the hidden buffer. And the next step is an iteration of the previous step.</p><p>For more details, you can see the <strong><a title="LedMatriks.zip" href="http://resource.sulhansetiawan.com/microsource/LedMatriks.zip">program listing</a></strong> for the demo above that is written in the format of M51 and c. In the listing, there is DelayTime constants that you can replace to change the speed of picture motions.</p><p>To try on the simulator, then you must set the port link so that both Port0 and Port1 are linked to MXLED.exe by the message link with the WM_USER message, and lParam of Port0 is 2 and lParam of Port1 is 1. You also have to set the configuration of MXLED size as 8 x 32 landscape.</p><p>Happy trying and please do not hesitate to ask if there are less clear. Hopefully useful.</p> ]]></content:encoded> <wfw:commentRss>http://www.sulhansetiawan.com/menampilkan-gambar-pada-led-matriks-menggunakan-simulator/feed</wfw:commentRss> <slash:comments>102</slash:comments> </item> <item><title>3 Digits Counter</title><link>http://www.sulhansetiawan.com/counter-3-digit</link> <comments>http://www.sulhansetiawan.com/counter-3-digit#comments</comments> <pubDate>Mon, 22 Sep 2008 03:27:44 +0000</pubDate> <dc:creator>Sulhan</dc:creator> <category><![CDATA[Experiments]]></category> <category><![CDATA[Microcontroller]]></category> <category><![CDATA[All]]></category> <category><![CDATA[Microcontroller Learning]]></category> <category><![CDATA[Counter]]></category><guid isPermaLink="false">http://sulhansetiawan.com/?p=224</guid> <description><![CDATA[A friend asked me for help to create a program to perform calculations that can go up or down. The data displayed on a three-digit seven segment. Meanwhile, the buttons mounted on the port 3 used to raise or lower the count. Actually, he asked me to place the digits control using P0, and P2 [...]]]></description> <content:encoded><![CDATA[<p>A friend asked me for help to create a program to perform calculations that can go up or down. The data displayed on a three-digit seven segment. Meanwhile, the buttons mounted on the port 3 used to raise or lower the count.</p><p>Actually, he asked me to place the digits control using P0, and P2 for segment data. However, because previously I had made the program with P0 as the control of digits and P1 for segment data, so that I don&#8217;t need to reconfigure when I tried on the simulator, I keep using P0 as the control of digits and P1 for segment data. Therefore if you have already used P0 as the control of digits and P1 for segment data, then you need to change the PortDigit and PortData constants at the top of the program.</p><p>To realize the friend request, I use the way I usually do if I want to display data on the seven segment, i.e. put seven segment manager procedure on the timer interrupt. This ensures our programs to be able to display data on the seven segment with good brightness. There are several examples of programs that put the seven segment scanning process in the main program. But we know that the seven segment which installed in a multiplex must continuously scanned to be able to display the data. If the program are less keen in doing the scanning, then the display will be disturbed. Probably will not light up, and this is the worst, or at least the light intensity of the seven segment will be dimmed. And it is very unpleasant. By using a timer interrupt to do the scanning, we can relieve our attention from the scanning process, because it has been fully handled the interrupt handler. So this way is the best way (at least I think so, you may leave a comment if you do not agree).</p><p>Then, because the program is indeed a very simple program, then we can use all facilities owned by the microcontroller without much consideration. For easier handling in counter addition or subtraction, we can use the external interrupts, i.e. ext0 and ext1. So we just attach the button at P3.2 (ext0) and P3.3 (ext1). Of course we must use the button that really bounce-free (bounceless), so that if we press the button once, then we also get only one count. To raise the count, we use ext0. As for lowering the count, we use ext1. In the main program, we do not even do anything.</p><p>Using interrupts to handle button is very simple in terms of response. But the drawback is that the button used should be a bounceless type. In addition, only P3.2 and P3.3 can be used. Therefore, using debouncing technique as I have discussed in the <a title="Mudah dan Menyenangkan Belajar Mikrokontroler" href="http://www.sulhansetiawan.com/mudah-dan-menyenangkan-belajar-mikrokontroler"><strong>Easy and Fun Learning Microcontroller</strong></a> book will probably be a better solution in handling button. For that, I also will feature a program that handles the button not on the external interrupt, but placed on the timer interrupt. Thus, in addition to the timer interrupt is used to perform seven segment scanning is also used for button scanning.</p><p>In scanning through the timer interrupt, we can use any button, does not have to use the bounceless. We just need to adjust how quickly button bounce will be addressed. To try it, you can change the value MaxWait to 255 to slow down the response of the button bounce. If you use a simulator, and a computer that used is quite a fast computer, it may be the key response is still too fast. You simply change the TimeOutDown and TimeOutUp type to be <span style="color: #800000;">unsigned int</span>, and change the MaxWait value to higher rates. After that, try to press the button on Tombol.exe with high frequency. You will find that if the button is pressed too quickly, then presses the button too fast will be considered as a bounce. Thus, we can use the buttons that are not really bounce free. All you need to do is adjusting how sensitive your buttons, i.e. by setting the MaxWait value. And generally, you will not use numbers higher than 255. Therefore, the data type I use is <span style="color: #800000;">unsigned char</span>.</p><p>Remember, if you use Tombol.exe as simulated buttons, then you must set the used port (in this case is P3) on the simulator to be linked in <strong>Link Message</strong>. This is necessary because Tombol.exe send the keystrokes signals to the simulator through Window Message. As for the program that handles button via the external interrupts, then you can not use Tombol.exe, because Tombol.exe could not provide an interrupt signal to the simulator. You must use the existing buttons on the simulator. To display this button port window is from the <strong>View-Port</strong> menu. Then from the window, double-click on the desired port, which is the name of the port, not on its value, because if you double-click on the value, then it will appear the dialog to change the value of the port or the relevant registers.</p><p>Another friend asked me, &#8220;How do I create a program that constantly monitor keystrokes, but other operations continue to run without being interrupted by the oversight of the key&#8221;. Well, two examples of the above program, whether using an external interrupt and those that use the button scanning on the timer interrupt, has conducted monitoring of key presses continuously, while at the main program does not even do anything. Thus, the above example is also an answer to this question. You simply put the other operations in the main program, while the supervision of the button has been continuously monitored.</p><p><strong><a title="Counter3Digit.zip" href="http://resource.sulhansetiawan.com/microsource/Counter3Digit.zip">I wrote the program in c and M51 language only</a></strong>. So if you just have a Micro v5.4, which is the IDE that I include in the <strong><a title="Mudah dan Menyenangkan Belajar Mikrokontroler" href="http://www.sulhansetiawan.com/mudah-dan-menyenangkan-belajar-mikrokontroler">Easy and Fun Learning Microcontroller</a></strong> book, then you should first download the <strong><a title="Microcontroller Project" href="http://www.sulhansetiawan.com/microcontroller-project#download">latest version of the IDE that supports the C language.</a></strong></p><p>Happy trying, hopefully useful.</p><div id="download" class="wp-caption aligncenter" style="width: 97px"><a href="http://resource.sulhansetiawan.com/microsource/Counter3Digit.zip"><img class="  " title="Source" src="http://resource.sulhansetiawan.com/img/download.gif" alt="Source" width="87" height="30" /></a><p class="wp-caption-text">Source</p></div> ]]></content:encoded> <wfw:commentRss>http://www.sulhansetiawan.com/counter-3-digit/feed</wfw:commentRss> <slash:comments>14</slash:comments> </item> <item><title>Seven segment simulation for digital clock program with hours-minutes-seconds display</title><link>http://www.sulhansetiawan.com/simulasi-seven-segment-untuk-program-jam-digital-dengan-tampilan-jam-menit-detik</link> <comments>http://www.sulhansetiawan.com/simulasi-seven-segment-untuk-program-jam-digital-dengan-tampilan-jam-menit-detik#comments</comments> <pubDate>Mon, 22 Sep 2008 03:25:41 +0000</pubDate> <dc:creator>Sulhan</dc:creator> <category><![CDATA[Experiments]]></category> <category><![CDATA[All]]></category> <category><![CDATA[Microcontroller Learning]]></category> <category><![CDATA[Digital Clock]]></category> <category><![CDATA[Microcontroller]]></category> <category><![CDATA[Seven Segment]]></category> <category><![CDATA[Simulation]]></category><guid isPermaLink="false">http://sulhansetiawan.com/?p=222</guid> <description><![CDATA[Seven Segment is one of the most common components used primarily to display data in the form of numbers. For that, Microcontroller Project also provides a simulation for seven segment, namely SSLED.exe. Seven segment simulation provided by the SSLED.exe has eight-digit in multiplex manner. Multiplex technique is the most commonly used because of its compact [...]]]></description> <content:encoded><![CDATA[<p style="TEXT-ALIGN: center"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="339" height="159" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="menu" value="false" /><param name="quality" value="high" /><param name="scale" value="exactfit" /><param name="src" value="http://resource.sulhansetiawan.com/swf/SSLED.swf" /><embed type="application/x-shockwave-flash" width="339" height="159" src="http://resource.sulhansetiawan.com/swf/SSLED.swf" menu="false" scale="exactfit" quality="high"></embed></object></p><p>Seven Segment is one of the most common components used primarily to display data in the form of numbers. For that, <strong><a title="Micro Project Versi Terbaru" href="http://www.sulhansetiawan.com/microcontroller-project">Microcontroller Project</a></strong> also provides a simulation for seven segment, namely SSLED.exe.</p><p>Seven segment simulation provided by the SSLED.exe has eight-digit in multiplex manner. Multiplex technique is the most commonly used because of its compact wiring and requires only a few ports to control it. How to control the seven segment arranged in multiplex is by dividing two kinds of line, i.e. the data line and digits control line. Data line is used to determine which LED are lit, while the digits controller line is used to set which digits are lit.</p><p>Data line and digits control line of SSLED.exe received using window message as WM_USER. If lParam is 1, then the received signal will be considered as a signal for digits control line. Whereas if the lParam value is 2, then the received signal will be considered as a signal for the data line.</p><p>On the data line, bit 0 will be used for LED a, bit 1 to turn on the LED b, and so on until bit 6 to turn on the LED g. While the bit 7 is used to lit the decimal point LED. If a bit is 1, then the corresponding LED will lit. This would fit with the common cathode type. However, we can also reverse the data so that if the data sent value is FF, then the data would be considered 00. This capability is useful for adjustment with seven segment types to be used.</p><p>SSLED.exe provides two ways of controlling the digits, i.e. the parallel way and the counter way. In the parallel way, each digit can be individually activated depending on the bit of the line controller. Bit 0 in the line controller will control the rightmost digit and bit 7 will control the leftmost digit. If a bit is 1, then the corresponding digits will be active. And just as in the data line, the line controller digits can also be reversed.</p><p>In counter mode, only bit 0 and bit 1 in the line controller digit is used. Bit 0 is used to reset the counter, so the active digit will be the rightmost digit. While the bit 1 is used to shift the active digit to be the next left digit, or name it as raising the counter count. There are two kinds of how to raise the counter count, i.e. L to H transition or H to L transition. If we use the L to H transition, then the counter will be increased if bit 1 state changed from 0 to 1. Conversely, if the transition used are H to L, then counter would be raised if the bit condition changed from 1 to 0.</p><p>If the current digit is the leftmost digit and count raised, the active digit will return to the rightmost digit.</p><p>The picture above is an example of how simulation if operated for seven segment display digital clock program. Above program is actually a modification of the program on Interrupts chapter of the <a title="Mudah dan Menyenangkan Belajar Mikrokontroler" href="http://www.sulhansetiawan.com/buku/mudah-dan-menyenangkan-belajar-mikrokontroler/"><strong>Easy and Fun Learning Microcontroller</strong></a> book, ie on Timer.A51 program. But in the book we will try to program the actual seven segment, so we need to save money just by using four digits only. While in this simulation, we have simulated seven segment that provides eight digits. Therefore, we can show not only hours and minutes but also seconds. In fact we still have the remaining two digits. The remaining digits are used to separate hours to minutes and minutes to seconds, i.e. by displaying a (-) sign. Therefore, we need a little modification of the Timer.A51 program in order to display the seconds and the separation mark.</p><p><a title="Jam8Digit.zip" href="http://resource.sulhansetiawan.com/microsource/Jam8Digit.zip"><strong>The source code</strong></a> is written with the format of M51 and c where the data signal transmitted using P0, and the digit control signal using P1. Thus, we must set P0 to link by the Link Message with a WM_USER message, and lParam value is 2 and fill the Handle with the Handle of running SSLED.exe using Capture Handle button. Do this to P1 too. But in P1, lParam value is 1. And remember, remove the check mark on the <strong>Update Display</strong> menu on the simulator.</p><p>But keep in mind that the program is written to run on a microcontroller with a 11.592 MHz crystal. So the second change speed during the simulation may be is not correct. And its speed depends on the speed of the computer you use.</p><p>Well, interesting isn&#8217;t it? Happy trying <img src='http://www.sulhansetiawan.com/wp-includes/images/smilies/icon_exclaim.gif' alt=':!:' class='wp-smiley' /></p><div id="download" class="wp-caption aligncenter" style="width: 97px"><a href="http://resource.sulhansetiawan.com/microsource/Jam8Digit.zip"><img class="  " title="Source" src="http://resource.sulhansetiawan.com/img/download.gif" alt="Source" width="87" height="30" /></a><p class="wp-caption-text">Source</p></div> ]]></content:encoded> <wfw:commentRss>http://www.sulhansetiawan.com/simulasi-seven-segment-untuk-program-jam-digital-dengan-tampilan-jam-menit-detik/feed</wfw:commentRss> <slash:comments>98</slash:comments> </item> <item><title>Running LED simulation on Microcontroller</title><link>http://www.sulhansetiawan.com/simulasi-led</link> <comments>http://www.sulhansetiawan.com/simulasi-led#comments</comments> <pubDate>Tue, 09 Sep 2008 23:46:07 +0000</pubDate> <dc:creator>Sulhan</dc:creator> <category><![CDATA[Experiments]]></category> <category><![CDATA[All]]></category> <category><![CDATA[Microcontroller Learning]]></category> <category><![CDATA[Microcontroller]]></category> <category><![CDATA[Simulation]]></category><guid isPermaLink="false">http://sulhansetiawan.com/?p=182</guid> <description><![CDATA[Early game which is always done by people who are just learning the microcontroller is lit the LED. Although the first time we usually just turn on the LEDs moving to the right or left only, and usually things like that would be boring, but it is very important to understand how to program the [...]]]></description> <content:encoded><![CDATA[<p style="TEXT-ALIGN: center"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="217" height="115" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="menu" value="false" /><param name="quality" value="high" /><param name="scale" value="exactfit" /><param name="src" value="http://resource.sulhansetiawan.com/swf/VirLED.swf" /><embed type="application/x-shockwave-flash" width="217" height="115" src="http://resource.sulhansetiawan.com/swf/VirLED.swf" menu="false" scale="exactfit" quality="high"></embed></object></p><p>Early game which is always done by people who are just learning the microcontroller is lit the LED. Although the first time we usually just turn on the LEDs moving to the right or left only, and usually things like that would be boring, but it is very important to understand how to program the microcontroller. Besides, if we want to develop programs that not only lit the LED which is lit only shifted to the right or left, then this game could get very interesting.</p><p>For example, the LED experiment using the table ie LED5.A51 in the <a title="Mudah dan Menyenangkan Belajar Mikrokontroler" href="http://www.sulhansetiawan.com/buku/mudah-dan-menyenangkan-belajar-mikrokontroler/"><strong>Easy and Fun Learning microcontroller</strong></a> book, is a very interesting LED game. The picture above shows how the LED game if run on the simulator which is connected to VLED.</p><p>All you need to do to use VLED.exe when running simulations for LED5.A51 is connecting the P1 by Link Message with Message to be sent = WM_USER (1024), then fill Handle by Capture Handle to the running VLED.</p><p>Link setting is done by clicking the <strong>Option-Port</strong> menu of the simulator window. After that, the Port Settings window will appear. In this window, there are four tabs, the tab for Port 0 to Port 3. The contents of each tab are the same, that govern how the ports are connected. If you do not want to connect the ports anywhere, then choose None Link. Then Link Port is chosen if simulation port will be linked with the physical ports, such as parallel port or installed PPI port. Meanwhile, Link Message is used if the simulator is connected to another program via the Window Message. And the last is the Link File, that is if the port will be connected to a file.</p><p>If the Link Message selected, you must specify the Message to be sent, lParam to be sent, also Handle of the Window of the program receives the message. This parameter depends on the program that you want to link. For example, VLED received a WM_USER message, i.e. 1024. So the Message to be sent will also have to be 1024. While the lParam is not taken into account by VLED, so let it be what it is. And that should not be forgotten is to fill the Window Handle of the linked program.</p><p id="capturehandle">To fill this Handle value can be done by clicking on the <strong>Capture Handle</strong> button, then click on the program that you want to link. Remember! After you click on the Capture Handle button should not click on anything other than the program that you want to link. Because the Capture Handle will fetch the handle of any clicked after this button is clicked. If the handle filling was done, then the Caption will usually appear the words as in the linked program. For example if the linked is VLED, then it would appear the words &#8220;Virtual LED&#8221;. After that, close the Port Setting window and enjoy the simulation.</p><p>You can also see how the LEDs run on the real LED by linking Port1 using the Link Port, then fill out the Address to 378, i.e. the address for the port. And you must install the LEDs on the parallel port as shown here:</p><div class="wp-caption aligncenter" style="width: 212px"><img title="Installation of the LED display on the parallel port" src="http://resource.sulhansetiawan.com/img/LEDPortPLL.gif" alt="Installation of the LED display on the parallel port." width="202" height="313" /><p class="wp-caption-text">Installation of the LED display on the parallel port.</p></div><p>To try the program, you can <a title="LED5.zip" href="http://resource.sulhansetiawan.com/microsource/LED5.zip"><strong>download the source code</strong></a> written either using assembly language and c language. And remember! You should discard the checkmark on the <strong>Option-Update Display</strong> menu in the simulator to make the simulator run faster. LED running speed may be not the same between your computer with the animation above. The speed of simulation depends on the speed of your computer.</p><p>Happy trying.</p><div id="download" class="wp-caption aligncenter" style="width: 97px"><a href="http://resource.sulhansetiawan.com/microsource/LED5.zip"><img class="  " title="Source" src="http://resource.sulhansetiawan.com/img/download.gif" alt="Source" width="87" height="30" /></a><p class="wp-caption-text">Source</p></div> ]]></content:encoded> <wfw:commentRss>http://www.sulhansetiawan.com/simulasi-led/feed</wfw:commentRss> <slash:comments>44</slash:comments> </item> <item><title>SimulatorInDLL &#8211; MCS-51 Microcontroller Simulator</title><link>http://www.sulhansetiawan.com/simulatorindll-simulator-mikrokontroler-mcs-51</link> <comments>http://www.sulhansetiawan.com/simulatorindll-simulator-mikrokontroler-mcs-51#comments</comments> <pubDate>Sun, 31 Aug 2008 07:16:17 +0000</pubDate> <dc:creator>Sulhan</dc:creator> <category><![CDATA[All]]></category> <category><![CDATA[Simulator]]></category> <category><![CDATA[Microcontroller Learning]]></category> <category><![CDATA[Microcontroller IDE]]></category> <category><![CDATA[Microcontroller]]></category> <category><![CDATA[Simulation]]></category> <category><![CDATA[FREE! Software]]></category><guid isPermaLink="false">http://sulhansetiawan.com/?p=129</guid> <description><![CDATA[Simulator in this version is made separately from the IDE, which is made into the file &#8220;SimulatorInDLL.dll&#8221;. This way you can develop a simulator in order to work in your favor. Actually, this simulator only support assembly. But you can set limits to the simulator as if working for C. Condition, you need to know [...]]]></description> <content:encoded><![CDATA[<p>Simulator in this version is made separately from the IDE, which is made into the file &#8220;SimulatorInDLL.dll&#8221;. This way you can develop a simulator in order to work in your favor.</p><p>Actually, this simulator only support assembly. But you can set limits to the simulator as if working for C. Condition, you need to know exactly how C make a program. This is possible if you are a multi-programmer, meaning not only understand microcontroller programming, but also other programming. You also need quite understand how the SDCC works. If not, you can only use the simulator for assembly.</p><p>Wait, do not worry, although the simulator is only able to work in assembly language, but <a title="Microcontroller Project" href="http://www.sulhansetiawan.com/microcontroller-project">Microcontroller Project</a> will convert the program you are writing with SDCC into assembly. So your C program can be tested with the simulator. Well now we will discuss the use of simulators in general.</p><div class="wp-caption aligncenter" style="width: 524px"><a href="http://resource.sulhansetiawan.com/img/SimulatorMainMenu.jpg"><img title="The SimulatorInDLL main menu" src="http://resource.sulhansetiawan.com/img/SimulatorMainMenu.jpg" alt="The SimulatorInDLL main menu" width="514" height="72" /></a><p class="wp-caption-text">The SimulatorInDLL main menu</p></div><p>Seven main menu on the simulator:</p><ol style="text-align: justify;" type="1"><li><strong>Start</strong>. Of course, this menu function is to run the simulation. This menu will change to Stop if it is running, so of course serves to stop the simulation.</li><li><strong>Single Step (F7)</strong>. This menu function is to execute just one line of instructions.</li><li><strong>Step Over (F8)</strong>. The menu is almost the same as Single Step. The difference appears if the executed instruction is a call instruction. Single Step will jump to the invoked subprogram, whereas Step Over will execute subprogram to its completion.</li><li><strong>Reset</strong>. This menu serves as we hit the reset button on the microcontroller circuit. Usually when you first run the simulator, you can not run the simulation until you click on this menu. Likewise, after you make changes to options.</li><li><strong>View</strong>. This menu serves to select a window which will be displayed. i.e window of internal RAM, external RAM, Ports, SFR, and Registers.</li><li><strong>Option</strong>. Well, this really must be considered in order to optimally use the simulator.<ul style="text-align: justify;"><li><strong>External Updates</strong>. If the menu is marked with a check, then any access to external ram will cause the contents of registers in the external ram windows will automatically be updated.</li><li><strong>Update Display</strong>. If the menu is given a check mark, then every execution of the program will immediately cause all the windows updated. You should uncheck the menu if you want to see every change of the data on each program execution. But this will cause the speed of the simulation becomes much slower. So if you just want to see the final result or just want to see the work shown in the port, you should remove the check mark.</li><li><strong>Separate 4-bit binary</strong>. Well if the menu is marked with a check, then the binary number on the window of port, sfr, registers, or external ram will be split in two nibble.</li><li><strong>Com</strong>. Well this menu is very important menu if you are trying the program for serial communication. You can select COM1 through COM4 if you want any assignment to the SBUF register actually sent to the serial port on your computer. In addition you can also connect SBUF with other simulator through the window message. If you select this link, then the data loaded into the SBUF will be sent to the destination window with the data in wParam. First you must set the required parameters. The first is the handle of the target window. To fill this value, you simply click on the Capture Handle button, then point the mouse pointer to the destination window, then click on the window. Next is the Message to be sent. If the simulator window target need a WM_USER, then you simply click on the button to get the constants for the WM_USER. Likewise, if the window target want a WM_CHAR, then you simply click on the WM_CHAR button. You can use notepad to capture the character data sent via SBUF if it is a WM_CHAR message. The latter is the lParam. These parameters are not always used. This may be important if you make your own simulator and require additional information, such as if you also want your simulator to communicate directly with this simulator. You can just check the &#8220;Handle of this application&#8221; to get the handle of the running simulator. Of course this information will only be understood if you are accustomed to make a program in Windows.</li><li><strong>Thread priority</strong>. Well, you have to carefully select them. If you choose the highest priority, then all the CPU time will be spent almost just to run this simulation. So sometimes you will even be difficult to move the mouse.</li><li><strong>Port</strong>. Which is useful to set a link from P0 to P1. If you click on this menu, then you will be taken to a window to set the link of these ports. There are four options for each port link, i.e. link is none, if you don&#8217;t want to connect the port anywhere; link port, if you want to connect the port to physical ports, such as parallel port, PPI or other physical ports installed on your computer; link message, if you want to link the data on the port to the running application or to other simulators, and the last is the link file, ie if the data sent to the port will be sent to a file. Link message settings can be considered the same with the settings on COM link message.</li><li><strong>Reset Port+Com setting on close</strong>. If the menu is marked with a check, then the settings on the port and com will be returned to the &#8220;link none&#8221; state after the simulation is closed. Conversely, the setting will be stored in the registry and will be used to set the simulator when the simulator is run again.</li><li><strong>Simulation speed</strong>. This is the last menu in the Options menu. This will determine the delay of any simulated execution. Of course, this menu will only be meaningful if the Display Update menu marked with a check.</li></ul></li><li><strong>About</strong>. Which is not so important, just sometimes when we make a program, then we also want to be known. Well if you click on this menu, you&#8217;ll see the logo of my pride.</li></ol><h4>Break point</h4><p>There are times when we want to run the simulation without having to watch every step. We just want to know the circumstances of the particular line, eg state of the registers just before a subprogram return back (on the RET command). If so, you simply mark a break point on the line that you want as the cessation of the simulation. The trick, double-click on the line where you want the simulation to stop. To remove the break point, you just double click again on that line.</p><h4>Update Point</h4><p>If we want to run simulations quickly, then we must remove the check mark on the Option-Update Display menu. Unfortunately if we do, then all display at the windows will only be updated after we stop the simulation. So we can not observe the changes that occur in the registers. We can make so that at certain points, the values of registers will be updated without having to stop the simulation. Well, if this is what you want, then you can add the update point on certain line. For example on the line after a port is modified so that we can observe changes in the value of the port. The trick is to double click while pressing the Ctrl key on the line you want to add the update point.</p><div class="wp-caption aligncenter" style="width: 381px"><a href="http://resource.sulhansetiawan.com/img/Break_Update.jpg"><img title="Breakpoint and Updatepoint" src="http://resource.sulhansetiawan.com/img/Break_Update.jpg" alt="Breakpoint and Updatepoint" width="371" height="153" /></a><p class="wp-caption-text">Breakpoint (red) and Updatepoint (yellow)</p></div> ]]></content:encoded> <wfw:commentRss>http://www.sulhansetiawan.com/simulatorindll-simulator-mikrokontroler-mcs-51/feed</wfw:commentRss> <slash:comments>10</slash:comments> </item> </channel> </rss>
