Friday, July 1, 2011

Linux Fever



Hello Again!
Well my latest project on PIC microcontrollers is talking longer than expected so i thought i would share one of my favorite operating systems with you.

Some of you might already be familiar with it ,but i know that a lot of people just don't know a thing about Linux.So i want to introduce you to Linux.

First of all lets go over a few things .A lot of people have a lot of misconceptions about Linux,Some see it as being a command line operating system,some see it as being incredibly hard and tough to learn .Most of the people who use windows and are told about linux see it as one of the above mentioned things.

Well its true that linux is command line but there are distributions that come with a desktop environment and it's true that Linux does has a bit of a learning curve if you want to perform advanced functions or anything involving the shell but the everyday stuff you do is extremely easy to do and sometimes a better experience than windows.

First let me tell you where you can get a distribution of linux.There are a lot of options you can choose from .Some of the popular ones being:
Ubuntu
Linux Mint
Fedora
Open suse
Arch


The downloads of ISO's are available on the websites,you can download via ftp or torrent.There are also USB versions,available for downloads.You can choose from the available options.


For first time users i would recommend Ubuntu .Its easy to install and operate,but you can choose any,although i would discourage you from choosing Arch first,as it requires a lot of set up and you are not greeted with a GUI but a command line interface after the installation.It is for those who require a custom selection of packages installed and for advanced users.

There's also some more things you need to decide before you choose a distro .You need to choose a desktop environment.Most distros offer a choice of different desktop environments most popular of which are Gnome.KDE,XFCE and LXDE .I would recommend Gnome.

I would also recommend using Ubuntu 10.10(Maverick Meerkat) instead of the latest version.The torrent file for Intel pc's can be downloaded here if you have a different pc you can find a suitable download here.

Now let me tell you whats the best thing about Linux distributions,they are FREE!!

Yeah you heard that right ,free,but how can that be? well you can read all about it here.

Another great advantage of using linux is that you have a great community to help you with anything that you would want to know about linux or may need help with.

Now there are many ways to get started with,but i would suggest you first try out the Live CD.Most of the linux distributions let you try out the distribution without affecting your computer in any way.You just change your boot order to make the DVD rom primary ,insert the CD and follow the on screen instructions.

If you are satisfied with the experience and decide to install the distribution on you pc,i would recommend using a virtual machine and installing the distro on it first rather than trying your hand on the actual pc and accidentally end up losing any data.If you have chosen Ubuntu you can  use the windows installer.

Both the above mentioned methods let you try out the distro,keeping the host operating system safe while you familiarize with the distro.

If you do decide to install your hard disks,you should check out the forums for the chosen distro first.It has a lot of guides on how to install,how to dual boot etc.

You can take a look at the following for Ubuntu(Ubuntu install guide)

Most distributions come with a number of pre installed applications .Some of them are Open office or Libre office that is a office suite which acts as an alternative for Microsoft Office in Windows, Evolution (E-mail client),Empathy(IM client), Gwibber(Social networking client),Banshee or Rythmbox(music management and playback),Mozilla Firefox(Internet Browser),Transmission(a bit torrent client),some games and other stuff.

But your disto may or may not have these exact applications necessarily as they vary from distro to distro and also with change in desktop environments but they may have some applications that perform similar functions.

And don't worry all these are free and won't cost you a dime.

You can install new software from Ubuntu Software Center under the Applications menu in ubuntu or thorough the terminal (found under Applications>Accessories)

Another great thing is that your hardware just works out of the box.Although of you have an Nvidia or Ati graphics card you may want to install a propriety driver .You should get a notification about the same and if you don't you can find it under System>Administration>Additional drivers and activate the current driver from there.

Now let's assume you have installed the distro and you want to set it up,though most of the stuff works out of the box I recommend that you install the following:-

Ubuntu restricted extras(in ubuntu only)-
This is a collection of restricted softwares(flash,java,codecs etc.)
Terminal code:-
sudo apt-get install ubuntu-restricted-extras
*note:-
-This will prompt you for a password,the one you entered during the installation
-You can copy and paste the above code

