tag:blogger.com,1999:blog-9157876539902435702024-03-14T10:07:59.813-07:00Shovon's workShovonbdhttp://www.blogger.com/profile/04302437234075930187noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-915787653990243570.post-83747446961371101772017-06-19T07:53:00.003-07:002017-07-09T15:42:44.608-07:00Bot, my personal pet robot<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
It has been about a two months since I started writing to my blog again after may be 2-3 years. I wish to continue writing from now on. So, today I post about my personal pet robot, Bot.</div>
<div style="text-align: justify;">
I first started working on my personal robot about probably a year and a half ago. I wanted to make a robot which I can use for various experiments and of course I have a dream of having my own pet robot. The picture posted here is the latest revision of the robot. It has undergone three revisions due to various issues and my personal preferences.</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3gXlNcvhyEAgXYZt9PN1kp7fTokSmAD0umcqzMhWevCLQZd56u7ng9iJcMTcHLCCjiub6flhsf0_Hpd5WJVOFHWPR7jdp5P6Aghs4z0QebJfl9PWMmQ_3w3afObmPgee75Ojh6tc0dkWQ/s1600/IMG_20170619_035908.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" data-original-height="1200" data-original-width="1600" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3gXlNcvhyEAgXYZt9PN1kp7fTokSmAD0umcqzMhWevCLQZd56u7ng9iJcMTcHLCCjiub6flhsf0_Hpd5WJVOFHWPR7jdp5P6Aghs4z0QebJfl9PWMmQ_3w3afObmPgee75Ojh6tc0dkWQ/s640/IMG_20170619_035908.jpg" width="640" /></a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br />
<br />
<br />
<br />
<br />
<div style="text-align: center;">
<br />
<br />
Latest revision of Bot. Yeah,its untidy. But I still love it.</div>
</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The first Bot only had an ESP8266 as a its brain. That was only used for an OpenCV experiement. Later on I bought another chassis with two wheels and encoders. But That platform turned out to be unstable and the motors were of bad quality.</div>
<div style="text-align: justify;">
Bot rev. 2.0 had a raspberry pi 2 as its brain and an Arduino UNO for more "realtime" things like controlling the motors,taking battery voltage reading and acquiring data from IMU etc. I also added a Raspberry pi NoIR camera and a dot matrix display as its face. </div>
<div style="text-align: justify;">
Here is a video of that robot smiling when it saw a ball,</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/zSg2SpqIIGQ/0.jpg" frameborder="0" height="266" src="https://www.youtube.com/embed/zSg2SpqIIGQ?feature=player_embedded" width="320"></iframe></div>
<div style="text-align: justify;">
This was just a basic color based object tracking demo. After facing numerous stability issues and lack of space, I gave up that platform and finally bought the current chassis you can see in the previous photo. It has two motors built in.</div>
<div style="text-align: justify;">
This chassis is great as it doesn't overspeed and both motors rotate almost at the same rate. Now my objective was to make it go in a straight line.As this chassis had no encoder, I had to use an MPU6050 IMU.</div>
<div style="text-align: justify;">
This Intertial Measurement UNIT has a 3 axis accelerometer and a 3 axis gyroscope and is an excellent bargain for $2-$3(in my country). Now,in order to move in a straight line, the robot must keep its yaw angle constant. Now we all know that accelerometers can't measure yaw angle and gyros have a drift problem, which means they tend to drift and therefore for the same orientation, their reading changes. So I would need a magnetometer. Fortunately, MPU6050 has a built in digital motion processor which runs some sort of weird and wonderful low pass filtering algorithm that keeps the yaw angle stable enough(note this enough) even without help from a magnetometer. </div>
<div style="text-align: justify;">
The arduino runs a simple nested if...else... to keep itself steady when going straight or steering 90 degrees. I could have used PID there, but this if else seems to be working so didnt.</div>
<div style="text-align: justify;">
Then comes another problem. This robot runs on a 7.4V 800mAh lipo battery. Battery voltage is not a constant thing.When you charge it, it goes up to a value. When you use it, the voltage drops. As a result, the minor speed tweaking of the two motors of our differential drive system doesnt work anymore and the robot canoot correct its orientation properly or turn efficiently etc.</div>
<div style="text-align: justify;">
Now this issue can be solved in many ways like taking voltage reading and adjusting calibration accordingly in the code. But I did something that is not very efficient but easy. </div>
<div style="text-align: justify;">
I connected a boost converter followed by a buck converter between battery and motor driver. The boost converter boosts the voltage to about 9V and then the buck converter converts it to about 8 volts, at which I did my tweaks.That way the voltage remains pretty much constant but since nothing is free in our world, I lose efficiency that means my battery runs out faster but thats okay for now.</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfUfIGMgOCzvEphvU-HfOxGJpVhTr9oX0WeP59qlJ9EAsKXhGna4cOSDN-TcW5SGewMJTp4B0ccpdiO3vdFmGRmyv3_OafcixjYA4C4SG46n5mz5u_T939pZ8IGBdcTn8PzkVyY7riV_qg/s1600/IMG_20170619_193731.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="1200" data-original-width="1600" height="480" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfUfIGMgOCzvEphvU-HfOxGJpVhTr9oX0WeP59qlJ9EAsKXhGna4cOSDN-TcW5SGewMJTp4B0ccpdiO3vdFmGRmyv3_OafcixjYA4C4SG46n5mz5u_T939pZ8IGBdcTn8PzkVyY7riV_qg/s640/IMG_20170619_193731.jpg" width="640" /></a></div>
<div style="text-align: justify;">
Dusty, very very dusty. On the left are the power input cables for motor driver and on the right are the battery cables </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Now let's take a look at the brain, the raspberry pi 2. It is running raspbian jessie. Its a great sbc for community support etc. but not powerful enough to do anything beyond very basic image processing. So when I work with image processing things with this robot. I usually stream video from the pi over wifi and use opencv on PC to process the stream. </div>
<div style="text-align: justify;">
The following link contains an excellent set of instructions on how to do this.</div>
<div style="text-align: justify;">
<a href="http://petrkout.com/electronics/low-latency-0-4-s-video-streaming-from-raspberry-pi-mjpeg-streamer-opencv/" target="_blank">http://petrkout.com/electronics/low-latency-0-4-s-video-streaming-from-raspberry-pi-mjpeg-streamer-opencv/</a></div>
<div style="text-align: justify;">
Reducing image size or 320x240 resulted in a near instant streaming with almost zero lag,but we are using wifi dongle, so sometimes it suffers some lag.</div>
<div style="text-align: justify;">
I am working on adding autonomy but for now,I use it as a remote controlled car to test its driving performance etc. This is a very slow project as I work on it maybe once a week or month. But work is progressing and I hope it will be done someday.</div>
<div style="text-align: justify;">
I wanted to implement a ROS based control environment for this robot. So I installed ROS in raspberry pi following the instructions at ROS website.</div>
<div style="text-align: justify;">
After initializing etc. if you want to connect your pi to your PC,then change the ROS_MASTER_URI environment variable in pi to your PC ip address.</div>
<div style="text-align: justify;">
run these commands</div>
<div style="text-align: justify;">
<span style="font-family: "courier new" , "courier" , monospace;">nano ~/.bashrc</span></div>
<div style="text-align: justify;">
then at the end of that file. Paste the following,</div>
<div style="text-align: justify;">
</div>
<span style="font-family: "courier new" , "courier" , monospace;">export ROS_MASTER_URI="http://<your host="" ip="" ros=""><pc_ip_address>:11311"</pc_ip_address></your></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: "arial" , "helvetica" , sans-serif;">then close nano by pressing Ctrl+x->y->Enter</span></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: "arial" , "helvetica" , sans-serif;">run <span style="font-family: "courier new" , "courier" , monospace;">source ~/.bashrc</span></span></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: "arial" , "helvetica" , sans-serif;">Now, you can run roscore in your pc and the pi will talk to it.</span> </span> </span></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: "arial" , "helvetica" , sans-serif;">Right now, I am working on ROS integration. will post more when its done.</span></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: "arial" , "helvetica" , sans-serif;">My ultimate goal is to make a robot that can move between rooms and find the caller. It may also notify me about important emails and things. It has a speaker. I shall add a microphone. I added one but the audio reception was really bad.</span></span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: "arial" , "helvetica" , sans-serif;">If any of you are wondering about the laser beside the camera, I used it to implement a laser rangefinder using image processing. I shall post it soon. </span> </span><br />
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
</div>
</div>
Shovonbdhttp://www.blogger.com/profile/04302437234075930187noreply@blogger.com0tag:blogger.com,1999:blog-915787653990243570.post-41983236218523627942017-04-25T15:05:00.001-07:002017-06-19T09:51:42.547-07:00An attempt to make a minimal busybox rootfs with glibc dropbear and wpa_supplicant on Orange pi zero Part1<div dir="ltr" style="text-align: left;" trbidi="on">
This blog post and anything that comes after this and is related to this is probably gonna be less like a tutorial and more like an attempt to keep a record of whatever I am doing/did as I have found the steps forgotten pretty much every time I tried repeating them.<br />
<br />
<div style="text-align: justify;">
Okay,lets get started. I love single board computers. I have various ones(mostly from China). I was formerly working in an R&D company and I was doing basic linux image building using various build systems there. Now,up untill a few days ago,I was quite happy with the build systems available but then I saw a wonderful video on how someone managed to boot linux with busybox in just 1 frigging second! Here is the video, </div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/KTRA1PRJWH8/0.jpg" frameborder="0" height="266" src="https://www.youtube.com/embed/KTRA1PRJWH8?feature=player_embedded" width="320"></iframe></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
That got me thinking, hmm ,lets try that! First I will try to create a very basic filesystem and boot and will also enable wifi. Fast booting is for later experiments.</div>
<div style="text-align: justify;">
I chose Orange pi Zero as my guinea pig as I am playing with that board now.Its a pretty nice board with an Allwinner H2 quad core processor,512MB RAM and 10/100 ethernet and wifi! It costs about $6.99 in aliexpress(mine was twice as much as I bought it from a local source).</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5ooNeeAzTeg0dyWxmID-cJhg9Kgb7Sm3XQj8gmJvkedDmjqjxxNF_sVYuAMQcm5_zCGydTaTbMnmzlKuK6fSrr7CuJRj1IJICnQJ-am94oIHE6gtgNEk5pDpblc9d22lA_67aOFMTAYmH/s1600/Orange-Pi-Zero-H2-Quad-Core-Open-source-256MB-development-board-beyond-Raspberry-Pi-.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5ooNeeAzTeg0dyWxmID-cJhg9Kgb7Sm3XQj8gmJvkedDmjqjxxNF_sVYuAMQcm5_zCGydTaTbMnmzlKuK6fSrr7CuJRj1IJICnQJ-am94oIHE6gtgNEk5pDpblc9d22lA_67aOFMTAYmH/s320/Orange-Pi-Zero-H2-Quad-Core-Open-source-256MB-development-board-beyond-Raspberry-Pi-.jpg" width="320" /></a></div>
<div style="text-align: justify;">
</div>
<div style="text-align: justify;">
Alright,so the first step was to boot obviously.So,I downloaded the latest u-boot source and tried to build it for orange pi zero(u-boot has defconfig for this board so I didnt have to write my own) and volla! it failed. It was a gcc issue.I am running Ubuntu 16.04 and the default gcc version is 5.4.0(same for the arm-linux-gnueabihf-gcc I used) and u-boot and linux build for Allwinner boards doesnt go well with that. </div>
<div style="text-align: justify;">
Then after some other random attempts,I tried another weird idea. I saw this link where they ran OpenWrt on that board using kernel and u-boot from Armbian build system.</div>
<div style="text-align: justify;">
<a href="https://gist.github.com/praveenbm5/3c81692e6b2b651bb450fb7fc45dff4d" target="_blank">https://gist.github.com/praveenbm5/3c81692e6b2b651bb450fb7fc45dff4d</a></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
So I thought,lets try it this way first.But, my requirement is a very basic filesystem with thing that I need only.For now, that is just wifi and dropbear with scp support.Now I am using u-boot and kernel from Armbian with all the drivers(I will load whatever I want).</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
For doing most of the steps,a linux system is needed. You can try linux in VirtualBox or VMWare if you are in Windows. For some of the super annoying problems, even I had to switch to a 32bit ubuntu server VM image as my 64 bit Ubuntu was throwing errors during some builds.</div>
<div style="text-align: justify;">
<b>Note: use sudo if you see permission denied.</b> </div>
<div style="text-align: justify;">
so here are my steps.</div>
<ol style="text-align: left;">
<li>Download/build an armbian ubuntu xenial headless image(kernel 3.4.113 for now). Armbian website has very nice download page for each of the single board computers they support.The Legacy one was the choice here.I will try the mainline one too.</li>
<li>Write that to SD card.Now you have a nice Armbian filesystem with u-boot and 3.4.113 legacy kernel.</li>
<li>Now delete everything there except <b>boot</b> and <b>lib</b> folder. Inside <b>lib</b> folder, you can delete everything except <b>modules</b> and <b>firmware</b> folders.</li>
<li>Now time for some build operations. First some prerequisites.Some of them may not even be prerequisites, but I am still including them anyway.Note that these may not contain everything you need.So if an error comes like no such file bla bla bla,feel free to google.Now,open up a terminal and type,<br /><span style="font-family: "courier new" , "courier" , monospace;">sudo apt-get install build-essential gawk autoconf libncurses5-dev git libssl-dev crossbuild-essential-armhf</span></li>
<li><span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: "arial" , "helvetica" , sans-serif;">Once we are done with that. its time to build busybox. Its a set of many useful linux tools. Some of the version selections etc might look weird but its basically a compilation of things I scavenged from the internet. <br /><span style="font-family: "courier new" , "courier" , monospace;">wget http://busybox.net/downloads/busybox-1.24.1.tar.bz2<br />tar -xjf busybox-1.24.1.tar.bz2<br />make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- defconfig<br />make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j8<br />make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- install</span> It then copies the files to _install folder in the busybox directory. Now we copy it to SD card. probably we could have copied it in the last command by specifying <span style="font-family: "courier new" , "courier" , monospace;">CONFIG_PREFIX</span>.<br />Now run,<span style="font-family: "courier new" , "courier" , monospace;"><br />sudo rsync -a _install/ /path/to/sd/card</span><br />This copies the contents of _install to SD card with proper permission.</span></span></li>
<li><span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: "arial" , "helvetica" , sans-serif;">We are almost done on that.Now time to do some finishing touches.<br /><span style="font-family: "courier new" , "courier" , monospace;">cd /path/to/sd/card<br />mkdir proc sys dev etc<br />sudo mknod dev/console c 5 1</span> (note the missing / before dev.we are not working on our PC filesystem here.so dont put a / before anything unless specified here)<br /><span style="font-family: "courier new" , "courier" , monospace;">sudo mknod dev/null c 1 3</span><br />Now we create the inittab file where we specify what to load during boot<br /><span style="font-family: "courier new" , "courier" , monospace;">gedit etc/inittab</span> (add sudo if says permission denied)<br />copy paste the following<br /><span style="font-family: "courier new" , "courier" , monospace;">null::sysinit:/bin/mount -t proc proc /proc<br />null::sysinit:/bin/hostname -F /etc/hostname<br />null::respawn:/sbin/getty -L ttyS0 115200 vt100<br />null::shutdown:/sbin/umount -a -r<br /> </span>Save and close<br />Now,<br /><span style="font-family: "courier new" , "courier" , monospace;">mkdir root<br />gedit etc/passwd</span><br />copy paste the following<br /><span style="font-family: "courier new" , "courier" , monospace;">root:x:0:0:root:/root:/bin/sh</span><br />Save and exit<br /><span style="font-family: "courier new" , "courier" , monospace;">gedit etc/shadow</span><br />copy paste<br /><span style="font-family: "courier new" , "courier" , monospace;">root::10933:0:99999:7:::</span><br />Save and exit<br /><span style="font-family: "courier new" , "courier" , monospace;">mkdir -p usr/share/udhcpc<br />cp /path/to/busybox_src/examples/udhcp/simple.script usr/share/udhcpc/default.script<br />gedit etc/hostname<br />testlinux</span></span></span></li>
<li><span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: "arial" , "helvetica" , sans-serif;">Now we make glibc which is used by various programs.<br /><span style="font-family: "courier new" , "courier" , monospace;">wget http://ftp.gnu.org/gnu/libc/glibc-2.22.tar.xz<br />tar -xJf glibc-2.22.tar.xz<br />mkdir glibc-build<br />cd glibc-build/<br />../glibc-2.22/configure arm-linux-gnueabihf --target=arm-linux-gnueabihf --build=x86_64-pc-linux-gnu --prefix= --enable-add-ons<br />make<br />make install install_root=/path/to/sd/card <span style="font-family: Arial, Helvetica, sans-serif;"><br />If you get error like LD_LIBRARY_PATH should not contain current directory etc. during configuration, run </span></span></span></span><pre><span style="font-size: large;"><span style="font-family: "Courier New",Courier,monospace;"><span class="pl-c1">unset</span> LD_LIBRARY_PATH</span></span></pre>
<pre><span style="font-size: large;"><span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: Arial, Helvetica, sans-serif;">then run configure again.</span> </span></span></pre>
<span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: Arial, Helvetica, sans-serif;"> </span></span></span></span></li>
<li><span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: "arial" , "helvetica" , sans-serif;">Now that everything is done,Open up a terminal in ur sd card folder and type <span style="font-family: "courier new" , "courier" , monospace;">sync</span></span>.</span></span></span></li>
</ol>
<div style="text-align: justify;">
<span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: "arial" , "helvetica" , sans-serif;">Now remove the SD card and put it in your Orange pi Zero SD slot. Attach a USB-serial to it and fire up your favorite terminal emulator(picocom in my case). Power the Orange pi and you should see something like this.</span> </span> </span></span></div>
<span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: "arial" , "helvetica" , sans-serif;"><span style="font-family: "courier new" , "courier" , monospace;">U-Boot SPL 2017.03-armbian (Mar 16 2017 - 14:23:25)<br />DRAM: 512 MiB<br />Trying to boot from MMC1<br /><br /><br />U-Boot 2017.03-armbian (Mar 16 2017 - 14:23:25 +0600) Allwinner Technology<br /><br />CPU: Allwinner H3 (SUN8I 1680)<br />Model: Xunlong Orange Pi Zero<br />DRAM: 512 MiB<br />MMC: SUNXI SD/MMC: 0<br />*** Warning - bad CRC, using default environment<br /><br />Setting up a 720x576i composite-pal console (overscan 32x20)<br />Error: no valid bmp image at 66000000<br />In: serial<br />Out: vga<br />Err: vga<br />Net: phy interface0<br />eth0: ethernet@1c30000<br />Hit any key to stop autoboot: 0 <br />6944 bytes read in 159 ms (42 KiB/s)<br />switch to partitions #0, OK<br />mmc0 is current device<br />Scanning mmc 0:1...<br />Found U-Boot script /boot/boot.scr<br />1884 bytes read in 147 ms (11.7 KiB/s)<br />## Executing script at 43100000<br />115 bytes read in 123 ms (0 Bytes/s)<br />5156878 bytes read in 633 ms (7.8 MiB/s)<br />4754656 bytes read in 620 ms (7.3 MiB/s)<br />Found legacy kernel configuration<br />35384 bytes read in 487 ms (70.3 KiB/s)<br />## Loading init Ramdisk from Legacy Image at 43300000 ...<br /> Image Name: uInitrd<br /> Image Type: ARM Linux RAMDisk Image (gzip compressed)<br /> Data Size: 5156814 Bytes = 4.9 MiB<br /> Load Address: 00000000<br /> Entry Point: 00000000<br /> Verifying Checksum ... OK<br /> Loading Ramdisk to 49b15000, end 49ffffce ... OK<br /><br />Starting kernel ...<br /><br />[sun8i_fixup]: From boot, get meminfo:<br /> Start: 0x40000000<br /> Size: 512MB<br />ion_carveout reserve: 160m@0 256m@0 130m@1 200m@1<br />ion_reserve_select: ion chipid [0x2c00042!<br />ion_reserve_common: ion reserve: [0x57e00000, 0x60000000]!<br />Loading, please wait...<br />starting version 229<br />Begin: Loading essential drivers ... done.<br />Begin: Running /scripts/init-premount ... done.<br />Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.<br />Begin: Running /scripts/local-premount ... Scanning for Btrfs filesystems<br />done.<br />Begin: Will now check root file system ... fsck from util-linux 2.27.1<br />[/sbin/fsck.ext4 (1) -- /dev/mmcblk0p1] fsck.ext4 -a -C0 /dev/mmcblk0p1 <br />/dev/mmcblk0p1: recovering journal<br />/dev/mmcblk0p1: clean, 4787/89584 files, 89637/358144 blocks<br />done.<br />done.<br />Begin: Running /scripts/local-bottom ... done.<br />Begin: Running /scripts/init-bottom ... done.<br />mount: mounting /run on /root/run failed: No such file or directory<br /><br />testboard login: root<br />login[151]: root login on 'ttyS0'<br />~ # </span> </span> </span> <br />
<div>
<div style="text-align: justify;">
Right now some errors are there and we will fix them.Right now the boot time is about 9 seconds from boot to console login.<br />
References used:<br />
<ul>
<li><a href="http://wiki.beyondlogic.org/index.php?title=Cross_Compiling_BusyBox_for_ARM#Building_a_minimal_RootFS_with_Busybox.2C_GLIBC_and_DropBear" target="_blank">http://wiki.beyondlogic.org/index.php?title=Cross_Compiling_BusyBox_for_ARM#Building_a_minimal_RootFS_with_Busybox.2C_GLIBC_and_DropBear</a> </li>
<li><a href="https://gist.github.com/vsergeev/2391575" target="_blank">https://gist.github.com/vsergeev/2391575</a> </li>
</ul>
</div>
</div>
</div>
Shovonbdhttp://www.blogger.com/profile/04302437234075930187noreply@blogger.com0tag:blogger.com,1999:blog-915787653990243570.post-5713572022178806332013-09-18T08:29:00.000-07:002013-09-19T12:03:46.197-07:00So,you want to start learning microcontroller and other embedded stuffs?<div dir="ltr" style="text-align: left;" trbidi="on">
Hello guys,<br />
Well...this is a post for newbies in microcontroller world.Here,I didnt mean a complete newbie by the term "newbie".I am neither gonna talk about resistor capacitor and transistors nor what is microcontroller etc.This post is for someone who knows at least what a microcontroller is and wants to start learning it and requires a guide line on how to start.<br />
<br />
WELL...you know what a microcontroller is...hmm???okay...thats cool.Now lets talk about how to start.Well...the first thing is to choose a microcontroller family.Well...I dont want to hurt the feelings of the fanboys of other families...but AVR from Atmel and PIC from Microchip are the two best families for newbies currently...its because of the gigantic number of tutorials and example projects you are gonna find online. <a href="http://www.extremeelectronics.co.in/">www.extremeelectronics.co.in</a> is an excellent site for learning both these families,or the <a href="http://winavr.scienceprog.com/">winavr.scienceprog.com</a> for AVR.One hint for the first site...their tutorials are kept in reverse order...so for getting the basic tutorials...u need to go to the last page of the tutorials.<br />
Now lets come to another very very important thing...availability of microcontroller and tools.Well...u need a microcontroller and a tool to program it.Now if you are not confident enough to make your own programming tool or if you havent got someone who can do it for you,I recommend you buy one...for PIC,buy Pickkit2 or 3(2nd one isrecommended).If you cant buy them,look for their clones.I am giving a few links here<br />
<br />
<a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en538340&redirects=pickit3">http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en538340&redirects=pickit3</a><br />
<br />
<a href="http://www.ebay.com/sch/i.html?_odkw=usbasp&_osacat=0&_from=R40&_trksid=p2045573.m570.l1313.TR0.TRC0.Xpickit2&_nkw=pickit2&_sacat=0">http://www.ebay.com/sch/i.html?_odkw=usbasp&_osacat=0&_from=R40&_trksid=p2045573.m570.l1313.TR0.TRC0.Xpickit2&_nkw=pickit2&_sacat=0</a><br />
<br />
<a href="http://www.ebay.com/sch/i.html?_odkw=pickit2&_osacat=0&_from=R40&_trksid=p2045573.m570.l1313.TR0.TRC0.Xpickit3&_nkw=pickit3&_sacat=0">http://www.ebay.com/sch/i.html?_odkw=pickit2&_osacat=0&_from=R40&_trksid=p2045573.m570.l1313.TR0.TRC0.Xpickit3&_nkw=pickit3&_sacat=0</a><br />
<br />
You can check other sources too.<br />
<br />
For AVR,<br />
<br />
<a href="http://www.ebay.com/sch/i.html?_odkw=pickit3&_osacat=0&_from=R40&_trksid=p2045573.m570.l1313.TR2.TRC1.A0.Xusbasp&_nkw=usbasp&_sacat=0">http://www.ebay.com/sch/i.html?_odkw=pickit3&_osacat=0&_from=R40&_trksid=p2045573.m570.l1313.TR2.TRC1.A0.Xusbasp&_nkw=usbasp&_sacat=0</a><br />
This little programmer is really cool,but its not their official programmer...but you can use it...In fact,I use it for my work and it works just great<br />
<br />
<a href="http://www.atmel.com/tools/AVRDRAGON.aspx">http://www.atmel.com/tools/AVRDRAGON.aspx</a><br />
This is the official one.<br />
<br />
Now...a million dollar question...which one to choose???PIC or AVR...well....u guys wont even believe that this question can trigger World war 3(u will see someday,trust me)!!!Well...I would say...go for any.See which one you can afford(Talking about tool),which one is available in your country,..or which one your friend or known ones are using(this suggestion has been given so that you might get help from them).<br />
Now...both Microchip PIC and Atmel AVR are families,not a single microcontroller.There are hundreds of different models of PIC and AVR microcontrollers...My advice is,decide which one you are gonna use,get to the market and buy one model,any model.But onw thing you must know...for starting,choose from 8bit PIC or AVRs...For AVR,I would suggest ATmega16 or ATmega32(a good general purpose microcontroller).For PIC,go for PIC16F877...these micros are highly available AFAIK.<br />
Now...one thing.you might have heard about another thing,ARDUINO....right?????If you havent,dont try to know about it for now.If you have and your friend told you its extremely easy bla bla bla,Now,for that,I want to ask you a question,<br />
Why do you want to learn microcontroller???Is it just for some university term project?Are you going to wipe off all you microcontroller lessons after that project???or do you want to learn microcontroller and become a professional embedded systems expert in your future life?If the first one is the reason,you can go for ARDUINO...but if the second is the reason,dont even think of getting near it for now.Its an excellent platform that uses several microcontrollers from Atmel AVR family(or Microchip PICs or ARMs in different but similar platforms).Its like a magical tool for rapid prototyping etc. and its highly tempting for newbies as well since its extremely easy to use...but sometimes shortcuts DO come with their side effects.If Arduino is your first choice for "learning", you wont even scratch the surface of this vast embedded systems world.First,learn the basics of AVR or PIC,then you will be able to use an Arduino to its limit.So, for now,forget the word Arduino.Its not for newbies who want to become professional.First learn AVR/PIC,then move to Arduino....the path wont be smooth,but at the end of it there is a huge reward.</div>
Shovonbdhttp://www.blogger.com/profile/04302437234075930187noreply@blogger.com0tag:blogger.com,1999:blog-915787653990243570.post-7558313167963822412013-06-19T23:59:00.000-07:002013-06-20T00:00:42.361-07:00Arduino...What are you???<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: justify;">
Well...here I am again and I am going to take some of your precious time and I am gonna talk about Arduino. Well...there are many people talking about it so you guys might think its another general Arduino project talk where I am gonna show you how easy Arduino is and all that.The answer is a BIG NOOOO!!!</div>
<div style="text-align: justify;">
All I am gonna talk about here is what Arduino is and I am gonna answer to some of the common stuffs in a visual way.</div>
<div style="text-align: justify;">
SO...NUMBER 1 ... WHAT IS ARDUINO????</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Answer:</div>
<div style="text-align: justify;">
Arduino IS NOT A NEW microcontroller...its merely AVR</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6Wr94vOphsk8WgL3OiNNaBNm2zEsD7ylWcW2nlnllOuQBYYbLP9hJd1DUxqe1hjpCBW6_7OADNm_zM06x0yW6lf3yVdfsLw19fvEps0b3fWpI3dIGt0vmvzS0Hxygt_5k1v9LW064_UTl/s1600/arduino.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="292" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6Wr94vOphsk8WgL3OiNNaBNm2zEsD7ylWcW2nlnllOuQBYYbLP9hJd1DUxqe1hjpCBW6_7OADNm_zM06x0yW6lf3yVdfsLw19fvEps0b3fWpI3dIGt0vmvzS0Hxygt_5k1v9LW064_UTl/s640/arduino.png" width="640" /> </a></div>
<div class="separator" style="clear: both; text-align: justify;">
So...this is the image of an ATmega328P sitting on an ARDUINO board.Now you believe it????If you dont,then I have got nothing to say.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
NOW...NUMBER 2...WHY DO WE CALL IT ARDUINO THEN?????</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Answer:</div>
<div class="separator" style="clear: both; text-align: justify;">
Well...Arduino is a development board.I am talking about the nice blue boards u see or any other board having the name Arduino or usually any "duino".But I should say its a development platform based on AVR microcontroller...THATS ALL...</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
NOW...NUMBER 3...YOU KNOW MAN,I KNOW ITS AVR...BUT I HEARD THEY HAVE PUT SOME ALIEN STUFF LIKE BOOTLOADER INSIDE THE CHIP...IS IT STILL LIKE NORMAL AVRs OR HAS IT BEEN TRANSFORMED BY THE MYSTICAL BOOTLOADER????</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Answer:</div>
<div class="separator" style="clear: both; text-align: justify;">
To be honest...this was my question as well when I was a newbee.But I read about things etc and came to know that the idea of such "Alien Transformation was merely a BULLSHIT".Actually ,this BOOTLOADER STUFF is nothing but a sweet small piece of program which sits in a specified place in the flash memory and its characteristics is....IT STARTS RIGHT AFTER YOU POWER UP YOUR MICROCONTROLLER AND IF THERE IS ANOTHER PROGRAM(YES...I AM NOT INSANE,BOOTLOADER AND SOME OTHER PROGRAM,BOTH CAN FUNCTION WHILE BEING IN THE SAME MICROCONTROLLER FLASH MEMORY),THAT RUNS AFTER THE EXECUITION OF BOOTLOADER.</div>
<div class="separator" style="clear: both; text-align: justify;">
Alright....so why do we need a bootloader????Well...bootloaders are capable of doing a magical thing.They can make an mcu SELF PROGRAMMABLE!!!!That means this bootloader can get data from some source in some way and put the data into the empty space of mcu's flash memory...so inshort...its capable of putting a SECOND PROGRAM into mcu program memory and THAT SECOND program is the program that you want to put into the mcu(sounds cool!!!)...so if we provide the mcu some way to communicate with a PC or programming source,it can program itself!!!And AVRs in arduino boards come with this bootloader thingy loaded,and the bootloader allows the micro to get program data from its UART(I guess u know what that is)!!!! so we dont need another programmer,just an usb to serial converter or a serial port on pc and any program we use to put our program into the mcu will actually communicate with the mcu via serial port!!! Thats the case of the mystical bootloader!!!</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
ALRIGHT...NUMBER 3...OK I GET IT...THEN WHY DID THEY MAKE THE WHOLE NEW COMPILER/IDE FOR ARDUINO????WHY ALL THESE TROUBLES?THEY COULD HAVE CREATED JUST A LOADER PROGRAM RIGHT?????</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Answer:</div>
<div class="separator" style="clear: both; text-align: justify;">
Hmm...Now I should tell you the truth....the Arduino guys were trying to create a whole new platform for rapid prototyping.They wanted to create a simple looking interface with vast amount of libraries so that it might become easy for us to do our mcu works fast.So basically what they did is,they used the same good old avr-gcc and avrlibc(WinAVR for windows people) and put some libraries over it and then they designed a simple looking IDE interface(or the Arduino Interface) and integrated everything into one folder called the arduino folder.If you browse through different folders of arduino,u will know that.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
So basically general arduino boards come with an USB 2 Serial converter and the target AVR microcontroller with bootloader into it and the IDE simply communicates with the target micro via the usb2 serial converter.</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
OKAY...OKAY....NUMBER 4...YOU SAID THAT WE BASICALLY USE WINAVR....AM I RIGHT????WELL...I DONT RECALL WRITING ANY pinMode() FUNCTION OR digitalWrite() FUNCTION IN WINAVR COMPILER AND MOREOVER,THE PIN NUMBERS ARE COMPLETELY DIFFERENT?HOW DO YOU EXPLAIN THAT....MHMMM???</div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: justify;">
Answer:</div>
<div class="separator" style="clear: both; text-align: justify;">
If you have ever used any C/C++ compiler,then you should be aware of <b>#define.</b>This preprocessor command can make things easy for us in many ways....alright,before I answer to your questions,lets have a look at Arduino UNO pinmapping image: </div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicsXNGX31_2xctlK2fhMetMgRzvdkGqb03uhFoqvKzbPB5nOpASHKzfl8YbhxwVB47wAvleG8ufhaHA0UMuhxquMItO1-uZDNTl-eg2LaY-kRaqMF9qtMZ7Qd7Zb-0-arCPBYU87Wihr2c/s1600/Atmega168PinMap2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="426" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicsXNGX31_2xctlK2fhMetMgRzvdkGqb03uhFoqvKzbPB5nOpASHKzfl8YbhxwVB47wAvleG8ufhaHA0UMuhxquMItO1-uZDNTl-eg2LaY-kRaqMF9qtMZ7Qd7Zb-0-arCPBYU87Wihr2c/s640/Atmega168PinMap2.png" width="640" /></a></div>
<div class="separator" style="clear: both; text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Okay...this picture also verifies that Arduino is merely AVR...this pinmapping is for Atmega168,almost the same pinout or this pinout is applicable for Atmega328 as well....</div>
<div style="text-align: justify;">
Now...look at it...the have created a new set of pinouts by providing a few definitions over the standard AVR pinout...thats all....and those pinMode and digitalWrite functions are either functions or definitions</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
NOW...a question...can we use the original AVR IO PORT definitons in Arduino compiler????OF COURSE AND YES!!!!!WE CAN!!!We can use almost everything unless its not being used by some arduino library such as timer 0 and etc.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br />
NOW.....the BIG BURNING QUESTION.....CAN I USE ANY COMPILER WITH ARDUINO BOARD????</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Answer:</div>
<div style="text-align: justify;">
YES,YES AND YES,you can.You can use any avr compiler with arduino...All you need to know is the actual pin numbers since on ardunio board its not written.You can use the picture attached above for atmega168 and for other,simply google the name of your arduino board with the word "pinmapping" at hte end, such as "Arduino Mega 2560 pinmapping" annd you will have the pin map.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Now another thing...how can you upload the code????Well...very simple!!!Like other compiler and IDEs,Arduino software generates its hex files as well but for some weird reason,it puts that file in the temporary folder.so you dont see it.But if you have a hex file of your program....here is how to do it</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<br />
1.Download XLoader or AVRpal.NET</div>
<div style="text-align: justify;">
AVRpal.NET link(<a href="http://sourceforge.net/projects/avrpalnet/" target="_blank">http://sourceforge.net/projects/avrpalnet/</a>)</div>
<div style="text-align: justify;">
XLoader link(<a href="http://russemotto.com/xloader/" target="_blank">http://russemotto.com/xloader/</a>)</div>
<div style="text-align: justify;">
2.Connect you Arduino board to PC.</div>
<div style="text-align: justify;">
3.If you have downloaded XLoader,then open it...it should look like this</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilxL6ohN7ldjW0eFOioR2M7YeGGQdY2XP5_q_QNvDDcrcVHoGqyPZBVzQCEI3C7dCPzfTfdgy5d9kfbOQ9rb4d-V_3W3K7rfE1Em4PnQRuDJ2MN1o2ynKVHWLQ0faQGoH9vtDjg-9RkTHE/s1600/xloader.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEilxL6ohN7ldjW0eFOioR2M7YeGGQdY2XP5_q_QNvDDcrcVHoGqyPZBVzQCEI3C7dCPzfTfdgy5d9kfbOQ9rb4d-V_3W3K7rfE1Em4PnQRuDJ2MN1o2ynKVHWLQ0faQGoH9vtDjg-9RkTHE/s1600/xloader.JPG" /></a></div>
The interface is straightforward...select your arduino board,select the COM port its connected to and then select the hex file you want to upload and then simply click "Upload"<br />
If you have downloaded AVRpal.NET then when you open it,it should look like this<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwUqBmZUZyr5bcGomE_G9VoCHpu4aXu8hUdlkEoX10im7YwSiRV4yDuutxuNvh29KjwnUH3jRlXeSUcHO3s7JS2Kc38RJ-ewV49vd-PhhHsdKzhOrxQtK73oPNet8bMPVD-D8KafRAjX0o/s1600/avrpal+int.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="392" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiwUqBmZUZyr5bcGomE_G9VoCHpu4aXu8hUdlkEoX10im7YwSiRV4yDuutxuNvh29KjwnUH3jRlXeSUcHO3s7JS2Kc38RJ-ewV49vd-PhhHsdKzhOrxQtK73oPNet8bMPVD-D8KafRAjX0o/s640/avrpal+int.JPG" width="640" /></a></div>
<br />
Alright...this software isnt just for arduino...its for AVR programmer USBasp as well...so click on ArduHexLoader button...a window like this should appear<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbpOo3m_992N3oxu38eV03hSYL9D0hUU1mmMi0wnIu2_9BlCkXEpIIPNFRJHmV6-CZjNpnFp5YpphxfFjHXKvrpIL59_1CxBRdYYwA-xf1HvKeidzRcwSMpuBcE930wGmqGglGlO3M7VKU/s1600/arduhex.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="396" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbpOo3m_992N3oxu38eV03hSYL9D0hUU1mmMi0wnIu2_9BlCkXEpIIPNFRJHmV6-CZjNpnFp5YpphxfFjHXKvrpIL59_1CxBRdYYwA-xf1HvKeidzRcwSMpuBcE930wGmqGglGlO3M7VKU/s400/arduhex.JPG" width="400" /></a></div>
<br />
<div style="text-align: justify;">
This is same as XLoader...select your board,the COM port and then the file and hit upload!!!<br />
<br />
So...now you see...ARDUNIO ISNT SOMETHING COMPLETELY NEW!!!!IT'S A CONCEPT BASD ON AVR....IF YOU HAVE ANY QUESTION,FEEL FREE to LEAVE IT IN THE COMMENTS.</div>
</div>
Shovonbdhttp://www.blogger.com/profile/04302437234075930187noreply@blogger.com2Dhaka, Bangladesh23.709921 90.40714300000001923.4774335 90.084419500000024 23.942408500000003 90.729866500000014tag:blogger.com,1999:blog-915787653990243570.post-39968897855137520592012-03-31T10:03:00.022-07:002012-03-31T11:46:01.141-07:00Simple Fun Morse Code decoder with AVR microcontroller<div style="text-align: center;"><br /></div><div style="text-align: center;"><br /></div><div style="text-align: center;"><br /></div><div style="text-align: justify;">Hi people...let's have some fun with AVR micros.This is my first post on any hardware project based on microcontroller except programmer or programming hardware.It's just a fun project but can also be useful to those who practice morse code...Well by this time u know what that thing is...it's a simple morse code decoder with one button,ATmega16(not overkill,kind of superkill for anything like this,but at that time,that was easy to work with for me as I had a development board for 40pin avrs),LCD for showing output.</div><div><div style="text-align: center;"><span><br /></span></div><div style="text-align: justify;">Unfortunately,that circuit is a history now so I cant post any image of it(Sorry folks).But I will post the schematic and a video I uploaded then to youtube(Though the video quality is...better see for yourselves).</div><div style="text-align: justify;">Okay let's come to the point.Many of you know what morse code is...it's an old system of electrical communication where messages are sent as a combination of Dash(long duration beeps or current flow) and dots(shot beeps or current flow).This was used in morse telegraph communications systems.The morse code chart is given below for interested people from wikipedia:</div><div style="text-align: center;"><br /></div><div></div><div><img src="http://upload.wikimedia.org/wikipedia/commons/b/b5/International_Morse_Code.svg" border="0" alt="" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 415px; height: 501px; " /></div><div><br /></div><div>Though I didnt follow the timing issues then,only used the codes.</div><div><br /></div><div style="text-align: justify;">Now,why this old stuff using new things right???Well,answer is simple...mainly for fun and some skill testing also :) .</div><div style="text-align: justify;">Here goes my schematic:</div><div><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhy7Kj9grkbFjM4QtCk_rvw46BTuEU4NZX2EdQ4Zq_9yfxdAeHImwDc9SK6v0uZAz8UiUcgUDoNzn09RmKE9yV1_G3MEpKxb2Rh_HibXAIRvenCXB9Gyvhqq5Zz48u-GjM3z6j2Y9Xjr5mk/s400/morse+code.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5726134220452811618" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 246px; " /></div><br /><div style="text-align: justify;">Circuit is pretty simple...just one button for taking input.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">I had to add some extra things for displaying to LCD and clearing the LCD etc. such as a 7sec delay after entering the code to show the result on LCD.</div><div style="text-align: justify;"><br /></div><div style="text-align: justify;">The source code was written in Bascom AVR.Its a pretty cool compiler and easy to work with and awesome for string handling and code optimization.The source code is not BIG so It is posted here.<br /></div></div><div style="text-align: justify;"><br /></div><div>THE CODE:</div><span><div><br /></div><div><div><span>'8th pin of PORTA used for input</span></div><div><span><br /></span></div><div><span>$regfile = "m16def.dat"</span></div><div><span><br /></span></div><div><span>$crystal = 8000000</span></div><div><span><br /></span></div><div><span>$lib "lcd4busy.lib"</span></div><div><span>'defining LCD pins</span></div><div><span>Const _lcdport = Portb</span></div><div><span>Const _lcdddr = Ddrb</span></div><div><span>Const _lcdin = Pinb</span></div><div><span>Const _lcd_e = 2</span></div><div><span>Const _lcd_rw = 1</span></div><div><span>Const _lcd_rs = 0</span></div><div><span>Dim A As Integer 'the delay counter</span></div><div><span>Dim Bttn_pressed As Integer 'variable to check if the button has been pressed before when released</span></div><div><span>Dim Mrsc As String * 32 'string for holding the morse code input</span></div><div><span>Dim Strf As String * 32 'string for holding the processed output</span></div><div><span>Dim X As Integer 'LCD upper line character position </span></div><div><span><br /></span></div><div><span>Mrsc = ""</span></div><div><span>Strf = ""</span></div><div><span>Ddra = 0</span></div><div><span>Cursor Off</span></div><div><span>Cls</span></div><div><span>X = 1</span></div><div><span>Do</span></div><div><span>If Pina.7 = 1 Then</span></div><div><span>A = A + 1</span></div><div><span>Bttn_pressed = 1</span></div><div><span>Waitms 500</span></div><div><span>Elseif Pina.7 = 0 Then</span></div><div><span>If Bttn_pressed = 1 Then</span></div><div><span>If A = 1 Then</span></div><div><span>A = 0</span></div><div><span>Bttn_pressed = 0</span></div><div><span>End If</span></div><div><span>If A > 1 And A < 3 Then</span></div><div><span>Upperline</span></div><div><span>Locate 1 , X</span></div><div><span>Lcd "."</span></div><div><span>Mrsc = Mrsc + "."</span></div><div><span>A = 0</span></div><div><span>'Waitms 10</span></div><div><span>Bttn_pressed = 0</span></div><div><span>X = X + 1</span></div><div><span>Elseif A >= 3 And A < 6 Then</span></div><div><span>Upperline</span></div><div><span>Locate 1 , X</span></div><div><span>Lcd "_"</span></div><div><span>Mrsc = Mrsc + "_"</span></div><div><span>A = 0</span></div><div><span>Bttn_pressed = 0</span></div><div><span>X = X + 1</span></div><div><span>'Waitms 10</span></div><div><span><br /></span></div><div><span>Elseif A >= 6 And A < 12 Then</span></div><div><span>Select Case Mrsc</span></div><div><span>Case "._"</span></div><div><span>Strf = Strf + "A"</span></div><div><span>Case "_..."</span></div><div><span>Strf = Strf + "B"</span></div><div><span>Case "_._."</span></div><div><span>Strf = Strf + "C"</span></div><div><span>Case "_.."</span></div><div><span>Strf = Strf + "D"</span></div><div><span>Case "."</span></div><div><span>Strf = Strf + "E"</span></div><div><span>Case ".._."</span></div><div><span>Strf = Strf + "F"</span></div><div><span>Case "__."</span></div><div><span>Strf = Strf + "G"</span></div><div><span>Case "...."</span></div><div><span>Strf = Strf + "H"</span></div><div><span>Case ".."</span></div><div><span>Strf = Strf + "I"</span></div><div><span>Case ".___"</span></div><div><span>Strf = Strf + "J"</span></div><div><span>Case "_._"</span></div><div><span>Strf = Strf + "K"</span></div><div><span>Case "._.."</span></div><div><span>Strf = Strf + "L"</span></div><div><span>Case "__"</span></div><div><span>Strf = Strf + "M"</span></div><div><span>Case "_."</span></div><div><span>Strf = Strf + "N"</span></div><div><span>Case "___"</span></div><div><span>Strf = Strf + "O"</span></div><div><span>Case ".__."</span></div><div><span>Strf = Strf + "P"</span></div><div><span>Case "__._"</span></div><div><span>Strf = Strf + "Q"</span></div><div><span>Case "._."</span></div><div><span>Strf = Strf + "R"</span></div><div><span>Case "..."</span></div><div><span>Strf = Strf + "S"</span></div><div><span>Case "_"</span></div><div><span>Strf = Strf + "T"</span></div><div><span>Case ".._"</span></div><div><span>Strf = Strf + "U"</span></div><div><span>Case "..._"</span></div><div><span>Strf = Strf + "V"</span></div><div><span>Case ".__"</span></div><div><span>Strf = Strf + "W"</span></div><div><span>Case "_.._"</span></div><div><span>Strf = Strf + "X"</span></div><div><span>Case "_.__"</span></div><div><span>Strf = Strf + "Y"</span></div><div><span>Case "__.."</span></div><div><span>Strf = Strf + "Z"</span></div><div><span>Case "____"</span></div><div><span>Strf = Strf + " "</span></div><div><span>End Select</span></div><div><span>Cls</span></div><div><span>Lowerline</span></div><div><span>Lcd Strf</span></div><div><span>Mrsc = ""</span></div><div><span>A = 0</span></div><div><span>X = 1</span></div><div><span>Bttn_pressed = 0</span></div><div><span><br /></span></div><div><span><br /></span></div><div><span>Elseif A >= 15 Then</span></div><div><span>Cls</span></div><div><span>Bttn_pressed = 0</span></div><div><span>Mrsc = ""</span></div><div><span>Strf = ""</span></div><div><span>A = 0</span></div><div><span>X = 1</span></div><div><span>End If</span></div><div><span>End If</span></div><div><span>End If</span></div><div><span>Loop</span></div><div><span>End</span></div></div></span><div><span><br /></span></div><div><span><br /></span></div><div><span>Code has been commented so It should be easy to understand...</span></div><div><span><br /></span></div><div><span>Here is the (Sorry again for quality)...well...video...:)</span></div><center><iframe width="420" height="315" src="http://www.youtube.com/embed/nwfWn01rykk" frameborder="0" allowfullscreen=""></iframe></center><div><span><br /></span></div><div><span>If you need some information...tell me.Have fun!!!</span></div>Shovonbdhttp://www.blogger.com/profile/04302437234075930187noreply@blogger.com0tag:blogger.com,1999:blog-915787653990243570.post-47009126965968228032012-01-30T16:04:00.000-08:002012-01-30T16:23:12.607-08:00<div style="text-align: center;"><br /></div><div style="text-align: center;"><span><span >CEMSTech AVRpal.NET</span></span></div><div style="text-align: center;"><span><br /></span></div><div style="text-align: center;"><span>An easy to use avrdude GUI for Windows platform</span></div><div style="text-align: center;"><span><br /></span></div><div style="text-align: justify;"><span>CEMSTech AVRpal.NET is a very easy to use avrdude GUI.NOw,avrdude is a very popular programmer application for AVR microcontroller mainly because its cross platform and its small in size but it has one major drawback...ITS COMM</span></div><div style="text-align: justify;"><span>AND LINE!!!!(well...I hate typing commands).So I decided to go for making an avrdude GUI.Now,avrdude is the "dude" of AVRs so I named my app. "AVRpal"(:D :D)...Now many of you will try to shoot me as I havent added any support for parallel,serial programmers and NOT even for USBtinyISP...IT only supports USBasp...its because</span></div><div style="text-align: justify;"><span> I had only USBasp and this works great,may be popular than USBtinyISP(Dont blame me if I am wrong guys).So,as I built this app. for me at first,I couldn't so didn't add any support for other programming hardwares but avrdude supports a lot.Now I did one thing for you,I made it OPEN SOURCE!!!If you can code in VB.NET,just download the code from <a href="http://sourceforge.net/projects/avrpalnet/files/src/">here</a> and enjoy!!!</span></div><div style="text-align: justify;"><span>Now...a screenshot of this app:</span></div><div style="text-align: justify;"><span><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPgC5XjFPRl9H87XpzzfRqTMYD_xiEmrZ9dL6lq6g0yvZS8rxov7Vv_6XIXiiNvNTCIjY3bKc7w2AKHex9SiIHgm_EzVeQmloM343ivfVjIKij7GMwNxDcTX1uXl2O6kCqR69Z7wUxa61o/s400/avrpal.net.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5703583201247283490" style="color: rgb(0, 0, 238); text-decoration: underline; display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 331px; " /></span></div><div style="text-align: justify;"><span><br /></span></div><div style="text-align: justify;"><span>Now you can see that the interface looks funny...well it was made so intentionally(I didn't provide support for many programmers,so at least I hope this is gonna save me from getting beaten up by embedded people(well...I hope so)).So guys,go to sourceforge.net and download the binary from <a href="http://sourceforge.net/projects/avrpalnet/">here</a>.</span></div><div style="text-align: justify;"><span><br /></span></div><div style="text-align: justify;"><span>Now this application requires a modified firmware for USBasp to enable the slow sck control feature from the application window.I will upload the modified firmware soon.</span></div><div style="text-align: justify;"><span><br /></span></div><div style="text-align: center;"><span>ENJOY!!!</span></div><div style="text-align: justify;"><br /></div><div><span><br /></span></div>Shovonbdhttp://www.blogger.com/profile/04302437234075930187noreply@blogger.com0tag:blogger.com,1999:blog-915787653990243570.post-33581875545081019552010-04-18T09:55:00.001-07:002012-03-30T12:46:07.411-07:00Softwares needed<div style="text-align: justify;">Hmm...this is the part where we will know which softwares are to be used for uC coding,simulation and programming.Well...the architecture of uC and your PC is different and so you can't use your computer compiler softwares to program your uC.Well...there are several compilers for programming avr like avr-gcc,bascom avr etc.they support the coding architecture of PC(For instance,avr-gcc is a c code compiler for avr uCs) but compiled output is different.But you can configure your programming editor(Hope you know the editor you use to write the code and the compiler you use to compile your code is different) with this uC compilers.Well,uCs can also be programmed with assembly language(a low level language) in which you can directly access memory addresses etc. but it's not as user friendly as a mid level language like c or high level language like basic(bascom avr).In this tutorial we will use avr-gcc as our compiler(for assembly,there is a good tutorial <a href="http://www.avr-asm-tutorial.net/avr_en/">here</a>).<br />Here is the list of softwares.First I am giving you the list for Windows OS,then Linux(Ubuntu,other distributions should also be compatible).<br /><span style="font-weight: bold;"><br />Softwares for windows:<br /><br /><span style="font-weight: bold;"><span style="font-weight: bold;"></span></span>1.AVR Studio:</span> This is a very good software and a complete IDE for avr uCs by Atmel with built in assembler(assembly compiler).You can also use it to compile C(if you have WinAVR installed) codes.It has a simulator in which you can run your codes to see if they are bug free.You can even program your uC right through this IDE if you have a AVR Studio compatible programmer(List of programmers can be found in it's menu) .This great software is absolutely free and requires only a free registration.The link is <a href="http://www.atmel.com/dyn/products/tools_card.asp?tool_id=2725">here</a>.<br />Visit the link and download "AVR Studio 4.18"(requires a free registration) then download the service pack(SP2 or SP3).Install AVR Studio 4.18 first then the service pack(because service pack is not the complete software,just an update).Check "install USB driver"(When shown).<br /><br /><span style="font-weight: bold;">2.WinAVR:</span> A collection of compiler and all the files you need(some you don't).A software for programming uC(avrdude) is integrated with it(This is highly necessary if you are using USBasp as programmer).Can be downloaded from <a href="http://winavr.sourceforge.net/">here</a>.(That's a open source one,so you can modify it if you want).An integrated editor(Programmer's Notepad) can be used as a code editor for avr-gcc.<br /><span style="font-weight: bold;">N.B. :-</span> It may show some errors if you are using windows vista or 7 (64 bit version). To fix it,you need to patch winavr.The patch can be found <a href="http://www.madwizard.org/electronics/articles/winavrvista">here</a>.Download it and follow the instructions(May be you need to replace a file given there as patch).Recent releases of WinAVR should be free from this problems.If not...then write to me.<br />DURING SETUP,CHANGE THE INSTALLATION DIRECTORY NAME FROM "WinAVR - something" to simply "WinAVR".<br /><br /><span style="font-weight: bold;">Proteus VSM:</span>A simply awesome software for simulating circuit you want to make(means you can just draw the circuit in it's workspace and run the circuit in you PC virtually).This software supports a lot of avr uCs and you can just add the compiled file there.You can even design PCBs for your circuits here.Unfortunately...this is not a free software and too much costly(>$2000 or $3000).There are many cracked versions available online.Search them(I can't give it's link here...the admin guys may shut my blog up!).<br /><br />Well...there are other IDE's available...such as Eclipse.To know how to use it with winavr,click <a href="http://winavr.scienceprog.com/other-valuable-tools/using-eclipse-as-ide-for-winavr-compiler.html">here</a>.<br /><br /><span style="font-weight: bold;">Ponyprog:</span>You can use this one if you are planning to build a parallel/serial programmer stated in the previous chapter.This is a very handy tool and can be downloaded from <a href="http://www.lancos.com/prog.html">here.</a><br /><br /><span style="font-weight: bold;">AVR-Burn-O-Mat:</span>AVRdude is a command line software(aahh...I hate command typing).This is a GUI(Graphical User Interface) for avrdude(means you give command to avrdude via this software by simply clicking things,REMEMBER,this is not an alternative to avrdude,just a GUI for it).Link is <a href="http://www.brischalle.de/avr8_burn-o-mat_avrdude_gui/avr8_burn_o_mat_avrdude_gui_en.html">here</a>.<br /><br />Well...I am writing a GUI for avrdude.You will get it soon!It's is not as versatile as Burn-O-Mat but a simple one to use.<br /><br /><span style="font-weight: bold;">Softwares for Linux:</span><br /><br />Hmm...the OS with ever growing popularity.Here is the list of softwares for it.<br /><br /><span style="font-weight: bold;">avr-libc,avrdude,uisp : </span>there is no collection like WinAVR available for Linux.In ubuntu,you will get them in your Synaptic Package Manager(Preference menu).Download them and this manager software will automatically mark necessary extra apps needed before download.After downloading,they will be installed automatically.<br /><br /><span style="font-weight: bold;">Kontrollerlab:</span>A very good IDE for Linux.You can even add any avrdude compatible programmer in it.That means it can even be used to program your uC.Link is <a href="http://www.cadmaniac.org/projectMain.php?projectName=kontrollerlab&section=download">here</a>.<br />Download the compatible package from the link.This is the one I am using in my Ubuntu OS.<br /><br />Eclipse can be used as a IDE for Linux too.<br /><br /><span style="font-weight: bold;">Installing Driver for programmer(Only if you are using USBasp):</span>Hmm...something else I still need to say...how to install the driver for USBasp.Well...download the latest zip archive from fischl.de then extract it.When you insert the USB cable of your USBasp hardware,a "Found New Hardware Box appears"(If you have already written the firmware into Atmega8 of USBasp and your connections are alright).There you show the "bin/win-driver" folder of your extracted USBasp folder.Then the setup will automatically locate driver for USBasp.<br />Now,time to test the hardware.Go to command prompt and type "avrdude -c usbasp -p m16" or replace the "m16" with "m8" or "m32" if you are using them as target uC.(No need to worry,I'll explain that!).Most probably,you will see "avrdude: error: could not find USB device "USBasp" with vid=0x16c0 pid=0x5dc".Well, this is because of the version difference between the driver given with avrdude and the one you installed.If you're lucky and you have set everything up,you should see an ok message.Otherwise,if you haven't connected the target uC or if there is any connection error in the connection between the uC and USBasp (Or in the power connection of target uC) and the driver version is perfect then you should see "target doesn't answer" message.If you haven't connected the target uC,then you can jump saying "yeppi,my USB device works!" or if you have,then you can say to yourself,"No problem...just to fix the target uC connections...my USBasp is alright!".<br />Now,if you have got an error message like "could not find USBasp",then unplug the hardware and reconnect it.If this does't work,copy the libusb0.dll & libusb.sys file to "WinAVR/bin" directory.A message will appear saying that these files already exist...but just press yes.Now test it,you should see a positive result.If not,then check your USBasp for connection errors.<br /></div>Shovonbdhttp://www.blogger.com/profile/04302437234075930187noreply@blogger.com0tag:blogger.com,1999:blog-915787653990243570.post-77979557234420725192010-04-17T12:47:00.001-07:002012-03-30T12:45:20.561-07:00Hardwares needed<div style="text-align: justify;">Well...now we are preparing for our voyage to uC world!This tutorial is about the hardwares or precisely programming hardware you need to insert the program into your avr chip.Well... what about other parts you need to make project circuits or your own circuits,right?well...you will get their values in schematics of projects and when you are making a project of your own...that's up to you!<br />First we need to build a power supply for our uC.uCs are mostly operated with +5V.This should be regulated(specially when you are using timing or communication features or ADC etc. because voltage ripples can cause incorrect data outputs).<br />This is the Schematic of the power supply for uC.<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9SWGOpOp7Rm63O_m2nzsQfqRTrSDUqcxqquI9ODNfHz3BXjog7QvJBlh_waXtl2hYOGTG4cFUD975PLTyBTrKh6JvdW3StG1OqPKDM0PDEaYrdLc3I7XACOYzJEQsQNbhv57b86DtcGoL/s1600/psu.gif" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 496px; height: 237px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9SWGOpOp7Rm63O_m2nzsQfqRTrSDUqcxqquI9ODNfHz3BXjog7QvJBlh_waXtl2hYOGTG4cFUD975PLTyBTrKh6JvdW3StG1OqPKDM0PDEaYrdLc3I7XACOYzJEQsQNbhv57b86DtcGoL/s320/psu.gif" alt="" id="BLOGGER_PHOTO_ID_5461205892793874818" border="0" /></a>This is actually not a full power supply.It's just the voltage regulator part.Build it according to schematic and don't forget to use a heatsink with 7805 IC(It may get terribly hot when used for a long time)<br />N.B. :- There are two ground pins in your uC,connect both of them to your circuit ground.<br />Parts list(picture is fair as schematics , not for seeing parts list):<ol><li>IC-7805(see Datasheet for pin config)</li><li>Capacitor-220uF,16V(others voltage ratings will work)</li><li>Resistor-1k</li><li>LED</li><li>Power connector</li><li>Switch</li></ol>Now let's come to program the uC.avr uCs can be programmed in two ways:<ol><li>Parallel programming(don't mistake,it doesn't mean programming with parallel port of pc)</li><li>Programming through SPI bus(this is what we will discuss,because this the way of in system programming.For informations on parallel programming,see datasheet)</li></ol><span style="font-weight: bold;">In system programming hardware</span>:Well...there are several programming hardwares for that.We will give schematics of the most popular hardwares.Some of them are commercially available(STK500,AVRISP mk II etc.).If you can afford them...then buy one(But we advise you to have the experience of building one of these hardwares)Here are the schematics:<br /><span style="font-weight: bold;">1.Parallel port programmer:</span>If you have an old PC(Old is gold!),then this one can be the starting programmer for you.There are several parallel port programmers.This one was tested by us.Schematic:<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjh1ysf4GdYAGhSbkwmn1yV7-CusxCa0k5hx3Wl7Fu9IIDhP_px7rtmdwrNgHjj5-8AW03P17HLCYvia-EKqdknvqGtc28m164knoszKKAYPwVepbeCffdG_pOS6ytukzBFx-cVjvXrSCT/s1600/isp-adapter-circuit.gif" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 490px; height: 252px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjh1ysf4GdYAGhSbkwmn1yV7-CusxCa0k5hx3Wl7Fu9IIDhP_px7rtmdwrNgHjj5-8AW03P17HLCYvia-EKqdknvqGtc28m164knoszKKAYPwVepbeCffdG_pOS6ytukzBFx-cVjvXrSCT/s320/isp-adapter-circuit.gif" alt="" id="BLOGGER_PHOTO_ID_5461201156821361874" border="0" /></a><br />N.B. : SCK,MOSI,MISO are the pins of SPI bus of your uC.Find their pin number from Datasheet(same applicable for RESET)In this circuit, a buffer IC has been used(74HC125).You may be thinking about the strange connection pattern of this circuit(You should be,if not experienced).Don't worry, that circuit is easy.But you need parallel port diagram to make this.Ok,here is it:<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixzYlfn9uZyoMyW2p-oysLY6cNheHoVGnqdIz1hB58gSVeUsbqo_kFtamxy-0RbYOBylVjkNKnDV8KuVN9HaS9pSHF8Qvah9k9L8h-z_ZnJynzfz64XHR6C0FjsRrgz0lKxtMuD3l2M0Lf/s1600/parallel.gif" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 478px; height: 258px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixzYlfn9uZyoMyW2p-oysLY6cNheHoVGnqdIz1hB58gSVeUsbqo_kFtamxy-0RbYOBylVjkNKnDV8KuVN9HaS9pSHF8Qvah9k9L8h-z_ZnJynzfz64XHR6C0FjsRrgz0lKxtMuD3l2M0Lf/s320/parallel.gif" alt="" id="BLOGGER_PHOTO_ID_5461219931682128482" border="0" /></a>This is the female side of the DB25 Connector Cable used here.You can directly connect the circuit without using the cable but I recommend you shouldn't(You may get some shocks due to earthing).<br />The Whole circuit can be built on a breadboard(including the power supply).<br />After building it,we shall use a program Ponyprog to send the program from PC.(will be discussed in the next chapter)<br /><span style="font-weight: bold;">2.Serial port programmer</span>I haven't seriously tested this one but many use it(may be!).It's a bit complex than the first one.</div><div style="text-align: justify;">N.B. : This one is not supported by USB 2 Serial Converters<br />Here is the Schematic:<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWbfVhIzXv13ZGbsXKgz6zWqnZm_dyng5Va3IT-PHeuvVGzk_9CFRKNNM8fQKJaD_Sk2-yh-ml3lZDohj3GNO8hTnM88tY2-m3EXavt19fq5kORoGb86ttvZw2E7lCUq5O6Rca7k9YXede/s1600/avr_programmer_schematic.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 451px; height: 200px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWbfVhIzXv13ZGbsXKgz6zWqnZm_dyng5Va3IT-PHeuvVGzk_9CFRKNNM8fQKJaD_Sk2-yh-ml3lZDohj3GNO8hTnM88tY2-m3EXavt19fq5kORoGb86ttvZw2E7lCUq5O6Rca7k9YXede/s320/avr_programmer_schematic.jpg" alt="" id="BLOGGER_PHOTO_ID_5461226202398821522" border="0" /></a>Here,Serial port config is already given.So I haven't shown it.<br />N.B. : I don't guarantee if it works but since I know,this is a popular one.<br /><span style="font-weight: bold;">USB programmer:</span><br />Hmm...now we are getting modern.Well...the programmers stated above are backdated as serial and parallel ports are not available in today's PCs or Laptops(However,if you have an old one,you can still build them...after a while...you will know why I said "Old is gold")To do something with USB port,Hardware driver is needed and to let the PC know what kind of hardware is connected to USB,some id codes and high/low operations are needed.That's why,in almost every USB device,there is a microcontroller or dedicated USB controller chip. Now you may have felt why I said "Old is Gold",because to make a USB programmer,you need a USB controller Chip or uC as driver in which you need to write the hardware program(firmware).Here is a diagram on how USB programmers work.<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_cTKKbt90vKaS-878_3Dt_Hy5LGZEFB4ll8X35Y0JZ1YgMsCgwVFM6twudHTbrFO2vhTfQ0aq6uXnjY7PqxPIiie-8XEIbRc8kyl6hv9tnFOJcLNHnxK07sF7WQz20Ce9Iz1okSo1feze/s1600/huw.GIF" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 597px; height: 294px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi_cTKKbt90vKaS-878_3Dt_Hy5LGZEFB4ll8X35Y0JZ1YgMsCgwVFM6twudHTbrFO2vhTfQ0aq6uXnjY7PqxPIiie-8XEIbRc8kyl6hv9tnFOJcLNHnxK07sF7WQz20Ce9Iz1okSo1feze/s320/huw.GIF" alt="" id="BLOGGER_PHOTO_ID_5461239918316458754" border="0" /></a>To know why we need to do that for USB,search google with the following keyword "USB in a nutshell".This is a very good book on USB.<br />Luckily , if you have an old PC/Laptop,you can make any of the first two programmers(they don't require a uC or controller chip to program your uC) and to be modern,you may use them temporarily to write the driver program(also called firmware) to your USB programmer's driver uC and forget them.Here is the Schematic of one of the most popular(may be the most) USB programmer(that I use at present),USBasp by Thomas Fischl(<a href="http://www.fischl.de/usbasp/">http://www.fischl.de/usbasp</a>):<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_1DU40_sUWxaK9NRfG9jUdQ7tOTLZuzFAlxLfc5PrM-zjlKE70yg7AevAVfKJ0SnH-z_yoiJQbPH2xdw-R3s_4THqvur7OmIIVSPl4mUyqeIkJcSTbvsdXm8UyJpF8pve28GaGbtIaQvl/s1600/usbasp.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 484px; height: 446px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg_1DU40_sUWxaK9NRfG9jUdQ7tOTLZuzFAlxLfc5PrM-zjlKE70yg7AevAVfKJ0SnH-z_yoiJQbPH2xdw-R3s_4THqvur7OmIIVSPl4mUyqeIkJcSTbvsdXm8UyJpF8pve28GaGbtIaQvl/s320/usbasp.png" alt="" id="BLOGGER_PHOTO_ID_5461232263583896898" border="0" /></a>Well...It looks horrible may be but quite easy to make.Here,as driver uC an Atmega48 has been used.But you can also use Atmega8(Even others if you understand the firmware code).This programmer requires a driver.It's available at the website stated above the schematic.<br />To build this, you need to know the usb pin config.to know this,visit this <a href="http://pinouts.ru/connector/4_pin_USB_A_or_USB_B_plug_connector.shtml">site</a>.<br />N.B. :- Some connections are not very necessary in this circuit.For example...the connection between pin 1 and pin 16(self programing) is for firmware upgrading and not important so it can be deducted from the circuit(But NOT THE ONE FROM PIN 16 TO x2).Connections from pin 2 and 3 to X2 are also not important(keep them if you want).X2 is a connector.You can simply use serial rail to make this one(this would be better if you want to keep your uC circuit on breadboard).This circuit can be built on breadboard but I recommend you build it on a veroboard or PCB.PCB Layouts are available at the site stated above schematic.<br />Some useful pics:<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlzpJSwQAD3Naz6_Cuuzj1mtgLhlfbt93bISQYu5SRO1AOa1QcKS8JK_haKBsP6CFLpT8B1_-in1DOku4NylpL3ZXJoBXJNK1WObmQZi-cgn3nAiyTspywURNyNmgRVUEWKKkm7z1Wvgi5/s1600/Image0022.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 240px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlzpJSwQAD3Naz6_Cuuzj1mtgLhlfbt93bISQYu5SRO1AOa1QcKS8JK_haKBsP6CFLpT8B1_-in1DOku4NylpL3ZXJoBXJNK1WObmQZi-cgn3nAiyTspywURNyNmgRVUEWKKkm7z1Wvgi5/s320/Image0022.jpg" alt="" id="BLOGGER_PHOTO_ID_5484529977504893266" border="0" /></a> My USBasp board<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggkYyF0T27TMnqR938FIZHE7vWCQYT7ncoZg1HlN-1IW2lYLqp4iPPwrmpBJufo7ETPLQbZYoWpC8jdkI8O_4m7L-G-DGWB3qsNZVN89oYCWaQGMRWYy3tPfrJ-VXCDsJmJu6lRM7pcYs8/s1600/Image0023.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 240px; height: 320px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggkYyF0T27TMnqR938FIZHE7vWCQYT7ncoZg1HlN-1IW2lYLqp4iPPwrmpBJufo7ETPLQbZYoWpC8jdkI8O_4m7L-G-DGWB3qsNZVN89oYCWaQGMRWYy3tPfrJ-VXCDsJmJu6lRM7pcYs8/s320/Image0023.jpg" alt="" id="BLOGGER_PHOTO_ID_5484529988430448898" border="0" /></a> The ISP connector of the board(just serial rail....X2 in the schematic)<br /> These pins are connected to Atmega8's MOSI,MISO,SCK,pin 16 and ground....<br /> Others are unnecessary<br /><br />One thing to tell you about this circuit is that if you are planning to build a PCB in which you will put your target uC to program,then keep the VCCINT(the target uC will be powered by USB).Otherwise,for ISP operation,deduct it.<br /></div>Shovonbdhttp://www.blogger.com/profile/04302437234075930187noreply@blogger.com0tag:blogger.com,1999:blog-915787653990243570.post-21459677944426384732010-04-17T02:30:00.000-07:002010-04-18T09:55:18.450-07:00Getting Started with avr microcontroller<div style="text-align: justify;">Well...time to stop this history lecture and come to the point.We are using atmel avr microcontroller.Many of you may ask why we are using this one.Well...actually I have already answered it but missed one point.Atmel guys write their datasheets very well and they are easy to understand(Datasheet is the documentation of the device you are using...means pin configs,register descriptions etc.).<br />Atmega16 is an 8bit avr microcontroller with 16k in system programmable flash.Well...after all these almost non-technical stuffs,the aforesaid one is like instantly changing speed from as slow as a cycle to as fast as a bullet train!!!Well, avr is a computer architecture developed by Atmel.It's a <a href="http://en.wikipedia.org/wiki/Modified_Harvard_architecture">modified harvard architecture system</a>.8bit means the register size(a temporary memory where data can be stored,exchanged etc.) is limited to 8bits and more precisely...the arithmetic logic unit(CPU) can process 8bit data at a time(maximum).Register is like a set of memory blocks.Each of them can store one bit(0 or 1).So each register of avr should have 8blocks for 8bits.There are some 10bit,16bit registers too,but they are actually collections of several 8bit registers(We shall see them in datasheet).<br />Now...what is that "in system programmable flash" thing?Well...flash is a non-volatile memory and in avr microcontroller(and in many others),this is the memory where the program you have written is kept."In system" means you can program the microcontroller even after installing it in your circuit.That's a great thing because you don't need to remove uC from circuit to program it.You just power your circuit and connect your programming hardware to it and just send the program from your PC or Laptop!<br />Now...I have stated something new here what I haven't stated before:"Programming Hardware".Well...Since the beginning of this tutorial I have been saying that uC can be "programmed".But how?You can't just load the program into a pendrive and then insert it into uC!You need a circuit that will work as an interfacing medium between the uC and your PC.This is the programming hardware.There are many kinds of programming hardwares available for avr(We will discuss it soon).<br />Besides, you also need a software that will use the hardware to send the program to uC.Well...we will discuss it too!<br />Now...let's come to datasheet.I said you need it to know about the uC you are using.Seeing it you can know the features of your uC,pin config, internal devices and how to access them through your code etc.A very good video on accessing the datasheet is about to be published(It's on atmega8 but you can easily get the main theme).Well...let's move to our next chapter.<br /></div>Shovonbdhttp://www.blogger.com/profile/04302437234075930187noreply@blogger.com0tag:blogger.com,1999:blog-915787653990243570.post-32503979162614402232010-04-16T14:51:00.000-07:002010-04-18T09:54:12.527-07:00How to select a perfect microcontroller for your work<div style="text-align: justify;">Well...after having a basic knowledge of uCs (microcontroller) , we move to an essential part...there are many uC models and manufacturers....which uC should we select for our work,right? Well...it's a bit like choosing other electronic components.For example, for timing pulse operation,we select NE555 IC , not CD4017.Like this, we will select our uC according to what we want to do with it....means what integrated facilities it must have to meet our demands.Cost is also a big factor if you want to go commercial.If your desired work can be done with a $1 uC,then it is impractical to choose a $5 uC for that.Size can also be a big factor.two uCs can be of same price but different size and sometimes you may have to choose the smaller one to make your circuit compact.<br />Well...internal facilities or hardwares play the main role so this factor has the first priority in case of choosing a suitable uC.Like,for your work , you need an analog to digital converter or a higher clock rate or built in USB hardware(this stuffs will be discussed later...so don't get scared seeing them) etc. etc. etc. There are some uCs that may meet all your demands...means you may use one like them in every application but they may be costly so you have to choose cheaper , specially dedicated uCs("dedicated" doesnt mean these uCs can only do a single job,they can do other jobs but are "specialized" for doing that single job).<br />A good example is this tutorial...as we are explaining every basic thing of uCs...so we have to choose a uC in which every general hardware is present(means the common hardwares found in most of the uCs).So we are using Atmega16.There is another reason behind choosing this one.This is a general purpose uC and...almost all the tools you need(software,circuit schematics) to work is free(except hardware) and AVR microcontrollers are good to be used in novice level.<br /></div>Shovonbdhttp://www.blogger.com/profile/04302437234075930187noreply@blogger.com0tag:blogger.com,1999:blog-915787653990243570.post-88337669868371929732010-04-16T08:32:00.001-07:002012-03-30T12:04:04.053-07:00What is microcontroller and why it is used<div style="text-align: justify;">We live in electronics age.Electronic stuffs are all around us and doing a lot of works for us every day...every moment.Many of them are quite smart and complex too.For example,let's take a look at a very familiar thing...mobile phone!They are like small computers and have so many functionalities. Of course these functions...no matter how complex... are built with many logics...to know what logic is...simply visit this <a href="http://electronics.howstuffworks.com/digital-electronics1.htm">link</a>.<br />Now...to make this logic gates "electronically",there are many logic gate IC's available or you may make them using simple equipments like relays,transistors etc.You can do this when you are building a very simple circuit. But...what about complex ones...huh?Like your mobile phone?there you need to control the LCD,display various informations on it...that requires very complex logic operation,let alone controlling other thing such as network communication,phone book,internet ,application...bla bla bla.Well,if u want to make a phone without microcontroller, then the size would be as big as a truck(!!!!!!!!!!!!!) and to add a new function,you will have to change the entire circuit.Well...there is one thing that will stand with you to face such challenges...<span style="font-weight: bold;">microcontroller</span>.<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK087044EsOBHeC1pLwxI2TxGHLa5W8j8STngHmMqA780mfrtDHpT-6cthINj1xkbx31nfIG_oMLjaG2GHJNLBk4UrJHfqlEZRxdPY2f_vAPFbMuUhfAg7EkhCfIe36p04tskD6hz1_rPn/s1600/Sell_ATmega16-16PU_ATmega16-16PI_ATmega16_AVR_ATMEL_Integrated_Circuits_Manufacturer_exporting_direct_from_China.jpg" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; width: 320px; height: 254px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhK087044EsOBHeC1pLwxI2TxGHLa5W8j8STngHmMqA780mfrtDHpT-6cthINj1xkbx31nfIG_oMLjaG2GHJNLBk4UrJHfqlEZRxdPY2f_vAPFbMuUhfAg7EkhCfIe36p04tskD6hz1_rPn/s320/Sell_ATmega16-16PU_ATmega16-16PI_ATmega16_AVR_ATMEL_Integrated_Circuits_Manufacturer_exporting_direct_from_China.jpg" alt="" id="BLOGGER_PHOTO_ID_5460766012953807234" border="0" /></a> Image : Atmega16 Microcontroller (We will use it)<br />Microcontroller is a small computer in a single chip.I mean,it has almost everything a computer consists of...CPU,RAM,Non- Volatile memory like Hard disk(not actually like that,in a solid state form without any rotating parts).Like a computer you can program it and through it's I/O pins,you can send command or take datas for processing.And logics can be programmed,so you don't need a truck size board now(Yeppi!) .So, your circuits can now be extremely small...highly customizable...and very easy...and secure.Now where is this security stuff coming from...right?<br />Well...you want to sell a complex (with many logics) circuit you have built with great labour.You sell it...and someone buys it and copies it and...sells it at a lower price..because he has just copied it...so he can cut the extra cost you added for research(ohhhh)...but if that was a microcontroller based one...you could just "lock" the microcontroller code and sell it and...that copier guy cannot make your circuit because he doesn't have your code to run the circuit(Now do that...copier).So it makes your work easy and safe too.<br />Now...where can we find microcontrollers?Well...they are everywhere,mobile phone,washing machine,microwave oven,television,printer,photocopier,modem,toys(aaahhh)...and many other.<br />So,we can say that...they have become a part of our life<br /><br /></div>Shovonbdhttp://www.blogger.com/profile/04302437234075930187noreply@blogger.com0tag:blogger.com,1999:blog-915787653990243570.post-29815232944651663802010-03-14T11:02:00.000-07:002010-04-18T10:57:30.803-07:00Atmel microcontroller tutorial - Indexhi guys.I am Shovon(M.E. BUET).I am an electronics and robotics enthusiast.I have been working with uCs for a long time and I have collected valuable infos and willing to share 'em. I am writing a tutorial on uC(Microcontroller).The uC I'm gonna use is Atmel Atmega16(8,32 will be ok).Well,let's keep this mumbo jumbos short...and move to the tutorial<br />N.B. :-For descriptions...see other blog posts<br />Here is the complete index:<br /> <span style="font-size:180%;"><span style="font-weight: bold; color: rgb(102, 204, 204);font-family:verdana;" >Atmel uC tutorial</span></span><br /><ul><li><a href="http://researchbd.blogspot.com/2010/04/whai-is-microcontroller-and-why-it-is.html">What is microcontroller and why it is used</a></li><li><a href="http://researchbd.blogspot.com/2010/04/how-to-select-perfect-microcontroller.html">How to select a perfect microcontroller for your work</a></li><li><a href="http://researchbd.blogspot.com/2010/04/getting-started-with-avr.html">Getting started with avr microcontroller</a></li><li><a href="http://researchbd.blogspot.com/2010/04/hardwares-needed.html">Hardwares required</a><br /></li><li><a href="http://researchbd.blogspot.com/2010/04/softwares-needed.html">Softwares required</a></li><li>putting it altogether-test everything<br /></li><li>At last!!!The very first program-see it works!!!</li><li>Input Output</li><li>Something special-Interrupt</li><li>Make your microcontroller count time-the Timer/Counter</li></ul><ol><li>8 bit timer</li><li>16 bit timer</li><li>Project - a clock<br /></li><li>Special application - the PWM</li></ol><ul><li>Analog to digital converter - the magical connector between analog and digital world!!</li></ul><ol><li>ADC description</li><li>Some Coding</li><li>Project - voltimeter</li></ol><ul><li>LCD Display...your monitor for uC Computer!!</li></ul><ol><li>Overview</li><li>LCD pin configuration</li><li>Now... some coding</li><li>Project...LCD Clock!!</li></ol><ul><li>Make your uC remember things even when it's turned off - the EEPROM</li></ul><ol><li>Overview</li><li>Registers</li><li>Some Coding</li><li>Project...Alarm Clock</li></ol><ul><li>Tick...Tick...Tick...tititi...Time to communicate with your pc...the USART</li></ul><ol><li>Overview</li><li>Serial Communication Basic</li><li>Register</li><li>Project...computer controlled stepper motor</li></ol><ul><li>Some other uC stuffs</li></ul><ol><li>Serial Peripheral Interface - SPI</li><li>I2C/TWI</li><li>Some good tutorials on uCs<br /></li></ol>Shovonbdhttp://www.blogger.com/profile/04302437234075930187noreply@blogger.com0