tag:blogger.com,1999:blog-74811979861076113372024-02-19T13:03:35.173+07:00PIC Microcontroller NoteAddicted to electronics, microcontroller, LED Dot Matrix, Led 7-Segment, PIC Digital Clock, Digital Watch, Led Dot Matrix Clock, Led Dot Matrix Watch, GPS and other DIY projects. Short notes about my PIC Microcontroller experiments sometimes it's just a short note sometimes it's a full PIC Microcontroller Project. The information here including source code and schematic are available for FREE, please contact me if you want the source files of the schematics/PCBs.Unknownnoreply@blogger.comBlogger64125tag:blogger.com,1999:blog-7481197986107611337.post-84206779000779430092010-10-18T23:31:00.000+07:002010-10-18T23:31:13.007+07:001.5V to 5V DC-DC ConvertorI was looking for a simple solution for pumping 1.5 volts to 5 Volts. I have designed various 1.5v- 5V DC-DC Convertors by using special purpose chips. The problem was those chips are very difficult to obtain. Moreover, DC-DC Convertors are mostly required to use coil which is also difficult to get.<br />
<br />
Luckily, I found this small breakout board in a local electronics shop (NPE). It was cheap, about USD 10 and small enough to fit in watch case (in the future).<br />
The instruction is very simple, put 1.5 Volt in your will get 5V at the output.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://img294.imageshack.us/img294/8614/dcconv.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="247" src="http://img294.imageshack.us/img294/8614/dcconv.jpg" width="400" /></a></div>By using this breakout board with my <a href="http://picnote.blogspot.com/2009/05/usb-coinbutton-cell-battery-charger.html">USB battery charger</a><br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://img62.imageshack.us/img62/4758/diywatchback.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="316" src="http://img62.imageshack.us/img62/4758/diywatchback.jpg" width="400" /></a></div>Attaching this module to my digital wristwatch, then I have a working digital wristwatch. It can be charged via USB. Fully charged batter will make the watch lasts for 10-12 Hours (the display is always on). Now, it needs good case + strap. I have idea but don't have time to continue the project.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://img294.imageshack.us/img294/228/diywatch.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="265" src="http://img294.imageshack.us/img294/228/diywatch.jpg" width="400" /></a></div>I have a plan to disclose the making process and give away the PCBs. But, there are some mistakes in the PCB. The problems can be resolved via firmware. However, I think it's not good to give away the incorrect PCBs. Please wait for the good PCBs and I'll give away some.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://img27.imageshack.us/img27/9864/diywatch1.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://img27.imageshack.us/img27/9864/diywatch1.jpg" width="400" /></a></div>Punkkyhttp://www.blogger.com/profile/11700093988230742727noreply@blogger.com10tag:blogger.com,1999:blog-7481197986107611337.post-2039967480054387042010-10-18T22:47:00.000+07:002010-10-18T22:47:29.107+07:00Free Circuit Simulator SoftwareMy list of Free Circuit Simulator Software<br />
<ul><li><a href="http://picnote.blogspot.com/2009/03/multisim-analog-devices-edition-100.html">Multisim Free Version</a></li>
<li><a href="http://www.linear.com/designtools/software/">Many types of simulators from Linear Technology</a></li>
<ul><li><b><span style="font-weight: normal;"><b>LTspice IV (Switchercad)</b> is free and powerful. It features all IC chips from Linear Technology. </span></b>SwitcherCAD™ III is a fully functional Spice III simulator with enhancements and models for easing the simulation of switching regulators. This Spice is a high performance circuit simulator, integrated waveform viewer, which also includes schematic capture. Our enhancements to Spice have made simulating switching regulators extremely fast compared to normal Spice simulators. Included in this download are Spice, Macro Models for 80% of Linear Technology's switching regulators and over 200 op amp models. Furthermore, resistors, transistors and MOSFET models are included as part of this package. With this Spice simulation, viewing of the waveforms of most switching regulators can be achieved in a few minutes on a high performance PC. Also, full circuits using op amps or transistors can easily be simulated.</li>
</ul><li><b><span style="font-weight: normal;"><a href="http://www.intusoft.com/demos.htm">Intusoft ICAP4 Demos</a> : A lot of limitations</span></b></li>
</ul>Punkkyhttp://www.blogger.com/profile/11700093988230742727noreply@blogger.com3tag:blogger.com,1999:blog-7481197986107611337.post-69128699460314123792010-05-21T19:27:00.005+07:002010-06-22T22:00:38.976+07:00DIY LED Watch vs Panerai PAM 127I have completed a prototype of my LED Watch. I will post the detail about how to make it later. The watch case and strap are missing :)<br />
<span style="font-weight: bold;">Features:</span><br />
- Programmable (via ICSP)<br />
- Vintage 7-segment LEDs with slim sigments<br />
- Powered from a coin cell 3.7V Li-ion rechargeable battery<br />
- Built-in USB battery charger<br />
<br />
Size comparison between the DIY LED Watch size and a 1 Thai Baht coin.<br />
<a href="http://farm5.static.flickr.com/4056/4394730917_d7a538bb2e.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img alt="" border="0" src="http://farm5.static.flickr.com/4056/4394730917_d7a538bb2e.jpg" style="cursor: pointer; display: block; height: 333px; margin: 0px auto 10px; text-align: center; width: 500px;" /></a><br />
<br />
On my wrist with help of transparent tape :).<br />
<a href="http://img294.imageshack.us/img294/228/diywatch.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img alt="DIY Led Watch" border="0" src="http://img294.imageshack.us/img294/228/diywatch.jpg" style="cursor: pointer; display: block; height: 399px; margin: 0px auto 10px; text-align: center; width: 600px;" /></a><br />
<br />
The LED Watch prototype is on the left.<a href="http://naliganote.blogspot.com/2010/06/photo-review-panerai-pam127.html"> Panerai PAM 127</a> or the "<a href="http://naliganote.blogspot.com/2010/06/photo-review-panerai-pam127.html">Fiddy</a>" is on the right. In case that you are wondering about the strap, it is custom made from a Louis Vuitton bag.<br />
<a href="http://farm3.static.flickr.com/2715/4395498910_dcb423b0f6.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img alt="DIY LED Watch, Panerai PAM127" border="0" src="http://farm3.static.flickr.com/2715/4395498910_dcb423b0f6.jpg" style="cursor: pointer; display: block; height: 333px; margin: 0px auto 10px; text-align: center; width: 500px;" /></a><br />
<br />
Please comeback and check out for the making of DIY LED Watch later.punkkyhttp://www.blogger.com/profile/03067979175859421757noreply@blogger.com15tag:blogger.com,1999:blog-7481197986107611337.post-3678238070970202992010-01-03T16:32:00.001+07:002010-01-03T23:44:21.091+07:00Eagle negative PCB output for printing<p>To make a PCB by using Dry Film photo resist, I need the PCB layout in negative mode. However, in Eagle PCB design software, I cannot print the PCB design in negative mode directly. After a few searches, I have found a good way to get negative films of my PCB designs from Eagle PCB software and it is very easy. There are  3 steps.</p> <p>1. Click ‘CAM’ on the menu bar</p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilXeOU7xBo0ECHOvrVvm3pnnOTvHEYBcrYRJ2sei5ZxwLnRqy6_nUESB0ZTt2AlSUsMERySbHryHkzWNMAjO5qB-hNXbDgOrbjb93R8bBoQn-gDRTbZnDU03m58C1WjUf87lYOS-8J43xk/s1600-h/cam-select%5B2%5D.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="cam-select" border="0" alt="cam-select" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3uRWEkVubHk1U60Zguz36B-rmKmCba5qV3Tw0QAD-nedwpGusuz7SyrXlUwF-aYSCwo30c77ARZca3KCzQTxHCvbYiEjMZVcLIGRtUxkHXA7GekXP_mWQwkNTJY2Y6A-1tbhMjS0-mD-Z/?imgmax=800" width="232" height="124" /></a></p> <p>2. Select ‘PS_INVERTED’ as the output device and then select layers that you want to export </p> <p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGaK7zEH-NyFYQ7wP9ACvVKT3mx12WjD0CRqNFxP2USSNzYbd8t7CgQ6KdN-Fzz-Hf9ZI3T0vzbqfSuUh-uF0gyZqugWjccQnYgC-aenQzfwL4327ZwpS_HC5czzxQiVrvlJEQC92ZHBSv/s1600-h/cam-output%5B6%5D.jpg"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="cam-output" border="0" alt="cam-output" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7NmXyxjRVm95szmD830UgIrLzV3j0cT-AazlNH76prDxV6JuuOi8JsqHYQSlUtxMzBn2y0kyppwfM5PzGsQDmjZxbfmKNY-6_9tQ_VUVAxr9w7k2E_F766qrlZ6Yfwxs08nikWnhQmB62/?imgmax=800" width="404" height="312" /></a></p> <p>3. Click ‘Process Job’ and it’s done!</p> <p> </p> <p>The output is ‘yourfile.eps’ which is an encapsulated PostScript. You can use Adobe Illustrator or similar Vector based graphics applications to view/edit/print it.</p> Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7481197986107611337.post-19421181121032188672009-11-29T22:56:00.004+07:002009-11-29T23:14:22.582+07:00I'm still aliveJust to let you know that I'm still alive. I'm just too busy (with my child and paid works). However, I have done some microcontroller projects. Yes, they are clock/watch related projects. I also want to complete many projects that the concepts have been proved for example, GPS Clock, Digital Wristwatch etc.,<br /><br />By the way, I have got many friends via this blog. <br />Thank you all of you who sending me emails.Unknownnoreply@blogger.com5tag:blogger.com,1999:blog-7481197986107611337.post-83964978432873427722009-08-04T21:54:00.001+07:002009-08-04T22:27:38.949+07:00Small LED dot matrix development boardI was very busy for the past two months so this blog just didn't move. As you may know, the LED dot matrix display is my favorite device. I have designed a small development board for testing my led dot matrix related programs.<br />The schematic is as the following:<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcbC7OhjPvTzleNuCjUCbvBBm4wvqchEIWeQYj0rttre_WiWfc_nxBINSfukCbe5bx05LKNaYKqHU494bQDcweWeVGrSb1INgF3tAFdEi729RwCa5ArOIsbUcNKLPkPJlLv4zB3qechGXI/s1600-h/devboard-schematic.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 284px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcbC7OhjPvTzleNuCjUCbvBBm4wvqchEIWeQYj0rttre_WiWfc_nxBINSfukCbe5bx05LKNaYKqHU494bQDcweWeVGrSb1INgF3tAFdEi729RwCa5ArOIsbUcNKLPkPJlLv4zB3qechGXI/s400/devboard-schematic.png" border="0" alt="LED dot matrix development board Schematic "id="BLOGGER_PHOTO_ID_5366129699789648018" /></a><br /><br />The PCB is single sided so I can make it at home. Most of the components are SMD to keep small footprint of the board. The PCB size: 58.4mm x 46mm<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWDDs8KB_jbNf2HmMk4raxTNN1iHcbyskPXMo5z3cCi9LLVJ39r6iJBbDH0i21302oVtiFtrWSzsUNPmr0Tpb_dYrgaliThFJQ7n_TF4VfORpUb73UF4LAFBcRpN0MwDmTQlzj6u8BP3NW/s1600-h/devboard-pcb.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 317px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWDDs8KB_jbNf2HmMk4raxTNN1iHcbyskPXMo5z3cCi9LLVJ39r6iJBbDH0i21302oVtiFtrWSzsUNPmr0Tpb_dYrgaliThFJQ7n_TF4VfORpUb73UF4LAFBcRpN0MwDmTQlzj6u8BP3NW/s400/devboard-pcb.png" border="0" alt="LED dot matrix development board PCB"id="BLOGGER_PHOTO_ID_5366129703070330162" /></a><br /><br />Acutally, I made a PCB and installed all components but the board didn't work :p. It was working when I tested the schematic on breadboard (with through hole version of PIC16F887). I think the SMD PIC16F887 may be broken or the PCB is bad but I just don't have time to figure out the problem. I will try new PCB and PIC16F887.Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-7481197986107611337.post-36077890185776034622009-05-17T19:22:00.007+07:002009-05-17T20:59:37.368+07:00USB Coin/Button Cell Battery ChargerI have designed many small footprint PIC projects (such as, pocket watches and wristwatches) but I cannot make them really portable. To make them portable, I need small power sources. Of course, Coin Cell battery would be the smallest DC source that I can buy. The problem is that a Lithium button cell provides 3 V. which is not enough to drive my projects. I thought about using DC-DC step-up converter to boost 3 V. to 5 V. However, it's a little bit complex to add DC-DC converter to the projects. Moreover, my projects consume a lot of power as they consist of many LEDs, a button battery will not last for a day. So, I stopped my think at that point.<br /><br />Just recently, I have found a rechargeable coin cell battery at Sparkfun.com. It provides 3.7 V. at 200mAh. I don't know that my projects will work at 3.7 V. or not. But, I want to give it a try. For portability, I want to charge the battery from my computer's USB port. So, I designed a USB coin cell battery + charger breakout board. Like many simple battery charger, I use MAX 1555 as the controller of the charger.<br /><br />The schematic:<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5EpKt2SYGoiYzpZ4Fcm7Vh3Q6txB6CqtaNjZcM1v1uVbcTLiUdkf5d95HQPWPtjWI0W9IWyugZ9S9w_kSgCrmQbijRwYZgfRCrNOSWQHir_H1JAXnGx0oZwxt4iIVCqHaoQbH-AevnxrQ/s1600-h/coin-cell-usb-charger.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 265px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5EpKt2SYGoiYzpZ4Fcm7Vh3Q6txB6CqtaNjZcM1v1uVbcTLiUdkf5d95HQPWPtjWI0W9IWyugZ9S9w_kSgCrmQbijRwYZgfRCrNOSWQHir_H1JAXnGx0oZwxt4iIVCqHaoQbH-AevnxrQ/s400/coin-cell-usb-charger.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5336791600185970098" /></a><br /><br />The single sided PCB (40mm x 30mm): <br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjl6qTqERfhxdkjv9zPQznHGiXZtvQYlx4-krNSaiZ_DY1tlCGVvf7oOR3a3D2dUONzwoNkR4XXFbh5uMfvllaNx-Qspi221hrYhEbRYPciSVr0NLSATIYP9Fjpg8y4fF9AY1av98VQvyW9/s1600-h/coin-cell-usb-charger-PCB.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 297px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjl6qTqERfhxdkjv9zPQznHGiXZtvQYlx4-krNSaiZ_DY1tlCGVvf7oOR3a3D2dUONzwoNkR4XXFbh5uMfvllaNx-Qspi221hrYhEbRYPciSVr0NLSATIYP9Fjpg8y4fF9AY1av98VQvyW9/s400/coin-cell-usb-charger-PCB.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5336791601075309330" /></a><br />The LED goes off when the battery is fully charged (but the charger is still charging).<br />Please note that the schematic/PCB are just the design and I haven't made it yet. The parts are ordered and I will update when I complete the hardware.Unknownnoreply@blogger.com7tag:blogger.com,1999:blog-7481197986107611337.post-89040712432462586472009-04-14T00:52:00.002+07:002009-04-14T00:57:57.965+07:00Classic LED 7-Segment DisplaysJust recently I have been addicted to old LED displays as they are small and bright and I love the classic look. We can see them in vintage calculators and vintage led watches. However these displays consume significant amount of power, so they are not used in watches and calculators anymore. As they are replaced by LCD, these LED 7-Segment displays are not in production anymore and difficult to obtain.<br /><br />Now, I have 2 models of the classic LED 7-Segment as shown in the picture below: HP 5082-7414 from HP is on the left. It’s a 4-digit Red LED 7-Segment very nice for wristwatch. The one on the right is an 2-digit Red LED 7-Segment from an unknown maker. It can be used in a wristwatch too (with a little bit bigger case).<br /><br /><img src="http://farm4.static.flickr.com/3380/3436649902_77da598c14.jpg" alt="LED 7-Segment Display HP 5082-7414"/><br /><br />Based on my inspection, I have made symbols for these displays with Eagle 5.4.0 free version. The displays are common cathode and the symbols are below<br /><br /><img src="http://farm4.static.flickr.com/3405/3435844903_abca560980_o.png" alt="LED 7-Segment Display HP 5082-7414 schematic"/><br /><br />The PCB footprints are as the following (DIP 12)<br /><br /><img src="http://farm4.static.flickr.com/3577/3435844855_4fc385f0d7_o.png" alt="LED 7-Segment Display HP 5082-7414 PCB footprint"/><br /><br />I have made simple clocks using these displays and PIC16F887. The real thing looks much better than the photo. The displays are bright red and sun light viewable. Very COOL!!! They are on my computer desk and I love to see them very often.<br /><a href="http://www.flickr.com/photos/punkky/3436650460/" title="bubble-7-segment-clock by punkkyja, on Flickr"><img src="http://farm4.static.flickr.com/3311/3436650460_402de87fc9.jpg" width="500" height="333" alt="bubble-7-segment-clock" /></a><br /><br /><img src="http://farm4.static.flickr.com/3393/3435846397_77786908dd.jpg" alt="LED 7-Segment Display HP 5082-7414 clock"/><br /><br /><img src="http://farm4.static.flickr.com/3595/3435846077_0e247a784f.jpg" alt="LED 7-Segment Display HP 5082-7414 digital clock"/><br /><br />Each clock consumes about 0.25W (50mA, 5V) when the PIC16F887 operates at 250kHz (display refresh rate is about 61Hz). The amount of consumed current can be reduced significantly if I use some current limit resistors. But the displays will be dimmer than without resistors. I will try to use PWM for reducing the power consumption as I don’t want to put 8 resistors into my design. The schematic/PCB and firmware including source code in MikroC will be made public once I have complete all of the designs. I will even have kits for sell if my time permitted.Unknownnoreply@blogger.com16tag:blogger.com,1999:blog-7481197986107611337.post-69053218705655071572009-03-11T22:00:00.002+07:002009-03-11T22:05:25.369+07:00Setting Internal Oscillator for PIC16F627AI love to use PIC16F627A and PIC16F628 because they come with internal oscillators. That means I can make a project with lower component count (without 1 crystal and 2 load capacitors). The project setting of MikroC for using internal oscillator of the PIC16F627A shows below:<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqHCb9fGrGNzefyj41hmrwzJ6E0rlzv3zehA3Y_DRNu1dJ5b8elW2uzkoFmIcOgDhKGmb4C7Cz3TwyuMhqa85qocBcI-Y597rTe5fNTmpxtfNzrb65E7uvagTc1_GOreNH58VDA3s63xiZ/s1600-h/10sec-counter.png"><img id="BLOGGER_PHOTO_ID_5265518392280134610" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 385px; CURSOR: hand; HEIGHT: 400px; TEXT-ALIGN: center" alt="Setting MikroC for Internal Oscillator" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqHCb9fGrGNzefyj41hmrwzJ6E0rlzv3zehA3Y_DRNu1dJ5b8elW2uzkoFmIcOgDhKGmb4C7Cz3TwyuMhqa85qocBcI-Y597rTe5fNTmpxtfNzrb65E7uvagTc1_GOreNH58VDA3s63xiZ/s400/10sec-counter.png" border="0" /></a>Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-7481197986107611337.post-78464083344641834012009-03-07T15:09:00.009+07:002010-10-18T22:25:14.199+07:00Multisim Analog Devices Edition 10.0 Free DownloadI have found a good and free circuit simulator,Multisim Analog Devices Edition 10.0. As you may know that Multisim is a famous electronics circuit simulation software (circuit simulator). It's based on Electronics Workbench from the same company. I have found the free version (not the cracked version) of Multisim by chance and you may not find it on the <a href="http://www.ni.com/" target="_blank">National Instruments website</a>. It comes with a lot of measurement tools and it's very easy to use. I use it to simulate various analog circuits. The image below shows the screen shot of the simulation of DC-Boost Converter (12V to 150V step up).<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1fhpw2XRYmv0vdIW9SpPT5c90K1TdOdZaAZYJ8PLLkQiWIzF20-U9lEdsfzlncm5OvLkDcPphm0n1O50FhX3fN2LS7ZQtDaRZClLvFLzp7LbMJnBWlUafeLggTALEQdqzIMmOCB7cSRVV/s1600-h/multisim-analog.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img alt="Multisim Analog Devices Edition 10.0" border="0" id="BLOGGER_PHOTO_ID_5310355202731829762" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1fhpw2XRYmv0vdIW9SpPT5c90K1TdOdZaAZYJ8PLLkQiWIzF20-U9lEdsfzlncm5OvLkDcPphm0n1O50FhX3fN2LS7ZQtDaRZClLvFLzp7LbMJnBWlUafeLggTALEQdqzIMmOCB7cSRVV/s400/multisim-analog.png" style="cursor: pointer; display: block; height: 258px; margin: 0px auto 10px; text-align: center; width: 400px;" /></a><br />
<br />
Not only analog circuit, but it also simulates digital circuit as one may call it 'Mixed-Mode Simulator'.<br />
Some features and limitations:<br />
<ul><li>Build simulated component evaluation circuits to quickly assess behavior of over 800 Analog Devices operational amplifiers, switches and voltage references</li>
<li>Examine the unit under test in the intended circuit topology with up to 25 components</li>
<li>Use built-in instruments and analyses including oscilloscopes and worst-case analysis</li>
<li>Swap components easily to pinpoint best design options</li>
<li>Link to the Analog Devices Design Center for more online evaluation tools</li>
<li>Instantly access product pages and datasheets of each Analog Devices component</li>
<li>Upgrade to a full edition of NI Multisim to complete designs and transfer to board layout with NI Ultiboard</li>
</ul><br />
Please follow the link for <a href="http://www.analog.com/en/design-tools/dt-multisim-spice-program-download/design-center/index.html">Free Download Multisim</a> 183MBUnknownnoreply@blogger.com2tag:blogger.com,1999:blog-7481197986107611337.post-43850883687785195512009-02-20T23:06:00.004+07:002009-02-20T23:24:16.001+07:001Hz Clock Generator using PIC12F675Based on the idea from <a href="http://www.josepino.com/pic_projects/?timebase" target="_blank">http://www.josepino.com/pic_projects/?timebase</a>I have created a 1Hz Clock Generator. I use PIC12F675 as it's available locally. Its price is just about US$1.<br />The concept is using 32.768kHz crystal as a clock for the PIC. Therefor, the internal instruction clock is 32768/4 = 8192 Hz. By using the 16 bit Timer1 to count the instruction clock cycles, the interrupt will occur every 8 second. This period can be reduced by setting initial value of the Timer1 (TMR1H:TMR1L). I have to make Timer1 to count up to 8192 for generating overflow interrupt every 1 second. To make Timer1 count up to 8192, the initial value of TMR1 must be 65536-8192 = 57344 or 0xE000. This means TMR1H = 0xE0 and TMR1L = 0x00. In this case, I need to set only the TMR1H=0xE0 and let TMR1L runs continuously. By changing the initial value of Timer1, I can generate almost any frequencies.<br /><br />An application for this project is a precise 1Hz blinking LED signal :) ha ha. I know that it's not useful but I think it's fun to look at (am I crazy?). Another application is a precise 1Hz time base for a clock. <br /><br />The source code is written in MikroC.<div style="BORDER-RIGHT: black 1px dotted; BORDER-TOP: black 1px dotted; BACKGROUND: white; BORDER-LEFT: black 1px dotted; BORDER-BOTTOM: black 1px dotted; BORDER-BOTTOM-: black 1px dottedcolor:black"><font face="Monospace"><br /><font color="#808080"><i>// PIC12F675</i></font><br /><font color="#808080"><i>// 1Hz Time Base Osc.</i></font><br /><font color="#808080"><i>// Timer1 Module</i></font><br /><font color="#808080"><i>// 32.768 KHz</i></font><br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">tick</font>;<br /><font color="#800000">void</font> <font color="#000000">Init</font> ();<br /><font color="#800000">void</font> <font color="#000000">interrupt</font> ()<br />{<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">PIR1</font>.<font color="#000000">TMR1IF</font>)<br /> {<br /> <font color="#000000">TMR1H</font> = <font color="#008080">0xE0</font>;<br /> <font color="#000000">PIR1</font>.<font color="#000000">TMR1IF</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">tick</font> = <font color="#0000FF">1</font>;<br /> }<br />}<br /><font color="#800000">void</font> <font color="#000000">main</font> ()<br />{<br /> <font color="#000000">tick</font> = <font color="#0000FF">0</font>;<br /> <font color="#808080"><i>//Initialize Ports and Timer1 Module</i></font><br /> <font color="#000000">Init</font> ();<br /> <font color="#000000"><b>while</b></font> (<font color="#0000FF">1</font>)<br /> {<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">tick</font>)<br /> {<br /> <font color="#000000">tick</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">GPIO</font> = (<font color="#0000FF">1</font> << <font color="#0000FF">2</font>);<br /> }<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">TMR1H</font> > <font color="#008080">0xF0</font>)<br /> {<br /> <font color="#000000">GPIO</font> = <font color="#0000FF">0</font>;<br /> }<br /> }<br />}<br /><font color="#800000">void</font> <font color="#000000">Init</font> ()<br />{<br /> <font color="#000000">TRISIO</font> = <font color="#0000FF">0</font>;<br /> <font color="#808080"><i>//Make all pins as output ports</i></font><br /> <font color="#000000">GPIO</font> = <font color="#0000FF">0</font>;<br /> <font color="#808080"><i>//Use Timer1 module</i></font><br /> <font color="#000000">INTCON</font>.<font color="#000000">GIE</font> = <font color="#0000FF">1</font>;<br /> <font color="#000000">INTCON</font>.<font color="#000000">PEIE</font> = <font color="#0000FF">1</font>;<br /> <font color="#000000">T1CON</font> = <font color="#008080">0x01</font>;<br /> <font color="#808080"><i>//Overflow every 8192</i></font><br /> <font color="#000000">TMR1H</font> = <font color="#008080">0xE0</font>;<br /> <font color="#000000">TMR1L</font> = <font color="#008080">0x00</font>;<br /> <font color="#808080"><i>// Enable TMR1 interrupt</i></font><br /> <font color="#000000">PIE1</font>.<font color="#000000">TMR1IE</font> = <font color="#0000FF">1</font>;<br />}<br /></font><br /></div><br /><br />The schematic is as the following image.<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDwWnJR0Gs7EszC1gmZnqCsiKgAOBWdGCobxQxQRrYue1NjiUxZcSBRLoh99nbtAxzNv7ILvrM2s2EAZlEyaQZuggdEszg7j6N4lFnbSJzjHnUUHO9uJljAZ9p8uXSw_xz8BvuxGhJyXoE/s1600-h/1Hz-schematic.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 271px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDwWnJR0Gs7EszC1gmZnqCsiKgAOBWdGCobxQxQRrYue1NjiUxZcSBRLoh99nbtAxzNv7ILvrM2s2EAZlEyaQZuggdEszg7j6N4lFnbSJzjHnUUHO9uJljAZ9p8uXSw_xz8BvuxGhJyXoE/s400/1Hz-schematic.png" border="0" alt="1Hz Clock generator using PIC12F675"id="BLOGGER_PHOTO_ID_5304912761046672290" /></a><br /><br /><br />The PCB:<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYi4_SV6F5TU3q5Pxzlshi7cKf9kOIw0QwN2ObzOjbp-hqzsxLhgTFzuyDDLQMuP4arzDAXZcbnbr0areV_HswiSwlxvcTl4veqjA9RJ0pkHHpaKZwuoCQ3qLlGsh2pP-PNBORtV54wZua/s1600-h/1Hz-PCB.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 391px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYi4_SV6F5TU3q5Pxzlshi7cKf9kOIw0QwN2ObzOjbp-hqzsxLhgTFzuyDDLQMuP4arzDAXZcbnbr0areV_HswiSwlxvcTl4veqjA9RJ0pkHHpaKZwuoCQ3qLlGsh2pP-PNBORtV54wZua/s400/1Hz-PCB.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5304912758524862194" /></a><br /><br />3D version:<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgD1sr29r3bPo6blgGxOjHHIrIrRH6cwykX_BlvzU4X714NGfGqdk079ukHrk023N09k40Z22-_hMHc-TeDJvwUl6-9hw5yzoI5FHKIR61uzlE2rhPVp3w8qhq92yooRMZNVkreZLoMzJ2J/s1600-h/1Hz-3D.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 300px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgD1sr29r3bPo6blgGxOjHHIrIrRH6cwykX_BlvzU4X714NGfGqdk079ukHrk023N09k40Z22-_hMHc-TeDJvwUl6-9hw5yzoI5FHKIR61uzlE2rhPVp3w8qhq92yooRMZNVkreZLoMzJ2J/s400/1Hz-3D.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5304912763902683570" /></a>Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-7481197986107611337.post-78163763975798822312009-02-11T10:48:00.007+07:002009-02-11T22:14:31.047+07:00Transistor arrayI am looking for transistor arrays for my LED projects as I want to reduce number of components on board. After some searches, I have found that there are two candidates for current source and sink transistor arrays as the following:<br />UDN2981 : 8 channels high current source MAX 500mA<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix6-E4WfSbbOs-GDz9hukVGKUCCj8479r7zqVTs30XuQX8x7EC3xe5ytMxCKQWh1wSXHQnWpMGaqPPEtzKdvFdoGsQO3a8cjRMMybcOv8PNMuvD0Tkgv8d8lf0NkU75x6ZrBMt_0oBg0uW/s1600-h/udn2981.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 188px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix6-E4WfSbbOs-GDz9hukVGKUCCj8479r7zqVTs30XuQX8x7EC3xe5ytMxCKQWh1wSXHQnWpMGaqPPEtzKdvFdoGsQO3a8cjRMMybcOv8PNMuvD0Tkgv8d8lf0NkU75x6ZrBMt_0oBg0uW/s400/udn2981.png" border="0" alt="UDN2981 : 8 channels high current source"id="BLOGGER_PHOTO_ID_5301554844450880818" /></a><br />ULN2003 : 7 channels high current sink MAX 500mA <br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtIuNCQFi7KYBIN8XW1DQQMIBoJ-QNGnowVJdXIb1cqojhB3wM3uZVygC0c5a4HrGPTJWuyLik7nDnajnvm3Na0Eke57_Bxe2i726edODM_MZYi7z7jignzJ2SBq2XNKbZsyoaSdGcDcyr/s1600-h/uln2003.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 149px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjtIuNCQFi7KYBIN8XW1DQQMIBoJ-QNGnowVJdXIb1cqojhB3wM3uZVygC0c5a4HrGPTJWuyLik7nDnajnvm3Na0Eke57_Bxe2i726edODM_MZYi7z7jignzJ2SBq2XNKbZsyoaSdGcDcyr/s400/uln2003.png" border="0" alt="ULN2003 : 7 channels high current sink "id="BLOGGER_PHOTO_ID_5301554841179935538" /></a><br />I will use these transistor arrays for driving large 7-segment display panel , bright led dot matrix panel and other LED projects.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7481197986107611337.post-29079570323579623082009-01-25T23:42:00.004+07:002009-01-26T00:10:18.183+07:003D Electronics DesignI just found a new thing to play with, 3D Electronics Design. I have seen some great 3D images of electronics component design for sometimes but I couldn't figure how they were made. Below image is one of my favorite. Please see <a href="http://www.blueroomelectronics.com/" target="_blank">http://www.blueroomelectronics.com/</a> for more images. <br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRYzsx8hSFaZdyGaVhHF1aiCjzbwv1lASZ7dnYVKwGxGzrl-kKvVmoeP7Z-azuOnI0aLsp3duhKhYxOTbjhEcxBemUy8LpT0HEz53KHYLfkrRMwCgwD36G5Qu-gdid6duK4EatW-dw48sg/s1600-h/Dragonfly2D.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 345px; height: 165px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRYzsx8hSFaZdyGaVhHF1aiCjzbwv1lASZ7dnYVKwGxGzrl-kKvVmoeP7Z-azuOnI0aLsp3duhKhYxOTbjhEcxBemUy8LpT0HEz53KHYLfkrRMwCgwD36G5Qu-gdid6duK4EatW-dw48sg/s400/Dragonfly2D.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5295276143638871250" /></a><br />I have been playing with <a href="www.matwei.de/doku.php?id=en:eagle3d:eagle3d" target="_blank">Eagle3D</a> for sometimes. However, I cannot manipulate my design interactively and cannot export models to render in other 3D renderers. Just today, I found that blueroomelectronics's designs were made with <a href="http://sketchup.google.com/" target="_blank">Google SketchUp</a>. So, I downloaded and installed it. The software is very easy to use. But, there is no electronics component library. However, there are some components available for you to download from <a href="http://sketchup.google.com/3dwarehouse/" target="_blank">google 3D warehouse</a>. If you want anything that not available in the google 3D warehouse, you have to make it by yourself.<br />Below is my first try on making a PIC16F887 with TQFP-44 package.<br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqeixTD3GrqLQqrgoBVckWoUL4xbJLDuWm7Z8LDp62g1zzurrgxGEYzz-JC4pxUODy9U2K31cDIh55XXGsPum7JSXP4Z8QfZEaZzLQk21xNcYDlyyXVOdIfdpKj7RV52mVQdDd5QTNNHiE/s1600-h/pic16f887-qfp.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 286px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqeixTD3GrqLQqrgoBVckWoUL4xbJLDuWm7Z8LDp62g1zzurrgxGEYzz-JC4pxUODy9U2K31cDIh55XXGsPum7JSXP4Z8QfZEaZzLQk21xNcYDlyyXVOdIfdpKj7RV52mVQdDd5QTNNHiE/s400/pic16f887-qfp.png" border="0" alt="SketchUp PCB Electronics component"id="BLOGGER_PHOTO_ID_5295278847601136898" /></a><br />I hope that I will come up with complete 3D designs of my clock projects. It's very fun to do these things.Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7481197986107611337.post-49131133377965625362009-01-25T07:47:00.002+07:002009-01-25T08:19:40.202+07:00Things to doThere are requests from readers as the following:<br />1. Complete project of the <a href="http://picnote.blogspot.com/2008/06/my-gps-clock-is-up-and-running.html">GPS clock</a><br />2. Adding calendar to my <a href="http://picnote.blogspot.com/2008/11/making-digital-clock-updated.html">Digital Clock</a><br />3. Full function <a href="http://picnote.blogspot.com/2009/01/simple-clock-using-ds1307-pic16f877a.html">DS1307 Clock </a><br /><br />And my own to do list:<br />4. <a href="http://picnote.blogspot.com/2008/11/cheapest-pic-with-internal-osc-and-i2c.html">FM Radio</a> <br />5. <a href="http://picnote.blogspot.com/2008/11/small-nixie-tube.html">Nixie Clock</a><br />6. Chronograph (stop watch)<br />7. Digital clock with 7-segment multiplexing using PIC16F627a or PIC16F628 + DS1307 + DS18S20 (Clock+Thermometer)<br />8. Digital clock + radio + thermometer (PIC16F887 + DS1307 + DS18S20 + Radio chip)<br />9. Complete led dot matrix clock<br />10.16x16 Led Dot matrix displayUnknownnoreply@blogger.com0tag:blogger.com,1999:blog-7481197986107611337.post-79702262822561711042009-01-21T11:31:00.002+07:002009-01-21T11:49:52.687+07:002-digit BCD to decimal conversionNow, I'm working on the full feature clock using DS1307. In the clock, I use many BCD to decimal (bcd2dec) and decimal to BCD conversions for reading and setting time of the DS1307 RTC. MikroC provides buit-in functions for these conversions but the functions consume modest amount of MCU memory space. I have came up with simple functions that consume less memory for doing 2-digit BCD to decimal and the reverse conversions.<br /><br />2-digit BCD to Decimal conversion function:<br /><div style="BORDER-RIGHT: black 1px dotted; BORDER-TOP: black 1px dotted; BACKGROUND: white; BORDER-LEFT: black 1px dotted; BORDER-BOTTOM: black 1px dotted; BORDER-BOTTOM-: black 1px dottedcolor:black"><em>unsigned short</em> <strong>myBcd2Dec</strong>(<em>unsigned short</em> <span style="color:#cc0000;">bcd</span>){<br /><span style="color:#009900;">return</span> ((bcd >> 4)*10+(bcd & 0x0F));<br />}</div><br />Example: <strong>myBcd2Dec</strong>(01000101) = <span style="color:#ff0000;">45</span><br /><br />2-digit Decimal to BCD conversion function:<br /><div style="BORDER-RIGHT: black 1px dotted; BORDER-TOP: black 1px dotted; BACKGROUND: white; BORDER-LEFT: black 1px dotted; BORDER-BOTTOM: black 1px dotted; BORDER-BOTTOM-: black 1px dottedcolor:black"><em>unsigned short</em> <strong>myDec2Bcd</strong>(<em>unsigned short</em> <span style="color:#cc0000;">dec</span>){<br /><span style="color:#009900;">return</span> (((dec/10)<<4)(dec%10));<br />}</div><br />Example: <strong>myDec2Bcd(45)</strong> = <span style="color:#ff0000;">01000101</span>Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-7481197986107611337.post-14984880891177069672009-01-11T10:51:00.004+07:002009-01-11T12:14:14.341+07:00Square Wave output from DS1307For the clock that uses DS1307 RTC chip, I want a blinking led for indication of second. So, I have placed a resistor and an LED to pin 7 (SQW/OUT) of the DS1307 like below schematic:<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK4aXYea3lGedWuTzfx0cCfNqdVKADvj-7VH4vAfpaON-JqbBQZyAUV_GhNARgPJZffBHd2NIfQMngimgj9Nwm6uaXD_LhcNCop_ROe_2z6UcXTYiZnFp38VUUu4TvzaLmtduAWyfrj3pz/s1600-h/ds1307-square-wave-schematic.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 298px; height: 299px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK4aXYea3lGedWuTzfx0cCfNqdVKADvj-7VH4vAfpaON-JqbBQZyAUV_GhNARgPJZffBHd2NIfQMngimgj9Nwm6uaXD_LhcNCop_ROe_2z6UcXTYiZnFp38VUUu4TvzaLmtduAWyfrj3pz/s400/ds1307-square-wave-schematic.png" border="0" alt="Schematic for Square Wave Output DS1307"id="BLOGGER_PHOTO_ID_5289886857563418354" /></a> <br /><br />With this configuration (hardware+software), the LED was blinking at 1 time/second but the blink pattern was not my expectation. The LED is Off when the clock is updated and it is On at 0.5 second later. Quoted from the Control Register section of the DS1307's Datasheet:<br /><br /><div style="BORDER-RIGHT: black 1px dotted; BORDER-TOP: black 1px dotted; BACKGROUND: white; BORDER-LEFT: black 1px dotted; BORDER-BOTTOM: black 1px dotted; BORDER-BOTTOM-: black 1px dottedcolor:black">With the square wave output set to 1Hz, the clock registers update on the<span class="Apple-style-span" style="color: rgb(0, 102, 0);"> <span class="Apple-style-span" style="color: rgb(255, 0, 0);"><span class="Apple-style-span" style="font-weight: bold;">falling edge</span></span> </span>of the square wave.</div><br />I want the reverse pattern (the LED is On when the time is updated and it is Off at 0.5 second later). So, I will add an invert logic before the LED like:<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBfcJbvVzL8sOikC5LwVLPOp-v1Eik5Y3lIFq_E1RzaIrkGmvySE7oxqXk_UQXaJW7fiPo-84XUCLAZ_IfW-VnOMGv8zVAbgO4N0JFF-A_1nSds2CwBV4HPs0Ayu_G2-ofQ2We-6H71Ddk/s1600-h/ds1307-square-wave-schematic-invert.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 342px; height: 316px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBfcJbvVzL8sOikC5LwVLPOp-v1Eik5Y3lIFq_E1RzaIrkGmvySE7oxqXk_UQXaJW7fiPo-84XUCLAZ_IfW-VnOMGv8zVAbgO4N0JFF-A_1nSds2CwBV4HPs0Ayu_G2-ofQ2We-6H71Ddk/s400/ds1307-square-wave-schematic-invert.png" border="0" alt="Invert logic at the output of DS1307"id="BLOGGER_PHOTO_ID_5289896053877721938" /></a><br />I have a plan to use this square wave output of the DS1307 for generating an interrupt to instruct the MCU to read time from the DS1307 and I will keep in mind that "The clock is updated at the <span style="font-style:italic;">falling edge</span> of the square wave". The complete clock will be posted here later.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7481197986107611337.post-597831619266719132009-01-05T01:56:00.004+07:002009-01-05T02:35:41.429+07:00A Simple Clock using DS1307 + PIC16F877AEven I have posted about "<a href="http://picnote.blogspot.com/2008/06/ds1307-pic16f877a.html">DS1307 + PIC16F877A</a>", I didn't have chance to make a real prototype of the clock. I have done only on the simulation software. Today, I have received a comment about that post. ah_bear followed my code and schematic on that post but the clock didn't work. This is because the code on that post is for reading time from DS1307 so there must be some values in the DS1307 before you can read. The solution is simple. Just place setting time codes before reading codes.<br /> <br />This time, I have made a real prototype to confirm that it's working. There is no setting buttons. If you want to make a real usable clock you have to implement the button interfaces (I may make one and post it here). The photo of my working prototype is featured below. Please check out my flikr at <a href="http://flickr.com/photos/punkky/">http://flickr.com/photos/punkky/</a> for more photos.<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWGM8BZJNdaSJI5Q0Xde-aOe-9eg3xBJ74EHZC7vvA-o4iXaZTkoZoxNz3-cJEWmXEzIed2z-GCN2JckrQHJgc4fAvlsK1HvZ_D_yHEMzq6OJasfvroD5ruF-yPbwYC0xh1KIJrIfoOO5u/s1600-h/DS1307-Clock.jpg"><img id="BLOGGER_PHOTO_ID_5287514956823836466" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 266px; TEXT-ALIGN: center" alt="A simple clock using DS1307 and PIC16F877A" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWGM8BZJNdaSJI5Q0Xde-aOe-9eg3xBJ74EHZC7vvA-o4iXaZTkoZoxNz3-cJEWmXEzIed2z-GCN2JckrQHJgc4fAvlsK1HvZ_D_yHEMzq6OJasfvroD5ruF-yPbwYC0xh1KIJrIfoOO5u/s400/DS1307-Clock.jpg" border="0" /></a><br />The schematic of the clock is very simple. Please note that the schematic does not show power supply to the PIC16F877A and the DS1307, you have to connect them by youself. If you are new to PIC/LCD interface please see <a href="http://picnote.blogspot.com/2008/10/mikroc-hello-world-lcd-example.html">MikroC "Hello World!" LCD example </a>.<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBYUhxrP_AIJ_ylQ_x2uH9YGdNj5EG3tkVsL22Po0OgEZ-7gH85l3Zvdm0sZ75O89qBcyvQOkbnFmSUlWSAHtEeNbcHQWeK_jeMPDRbetnLLrZxf7wLev6pMjff2qdQGhgya4GHl5f6Rz4/s1600-h/Simple_DS1307_clock.png"><img id="BLOGGER_PHOTO_ID_5287514949850763250" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 249px; TEXT-ALIGN: center" alt="Schematic of a simple clock using DS1307 and PIC16F877A" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBYUhxrP_AIJ_ylQ_x2uH9YGdNj5EG3tkVsL22Po0OgEZ-7gH85l3Zvdm0sZ75O89qBcyvQOkbnFmSUlWSAHtEeNbcHQWeK_jeMPDRbetnLLrZxf7wLev6pMjff2qdQGhgya4GHl5f6Rz4/s400/Simple_DS1307_clock.png" border="0" /></a><br /><br />The source code:<br /><div style="BORDER-RIGHT: black 1px dotted; BORDER-TOP: black 1px dotted; BACKGROUND: white; BORDER-LEFT: black 1px dotted; BORDER-BOTTOM: black 1px dotted; BORDER-BOTTOM-: black 1px dottedcolor:black"><font face="Monospace"><font color="#808080"><i>//Sample code for</i></font><br /><font color="#808080"><i>//DS1307 RTC Interfacing with PIC16F877A</i></font><br /><font color="#808080"><i>//Coded by punkky@gmail.com</i></font><br /><font color="#808080"><i>//Compiler: mikroC 8.0.0</i></font><br /><font color="#808080"><i>//http://picnote.blogspot.com</i></font><br /><font color="#808080"><i>//05/01/2009</i></font><br /><font color="#808080"><i>//Use with your own risk</i></font><br /><br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">read_ds1307</font>(<font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">address</font> );<br /><font color="#800000">void</font> <font color="#000000">write_ds1307</font>(<font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">address</font>,<font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">w_data</font>);<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">sec</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">minute</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">hour</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">day</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">date</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">month</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">year</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">data</font>;<br /><font color="#800000">char</font> <font color="#000000">time</font>[<font color="#0000FF">9</font>];<br /><font color="#800000">char</font> <font color="#000000">ddate</font>[<font color="#0000FF">11</font>];<br /><br /><font color="#800000">unsigned</font> <font color="#800000">char</font> <font color="#000000">BCD2UpperCh</font>(<font color="#800000">unsigned</font> <font color="#800000">char</font> <font color="#000000">bcd</font>);<br /><font color="#800000">unsigned</font> <font color="#800000">char</font> <font color="#000000">BCD2LowerCh</font>(<font color="#800000">unsigned</font> <font color="#800000">char</font> <font color="#000000">bcd</font>);<br /><br /><font color="#800000">void</font> <font color="#000000">main</font>(){<br /><br /><font color="#000000">I2C_Init</font>(<font color="#0000FF">100000</font>); <font color="#808080"><i>//DS1307 I2C is running at 100KHz</i></font><br /><font color="#000000">PORTB</font> = <font color="#0000FF">0</font>;<br /><font color="#000000">TRISB</font> = <font color="#0000FF">0</font>; <font color="#808080"><i>// Configure PORTB as output</i></font><br /><font color="#000000">TRISC</font> = <font color="#008080">0xFF</font>;<br /><font color="#000000">Lcd_Init</font>(&<font color="#000000">PORTB</font>); <font color="#808080"><i>// Initialize LCD connected to PORTB</i></font><br /><font color="#000000">Lcd_Cmd</font>(<font color="#000000">Lcd_CLEAR</font>); <font color="#808080"><i>// Clear display</i></font><br /><font color="#000000">Lcd_Cmd</font>(<font color="#000000">Lcd_CURSOR_OFF</font>); <font color="#808080"><i>// Turn cursor off</i></font><br /><font color="#000000">Lcd_Out</font>(<font color="#0000FF">1</font>, <font color="#0000FF">1</font>, <font color="#FF0000">"TIME:"</font>);<br /><font color="#000000">Lcd_Out</font>(<font color="#0000FF">2</font>, <font color="#0000FF">1</font>, <font color="#FF0000">"DATE:"</font>);<br /><br /><font color="#808080"><i>//Set Time</i></font><br /><font color="#000000">write_ds1307</font>(<font color="#0000FF">0</font>,<font color="#008080">0x80</font>); <font color="#808080"><i>//Reset second to 0 sec. and stop Oscillator</i></font><br /><font color="#000000">write_ds1307</font>(<font color="#0000FF">1</font>,<font color="#008080">0x10</font>); <font color="#808080"><i>//write min 27</i></font><br /><font color="#000000">write_ds1307</font>(<font color="#0000FF">2</font>,<font color="#008080">0x01</font>); <font color="#808080"><i>//write hour 14</i></font><br /><font color="#000000">write_ds1307</font>(<font color="#0000FF">3</font>,<font color="#008080">0x02</font>); <font color="#808080"><i>//write day of week 2:Monday</i></font><br /><font color="#000000">write_ds1307</font>(<font color="#0000FF">4</font>,<font color="#008080">0x05</font>); <font color="#808080"><i>// write date 17</i></font><br /><font color="#000000">write_ds1307</font>(<font color="#0000FF">5</font>,<font color="#008080">0x01</font>); <font color="#808080"><i>// write month 6 June</i></font><br /><font color="#000000">write_ds1307</font>(<font color="#0000FF">6</font>,<font color="#008080">0x09</font>); <font color="#808080"><i>// write year 8 --> 2008</i></font><br /><font color="#000000">write_ds1307</font>(<font color="#0000FF">7</font>,<font color="#008080">0x10</font>); <font color="#808080"><i>//SQWE output at 1 Hz</i></font><br /><font color="#000000">write_ds1307</font>(<font color="#0000FF">0</font>,<font color="#008080">0x00</font>); <font color="#808080"><i>//Reset second to 0 sec. and start Oscillator</i></font><br /><br /><font color="#000000"><b>while</b></font>(<font color="#0000FF">1</font>)<br />{<br /><font color="#000000">sec</font>=<font color="#000000">read_ds1307</font>(<font color="#0000FF">0</font>); <font color="#808080"><i>// read second</i></font><br /><font color="#000000">minute</font>=<font color="#000000">read_ds1307</font>(<font color="#0000FF">1</font>); <font color="#808080"><i>// read minute</i></font><br /><font color="#000000">hour</font>=<font color="#000000">read_ds1307</font>(<font color="#0000FF">2</font>); <font color="#808080"><i>// read hour</i></font><br /><font color="#000000">day</font>=<font color="#000000">read_ds1307</font>(<font color="#0000FF">3</font>); <font color="#808080"><i>// read day</i></font><br /><font color="#000000">date</font>=<font color="#000000">read_ds1307</font>(<font color="#0000FF">4</font>); <font color="#808080"><i>// read date</i></font><br /><font color="#000000">month</font>=<font color="#000000">read_ds1307</font>(<font color="#0000FF">5</font>); <font color="#808080"><i>// read month</i></font><br /><font color="#000000">year</font>=<font color="#000000">read_ds1307</font>(<font color="#0000FF">6</font>); <font color="#808080"><i>// read year</i></font><br /><br /><font color="#000000">time</font>[<font color="#0000FF">0</font>] = <font color="#000000">BCD2UpperCh</font>(<font color="#000000">hour</font>);<br /><font color="#000000">time</font>[<font color="#0000FF">1</font>] = <font color="#000000">BCD2LowerCh</font>(<font color="#000000">hour</font>);<br /><font color="#000000">time</font>[<font color="#0000FF">2</font>] = <font color="#FF00FF">':'</font>;<br /><font color="#000000">time</font>[<font color="#0000FF">3</font>] = <font color="#000000">BCD2UpperCh</font>(<font color="#000000">minute</font>);<br /><font color="#000000">time</font>[<font color="#0000FF">4</font>] = <font color="#000000">BCD2LowerCh</font>(<font color="#000000">minute</font>);<br /><font color="#000000">time</font>[<font color="#0000FF">5</font>] = <font color="#FF00FF">':'</font>;<br /><font color="#000000">time</font>[<font color="#0000FF">6</font>] = <font color="#000000">BCD2UpperCh</font>(<font color="#000000">sec</font>);<br /><font color="#000000">time</font>[<font color="#0000FF">7</font>] = <font color="#000000">BCD2LowerCh</font>(<font color="#000000">sec</font>);<br /><font color="#000000">time</font>[<font color="#0000FF">8</font>] = <font color="#FF00FF">'\0'</font>;<br /><br /><font color="#000000">ddate</font>[<font color="#0000FF">0</font>] = <font color="#000000">BCD2UpperCh</font>(<font color="#000000">date</font>);<br /><font color="#000000">ddate</font>[<font color="#0000FF">1</font>] = <font color="#000000">BCD2LowerCh</font>(<font color="#000000">date</font>);<br /><font color="#000000">ddate</font>[<font color="#0000FF">2</font>] =<font color="#FF00FF">'/'</font>;<br /><font color="#000000">ddate</font>[<font color="#0000FF">3</font>] = <font color="#000000">BCD2UpperCh</font>(<font color="#000000">month</font>);<br /><font color="#000000">ddate</font>[<font color="#0000FF">4</font>] = <font color="#000000">BCD2LowerCh</font>(<font color="#000000">month</font>);<br /><font color="#000000">ddate</font>[<font color="#0000FF">5</font>] =<font color="#FF00FF">'/'</font>;<br /><font color="#000000">ddate</font>[<font color="#0000FF">6</font>] = <font color="#FF00FF">'2'</font>;<br /><font color="#000000">ddate</font>[<font color="#0000FF">7</font>] = <font color="#FF00FF">'0'</font>;<br /><font color="#000000">ddate</font>[<font color="#0000FF">8</font>] = <font color="#000000">BCD2UpperCh</font>(<font color="#000000">year</font>);<br /><font color="#000000">ddate</font>[<font color="#0000FF">9</font>] = <font color="#000000">BCD2LowerCh</font>(<font color="#000000">year</font>);<br /><font color="#000000">ddate</font>[<font color="#0000FF">10</font>] = <font color="#FF00FF">'\0'</font>;<br /><br /><font color="#000000">Lcd_Out</font>(<font color="#0000FF">1</font>,<font color="#0000FF">6</font>,<font color="#000000">time</font>);<br /><font color="#000000">Lcd_Out</font>(<font color="#0000FF">2</font>,<font color="#0000FF">6</font>,<font color="#000000">ddate</font>);<br /><font color="#000000">Delay_ms</font>(<font color="#0000FF">50</font>);<br />}<br />}<br /><br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">read_ds1307</font>(<font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">address</font>)<br />{<br /><font color="#000000">I2C_Start</font>();<br /><font color="#000000">I2C_Wr</font>(<font color="#0000FF">0</font><font color="#000000">xd0</font>); <font color="#808080"><i>//address 0x68 followed by direction bit (0 for write, 1 for read) 0x68 followed by 0 --> 0xD0</i></font><br /><font color="#000000">I2C_Wr</font>(<font color="#000000">address</font>);<br /><font color="#000000">I2C_Repeated_Start</font>();<br /><font color="#000000">I2C_Wr</font>(<font color="#0000FF">0</font><font color="#000000">xd1</font>); <font color="#808080"><i>//0x68 followed by 1 --> 0xD1</i></font><br /><font color="#000000">data</font>=<font color="#000000">I2C_Rd</font>(<font color="#0000FF">0</font>);<br /><font color="#000000">I2C_Stop</font>();<br /><font color="#000000"><b>return</b></font>(<font color="#000000">data</font>);<br />}<br /><br /><font color="#800000">unsigned</font> <font color="#800000">char</font> <font color="#000000">BCD2UpperCh</font>(<font color="#800000">unsigned</font> <font color="#800000">char</font> <font color="#000000">bcd</font>)<br />{<br /><font color="#000000"><b>return</b></font> ((<font color="#000000">bcd</font> >> <font color="#0000FF">4</font>) + <font color="#FF00FF">'0'</font>);<br />}<br /><br /><font color="#800000">unsigned</font> <font color="#800000">char</font> <font color="#000000">BCD2LowerCh</font>(<font color="#800000">unsigned</font> <font color="#800000">char</font> <font color="#000000">bcd</font>)<br />{<br /><font color="#000000"><b>return</b></font> ((<font color="#000000">bcd</font> & <font color="#008080">0x0F</font>) + <font color="#FF00FF">'0'</font>);<br />}<br /><font color="#800000">void</font> <font color="#000000">write_ds1307</font>(<font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">address</font>,<font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">w_data</font>)<br />{<br /><font color="#000000">I2C_Start</font>(); <font color="#808080"><i>// issue I2C start signal</i></font><br /><font color="#808080"><i>//address 0x68 followed by direction bit (0 for write, 1 for read) 0x68 followed by 0 --> 0xD0</i></font><br /><font color="#000000">I2C_Wr</font>(<font color="#008080">0xD0</font>); <font color="#808080"><i>// send byte via I2C (device address + W)</i></font><br /><font color="#000000">I2C_Wr</font>(<font color="#000000">address</font>); <font color="#808080"><i>// send byte (address of DS1307 location)</i></font><br /><font color="#000000">I2C_Wr</font>(<font color="#000000">w_data</font>); <font color="#808080"><i>// send data (data to be written)</i></font><br /><font color="#000000">I2C_Stop</font>(); <font color="#808080"><i>// issue I2C stop signal</i></font><br />}<br /></font><br /></div>Unknownnoreply@blogger.com65tag:blogger.com,1999:blog-7481197986107611337.post-86314053388028274342008-12-31T23:59:00.000+07:002008-12-31T23:27:16.577+07:006 Digits 7-Segment LED Multiplexing using a Shift RegisterMultiplexing technique can reduce number of needed I/O pins of the MCU as I have explained in <a href="http://picnote.blogspot.com/2008/12/led-7-segment-multiplexing.html">'LED 7-Segment Multiplexing'</a> and <a href="http://picnote.blogspot.com/2008/11/6-digit-led-7-segment-multiplexing.html">'6 Digits LED 7-Segment Multiplexing'</a>. In those posts, <span style="color:#000099;"><strong>I used 13 I/O pins</strong></span> for driving 6 digits LED 7-Segment. However, the PIC16F627A and PIC16F628 have only 15 usable I/O pins that include 2 pins for external 32.768KHz oscillator. So, there is no pin left for time setting buttons. I can change to the PIC that has more I/O pins, but I don't think it's a good solution. From my searches, I can overcome this I/O pins shortage problem by using shift register to expand the MCU I/O pins.<br /><br />The concept is very similar to led dot matrix driving technique. Each digit is multiplexed via a shift register 74HC595 which is required 3 pins of the MCU. Each segment of the 7-segment display is driven by PORTA of the PIC16F628. As a result, the required pins for driving 6-Digit 7-Segment display are just <strong><span style="color:#009900;"><em>3+7 = 10 pins!</em></span></strong>. With this configuration, there are 3 I/O pins that are free for time setting buttons and driving blinking second LEDs.<br /><br />I use TMR2 module for scanning digits. TMR2 is an 8-bit timer which overflows every 256 (0xFF) counts. It's known that the refresh rate above 50Hz would be enough for human's eyes to see the display without recognizing the flickering. If I set TMR2 with 1:8 Prescaler (T2CON = 0x3C), the multiplexing frequency will be 81.3Hz (4MHz/4/256/8/6 = 81.3Hz) which is enough for flicker free display.<br /><br />PORTA is used to drive each segment of the 7-segment displays. However, I have to skip the RA5 as it's a MCLR pin and it can be only input pin. So, my 7-segment digit mask is different then the normal 7-segment digit mask.<br /><br /><div style="BORDER-RIGHT: black 1px dotted; BORDER-TOP: black 1px dotted; BACKGROUND: white; BORDER-LEFT: black 1px dotted; BORDER-BOTTOM: black 1px dotted; BORDER-BOTTOM-: black 1px dottedcolor:black;" ><span style="color:#993300;">my PORTA</span> 7-segment digit mask : {0x5F, 0x06, 0x9b, 0x8f, 0xC6, 0xCd,0xDD, 0x07,<br />0xDf, 0xCf}<br /><span style="color:#000099;">Normal</span> 7-segment digit mask : {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f} for number 0-9 respectively.</div><br /><br />Below is the example schematic of 999999-second counter using the PIC16F627A or PIC16F628 and a shift register. I will not implement a clock with this configuration as I need more free MCU pins for driving Alarm buzzer and other things.<br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEia9oU0yzwMCgAPnRvcbN9UzZVU2U544aKsjXVjl65pnwDepoKjIz2wn57B6MuTMeC8wJJYLNQnvO5mb5MuC_kPY1TEhSHEZUf2xWeupVSOLBKLIB83dCmZSPpWVlG_EztI59y7Bx2u-olK/s1600-h/pic16f628-74HC595-7-segment-multiplex.png"><img id="BLOGGER_PHOTO_ID_5285827295872979394" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 249px; TEXT-ALIGN: center" alt="pic16F627a PIC16F628 74HC595 LED 7-segment multiplex" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEia9oU0yzwMCgAPnRvcbN9UzZVU2U544aKsjXVjl65pnwDepoKjIz2wn57B6MuTMeC8wJJYLNQnvO5mb5MuC_kPY1TEhSHEZUf2xWeupVSOLBKLIB83dCmZSPpWVlG_EztI59y7Bx2u-olK/s400/pic16f628-74HC595-7-segment-multiplex.png" border="0" /></a><br /><br />The source code for 999999-second counter in MikroC is listed below<br /><br /><div style="BORDER-RIGHT: black 1px dotted; BORDER-TOP: black 1px dotted; BACKGROUND: white; BORDER-LEFT: black 1px dotted; BORDER-BOTTOM: black 1px dotted; BORDER-BOTTOM-: black 1px dottedcolor:black"><font face="Monospace"><font color="#808080"><i>//PIC16F627A or PIC16F628</i></font><br /><font color="#808080"><i>//4MHz Internal OSC</i></font><br /><font color="#808080"><i>//MUX by using Shift Register 595</i></font><br /><font color="#808080"><i>// Critical parameters:</i></font><br /><font color="#808080"><i>// Delay, Postscaler, Prescaler</i></font><br /><font color="#808080"><i>// Low delay + High Prescaler</i></font><br /><font color="#808080"><i>// 03/11/2008</i></font><br /><font color="#808080"><i>// punkky@gmail.com</i></font><br /><font color="#008000">#define SH_CP PORTB.F0</font><br /><font color="#008000">#define DS PORTB.F1</font><br /><font color="#008000">#define ST_CP PORTB.F2</font><br /><font color="#808080"><i>// 7-Segment code is skipping RA5, so the code is not as normal 7-segment coding</i></font><br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">number</font> [<font color="#0000FF">10</font>] = {<br /> <font color="#008080">0x5F</font>, <font color="#008080">0x06</font>, <font color="#008080">0x9</font><font color="#000000">b</font>, <font color="#008080">0x8</font><font color="#000000">f</font>, <font color="#008080">0xC6</font>, <font color="#008080">0xC</font>d, <font color="#008080">0xDD</font>, <font color="#008080">0x07</font>,<br /> <font color="#008080">0xD</font>f, <font color="#008080">0xC</font>f<br />};<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">digit</font> [<font color="#0000FF">6</font>] = {<br /> <font color="#0000FF">0</font>, <font color="#0000FF">0</font>, <font color="#0000FF">0</font>, <font color="#0000FF">0</font>, <font color="#0000FF">0</font>, <font color="#0000FF">0</font><br />};<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">i</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">n</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">counter</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">tick</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">shift_register</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">x1</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">x2</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">x3</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">x4</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">x5</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">x6</font>;<br /><font color="#800000">void</font> <font color="#000000">interrupt</font> ()<br />{<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">PIR1</font>.<font color="#000000">TMR2IF</font>)<br /> {<br /> <font color="#000000">PIR1</font>.<font color="#000000">TMR2IF</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">counter</font> == <font color="#0000FF">5</font>)<br /> {<br /> <font color="#808080"><i>//Shift data</i></font><br /> <font color="#000000">DS</font> = <font color="#0000FF">0</font>;<br /> <font color="#808080"><i>//Store data</i></font><br /> <font color="#000000">SH_CP</font> = <font color="#0000FF">1</font>;<br /> <font color="#000000">SH_CP</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">Delay_us</font> (<font color="#0000FF">250</font>);<br /> <font color="#000000">counter</font> = <font color="#0000FF">0</font>;<br /> }<font color="#000000"><b>else</b></font><br /> {<br /> <font color="#808080"><i>//Shift data</i></font><br /> <font color="#000000">DS</font> = <font color="#0000FF">1</font>;<br /> <font color="#808080"><i>//Store</i></font><br /> <font color="#000000">SH_CP</font> = <font color="#0000FF">1</font>;<br /> <font color="#000000">SH_CP</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">Delay_us</font> (<font color="#0000FF">250</font>);<br /> <font color="#000000">counter</font> ++;<br /> }<br /> <font color="#000000">ST_CP</font> = <font color="#0000FF">1</font>;<br /> <font color="#000000">ST_CP</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">PORTA</font> = <font color="#008080">0x00</font>;<br /> <font color="#000000">PORTA</font> = <font color="#000000">number</font> [<font color="#000000">digit</font> [<font color="#000000">counter</font>]];<br /> }<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">PIR1</font>.<font color="#000000">TMR1IF</font>)<br /> {<br /> <font color="#000000">TMR1H</font> = <font color="#008080">0x80</font>;<br /> <font color="#000000">PIR1</font>.<font color="#000000">TMR1IF</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">tick</font> = <font color="#0000FF">1</font>;<br /> <font color="#000000">x6</font> ++;<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">x6</font> > <font color="#0000FF">9</font>)<br /> {<br /> <font color="#000000">x6</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x5</font> ++;<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">x5</font> > <font color="#0000FF">9</font>)<br /> {<br /> <font color="#000000">x5</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x4</font> ++;<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">x4</font> > <font color="#0000FF">9</font>)<br /> {<br /> <font color="#000000">x4</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x3</font> ++;<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">x3</font> > <font color="#0000FF">9</font>)<br /> {<br /> <font color="#000000">x3</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x2</font> ++;<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">x2</font> > <font color="#0000FF">9</font>)<br /> {<br /> <font color="#000000">x2</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x1</font> ++;<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">x1</font> > <font color="#0000FF">9</font>)<br /> {<br /> <font color="#000000">x1</font> = <font color="#0000FF">0</font>;<br /> }<br /> }<br /> }<br /> }<br /> }<br /> }<br /> }<br />}<br /><font color="#800000">void</font> <font color="#000000">main</font> ()<br />{<br /> <font color="#808080"><i>//Digital I/O for PORTA</i></font><br /> <font color="#000000">CMCON</font> = <font color="#008080">0x07</font>;<br /> <font color="#000000">TRISA</font> = <font color="#008080">0x00</font>;<br /> <font color="#000000">PORTA</font> = <font color="#008080">0x00</font>;<br /> <font color="#000000">TRISB</font> = <font color="#008080">0x00</font>;<br /> <font color="#000000">PORTB</font> = <font color="#008080">0x00</font>;<br /> <font color="#808080"><i>//Internal Clock 4MHz</i></font><br /> <font color="#000000">PCON</font>.<font color="#000000">OSCF</font> = <font color="#0000FF">1</font>;<br /> <font color="#000000">counter</font> = <font color="#0000FF">0</font>;<br /> <font color="#808080"><i>// Set GIE, PEIE</i></font><br /> <font color="#000000">INTCON</font> = <font color="#008080">0xC0</font>;<br /> <font color="#808080"><i>//1:8 post scaler</i></font><br /> <font color="#000000">T2CON</font> = <font color="#008080">0x3C</font>;<br /> <font color="#808080"><i>// enable interupt</i></font><br /> <font color="#000000">PIE1</font>.<font color="#000000">TMR2IE</font> = <font color="#0000FF">1</font>;<br /> <font color="#000000">T1CON</font> = <font color="#008080">0x0F</font>;<br /> <font color="#808080"><i>//Initial value TMR1: 0x8000</i></font><br /> <font color="#000000">TMR1H</font> = <font color="#008080">0x80</font>;<br /> <font color="#000000">TMR1L</font> = <font color="#008080">0x00</font>;<br /> <font color="#808080"><i>// enable interupt</i></font><br /> <font color="#000000">PIE1</font>.<font color="#000000">TMR1IE</font> = <font color="#0000FF">1</font>;<br /> <font color="#808080"><i>//Data</i></font><br /> <font color="#000000">DS</font> = <font color="#0000FF">0</font>;<br /> <font color="#808080"><i>//Store</i></font><br /> <font color="#000000">SH_CP</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">ST_CP</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x1</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x2</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x3</font> = <font color="#0000FF">0</font> ;<br /> <font color="#000000">x4</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x5</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x6</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000"><b>while</b></font> (<font color="#0000FF">1</font>)<br /> {<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">tick</font>)<br /> {<br /> <font color="#000000">tick</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">digit</font> [<font color="#0000FF">0</font>] = <font color="#000000">x1</font>;<br /> <font color="#000000">digit</font> [<font color="#0000FF">1</font>] = <font color="#000000">x2</font>;<br /> <font color="#000000">digit</font> [<font color="#0000FF">2</font>] = <font color="#000000">x3</font>;<br /> <font color="#000000">digit</font> [<font color="#0000FF">3</font>] = <font color="#000000">x4</font>;<br /> <font color="#000000">digit</font> [<font color="#0000FF">4</font>] = <font color="#000000">x5</font>;<br /> <font color="#000000">digit</font> [<font color="#0000FF">5</font>] = <font color="#000000">x6</font>;<br /> }<br /> }<br />}</font><br /></div>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7481197986107611337.post-35751155204268254502008-12-27T18:20:00.006+07:002008-12-27T23:41:56.726+07:00Trojan Attack : Trojan.vundoIn last couple days, I have been getting headache with Trojan attack on my computer. The symptoms were a lot of Antispyware 2009 ads and other annoying popups (Browser Hijack). I started the task manager and found that iexplore.exe was running even I didn't use IE. I found some strange files in windows/system32 such as<br /><br />- sakalimo.dll<br />- fodituva.dll<br />- yidaziwi.dll<br />- dobafigi.dll<br />- juvilisi.dll<br />- igifabod.ini<br />- vefiyohu.dll<br />- gujayiwo.dll<br />- titubeve.dll<br /><br />I tried Trojan Hunter, NOD32 and Spybot Search&Destroy. They found some Trojans & Malwares but they could not kill the annoying popups. After some searches, I have found that I got attack from Trojan.vundo and Trojan.vundo.H . And from my searches, I found only one mulware/trojan removal program, Malwarebytes' Anti-Mulware or MBAM, from <a href="http://www.malwarebytes.org/">http://www.malwarebytes.org/</a> that can remove these Trojans.<br /><br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUR6eCkr8Yp2snvwMtmW4lVWehTyG1OBXPaO0vHPs8wxBtxMdwQljOjkrwTJDMaH32KIoaszN3MiUAo1VnMEbFEtiW5NUCg1Fv3n5bl609ACy4537jBvHfX6hFPCP3YHFLSCiMIpf1f1d_/s1600-h/malwarebytes.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 304px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUR6eCkr8Yp2snvwMtmW4lVWehTyG1OBXPaO0vHPs8wxBtxMdwQljOjkrwTJDMaH32KIoaszN3MiUAo1VnMEbFEtiW5NUCg1Fv3n5bl609ACy4537jBvHfX6hFPCP3YHFLSCiMIpf1f1d_/s400/malwarebytes.png" border="0" alt="Malwarebytes' Anti-Mulware "id="BLOGGER_PHOTO_ID_5284436770813068306" /></a><br />It's FREE! I installed it and did full system scan. It took about 3 hours for my system scan. As expected, it found and removed a lot of Trojan.vundo from my machine. After cleaning those Trojans, my machine is running fine and consuming less RAM than before.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-7481197986107611337.post-91936313860240393822008-12-21T18:08:00.005+07:002008-12-23T15:07:03.002+07:006 Digits LED 7-Segment MultiplexingIn the post '<a href="http://picnote.blogspot.com/2008/12/led-7-segment-multiplexing.html">LED 7-Segment Multiplexing</a>', I have explained about the concept and benefits of multiplexing. Multiplexing implementation is very similar to driving Led Dot Matrix. I use Timer0 interrupt for switching through each digit. Timer0 or TMR0 is an 8-bit timer which overflows every 256 (0xFF) counts. It's known that the refresh rate above 50Hz would be enough for human's eyes to see the display without recognizing the flickering. If I set TMR0 with 1:8 Prescaler, the multiplexing frequency will be<br /><br /><div style="BORDER-RIGHT: black 1px dotted; BORDER-TOP: black 1px dotted; BACKGROUND: white; BORDER-LEFT: black 1px dotted; BORDER-BOTTOM: black 1px dotted; BORDER-BOTTOM-: black 1px dottedcolor:black">4MHz(internal OSC.)/4(working OSC)/8(prescaler)/256(max counts of TMR0)/6(number of digits) = <span class="Apple-style-span" style="COLOR: rgb(0,0,153)">81.3 Hz</span> which is good for a display. </div><br />Just an example, I have implemented (in Proteus) a 999999-second counter by using 6 Digits LED 7-Segment Multiplexing technique. There are 2 main components in the project, PIC16F627A or PIC16F628 and 6 x LED7-segment display. The schematic shows below. The crystal is 32.768KHz as usual. There is a 10KOhm pull up resistor at RA4 pin as this pin is an open-drain pin as I described in "<a href="http://picnote.blogspot.com/2008/10/open-drain-ra4-pin-on-pic.html">Open-Drain RA4 pin on PIC Microcontroller</a>".<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheE1letZoQRlowrV6NoeJLAEqh5PXJH_DPE2Ks-i3KZ2kGZl1bnyP9DsQ8Z9Hpg0kcW_bf0OcfWTaSQKoXTBMKtfOkFaXrj_bVneGEabTgqXiKr5qXHx-iODeegHCi6lA4-NTnHpKk3APz/s1600-h/7-segment-multiplex-999999-counter.png"><img id="BLOGGER_PHOTO_ID_5282179698233304130" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 279px; TEXT-ALIGN: center" alt="7-Segment LED Multiplexing PIC16F627A or PIC16F628" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheE1letZoQRlowrV6NoeJLAEqh5PXJH_DPE2Ks-i3KZ2kGZl1bnyP9DsQ8Z9Hpg0kcW_bf0OcfWTaSQKoXTBMKtfOkFaXrj_bVneGEabTgqXiKr5qXHx-iODeegHCi6lA4-NTnHpKk3APz/s400/7-segment-multiplex-999999-counter.png" border="0" /></a><br />The source code in MikroC is listed below: (.hex is also available, please feel free to contact me)<br /><div style="BORDER-RIGHT: black 1px dotted; BORDER-TOP: black 1px dotted; BACKGROUND: white; BORDER-LEFT: black 1px dotted; BORDER-BOTTOM: black 1px dotted; BORDER-BOTTOM-: black 1px dottedcolor:black"> <font face="Monospace"><font color="#808080"><i>//PIC16F627A</i></font><br /><font color="#808080"><i>//4MHz Internal OSC</i></font><br /><font color="#808080"><i>//MUX by the MUC itself with Interrupt</i></font><br /><font color="#808080"><i>//TMR0 .. check the prescelar+delay in scan routine as they are related</i></font><br /><font color="#808080"><i>//punkky@gmail.com</i></font><br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">number</font> [<font color="#0000FF">10</font>] = {<br /> <font color="#008080">0x5F</font>, <font color="#008080">0x06</font>, <font color="#008080">0x9</font><font color="#000000">b</font>, <font color="#008080">0x8</font><font color="#000000">f</font>, <font color="#008080">0xC6</font>, <font color="#008080">0xC</font>d, <font color="#008080">0xDD</font>, <font color="#008080">0x07</font>,<br /> <font color="#008080">0xD</font>f, <font color="#008080">0xC</font>f<br />};<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">digit</font> [<font color="#0000FF">6</font>];<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">counter</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">shift_register</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">x1</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">x2</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">x3</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">x4</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">x5</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">x6</font>;<br /><font color="#800000">unsigned</font> <font color="#800000">short</font> <font color="#000000">tick</font>;<br /><font color="#800000">void</font> <font color="#000000">interrupt</font> ()<br />{<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">INTCON</font>.<font color="#000000">T0IF</font>)<br /> {<br /> <font color="#808080"><i>//Scan digits with TMR0</i></font><br /> <font color="#000000">INTCON</font>.<font color="#000000">T0IF</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">counter</font> == <font color="#0000FF">5</font>)<br /> {<br /> <font color="#000000">PORTA</font> = <font color="#000000">number</font> [<font color="#000000">digit</font> [<font color="#000000">counter</font>]];<br /> <font color="#000000">Delay_us</font> (<font color="#0000FF">500</font>);<br /> <font color="#000000">shift_register</font> = <font color="#008080">0x01</font>;<br /> <font color="#000000">PORTB</font> = ~<font color="#000000">shift_register</font>;<br /> <font color="#000000">PORTA</font> = <font color="#008080">0x00</font>;<br /> <font color="#000000">counter</font> = <font color="#0000FF">0</font>;<br /> } <font color="#000000"><b>else</b></font><br /> {<br /> <font color="#000000">PORTA</font> = <font color="#000000">number</font> [<font color="#000000">digit</font> [<font color="#000000">counter</font>]];<br /> <font color="#000000">Delay_us</font> (<font color="#0000FF">500</font>);<br /> <font color="#000000">shift_register</font> = <font color="#000000">shift_register</font> << <font color="#0000FF">1</font>;<br /> <font color="#000000">PORTB</font> = ~<font color="#000000">shift_register</font>;<br /> <font color="#000000">PORTA</font> = <font color="#008080">0x00</font>;<br /> <font color="#000000">counter</font> ++;<br /> }<br /> }<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">PIR1</font>.<font color="#000000">TMR1IF</font>)<br /> {<br /> <font color="#000000">TMR1H</font> = <font color="#008080">0x80</font>;<br /> <font color="#000000">PIR1</font>.<font color="#000000">TMR1IF</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">tick</font> = <font color="#0000FF">1</font>;<br /> <font color="#808080"><i>//update current time</i></font><br /> <font color="#000000">x6</font> ++;<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">x6</font> > <font color="#0000FF">9</font>)<br /> {<br /> <font color="#000000">x6</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x5</font> ++;<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">x5</font> > <font color="#0000FF">9</font>)<br /> {<br /> <font color="#000000">x5</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x4</font> ++;<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">x4</font> > <font color="#0000FF">9</font>)<br /> {<br /> <font color="#000000">x4</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x3</font> ++;<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">x3</font> > <font color="#0000FF">9</font>)<br /> {<br /> <font color="#000000">x3</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x2</font> ++;<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">x2</font> > <font color="#0000FF">9</font>)<br /> {<br /> <font color="#000000">x2</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x1</font> ++;<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">x1</font> > <font color="#0000FF">9</font>)<br /> {<br /> <font color="#000000">x1</font> = <font color="#0000FF">0</font>;<br /> }<br /> }<br /> }<br /> }<br /> }<br /> }<br /> }<br />}<br /><font color="#800000">void</font> <font color="#000000">main</font> ()<br />{<br /> <font color="#808080"><i>//Digital I/O for PORTA</i></font><br /> <font color="#000000">CMCON</font> = <font color="#008080">0x07</font>;<br /> <font color="#000000">TRISA</font> = <font color="#008080">0x00</font>;<br /> <font color="#000000">PORTA</font> = <font color="#008080">0x00</font>;<br /> <font color="#000000">TRISB</font> = <font color="#008080">0x00</font>;<br /> <font color="#000000">PORTB</font> = <font color="#008080">0x00</font>;<br /> <font color="#808080"><i>//Internal Clock 4MHz</i></font><br /> <font color="#000000">PCON</font>.<font color="#000000">OSCF</font> = <font color="#0000FF">1</font>;<br /> <font color="#000000">counter</font> = <font color="#0000FF">0</font>;<br /> <font color="#808080"><i>// Enable TMR0</i></font><br /> <font color="#000000">OPTION_REG</font>.<font color="#000000">T0CS</font> = <font color="#0000FF">0</font>;<br /> <font color="#808080"><i>// Enable Prescaler</i></font><br /> <font color="#000000">OPTION_REG</font>.<font color="#000000">PSA</font> = <font color="#0000FF">0</font>;<br /> <font color="#808080"><i>// PS0,1,2 = 010 = 3</i></font><br /> <font color="#808080"><i>// 3 means 1:8 prescaler</i></font><br /> <font color="#808080"><i>// 1:2, 1:4, 1:8, 1:16, 1:32, 1:64, 1:128, 1:256</i></font><br /> <font color="#000000">OPTION_REG</font>.<font color="#000000">PS2</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">OPTION_REG</font>.<font color="#000000">PS1</font> = <font color="#0000FF">1</font>;<br /> <font color="#000000">OPTION_REG</font>.<font color="#000000">PS0</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">INTCON</font>.<font color="#000000">T0IF</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">INTCON</font>.<font color="#000000">T0IE</font> = <font color="#0000FF">1</font>;<br /> <font color="#000000">INTCON</font>.<font color="#000000">GIE</font> = <font color="#0000FF">1</font>;<br /> <font color="#000000">INTCON</font>.<font color="#000000">PEIE</font> = <font color="#0000FF">1</font>;<br /> <font color="#000000">T1CON</font> = <font color="#008080">0x0F</font>;<br /> <font color="#000000">TMR1H</font> = <font color="#008080">0x80</font>;<br /> <font color="#000000">TMR1L</font> = <font color="#008080">0x00</font>;<br /> <font color="#808080"><i>// Enable TMR1 interrupt</i></font><br /> <font color="#000000">PIE1</font>.<font color="#000000">TMR1IE</font> = <font color="#0000FF">1</font>;<br /> <font color="#000000">shift_register</font> = <font color="#008080">0x01</font>;<br /> <font color="#000000">x1</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x2</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x3</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x4</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x5</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000">x6</font> = <font color="#0000FF">0</font>;<br /> <font color="#000000"><b>while</b></font> (<font color="#0000FF">1</font>)<br /> {<br /> <font color="#000000"><b>if</b></font> (<font color="#000000">tick</font>)<br /> {<br /> <font color="#000000">tick</font> = <font color="#0000FF">0</font>;<br /> <font color="#808080"><i>//update digits</i></font><br /> <font color="#000000">digit</font> [<font color="#0000FF">0</font>] = <font color="#000000">x1</font>;<br /> <font color="#000000">digit</font> [<font color="#0000FF">1</font>] = <font color="#000000">x2</font>;<br /> <font color="#000000">digit</font> [<font color="#0000FF">2</font>] = <font color="#000000">x3</font>;<br /> <font color="#000000">digit</font> [<font color="#0000FF">3</font>] = <font color="#000000">x4</font>;<br /> <font color="#000000">digit</font> [<font color="#0000FF">4</font>] = <font color="#000000">x5</font>;<br /> <font color="#000000">digit</font> [<font color="#0000FF">5</font>] = <font color="#000000">x6</font>;<br /> }<br /> }<br />}<br /> </font></div>Unknownnoreply@blogger.com3tag:blogger.com,1999:blog-7481197986107611337.post-2547241838529489192008-12-20T14:48:00.009+07:002008-12-20T17:03:26.175+07:00Frequency DividerI am always looking for perfect frequency oscillator for a given budget for my clock projects. Searching on eBay provided a lot of good frequency oscillators including OCXO (Oven Controlled Crystal Oscillator) and Rubidium Frequency Oscillator. Most of them are for telecommunication systems and audio systems. But, I want to use the oscillator just for making a good clock. Yes, just a real clock for telling time.Those oscillators on eBay provide frequencies that not suitable for making a clock. For example, 10MHz,11.2896, MHz, 16.9344MHz etc.,<br /><br />There are some techniques to make use of these oscillators in clock projects. I have post a solution for 11.2896MHz in "<a href="http://picnote.blogspot.com/2008/11/using-112896-mhz-with-tmr1-timer1.html">Using 11.2896 MHz with TMR1 (timer1 module)</a>".<br /><br />For 10MHz oscillator, I will use ripple counters as the frequency divider to divide the 10MHz to lower frequency and use it as a time reference for my clocks. I got information about 10MHz frequency division from <a href="http://www.interq.or.jp/japan/se-inoue/e_clock4.htm ">Seiichi Inoue's website</a>. From the web, 10MHz frequency can be divided by using 3 pcs. of Dual Decade Counter (74390 or 74HC390). By using the schematic below, I can get 100Hz from 10MHz input. By feeding 100Hz to PIC Microcontroller with appropriate firmware I will get a good accuracy clock.<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrRJfICG-oZMX4GeFga7jIV_7ef9KdeMBPqZk3iJIVsogzXu_Gvq3ll-OAjZqqhSMVLRQNobSh0MtKTMT1R1wltzi8ADJAnR48QRbAAHGFi67IuWpovceIJjudZLfg2L-GX7b3jd1rk53i/s1600-h/10MHz_freq_divider.png"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 241px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjrRJfICG-oZMX4GeFga7jIV_7ef9KdeMBPqZk3iJIVsogzXu_Gvq3ll-OAjZqqhSMVLRQNobSh0MtKTMT1R1wltzi8ADJAnR48QRbAAHGFi67IuWpovceIJjudZLfg2L-GX7b3jd1rk53i/s400/10MHz_freq_divider.png" border="0" alt="10MHz Frequency Divider"id="BLOGGER_PHOTO_ID_5281810621583455250" /></a>It's not so easy to divide 16.9344MHz to appropriate frequency for my clocks. However, I will try to figure it out and post it here.Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7481197986107611337.post-26260014657307565702008-12-06T16:19:00.005+07:002008-12-06T17:02:05.184+07:00Digital Clock without Microcontroller<a href="http://electronickits.com/start.php?BID=8906&AID=36276" target="_blank"><img id="BLOGGER_PHOTO_ID_5276605139363355458" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 163px; TEXT-ALIGN: center" alt="Digital Clock Big Digit" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtYs0fry_CsnRRPv3PCahJx81162lMFuBe-xlCxbdc-NQRVnm1_7mUZyYz3F1F85DEQ-pYTsQUY4wDHvJcSp44vixV_KD0PXIhFuvBxujsp6HdRtQq1dYqVFuH3cHGklQXcqv4ggaojdyy/s400/cana-digital-clock.jpg" border="0" /></a> I have found a digital clock that uses just a clock chip without microcontroller from <a href="http://electronickits.com/start.php?BID=1565&AID=36276" target="_blank">Electronickits.com </a>. The picture above is the <a href="http://www.ewebcart.com/cgi-bin/cart.pl?merchant=956&add=1&item_id=625" target="_blank">Digital Clock With 24 Hour Timer</a> made by <a href="http://www.canakit.com/" target="_blank">Canakit.com</a> . It uses LM8560 clock chip which incorporates a wide range of features such as alarm, snooze, and 24 hour timer. The digit height is 50mm and made of 87 discrete LEDs. It can be a unique wall clock by just cover the digits with red Plexiglas and hang it on the wall.Unknownnoreply@blogger.com5tag:blogger.com,1999:blog-7481197986107611337.post-69849698620050664002008-12-04T07:44:00.007+07:002008-12-04T08:06:13.156+07:00.htacess needs UTF-8 encodingYesterday, I was setting up a Wordpress Mu site and getting only "<strong>500 Internal Error</strong>". I checked web server log file and found a lot of errors like below<br /><br /><div style="BORDER-RIGHT: black 1px dotted; BORDER-TOP: black 1px dotted; BACKGROUND: white; BORDER-LEFT: black 1px dotted; BORDER-BOTTOM: black 1px dotted; BORDER-BOTTOM-: black 1px dottedcolor:black;" >[Wed Dec 3 19:29:38 2008] [alert] [client xxx.xxx.37.222] /home/punkky/public_html/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps mis-spelled or defined by a module not included in the server configuration<br /></div><br /><br />Firstly, I thought that the <strong>rewrite_mod</strong> might not be installed on the server. But it's not the case. Finally, I have found that <strong>\xef\xbb\xbfRewriteEngine</strong> was the source of problem. It means .htaccess has wrong encoding. I opened .htaccess in Notepad and saved it with <strong>'UTF-8'</strong> encoding. The problem is solved!. Now the site is up and running.Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-7481197986107611337.post-84725425349481094362008-12-02T20:22:00.004+07:002008-12-21T18:57:47.900+07:00LED 7-Segment MultiplexingIn my first <a href="http://picnote.blogspot.com/2008/11/making-digital-clock-updated.html">Digital Clock</a>, I use 6 pcs. of CD4543,BCD to 7-Segment decoder, to drive 6 digit LED 7-Segment display for the sake of simplicity of the software. However, the hardware needs many components. As you can see in the post, the PCB of the clock is quite big and containing a lot of solder points. To reduce the number of components, I will integrate the function of CD4543 into the firmware. One digit requires 7 connections (wires) for all segments and 1 connection for common cathode (or anode). If I connect 6 digits to the MCU without any modification, I will need <strong>7-segment x 6 digit = 42 connections . </strong>That means I need to use MCU with atleast 42 I/O pins. As you know, it is a waste for using a lot of MCU pins just for display. The required pins can be reduced dramatically by using a technique called Multiplexing.<br /><br /><strong>Multiplexing</strong><br /><br />Multiplexing technique is based on the idea of <a href="http://en.wikipedia.org/wiki/Persistence_of_vision" target="_blank">Persistence of vision</a> of the human eyes. The sample schematic of 3 digits multiplexing is shown below. Segment a-g of each digit are connected together. Each digit is switched on-off by controlling signal at Digit 1, Digit 2 and Digit 3. For example, if Digit 1 is '1' , Digit 1 will be on. If Digit 1 is '0', Digit 1 will be off. People will see all 3 digits display in the same time if each digit switch on and off fast enough.<br /><br /><br /><p><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSU_P4ehdv9cWgCPGX4HXiQGSNDPTb65xv21qwkHN8lWyw8y73q3AcnHhl3sP6kOnZ5lWlHri3BaK4IId4X0Scqw-fzV_EeL-gGl5iud2jA-Gw2MNIb6jWF7BaPPKPCSUWyZ3CKlWE5kbs/s1600-h/multiplexing-3digit.png"><img id="BLOGGER_PHOTO_ID_5275175156691831842" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 240px; TEXT-ALIGN: center" alt="Led 7-Segment multiplexing" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSU_P4ehdv9cWgCPGX4HXiQGSNDPTb65xv21qwkHN8lWyw8y73q3AcnHhl3sP6kOnZ5lWlHri3BaK4IId4X0Scqw-fzV_EeL-gGl5iud2jA-Gw2MNIb6jWF7BaPPKPCSUWyZ3CKlWE5kbs/s400/multiplexing-3digit.png" border="0" /></a><br />By using multiplexing technique the number of required connections for 6 digits display is reduced from <strong>42 pins</strong> to <strong>7-Segment+6 digits = 13 pins Wow!! </strong>I can drive 6 digits 7-segment display by using just a PIC16F627A.<br />Next time, I will post the program for LED 7-Segment Multiplexing </p><p>--- Updated 21 Dec 2008 --<br />The program for LED 7-Segment Multiplexing is now posted at <a href="http://picnote.blogspot.com/2008/11/6-digit-led-7-segment-multiplexing.html">6 Digits LED 7-Segment Multiplexing </a>Unknownnoreply@blogger.com4tag:blogger.com,1999:blog-7481197986107611337.post-39900305155688121912008-11-22T23:48:00.010+07:002008-11-24T11:49:51.408+07:00Small Nixie TubeI have a plan to build a Nixie Clock so I search for its information and blog it here for further reference.<br /><img id="BLOGGER_PHOTO_ID_5271658689139419746" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 392px; TEXT-ALIGN: center" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjsDls5li70gWVx49_LApXpf5iDSI1jt4OW_W_ojXzahQUDUsl7C3CDNc2yqG_pkhQNu6ajBmD6mtbHqXadzTL29ihmuls1K9K_YA40Je9ih77UtK9xJI9SP_WOQ1g19oAd9f0K1-BVUuC/s400/IN-16%2520datasheet.jpg" border="0" /><br />IN-16 may be not the smallest nixie tube but it's small enough to make a nice desk top nixie clock. The character height is about 13mm. I will use IN-16 for my upcoming nixie clock. There are some nixie clock kits that use IN-16 nixie tube so I am thinking about buying a kit or building it from scratch.Unknownnoreply@blogger.com2