Sun Java runtime environment(jre)
This is the jre by Sun,some of the softwares work better with the sun version rather than the openjdk version
Terminal code:-
sudo add-apt-repository ppa:sun-java-community-team/sun-java6
sudo apt-get update
sudo apt-get install sun-java6-jre

Mplayer/Smplayer-
Mplayer is a free and open source media player.MPlayer supports a wide variety of media formats and can also save all streamed content to a file.
Smplayer is a frontend for Mplayer
Terminal code:-
sudo apt-get install mplayer smplayer

Deluge-
A bit torrent client
Terminal code:-
sudo apt-get update deluge
Compiz-
Cool effects for your desktop
Terminal code:-
sudo apt-get install compizconfig-settings-manager compiz-fusion-plugins-extra

Tip:-If you want to go into advanced stuff you might want to learn to use the terminal,its a powerful and fun tool in your arsenal.You should take a look here or here for the same.

Before i end this post,take a look at this video showing off cool compiz effects in ubuntu 10.10.

Please feel free to leave a comment if you'd like to share anything or have a question about anything.

That's it for now!
See you next time!

Tuesday, April 5, 2011

POV Clock

POV CLOCK
This is my second post here and as i said in my previous post this is about a POV(Persistence Of Vision) clock.
First let us understand what is persistence of  vision.Well we've all seen the effects of persistence of vision in action when we watch a movie,a cartoon or a flip book.
Persistence of vision is the property of the human eye whereby an image leaves an impression on the retina for about 1/23 second.This property is used in movie theaters,displays etc. to give the perception of motion to the viewer.This can also be used to create a persistence of vision display with the help of mechanically scanned LED's.
Flip books use this principle. If the book is flipped at a fast enough speed, the illusion of smooth motion is created.

Ok, enough talk let's get down to business.
Now to build one of these babies you don't need much but the list of things  is given below:-
  • 12V DC motor (with RPM higher than 1500) x 1
  • 12-0-12 transformer x 1
  • 1N4007 diodes (used for rectification) x 2
  • PIC 18F4520 (I used this but you can use any of the other microcontrollers from pic 18f/16f series or atmel microcontrollers) x 1
  • Crystal Oscillators (4 Mhz and 32.768 Khz) x 1 each
  • Capacitors (22pF and 27pF) x 2 each
  • LM7805 (Voltage regulator) x 1
  • A 9V battery
    Most of the parts can be obtained easily, if not, their replacements can be easily found.

    The basic requirement is to perform LED blinking.That said it's not that easy to get everything right to create the effect of a number being displayed.
    The basic idea is to create numbers as shown in the picture.

This has to be done in such a manner that the number appears as a solid image.
Now our first aim is to get the numbers displayed and we'll worry about them being the time later.
As you saw in the requirement list that a motor with RPM higher than 1500 is required,let us see why so?
According to persistence of vision the time for which an image lasts is about 1/24 of a second.That can be achieved if the LED's pass a point 24 times in a second i.e 24 revolutions per second.
That comes out to be 24x60=1440 revolutions per minute hence the motor having RPM higher than 1500 is needed.
Assuming we are using 5mm LED's let us calculate the delay needed between two consecutive columns being displayed
The linear velocity of the arm will be 
V=ωr
where v=linear velocity of the arm
ω=angular velocity(lets say we choose a motor with 1800 RPM ,then 1800 will be the angular velocity)
r=length of the arm(9 cm for my )

V=30x9x10^(-2)
V=2.7 m/s

Time taken to cover 5mm distance is=5x10^(-3) /2.7
=0.001851 seconds
=1.851 milli seconds

