tag:blogger.com,1999:blog-72528154241230570682024-03-27T11:43:33.204-07:00Deepak's Microcontroller ProjectsMindfront Technologies blog site for Microcontroller circuits and other electronics projects.deepak guruswamyhttp://www.blogger.com/profile/14617132698458472389noreply@blogger.comBlogger10125tag:blogger.com,1999:blog-7252815424123057068.post-29599105227867002292018-11-12T00:06:00.001-08:002018-11-12T00:06:38.540-08:00YDLidar (lidar) X4 API in golang<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
YDLidar X4</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
This is a demo of the YDLidar using a golang API. The software supplied with the device only contains the drivers in C++ and the visualization tool need ROS to be installed. Since I was planning to integrate this with an existing project in golang, I decided to write a driver in Go for the lidar. The examples folder contains the usage patterns.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
https://github.com/deepakkamesh/ydlidar</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.blogger.com/video.g?token=AD6v5dwj4-aai84UIVYIkGCKI6OnxXY_q-GfefBjuoNVBwbyON4kYEUFLKSMb-jR3RQJx6TNXeXpSo6hXpPCTkY-oQ' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div>
<br /></div>
deepak guruswamyhttp://www.blogger.com/profile/14617132698458472389noreply@blogger.com5tag:blogger.com,1999:blog-7252815424123057068.post-28412599069977017692017-06-03T22:08:00.002-07:002017-06-03T22:50:07.408-07:00Roomba Dashboard - A cli dashboard for irobot create 2<div dir="ltr" style="text-align: left;" trbidi="on">
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJutcmWi2RsRQGCanrHax_-NL6Z8mloT_fPCrtD2QdS9Iq2lXXB30i8cFaSJQ0_Cdz3mwv8KoZyd6bKIOJe0L0iWDK237MgLO58MfBhczwlj1lG5f0GVMqm-doGIUZUG47Ok3huxTPWMd5/s1600/Screen+Shot+2017-06-03+at+10.15.51+PM.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" data-original-height="1107" data-original-width="1600" height="441" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJutcmWi2RsRQGCanrHax_-NL6Z8mloT_fPCrtD2QdS9Iq2lXXB30i8cFaSJQ0_Cdz3mwv8KoZyd6bKIOJe0L0iWDK237MgLO58MfBhczwlj1lG5f0GVMqm-doGIUZUG47Ok3huxTPWMd5/s640/Screen+Shot+2017-06-03+at+10.15.51+PM.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Roomba Dashboard</td></tr>
</tbody></table>
<h2 style="text-align: left;">
Background:</h2>
Roomba-Dash is a cli dashboard for the IRobot Create 2 platform. I got the roomba because I wanted to build a security robot for my home. Since I was not familiar with the capabilities of the Roomba, I build a dashboard to understand the sensors.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<iframe width="320" height="266" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/FgA5tsvSAhA/0.jpg" src="https://www.youtube.com/embed/FgA5tsvSAhA?feature=player_embedded" frameborder="0" allowfullscreen></iframe></div>
<div class="separator" style="clear: both; text-align: center;">
Demo of the dashboard driving a Roomba.</div>
<br />
<h2 style="text-align: left;">
Dashboard Details:</h2>
<div>
The dashboard is primarily used to get all the useful sensor data from the roomba. In addition it can also be used to send some of the commands to the Roomba. Particularly it can change between the different roomba modes (full, safe, passive). There are a couple of gauges that provide data about the current, volts and charge of the battery. The batt. level gauges also provides the battery level as a percentage but shows it as a graph over time.</div>
<div>
<br /></div>
<div>
Motor current gauge shows the current drawn by the motors. Encoder, Rotation shows the various encoder (L,R), Radius, Angle and Distance travelled. This is requested about 3 times a second and they reset on every call. The IR code shows the IR signal that is received by omni and left, right sensors. The cliff sensors show the signal level from the cliff sensors located beneath the roomba. In addition, if any of the sensors are triggered, they will also highlight in red. The velocity sensor shows the current velocity of the motors. The light bumper gauge shows the IR bumper signals from the 6 IR sensors across the front of the roomba. Similar to the cliff sensor gauge, this also lights up when a bump is detected. The wheel sensor tracks the wheel drops and the front bumper.</div>
<div>
<br /></div>
<div>
<br /></div>
<h2 style="text-align: left;">
Code Build Details:</h2>
<div>
The dashboard is build in golang using <a href="https://github.com/gizak/termui">termui</a> and <a href="https://github.com/xa4a/go-roomba">go-roomba</a> libraries runs on top of a <a href="https://getchip.com/">C.H.I.P</a> single board computer. The code for the dashboard is available on <a href="https://github.com/deepakkamesh/roomba-dash">github/deepakkamesh</a>. Building the dashboard is fairly straight forward. Just download the code and '<i>go build bin/main.go'</i>. Its important Download the github forked versions of these libraries or alternatively add my forked version as another remote and do a git pull. I have submitted by fixes as a pull request to the owners of the repos but yet to hear back from them. Until then either approaches outlines above should work. The second approach is preferable since it does not break the import paths.<br />
<br />
<h2 style="text-align: left;">
Hardware Build Details:</h2>
</div>
<div>
The hardware uses a CHIP single board computer. Its running a headless debian version for the OS. The CHIP comes with only one usb that I needed for a webcam. So I connected the TX/RX from the headers to the connectors on the roomba. The details of how to do that are available on the roomba website. Please follow the <a href="http://www.irobotweb.com/-/media/MainSite/PDFs/About/STEM/Create/Create_2_Serial_to_33V_Logic.pdf?la=en">3.3V logic </a>instructions as the CHIP uses 3.3v logic.</div>
<div>
<br /></div>
<div>
I decided to power the CHIP directly from the serial port on the Roomba which has always on power. The roomba website also has a <a href="http://www.irobotweb.com/-/media/MainSite/PDFs/About/STEM/Create/BatteryPower.pdf?la=en">tutorial</a> on how to accomplish this.</div>
<div>
<br /></div>
<div>
In addition, I tied the BRC pin to a GPIO pin on the CHIP and I pulse it for a second every minute ti prevent the Roomba from sleeping. </div>
<div>
<br /></div>
<div>
Post a comment if you have any questions. </div>
</div>
deepak guruswamyhttp://www.blogger.com/profile/14617132698458472389noreply@blogger.com18tag:blogger.com,1999:blog-7252815424123057068.post-28809009586863228282012-08-16T17:43:00.001-07:002012-08-16T17:43:21.842-07:00Installing Facebooks FlashCache on Fedora Root<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Step 1: Download and compile the flashcache<br />
<br />
Step 2: Install the flash cache and modules to the initramfs drive<br />
<br />
dracut --install "flashcache_load flashcache_create flashcache_destroy flashcache_setioctl dmsetup" initramfs-3.5.1-1.fc17.x86_64.img --force<br />
<br />
Step 2.5 Install a hook to load the flash cache volume before bootup. During initqueue/finished stage<br />
<div>
<br /></div>
<div>
Step3: Change the /etc/fstab and grub config to point to a new file system eg. /dev/mapper/cachedev</div>
<div>
<br /></div>
<div>
Step 4: Reboot and drop into dracut shell</div>
<div>
<br /></div>
<div>
Step 5: Create the new flashcache volume</div>
<div>
<br /></div>
<div>
Step 6: Reboot. </div>
<div>
<br /></div>
<div>
Bare Bones instructions..email me for more.</div>
</div>
deepak guruswamyhttp://www.blogger.com/profile/14617132698458472389noreply@blogger.com2tag:blogger.com,1999:blog-7252815424123057068.post-51183435442844354172011-12-21T23:06:00.000-08:002011-12-21T23:06:41.989-08:00Simple Programmable POV Display<div dir="ltr" style="text-align: left;" trbidi="on">I decided to develop a simple POV display keeping in line with the holiday spirit. the display can be mounted on a motor drive or used by hand.<br />
<br />
<b>Theory:</b><br />
The POV (Persistence of Vision) displays are based on the principle that the eye cannot discern movement beyond a certain speed. For example, a fast moving light would appear to be a contiguous line. This circuit exploits this principle to flash a straight line of LEDs in rapid succession in order to create words that appear in mid air. The circuit uses a PIC 16F88 microcontroller to control seven LEDs and flashes them based on the word that was programmed.<br />
<br />
<b>Programming:</b><br />
The project uses a single push button to program different letters into the EEPROM of the microcontroller. The push button is held down for about 5 secs to put it in programming mode. In order to enter different letters, the push button is depressed until the letter you need is reached. The letters are display in their binary format as follows:<br />
<br />
The LEDs are represented from most significant to least significant. 0 indicates off and 1 indicates on. After the desired letter is reached, wait for a few seconds for the character to be written to EEPROM. This will be indicated by all the LEDs going off. Repeat this process to program all the characters.<br />
<br />
<br />
A 0000001<br />
B 0000010<br />
C 0000011<br />
D 0000100<br />
E 0000101<br />
F 0000110<br />
G 0000111<br />
H 0001000<br />
I 0001001<br />
J 0001010<br />
K 0001011<br />
L 0001100<br />
M 0001101<br />
N 0001110<br />
O 0001111<br />
P 0010000<br />
Q 0010001<br />
R 0010010<br />
S 0010011<br />
T 0010100<br />
U 0010101<br />
V 0010110<br />
W 0010111<br />
X 0011000<br />
Y 0011001<br />
Z 0011010<br />
<space>[space] 0011011</space><br />
'0' 0011100<br />
'1' 0011101<br />
'2' 0011110<br />
'3' 0011111<br />
'4' 0100000<br />
'5' 0100001<br />
'6' 0100010<br />
'7' 0100011<br />
'8' 0100100<br />
'9' 0100101<br />
<div><br />
</div></div>deepak guruswamyhttp://www.blogger.com/profile/14617132698458472389noreply@blogger.com3tag:blogger.com,1999:blog-7252815424123057068.post-50070297527609011042011-03-25T13:02:00.000-07:002011-06-14T18:32:08.769-07:00Hacking a Passive Infared (PIR) Sensor with a PIC<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><br />
I got my hands on a quorum RR-150 PIR sensor from <a href="http://www.goldmine-elec.com/">Electronic Goldmine</a>. My goal was to make a receiver for the sensor. The PIR sensor uses a PT-2262 encoder chip connected with a DIP switch to generate random variations. The signal generated is 434 MHz<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgij9n9kmvmNKyCZ6mW6mBeqWu8b3hMQ0lFE_HDP082y3X_djTGSRX7vsJenVgjPhFw8M3KFXOA-hp0Gske7w6B1saoEYTF2XYSIOLLtjiD8y5SE_roJiM4nuLYduEiPOmz5DSknnKlZB4K/s1600/IMG_20110323_224851.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="297" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgij9n9kmvmNKyCZ6mW6mBeqWu8b3hMQ0lFE_HDP082y3X_djTGSRX7vsJenVgjPhFw8M3KFXOA-hp0Gske7w6B1saoEYTF2XYSIOLLtjiD8y5SE_roJiM4nuLYduEiPOmz5DSknnKlZB4K/s400/IMG_20110323_224851.jpg" width="400" /></a></div><br />
<br />
<br />
First things first. I needed to make sense of the signal pattern that was coming out of the PT-2262 encoder chip. I connected a RCR-433-AS receiver module to the <a href="http://www.hobbylab.us/USBOscilloscope/Home.htm">DisCo USB oscilloscope</a> I took a couple of screenshots of the pattern with different DIP settings to decipher it. <br />
<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh09kSk7aMjLcLdYAD5buM8al0anUlHPFMhBVmyE_2sIpqdfb1GIKXwwvquLY-bJsMFTUrR_-qs5ZUJ6izyzEUGF5i0m1X5f2uoDAQuKhck-0cfhLI8vu9QUVjZXV_C11fMEM74BCXCzVe6/s1600/IMG_20110323_224918.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="238" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh09kSk7aMjLcLdYAD5buM8al0anUlHPFMhBVmyE_2sIpqdfb1GIKXwwvquLY-bJsMFTUrR_-qs5ZUJ6izyzEUGF5i0m1X5f2uoDAQuKhck-0cfhLI8vu9QUVjZXV_C11fMEM74BCXCzVe6/s320/IMG_20110323_224918.jpg" width="320" /></a></div><br />
The DIP switch has 6 switches out of which 2 through 6 are connected to the PT2262 encoder. The 1st switch appears to control whether the remaining 5 switches are connected to Vdd or Vss. Turning on the DIP switch sets the port to Vdd or Vss (depending on switch 1) and turning it off leaves the port floating which is detected as a distinct state by the encoder. <br />
<br />
<div style="text-align: left;">The output pattern looks similar to this. There is a total of 25 bits in the pattern. The last 15 bits seem similar irrespective of the DIP switch setting. So that would be the signature to look for when detecting for this particular PIR sensor.</div><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj18TolieVDWpgw50K2F1Y1Z9ZwY9CT8kQHhK-f5WjUa_gHYTDqTplvwuSkwYn9x38Du-pKyJnuqG8C2eyxoczI92jqmYrmyIqR6J2i7o6z0hD5IcAabNBrjx7FdKaOVnGdOlXesLaDj98_/s1600/Screenshot.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="155" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj18TolieVDWpgw50K2F1Y1Z9ZwY9CT8kQHhK-f5WjUa_gHYTDqTplvwuSkwYn9x38Du-pKyJnuqG8C2eyxoczI92jqmYrmyIqR6J2i7o6z0hD5IcAabNBrjx7FdKaOVnGdOlXesLaDj98_/s400/Screenshot.png" width="400" /></a></div>The datasheet for PT 2622 indicates the following patterns for '1', '0' and floating<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsGJRWDj6u7RsrWL6OMKHMnPyYIXZNM9McsjReuB3ViM0kZaoz3Z1c_TDiOzpSI4_kfjQxVymrwI8SdL1REp_m-RYRXAyyftBTSRHoTkqiMLonNnpmAMhijOJySaLMeKeDRQria0QqEJ4z/s1600/000000.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="155" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsGJRWDj6u7RsrWL6OMKHMnPyYIXZNM9McsjReuB3ViM0kZaoz3Z1c_TDiOzpSI4_kfjQxVymrwI8SdL1REp_m-RYRXAyyftBTSRHoTkqiMLonNnpmAMhijOJySaLMeKeDRQria0QqEJ4z/s400/000000.png" width="400" /></a></div><b style="font-family: "Courier New",Courier,monospace;">DIP switch set at: 1-off 2-off 3-off 4-off 5-off 6-off</b><br />
The first 5 bits all show floating patterns.<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCv7Xcl5FBmnS2ffj_Nku6WxIbH-7kmG1QrxIEmcn9TrfsnGNi_uQNNpP9o7WmEOOF0QLSvPHCWB5_s4eiz4oYrOKQhUBSYnpBnha8Z7dfy4bHzoWhI7z8kasfmARqeSxXxCrsjxaAhuLq/s1600/010101.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="155" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCv7Xcl5FBmnS2ffj_Nku6WxIbH-7kmG1QrxIEmcn9TrfsnGNi_uQNNpP9o7WmEOOF0QLSvPHCWB5_s4eiz4oYrOKQhUBSYnpBnha8Z7dfy4bHzoWhI7z8kasfmARqeSxXxCrsjxaAhuLq/s400/010101.png" width="400" /></a><b style="font-family: "Courier New",Courier,monospace;"> DIP switch set at: 1-off 2-on 3-off 4-on 5-off 6-on </b><br />
Since the first switch is set to off the switches are all connected to Vss. So 'on' is represented by a '0' and a 'off' is represented by a floating pin.<br />
<br />
<br />
<br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitfs8GOzEWTwNuiMZZBKcvBaDE4rzRc61gZfBODZB-tfEKONIRl-immjVR8BUEHE3GBwyjjQkwYb6fQf4EovXzNsOVZz_VY5dlMQDtcTjEYjkVVtfceMnuLE84aig8jUaST9MTAe1gqQCm/s1600/110000.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="146" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitfs8GOzEWTwNuiMZZBKcvBaDE4rzRc61gZfBODZB-tfEKONIRl-immjVR8BUEHE3GBwyjjQkwYb6fQf4EovXzNsOVZz_VY5dlMQDtcTjEYjkVVtfceMnuLE84aig8jUaST9MTAe1gqQCm/s400/110000.png" width="400" /></a><br />
<b style="font-family: "Courier New",Courier,monospace;"></b><br />
<b style="font-family: "Courier New",Courier,monospace;">DIP switch set at: 1-on 2-on 3-off 4-off 5-off 6-off</b><br />
<span style="font-family: 'Courier New', Courier, monospace;"><span style="font-family: inherit;">Since the first switch is on, all the switches are connected to Vdd. So 'on' is represented by '1' and off is still floating pin. </span></span><b style="font-family: "Courier New",Courier,monospace;"></b><br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgE4cth79d2rBW0CePMLPHlGStr5i9Two4mZgPZ5wZ7B52vzlENKlr0qbqz6L3utCHPn9w2FglEO3upvPbhuW5LiqN4jBpWf-zH3PkVWcAqs3wAszLJhSr9iT0GNXVNri5PeolBbQmhM4en/s1600/IMG_20110323_224946.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><br />
</a><br />
<div class="separator" style="clear: both; text-align: center;"></div>So there is it...With this, we can now detect a unique signature pattern off the PIR and also detect the DIP switch setting.<br />
<br />
<iframe align="left" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://rcm.amazon.com/e/cm?t=deepakmicrocp-20&o=1&p=8&l=bpl&asins=0071472878&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;"></iframe><br />
<b>Operation:</b><br />
<br />
The pic I choose for the project is a midrange 12F683. Its perfect for this project because for its compact form fact (8 pin DIP) and Timer gating capability. (Timer gating is when the timer is incremented only when there is an input on the Timer Gating pin) <br />
<br />
In order to read these signals, The output from the RF receiver module is connected to the T1G port of the pic. This will increment timer when the input goes high. After a full pulse is received, the pic checks to see if the pulse is a long pulse or a short pulse based on the duration of the pulse.<br />
<br />
<pre class="C" name="code"></pre>After determining the type of the pulse, the bit type (1, 0 or floating) is constructed based on the sequence of the pulses. (ie. 2 shorts pulses is '0', 2 long pulses is '1', a short pulse followed by a long pulse is floating 'f') and store it in an array. Holding the push button down for 5 secs enables 'learning mode' which is used to store the code into the EEPROM. <br />
<br />
<br />
<b>Schematic:</b><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhx5L4OPlhMMMCkGjqejMC6akvL8uJ66whxz7W0Es40kxksLdiaNYgS0tcWjAvfmMTJvgktb_qb5oLLzdUw49AMwIcH4ssY2CUEoDjfpln5-gBXJzfJonlDmNv_djhsG9yTt0CmU6yopie-/s1600/pic_rcvr.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="301" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhx5L4OPlhMMMCkGjqejMC6akvL8uJ66whxz7W0Es40kxksLdiaNYgS0tcWjAvfmMTJvgktb_qb5oLLzdUw49AMwIcH4ssY2CUEoDjfpln5-gBXJzfJonlDmNv_djhsG9yTt0CmU6yopie-/s400/pic_rcvr.png" width="400" /> </a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;">Parts List:</div><ul style="text-align: left;"><li>IC1 - 12F683 PIC</li>
<li> LED1 - 3mm LED</li>
<li>R1 - 220 Ohm resistor</li>
<li>R2 - 39 Ohm resistor</li>
<li>S1 - Push button switch</li>
<li>K1 - Relay (170 ohm)</li>
<li>IC2 - 78L05 5v Voltage regulator</li>
<li>C1 - 0.1uF capacitor</li>
<li>Radiotronix RCR-433-RP RF receiver module</li>
</ul>Source code for this project is <a href="http://www.mindfront.net/pub/pir_rcvr.zip">available here</a> under GPL licence.<br />
<br />
To request the programmed chip, <a href="http://www.mindfront.net/contactus.html">click here</a> <br />
<ul style="text-align: left;"></ul><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: center;"><br />
</div><iframe allowfullscreen="" frameborder="0" height="390" src="http://www.youtube.com/embed/8Fg_3kPhlqs" title="YouTube video player" width="640"></iframe><br />
<br />
<div class="separator" style="clear: both; text-align: left;"></div></div><pre class="C" name="code"></pre></div>deepak guruswamyhttp://www.blogger.com/profile/14617132698458472389noreply@blogger.com20tag:blogger.com,1999:blog-7252815424123057068.post-58264907339311640982010-10-11T22:42:00.000-07:002010-10-11T22:42:49.965-07:00PIC 16F88 Digital Thermometer Light Meter and resistance ohm meter.<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">My original idea for this project was simply to try and interface the WINTEK WD-C2401P lcd panel to the pic (see my previous post). I figured it would be fun to add a couple of ADC readings to display something useful on the lcd. </span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<b><span class="Apple-style-span" style="font-family: Verdana, sans-serif;">Theory of Operation:</span></b><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">PORTB on the PIC is used as the data port for the LCD. The Enable, Register Select and Reset are tied to PORTA. Once the LCD is initialized, the PIC reads the ADC values from the thermistor, CDS cell and resistor (if connected) via a <a href="http://en.wikipedia.org/wiki/Voltage_divider">voltage divider</a>. The voltage divider translates any change in resistance from the sensors into changes in voltage. The V<span class="Apple-style-span" style="font-size: x-small;">out </span>is calculated as </span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">Vdd*(R2/R2+R1). ) So any change in R1 (the sensor's resistance) will result in a change in the output voltage. In order to translate this into the ADC value, a 10 bit ADC resolution microcontroller will have 1024 (2 to the power of 10) possible steps. So if the controller is operating on 5V then each step will increment the voltage by 5/1024 = 0.004882813V every increment. So the value in the ADC will be the voltage input at the ADC divided by 0.004882813. This allows for an accurate calculation of the resistance of the sensor. In order to translate the resistance to useful human readable form, its necessary to calibrate the sensors using real life instruments and extrapolating the values to the resistance offered. Since the display does not have any backlight, an LED is connected to PORTA4 to turn on whenever the light falls below a certain threshold. </span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><b>Parts:</b></span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">PIC 16F88</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">78L05 Voltage regulator</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">C1 - 1uf capacitor</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">R1,R3,R4 - 10K Ohm</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">R2 - 1K Ohm</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">R5 - 120 Ohm</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">LED</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">Thermistor</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">CDS Cell</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;">Wintek WD-C2401P LCD display</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><br />
</span><br />
<span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><b>Circuit Diagram:</b></span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlD7J56KD6rxhdw_rwoHZ3ULJUFUyiglZx8reXC1y5sP2s5Y6hTJj9mYf959pBHuEq7NTHIEZz9E107m0VpqwDz6a_ebfhXRYxMaQmj0C8KodNUXf9cjkR5Qr6v5UzuRFOQ6NIlx-0pi08/s1600/digital+Thermo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="499" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlD7J56KD6rxhdw_rwoHZ3ULJUFUyiglZx8reXC1y5sP2s5Y6hTJj9mYf959pBHuEq7NTHIEZz9E107m0VpqwDz6a_ebfhXRYxMaQmj0C8KodNUXf9cjkR5Qr6v5UzuRFOQ6NIlx-0pi08/s640/digital+Thermo.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><br />
</div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="color: #333333; font-family: Georgia, serif; font-size: small; line-height: 20px;">Designed by</span><span class="Apple-style-span" style="color: #333333; font-family: Georgia, serif; font-size: small; line-height: 20px;"> </span><span class="Apple-style-span" style="color: #333333; font-family: Georgia, serif; font-size: small; line-height: 20px;"><a href="http://www.mindfront.net/" style="color: #5588aa; text-decoration: none;">Mindfront Technologies</a></span><span class="Apple-style-span" style="color: #333333; font-family: Georgia, serif; font-size: small; line-height: 20px;"> </span><span class="Apple-style-span" style="color: #333333; font-family: Georgia, serif; font-size: small; line-height: 20px;">for </span> <a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4lsXcuTQfxnzULSJDWmOXqng_IKg2EBeUcuwelkXnnxLAp1JV9b5a9Ul_0AdBKc-vQ1STaxt_1g4fqn9BeCCCGrVYTUuaFMSIJAAJ3PdjVIry47PkCTOg3ZTtWbJyH20unwNcSJGWUDjd/s1600/Chaney.PNG" imageanchor="1" style="clear: left; display: inline !important; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="53" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg4lsXcuTQfxnzULSJDWmOXqng_IKg2EBeUcuwelkXnnxLAp1JV9b5a9Ul_0AdBKc-vQ1STaxt_1g4fqn9BeCCCGrVYTUuaFMSIJAAJ3PdjVIry47PkCTOg3ZTtWbJyH20unwNcSJGWUDjd/s200/Chaney.PNG" width="200" /></a></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="color: #333333; font-family: Georgia, serif; font-size: small; line-height: 20px;">The complete kit is available at <a href="http://www.chaneyelectronicsstore.com/servlet/the-505/Digital-Display-Geiger-Counter/Detail" style="color: #cc6600; text-decoration: underline;">www.chaneyelectroincs.com</a></span></div><span class="Apple-style-span" style="font-family: Verdana, sans-serif;"><b><br />
</b></span>deepak guruswamyhttp://www.blogger.com/profile/14617132698458472389noreply@blogger.com195tag:blogger.com,1999:blog-7252815424123057068.post-25328843160733833102010-09-28T22:03:00.000-07:002010-09-28T22:03:47.198-07:00ADC Conversions on MicrochipIn order to correctly perform an ADC it is important to ensure there is enough time between enabling the ADC module to performing a conversion. Here is a code sample for PIC 16F88<br />
<br />
<br />
#define TEMP 0x00 <span class="Apple-tab-span" style="white-space: pre;"> </span>//AN0<br />
#define LIGHT 0x08<span class="Apple-tab-span" style="white-space: pre;"> </span>//AN1<br />
<br />
<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ANSEL |= 0x03; //Select AN0-1 as analog<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>TRISA |= 0x03; //Select RA0-1 as input<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ADCON0 =0x00; //Configure A/D params<br />
<br />
<br />
unsigned int GetA2DLevel(unsigned char channel)<br />
{<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>unsigned int adc_result=0;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ADCON1 =0b10000000; //Configure A/D params<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ADCON0 =0b11000001 | channel; //Set the channel and start A/D module<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> __delay_us(20); //Delay required to ensure module is operating properly<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ADCON0 |= 0x04; //Start Conversion<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>while(ADCON0 & 0x04); //Wait for conversion<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>adc_result = ADRESH;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>adc_result = (adc_result<<8)|ADRESL;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ADCON0 =0x00;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return adc_result;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
}deepak guruswamyhttp://www.blogger.com/profile/14617132698458472389noreply@blogger.com4tag:blogger.com,1999:blog-7252815424123057068.post-15787571947229281482010-07-21T23:45:00.000-07:002010-10-07T16:28:28.720-07:00Interfacing Wintek WD-C2401P LCD with Microchip PIC Wintek WD-C2401P LCD panel is a 24x1 character display. The code for using the LCD was written for microchip PIC 16F88 but should work with all other micro controllers.<br />
<br />
<h1><span class="Apple-style-span" style="font-size: x-large;">Pinout for the WD-C2401P</span></h1><table border="0"><tbody>
<tr><td valign="top" width="15%">Pin #</td><td valign="top" width="15%">Name</td><td valign="top">Function</td></tr>
<tr><td valign="top" width="15%">1</td><td valign="top" width="15%">Vss</td><td valign="top">Ground ( 0v)</td></tr>
<tr><td valign="top" width="15%">2</td><td valign="top" width="15%">Vdd</td><td valign="top">+5 volts</td></tr>
<tr><td valign="top" width="15%">3</td><td valign="top" width="15%">Reset</td><td valign="top">When this pin is low it resets the LCD. You can either tie this pin to a pin on your microcontroller so you can reset the LCD before initializtion, or just tie it high. I had a couple of times where I couldn't init the LCD without first resetting it, so I'd recommend putting it under micro control, or some other powerup controller. The reset low time should be at least 10ms. The time after reset before you start commanding the LCD should also be at least 10 ms.</td></tr>
<tr><td valign="top">4</td><td valign="top">RS</td><td valign="top">Register Select. This pin determines whether the data you're about to write is a command or a data byte. Commands do interesting stuff to the LCD, like set the number of lines or contrast. Data is what actually gets put on the screen, or in the custom character registers. High means Data, Low means command</td></tr>
<tr><td valign="top">5</td><td valign="top">Read/Write</td><td valign="top">Set this pin high to read from the display. Set this pin low to write to it. If you don't need to update the display super fast you can save an I/O line by just tying it to ground. Wait at least a millisecond between each command and data, though, since you can't query the busy status without read capability.</td></tr>
<tr><td valign="top">6</td><td valign="top">E</td><td valign="top">Enable. This line works to clock in data and commands. See the protocol section below.</td></tr>
<tr><td valign="top">7</td><td valign="top">DB0</td><td valign="top">Least Significant Data Bit</td></tr>
<tr><td valign="top">8</td><td valign="top">DB1</td><td valign="top"></td></tr>
<tr><td valign="top">9</td><td valign="top">DB2</td><td valign="top"></td></tr>
<tr><td valign="top">10</td><td valign="top">DB3</td><td valign="top"></td></tr>
<tr><td valign="top">11</td><td valign="top">DB4</td><td valign="top"></td></tr>
<tr><td valign="top">12</td><td valign="top">DB5</td><td valign="top"></td></tr>
<tr><td valign="top">13</td><td valign="top">DB6</td><td valign="top"></td></tr>
<tr><td valign="top">14</td><td valign="top">DB7</td></tr>
</tbody></table><br />
Details of soldering the pins are available at <a href="http://www.serialwombat.com/parts/lcd111.htm">http://www.serialwombat.com/parts/lcd111.htm</a><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3iQKpCYKbQuZTFBEYTddUhNMLSmJGu_Povi6a1MgWQVpYYadeOfAF9B-Un9Y0zDslY8WAkoBokoyN9hyphenhyphen5NZT6FuwnGVIzkGiPfcvHCRP19lUuQ1X9jAtVD0FkGZ8jTDcLpC-mAimGIQcZ/s1600/2010-07-21+23.49.46.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3iQKpCYKbQuZTFBEYTddUhNMLSmJGu_Povi6a1MgWQVpYYadeOfAF9B-Un9Y0zDslY8WAkoBokoyN9hyphenhyphen5NZT6FuwnGVIzkGiPfcvHCRP19lUuQ1X9jAtVD0FkGZ8jTDcLpC-mAimGIQcZ/s320/2010-07-21+23.49.46.jpg" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYuIoYfQecHxWtF6ryC6kWhCtkBBhorxreWRNpO_7wqiF-lgMYBG9OPLGBo95A6-voL_pNcXeF-xP8xWveqHLvftVnpmEo_yrj7f-KKjYzkZDv-Vwhj_ieNr_5HZv9q3_UrUYKSLZAYEip/s1600/2010-07-21+23.49.33.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiYuIoYfQecHxWtF6ryC6kWhCtkBBhorxreWRNpO_7wqiF-lgMYBG9OPLGBo95A6-voL_pNcXeF-xP8xWveqHLvftVnpmEo_yrj7f-KKjYzkZDv-Vwhj_ieNr_5HZv9q3_UrUYKSLZAYEip/s320/2010-07-21+23.49.33.jpg" /></a></div><br />
<br />
<pre name="code" class="C">
lcd_wintek_wdc2401p.h:
#define E_LO PORTA &= ~0x80; //RA7
#define E_HI PORTA |=0x80
#define RS_HI PORTA |=0x40 //RA6
#define RS_LO PORTA &= ~0x40
#define RESET_LO PORTA &= ~0x04
#define RESET_HI PORTA |= 0x04
#define LCD_DATA PORTB
#define DELAY10MS __delay_ms(10)
#define DELAY1MS __delay_ms(1)
#define DELAY5MS __delay_ms(5)
#define DELAY20MS __delay_ms(20)
#define DELAY90MS __delay_ms(90)
#define DELAY0_5MS __delay_us(500)
#define DELAY5US __delay_us(5)
void LCDInitialize();
void LCDWriteChar(char c);
void LCDClockByte(char c); //Called internally do not use
void LCDClearScreen();
void LCDWriteString(char *s);
void LCDResetChar(); //Return back to first address
lcd_wintek_wdc2401p.c:
#include "lcd_wintek_wdc2401p.h"
void LCDInitialize()
{
DELAY90MS;
RESET_LO;
DELAY20MS;
RESET_HI;
DELAY20MS;
//Initialize Sequence
E_LO;
DELAY5US;
RS_LO;
DELAY1MS;
LCDClockByte(0x1C); //Turn on the lcd driver power
LCDClockByte(0x14); //Turn on the character display
LCDClockByte(0x28); //Set two display lines (The hd66717 considers
//12 characters to be a line. Our 24 character display is
//actually two 12-character lines right next to each other).
LCDClockByte(0x4F); //Set to darkest contrast
LCDClockByte(0xE0); //Set the data address to the first character
DELAY5MS;
}
void LCDClockByte(char c)
{
DELAY1MS;
LCD_DATA = c;
E_HI;
DELAY5US;
E_LO;
}
void LCDWriteChar(char c)
{
RS_HI;
LCDClockByte(c);
}
void LCDResetChar()
{
RS_LO;
LCDClockByte(0x02);
}
void LCDWriteString( char *s)
{
unsigned char c,i,end_flag=0;
DELAY1MS;
LCDResetChar();
DELAY1MS;
for(i=0;i< 24;i++) {
c = (s[i] == 0x00)?'-':s[i];
if(s[i] == 0x00 || end_flag == 1){
c = ' ';
end_flag = 1;
} else {
c = s[i];
}
LCDWriteChar(c);
}
}
void LCDClearScreen()
{
RS_LO;
LCDClockByte(0x01);
}
main.c: (Sample Usage)
#include "lcd_wintek_wdc2401p.h"
main() {
//Make sure you setup the pins on the micro controller for output
// and designate the pins properly in the include file.
char s[]="abcdefghijklmnop";
LCDInitialize();
LCDClearScreen();
LCDWriteString(s);
}
</pre>deepak guruswamyhttp://www.blogger.com/profile/14617132698458472389noreply@blogger.com6tag:blogger.com,1999:blog-7252815424123057068.post-39451101144690976412010-04-19T21:06:00.000-07:002010-04-19T21:15:30.586-07:00Zilog Microcontroller General Purpose Frequency Counter with 7 segment display<div style="font-family: inherit;"><span style="font-size: small;">This circuit is a frequency counter circuit original designed to be used with a Geiger Counter.</span><span style="font-size: small;">This circuit uses an 8 bit 8F0423 Zilog microcontroller to act as a frequency counter. The input to the circuit is driven through an optocoupler to isolate the source circuit. The output is displayed on a 3 digit seven segment display. There are 2 push buttons, one for reset and another to select between counter and frequency mode. Counter mode simply measures the counts whereas the frequency mode measures the counts per minute. The counter can accurately measure input up to 999,999, but only the 3 most significant digits are displayed. For example to display 19,832, 198 is displayed on the seven segment display and the x100 LED comes on. The overflow LED is used to indicate when the count has exceeded 999,999. It is fairly simple to add additional digits but for the purpose of my measurement the 3 most significant digits were sufficient. </span></div><div style="font-family: inherit;"><span style="font-size: small;"><br />
</span></div><div style="font-family: inherit;"><span style="font-size: small;"><b>Technical Details:</b></span></div><div style="font-family: inherit;"><span style="font-size: small;"><br />
</span></div><div class="separator" style="clear: both; font-family: inherit; text-align: center;"><span style="font-size: small;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjp5cTusUZsxl10rOpnN9AEhMMWz6dHoAXAJU_H9dazMK2ye1prrapNqqiyEuELCJmkMrUJeV1QSKSqrMeXLXvr9zOrb5OFLc_BQDw3c3St1IXogQKiU2rvNxC4X9jLQe4iIzlLI5nBXGWB/s1600/geiger.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="283" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjp5cTusUZsxl10rOpnN9AEhMMWz6dHoAXAJU_H9dazMK2ye1prrapNqqiyEuELCJmkMrUJeV1QSKSqrMeXLXvr9zOrb5OFLc_BQDw3c3St1IXogQKiU2rvNxC4X9jLQe4iIzlLI5nBXGWB/s640/geiger.png" width="640" /></a></span></div><div style="font-family: inherit;"><span style="font-size: small;"><br />
</span></div><div style="font-family: inherit;"><span style="font-size: small;"><br />
</span></div><div style="font-family: inherit;"><span style="font-size: small;">The output from the optocoupler is connected to pin 11 of the microcontroller with a pull up resistor. A pull up resistor is used to ensure that there is a proper logic on the microcontroller input even when the output from the optocoupler is floating. An interrupt service routine (ISR) is triggered every time there is a transition on the port (from low logic to high logic and vice versa). The ISR keeps track of the count. Timer 1 is configured as a timer to indicate when a full minute is elapsed. This allows for the calculation of the number of transitions per minute. The 2 pins which say "To Geiger LED" take the input from any source. </span></div><div style="font-family: inherit;"><span style="font-size: small;"> </span> </div><div style="font-family: inherit;"><span style="font-size: small;"><b>Driving the seven segment display:</b><br />
There are 7 LEDs per digit and to display 3 digits it will normally take 7x3 = 21 pins. This is beyond the packaging of most microcontrollers and a waste of resources. Instead a technique called multiplexing is used. Each digit on the display is turned on and off so rapidly that it gives an illusion that they are all on at the same time. This is due to the persistence of vision experienced by the eye. Timer 0 is configured to timeout every 1 ms and updates the seven segment display. </span></div><div style="font-family: inherit;"><span style="font-size: small;"><a href="http://www.blogger.com/post-edit.g?blogID=7252815424123057068&postID=3945110114469097641" name="0.1_graphic02"></a></span><span style="font-size: small;"><img alt="Your browser may not support display of this image." height="1" src="https://mail.google.com/mail/?name=d33be9805ff33117.jpg&attid=0.1&disp=vahi&view=att&th=127ac2e4793d53ba" width="1" /> </span></div><div style="font-family: inherit;"><span style="font-size: small;"><br />
</span></div><div style="font-family: inherit;"><span style="font-size: small;"><b>Mode and reset buttons: </b> <br />
The mode and reset buttons are driven by their own ISRs to interrupt every time they are pushed down. The internal pull up resistor is enabled on the pins connected to push button switches. This is to ensure there is always a clear logic level even when the push button is off (floating). </span><br />
<br />
<div class="separator" style="clear: both; font-family: inherit; text-align: left;"><span style="font-size: small;"><span class="Apple-style-span">Designed by <a href="http://www.mindfront.net/">Mindfront Technologies</a> for </span><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirduK79uJHtnyf8WADg8f2KUMAijlQQIJUhM7YZM9Wfl_zmR4XuBcCJHhJIUPaHNR0Ch2jnBR3bOHK1VXaK6pQvia7yyxzBq3Dm62SH-7-oDm_peUsMGtEhBZNXkf-71scSDyDrFniLjGC/s1600/Chaney.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="53" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirduK79uJHtnyf8WADg8f2KUMAijlQQIJUhM7YZM9Wfl_zmR4XuBcCJHhJIUPaHNR0Ch2jnBR3bOHK1VXaK6pQvia7yyxzBq3Dm62SH-7-oDm_peUsMGtEhBZNXkf-71scSDyDrFniLjGC/s200/Chaney.PNG" width="200" /></a></span></div><div class="separator" style="clear: both; font-family: inherit; text-align: left;"><span style="font-size: small;"><span class="Apple-style-span">The complete kit is available at <a href="http://www.chaneyelectronicsstore.com/servlet/the-505/Digital-Display-Geiger-Counter/Detail">www.chaneyelectroincs.com</a> </span></span></div><span style="font-size: small;"><br />
<a href="http://www.chaneyelectronicsstore.com/servlet/the-505/Digital-Display-Geiger-Counter/Detail"></a></span></div>deepak guruswamyhttp://www.blogger.com/profile/14617132698458472389noreply@blogger.com5tag:blogger.com,1999:blog-7252815424123057068.post-24213428397836559642010-04-05T21:19:00.000-07:002010-04-17T23:13:49.865-07:00PIC 16F88 Microcontroller PIC based Tengu<span style="font-family: Verdana,sans-serif;">Tengu derives its name from a mythical Japanese creature known for getting into mischief. Our Tengu, however is more earthly in nature. It responds to voice and sounds and takes on different facial features depending on the intensity of the sound. If no sound is heard for some time, it changes from a happy face to a sad face and then goes to sleep. Gently blowing on his face wakes him back up to his usual happy self. </span><br />
<span style="font-family: Verdana,sans-serif;"><br />
</span><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcIMwZeLtnKnM-jFtFbJ1y1AdEZ83GV5Htc8dPCfKwg7v0Ki_X0bYbJhWcZI3BciDNIkPagqrbtIOy9P3AgxGpizm99Wxq9WjQAZpIinD8JvxtOI1axfkTUBZDxFn6Antb5-yVJLQ6Sj7N/s1600/tengu.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjcIMwZeLtnKnM-jFtFbJ1y1AdEZ83GV5Htc8dPCfKwg7v0Ki_X0bYbJhWcZI3BciDNIkPagqrbtIOy9P3AgxGpizm99Wxq9WjQAZpIinD8JvxtOI1axfkTUBZDxFn6Antb5-yVJLQ6Sj7N/s320/tengu.jpg" /></a></div><span style="font-family: Verdana,sans-serif;"><br />
</span><br />
<span style="font-family: Verdana,sans-serif;"><b>The Technical Details:</b></span><br />
<span style="font-family: Verdana,sans-serif;">The project is based on a <a href="http://ww1.microchip.com/downloads/en/DeviceDoc/30487C.pdf">Microchip PIC 16F88</a> which is part of their mid range of microcontrollers. The sound is amplified through a pre-amp circuit based on 2N3904 and fed to the RB7/AN6 (pin 13) of the pic microcontroller. The A/D converter on the microcontroller is used to convert the analog signal from the pre-amp. The LED Matrix is directly driven by the pic. In order to be able to display the entire smiley, the LED dot matrix is multiplexed in such a way that only one row out of the seven is active at any given time. However the rows are turned on and off so rapidly, the human eye sees it as a full picture. This effect is called the persistence of vision. In order to achieve multiplexing, timer 0 on the pic is running at approximately 1 ms timeouts to switch the row that is being displayed on the LED Matrix. Timer 1 is configured as a general purpose timer used to keep track of the time since any noise over the threshold was heard. This is used to change the smiley from a happy to a sad one. The code is written in C using MPLAB and Hi-Tech C compiler ver 9.80.</span><br />
<span style="font-family: Verdana,sans-serif;"> <br />
</span><br />
<span style="font-family: Verdana,sans-serif;"><b>Parts List:</b></span><br />
<ul><li><span style="font-family: Verdana,sans-serif;">PIC Microchip 16F88</span></li>
<li><span style="font-family: Verdana,sans-serif;">7x5 LED Dot Matrix Display</span></li>
<li><span style="font-family: Verdana,sans-serif;">5 x 160 Ohm resistor</span></li>
<li><span style="font-family: Verdana,sans-serif;">2 x 10K Ohm resistor</span></li>
<li><span style="font-family: Verdana,sans-serif;">1 x 100K Ohm Resistor </span></li>
<li><span style="font-family: Verdana,sans-serif;">2N3904 NPN Transistor</span></li>
<li><span style="font-family: Verdana,sans-serif;">Electret Mic</span></li>
<li><span style="font-family: Verdana,sans-serif;">1 x 0.1 uf capacitor</span></li>
<li><span style="font-family: Verdana,sans-serif;">1uf capacitor</span></li>
<li><span style="font-family: Verdana,sans-serif;">78L05 5v voltage regulator</span></li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifvkGvqCxQs0LJWQb3WHm68aRkQsEYcSmMfRJq-W1k6QA3iPFRX9w81t7g-0OYfEY45CvXYDSjWzg_-jxI-xKdNgdqZO71OiARoFFAthEQ5f3IMDNleY5hJtaAQPjkXA9uOCCcaoosn9qm/s1600/Tengu.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="496" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifvkGvqCxQs0LJWQb3WHm68aRkQsEYcSmMfRJq-W1k6QA3iPFRX9w81t7g-0OYfEY45CvXYDSjWzg_-jxI-xKdNgdqZO71OiARoFFAthEQ5f3IMDNleY5hJtaAQPjkXA9uOCCcaoosn9qm/s640/Tengu.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: center;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif;">Circuit Diagram </span></div><div class="separator" style="clear: both; text-align: center;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif;">Eagle Schematic available <a href="http://cid-aab65fb96853e507.skydrive.live.com/self.aspx/.Public/workspace/tengu/tengu.sch">here</a></span></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif;"><br />
</span></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif;">The gain I was getting on the amp circuit above was only moderate. I changed the circuit to use a LM386 based on <a href="http://www.josepino.com/?mini_amplifier_lm386">Jose Pino's circuit</a> and got a much better gain. The circuit diagram is below. The 10K potentiometer is used to adjust the sensitivity of the mic while the 100K potentiometer is used to adjust the gain. </span></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif;"><br />
</span><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5FSpdSUREwA2JvUWkkTZo6vShdgNw0IFL5ck0kfSqmzuUEzihyphenhyphenOeHHzp2-S4pp8xslXECEPNfC7tx_Sp-plb0BKUJTJOlt4Nle_cHuUl6jxDo0HPIZ_Yr9Tb2lNm1p1uXsYSxaSmfM5UD/s1600/Tengu_amp.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="339" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5FSpdSUREwA2JvUWkkTZo6vShdgNw0IFL5ck0kfSqmzuUEzihyphenhyphenOeHHzp2-S4pp8xslXECEPNfC7tx_Sp-plb0BKUJTJOlt4Nle_cHuUl6jxDo0HPIZ_Yr9Tb2lNm1p1uXsYSxaSmfM5UD/s640/Tengu_amp.png" width="640" /></a></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif;"><br />
</span></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif;">Designed by <a href="http://www.mindfront.net/">Mindfront Technologies</a> for </span><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirduK79uJHtnyf8WADg8f2KUMAijlQQIJUhM7YZM9Wfl_zmR4XuBcCJHhJIUPaHNR0Ch2jnBR3bOHK1VXaK6pQvia7yyxzBq3Dm62SH-7-oDm_peUsMGtEhBZNXkf-71scSDyDrFniLjGC/s1600/Chaney.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="53" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirduK79uJHtnyf8WADg8f2KUMAijlQQIJUhM7YZM9Wfl_zmR4XuBcCJHhJIUPaHNR0Ch2jnBR3bOHK1VXaK6pQvia7yyxzBq3Dm62SH-7-oDm_peUsMGtEhBZNXkf-71scSDyDrFniLjGC/s200/Chaney.PNG" width="200" /></a></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif;">The complete kit is available at <a href="http://www.chaneyelectroincs.com/">www.chaneyelectroincs.com</a> </span></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif;"><br />
</span></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif;">Here is the video of the project in action:</span></div><object height="344" width="425"><param name="movie" value="http://www.youtube.com/v/_wSfgQfhQZA&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/_wSfgQfhQZA&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object><br />
<br />
<div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif;"><br />
</span></div><div class="separator" style="clear: both; text-align: left;"><span class="Apple-style-span" style="font-family: Verdana,sans-serif;"><br />
</span></div>deepak guruswamyhttp://www.blogger.com/profile/14617132698458472389noreply@blogger.com6