Thursday, June 25, 2015

Building your own Computer with NAND gates

Have you ever wondered how our computers works, how they display colorful graphics and let us play some awesome games. What are those tiny black things inside my laptop?

Recently I came across an online course on building your own computer starting with NAND gates.
Ok, then What is NAND gates? Well NAND gates are basic building block for any digital device ex- Laptops, Mobiles, Camera and many other devices.

Ok, then how to make NAND gates? NAND gates are made using even smaller components called as Transistor, they are like switch which can be turned ON and OFF, but by flowing a small current through them not the we have traditional tick tack type switches.

Ok, so you are telling me that everything is made from Transistors? Yess you got it.. every digital device is made from Transistors.

So, lets talk about that course. The name of the course is nand2tetris in which we have to make our own computer and run own softwares all starting with simple NAND gates. There is also a course on coursera by the same professors with video lectures. I think is worth to see once that site and course for every engineer who is interested in computers and digital devices.

So, I decided to write my own blog on how to build our own computer. This is just a guide for people to help and share whatever i learnt using that course. I will follow materials from there and build my own HACK computer using the resources provided on nand2tetris website.

Though there is no pre-requisite for this course but, I think if you have taken any course on Digital Circuits or Basic Electronics, It will be easier to follow up the course.

The course goes like this:

  • First Project: Simple Gates and Computational Logic like AND, OR, NOT, Muxes and DeMuxes.
  • Second Project: Adders, Incrementer and full ALU.
  • Third Project: Memory elements like Registers and RAMs.
  • Fourth Project: Machine Language Programming i Assembly.
  • Fifth Project: Combining everything you made in First Second and Third project to full functional CPU.
  • Sixth Project: Writing an Assembler Program to translate code written in Fifth project to Machine Code which your CPU will understand. 

Then there are more projects which i will discuss in future blogs. I will start with building our simple gates in next blog. Thanks for reading please have a look at nand2tetris website.

Saturday, June 13, 2015

Computer Vision - SURF Feature Extraction and Object Tracking using MATLAB

I am currently working on a Mobile robot which will use Vision based Navigation for automatically finding Charging spots when the battery is low and get attached to itself.

For this task first the steps are broken down into following pieces:

  • Taking a number of reference images of the object to be detected. (For checking purpose of my code i took a "POW"(power) written on a notebook and tracking those characters. Depending on the location of "POW" in the image, i will generate the control command for the robot, whether it should go left or right and by how much amount using PID controller.) 


  • Detection and Extraction of SURF features (which is faster version of SIFT features) from the reference images and making a feature vector by stacking features from different reference images. In my case, I have only taken a single reference image shown below but you take multiple images and create the feature vector.
  • Detection and Extraction of SURF features from the images captured from camera in real-time.
  • Matching of those features using different algorithms. In MATLAB, there is only one feature matching function which is very robust, but if you using openCV, you can go for Brute-Force Matcher of FLANN based matcher. I have done this same thing in openCV. If anyone want the code using openCV, comment below in comment section.
  • Depending on the matched feature, Calculate centroid of the "POW" symbol and if the symbol is right half plane, generate right command to the motor otherwise left command.
The MATLAB code is embedded below,


Here is a working demo of my code:

For any suggestion, comment below. Thanks!