So every consecutive column should have a delay of about 1.8 seconds between them.
I used a pic 18f4520 for this project so i used a timer(Timer 0 to be specific) to get the desired delay.
One digit=5 columns
One colon(:)=3 columns
Total digits =6
Total colons(:)=2
Distance covered by LED's while displaying 6 digits and 2
Colons(:)= (5*6) + (2*3) =36 columns
One column=5mm
Thirty six columns=36*5=180mm
Total distance travelled by LED's while displaying the time in Format (hh:mm:ss) =180+20
=200mm
5mm i.e. One column is left as space between two consecutive numbers, four such gaps constitute the extra 20mm.
The time must be displayed only once in a revolution, if there is no delay between two consecutive transmition results in difficulty in differentiating between two consecutive images.
One way of doing this is using a IR or LDR sensor and source on the board and providing an obstruction between them at a particular point,this would cause a signal to be sent to the microcontroller and the transmission starts.
Another way to do this is to switch off the LED's after one complete image for a predefined delay. This delay is calculated using the concept that the total angle at the centre of the circle is 360 degrees.
The angle subtended by the time image is calculated and subtracted from 360 to get the rest of the angle.
The total angle subtended at the centre by the 200mm image is =2.22 radians or 127 degrees.Hence the remaining angle is 4.06 radians or 233 degrees
The time for which the LED’s must be off is 135.3 milliseconds
Timer0 is used for the delays as timer1 is already being used as an RTC.Since the crystal used is 4Mhz the machine cycle is 1Mhz hence a pulse is generated every 1μsec.
The delay of 1.85 msec requires 1850 instructions pulses and since the timer used is 8 bit and the maximum value before it overflows is 255 prescaling is required.

1:8 prescaling ratio is used with the register initialized with an initial value of 24 to achieve a 1.85 msec delay.
The second delay is also achieved from timer0 in a similar manner.

Once the numbers are displayed,the time is fairly easy to show.
The 32.768 Khz crystal at TIMER1 creates a 1second delay if the high register for timer 1 is given the value 0x80.
After getting 1 second,a minute and hour can be easily detected.The 'C' code explains this much better.

The code for the microcontroller is available here.Everything else can be seen clearly from that.
The chip settings used are:-

  • High Speed Oscillator (4 to 20 MHz)
  • Fail-Safe Clock Monitor disabled
  • Oscillator Switchover mode disabled
  • Power-up Timer Enable disabled
  • Brown-out Reset disabled in hardware and software
  • Brown-out Reset Voltage Minimum setting
  • Watchdog Timer Disabled



Now let's get to my favourite part “Hardware”.


I made the project as a combination of two pcb's.A main board and an LED board,the schematics for both of which are given as follows


LED board


The RD0 and RD7 lines are connected to the PORT D of the microcontroller directly.
Make sure the LED's used have good brightness and if you use a microcontroller other than PIC you should make sure if the controller needs pull up's they are connected.

Main Board


The Lines left unnamed are PORT D lines and are connected to the led's in the LED board.
Q1 is the 4Mhz crystal with 22pf capacitors and Q2 is the 32.768 Khz crystal with 27pf capacitors.

I made the schematics and boards using a CAD program called EAGLE which has a freeware version for both Windows and Linux.

The coding was done in MPLAB using C18 compiler which works in Windows and also fairly well in Linux using Wine.

If you have any questions about anything in this project you can contact me at k_preet_singh@yahoo.com
I hope you like the post and please do comment.

And here's a video of it in action,well the video is not too good but that's all  I have for now.



 

Wednesday, January 12, 2011

My First Post

Hello Everybody!!

Well this is my first post so i think introductions are in order.I am Karan ,I am an engineering student in Delhi.
I am pursuing B.Tech from Indarprastha University in Electronics and Communication Engineering.

I thought why not share somethings you might find interesting.I like trying new things,but i am not successful in all of them,so through this blog may be i can share the successful ones and learn something from you that might make some of my failed exploits more to work.

I am a Linux user and I have an android powered phone so you guys will probably read a lot about that here.I also am an electronics buff so that's just one more topic you are likely to read about in this blog.

I recently made a POV (Persistence of Vision) Clock so,the next post is most likely to be about that.

This is is for now!
See you next time!