Blog Archives

Thats How We C


Two and a half years back, while I was still In college that I got this idea to write a book on Programming. By then I had spent almost 4 years learning and coding a couple of programming languages. I knew I was not an expert in the field, but I also knew that I could help a few who were struggling in programming. The very next semester had a course on C programming and I knew most of my classmates would need help, so I set out on this new venture to bring out text that will help people with no background in programming to understand what C programming is all about. It can never be considered as a replacement to any of the great books out there but still, I knew that It might help someone. So after almost six months of work I was able to have a printed copy of “Thats How We C”, I sold 25 copies of the book to my classmates at no profit, I charged them with the printing cost only.
I hope many more will find this useful and if you do please do let me know, because it will be an encouragement for me to write my next book.
Also please do give me any feedback that you might have.
You can download the book from here

An Introduction to compensator Design with matlab


This will be a series of posts where I will be dealing with Control system Compensator design using matlab. This is intended primarily for Btech Electrical and Electronics students.

I will try to be as brief as possible the underlying concepts have to be studied from standard text books.

If there are any mistakes please point them out.

Basically the compensators have to be designed based on the time domain specifications like rise time, maximum overshoot,damping ratio and settling time. these are the transient state specifications. And in frequency domain the transient state specifications are phase margin, gain margin, resonant peak and bandwidth.

The steady state responses in both cases are the error constants.

We will start with what compensators  are. Compensators are devices added to a  control system so that it meets the given specifications. They introduce poles and zeroes to the system.

The main types of compensators are the lag, lead and lag lead.

Lag Compensator

A compensator that introduces a phase lag to an input signal is called a lag compensator. It improves the steady state performance of the system, but reduces the bandwidth and results in a slower transient response too. It is basically a low pass filter.

Lead Compensator

A compensator that introduces a phase lead to an input signal is called a lead compensator. It increases bandwidth and improves speed ofresponse but there is only a small change in the steady state response. It is basically a high pass  filter.

Please do refer text books for more details on compensators.

Compensators can be designed with time domain specifications and it is done using root locus technique and If frequency domain techniques are used then Bode plot is used( other frequency domain plots can also be used but here we deal with bode Plot).

Commonly used functions in matlab

tf – converts system representation from transfer function to “system” format. This format provides an efficient way to store and manipulate the system model, but does not allow direct access to the system’s numerator and denominator orpoles and zeros. The syntax to convert from transfer function to “system” format is:
sys = tf (num, den);
tfdata – converts system representation from “system” format back to transfer function format. The syntax (for single-input, single-output systems) is:
[num, den] = tf data(sys, v );


series – forms the series combination of 2 blocks to produce the equivalent transfer function. The output of block 1 is the input to block 2. The syntax for the function in transfer function and in “system” formats are:
[num, den] = series(num1, den1, num2, den2);
sys = series(sys1, sys2);

parallel – forms the parallel combination of 2 blocks to produce the equivalenttransfer function. The outputs of block 1 and block 2 are added together. The same input is applied to both block 1 and block 2. The syntax for the function in transfer function and in “system” formats are:
[num, den] = parallel(num1, den1, num2, den2);
sys = parallel(sys1, sys2);

feedback – forms the closed-loop system that has block 1 in the forward path and block 2 in the feedback path. The default configuration is for negative feedback. In the syntax example shown below, the −1 for negative feedback is shown explicitly. For positive feedback, a +1 would be used in the function’s input argument list. For unity feedback, num2 = den2 = 1. The syntax for the function in transfer function and in “system” formats are:
[num, den] = f eedback(num1, den1, num2, den2, −1);
sys = f eedback(sys1, sys2, −1);


cloop – forms the closed-loop system when unity feedback is used. This function is obsolete, but is still available in most MATLAB versions. It can only be used when the block in the feedback path is unity, and it can only be used with the system model expressed in transfer function form, not in “system” format. The syntax for the function is:
[num, den] = cloop(num1, den1, −1);

rlocus – computes and plots the root locus for a system, using an internally generated set of gain values. A user-specified vector of gain values can be included as an input argument if desired. Output arguments of closed-loop poles and the corresponding gain values can also be obtained. In this case, no plot is made. If the root locus plot for negative gain values is desired, a minus sign is placed in front of num or sys. The syntax for the function in transfer function and in “system” formats are:
rlocus(num, den);
rlocus(sys);


rlocfind – computes the gain and the corresponding closed-loop pole locations for a specified point on the root locus. A crosshair is made available to select a point on the root locus plot. The gain corresponding to that point is returned, as well as all the closed-loop poles for that gain. The syntax for the function in transfer function and in “system” formats are:
[K, poles] = rlocf ind(num, den);
[K, poles] = rlocf ind(sys);


Instead of graphically selecting a point, one or more desired closed-loop pole locations can be input to the function. The gains and closed-loop poles cor- responding to those specified pole locations are returned. No error message is given if the specified pole locations are not actually on the root locus for the system. The syntax for the function in transfer function and in “system” formats are:
[K, poles] = rlocf ind(num, den, P );
[K, poles] = rlocf ind(sys, P );


bode – computes the magnitude (absolute value) and phase (degrees) of a system evaluated on the jω axis. If no frequency vector is provided as an input argument, MATLAB selects a set of frequency values. If no output arguments are specified, the Bode plots are automatically made. If output arguments are specified, no plots are made. Specifying a frequency vector and output
arguments, the syntax for the function in transfer function and in “system” formats are:
[mag, ph] = bode(num, den, w);
[mag, ph] = bode(sys, w);

margin – computes the following measures of relative stability based on the frequency response of a system: gain margin (Gm), phase margin (Pm), phase crossover frequency (Wcg), gain crossover frequency (Wcp). These measures
provide information about how much perturbation to a system can be tolerated without becoming unstable and are often used as design specifications. If no frequency vector is included as an input argument, the values are computed
analytically from the transfer function. If a frequency vector is included, the values are obtained by searching the magnitude and phase arrays at those frequencies. If no output arguments are specified, Bode plots are made with the gain and phase margins shown on the plots. The syntax for the function in transfer function and in “system” formats are:
[Gm, P m, W cg, W cp] = margin(num, den);
[Gm, P m, W cg, W cp] = margin(sys);
[Gm, P m, W cg, W cp] = margin(mag, ph, w);
nyquist – computes the real and imaginary components of the frequency response of a system (rather than magnitude and phase). A frequency vector is an optional input argument. If no output arguments are specified, a plot of the imaginary part vs. the real part of the frequency response is plotted, and the s = −1 + j0 point is indicated on the plot. If output arguments are specified, the real and imaginary parts are returned, and no plot is made. The syntax for the function in transfer function and in “system” formats are:
[re, im] = nyquist(num, den, w);
[re, im] = nyquist(sys, w);


step – computes the unit step response for a system. A time vector is an optional input argument. The vector of values of the step response is an optional output argument. If no output argument is specified, a plot of the response is made. The syntax for the function in transfer function and in “system” formats are:
c = step(num, den, t);
c = step(sys, t);

If you have learned the basics then please move on to the next Post.

Lag Compensator design with Bode plot

Lag Compensator design with Root Locus

Classification Of Software Bugs


Who is not afraid of bugs ? Most of my readers I know will shudder just at the thought of those creepy things crawling all over you .

Just like the tag line of the Movie Eight-Legged Freaks , “Do you hate spiders? Do you REALLY hate spiders? Well they don’t like you either”

But there is another class of bugs that can ruin your sleep, your peace of mind and can really make you go nuts, we engineers call the software bugs. They can make a beautiful program a mess and can get you right back to square one. Everyone who has written a program no matter how basic it is will have encountered bugs in the first trial. Bugs can be caused due to carelessness from the part of the programmer or the programmers inability to spot out an invalid condition and it can also be caused by hardware imperfections.

No matter how much care is taken to write a bug free software is an unrealized dream and software experts claim that it will remain unrealized. Software Bugs have caused alot of trouble. Paul Bourdeaux mentions Top Ten Most Infamous Software Bugs Of All Time in his blog.

“Debugging is like removing needles from the haystack” It can be one heck of a job to find bugs in a very large program. While working on my Btech Project I encountered a Similar situation the program started giving weird results I spent almost two days checking the logic and analyzing it and the real cause of the error was a wrong argument to a function.

Despite all this There has been an effort to classify bugs in an interesting way. All those who have learned programming might have heard terms like run time errors, Logical bugs, arithmetic bugs, syntax errors etc.

But there is another classification of bugs and these are :

Bohrbug

A BohrBug is just your average, straight-forward bug. Simple like the Bohr model of the atom: A small sphere. You push it, it moves. BohrBugs are reproducible, and hence are easily fixed once discovered. These are named after Niels Bohr, who proposed a simple and easy-to-understand atomic model in 1913. In Bohr’s model, things like the path and momentum of an electron in an atom are predictable.

Heisenbug

A bug that disappears or alters its behavior when one attempts to probe or isolate it. No matter how much time and effort is spent trying to reproduce the problem, the bug eludes us. Such bugs were named Heisenbugs, after Werner Heisenberg, who is known for his “uncertainty principle”. According to his theory, it is not possible to accurately or certainly determine the position and velocity of an electron in an atom at a particular moment.

Mandelbug

When the cause of the bug is too complex to understand, and the resulting bug appears chaotic, it is called a Mandelbug. These are named after Benoît Mandelbrot, who is considered the father of fractal geometry (fractals are complex, self-similar structures). A bug in an operating system that depends on scheduling is an example of a Mandelbug.

Schroedinbug

Sometimes, you look into the code, and find that it has a bug or a problem that should never have allowed it to work in the first place. When you try out the code, the bug promptly shows up, and the software fails! Though it sounds very uncommon, such bugs do occur and are known as Schroedinbugs. They are named after the scientist Erwin Schrödinger, who proposed that in quantum physics, quantum particles like atoms could exist in two or more quantum states.

By observing the problem in the code, you change the outcome — either the software works or breaks. So these kinds of bugs are known as Schroedinbugs.

Fractal Bugs

A bug, after which its resolution is found, reveals additional self-similar bugs elsewhere in the code, after which they are fixed, likewise appear elsewhere still.

Next time time you write a program and if it crashes unexpectedly you can tell your teacher or your friends that you have a heisenbug or a bohrbug in your program, let them figure out what the heck that means. Happy Hacking 🙂

References

[1] S.G Ganesh http://www.linuxforu.com/2010/10/joy-of-programming-types-of-bugs/

[2] The Jargon File http://www.catb.org/jargon/html/index.html

Toshiba L750 – A Review


Toshiba is showing clear signs of dominating the laptop Industry by its new array of products. I recently purchased a Toshiba L750 and I bought the product half heartedly because Dell was my favourite brand. But over the last two months Toshiba has amazed me with its performance and elegance.

Toshiba has always produced laptops for every budget and have always delivered maximum performance in the given budget

Toshiba L750 comes in the range of 40,000 INR.

The Toshiba Satellite L750 is available in many various configurations. Processor options range from the entry level Intel Core i3 2330M, the midrange processors Core i5 2410M and 2430M, up to the high performance Intel Core i7 2670QM. Intel’s integrated HD Graphics 3000 or Nvidia’s entry level graphics cards, GeForce GT 520M or the GeForce GT 525M can be selected as the graphics solution.

It has a sata Hard disk of 500GB and a DDR3 RAM of 4 GB. The hard disk is very fast and stores enough data.

The power socket is located on the rear right. It is followed by the DVD drive and two USB 2.0 ports.

The rear doesn’t have any interfaces. The 5in1 card reader, for MMC, MS/MS-PRO, SD and SDHC, is on the front.

The mandatory Kensington lock is found on the rear left. That is followed by the vents and the Gigabit LAN socket. The VGA and HDMI ports are also found on the left front. A USB 3.0 port with charge function has been placed between that. Headphones and microphone can also be connected on the left front.

Toshiba hasn’t done a good job with the interface positioning. All ports are located on the front area of the sides. Consequently, the room beside the notebook is very limited when the ports are used.

The 15.6 inch screen comes from Samsung and is called 156AT05-T02. It has the rather low resolution of 1366×768 pixels and is also reflective.

Toshiba L750 has a qwerty keyboard witha num pad. The touchpad is nothing more but an area with a rough surface , the area of touch pad is actually quite small compared to the total area. The keyboards too are not the best looking.

A 48 Wh lithium ion battery is used in the Satellite L750. The laptop manages a runtime of good four and a half hours with that.

The Satellite is remarkably rigid. The display lid can be dent clearly, but no color distortions are passed on to the screen. The hinges are strong and have a good grip on the screen. But the base unit has to be held down to open the laptop because it would otherwise lift up along.

The area of the optical drive can be dented a bit on the bottom. The rest of the notebook hardly yields. The area between the keyboard and display seem particularly stable. The base unit can’t be warped and doesn’t emit any creaking noise.

Heating is much less and even on over usage the whole laptop doesn’t get heated, only the air ducts area gets heated.

Overall, the Satellite L750 is aimed at users who need a solid notebook, but don’t want to squeeze out the last MHz of performance. The processor’s performance is easily sufficient for editing pictures or videos. On the whole Toshiba 750 is a promising product for mid range customers and it delivers high performance computing within your budget.

 

 

t1

Toshiba L750

Calibre – An Ebook Management System


Maintaining large collections of Ebooks can become a nightmare, if not maintained properly finding the desired books is also a difficult job. Calibre is a one word solution to this problem. calibre is free and open source e-book software that organizes and manages e-books, supporting a variety of formats. It also supports e-book syncing with a variety of popular e-book readers and will convert e-books between differing formats.

Calibre helps you catalog your e-book collection. First, it surveys all the e-books and other relevant files residing either on your hard drive or your e-reader, and then inserts them into Calibre’s main directory. Once that information is in the directory, you can use it to organise, categorize, annotate, search, rate and save to disk. You can customize or delete any of the data fields Calibre fills in, or add your own.

Its main features are :

  • Library Management
calibre manages your e-book collection for you. It is designed around the concept of the logical book, i.e., a single entry in your library that may correspond to actual e-book files in several formats. Calibre can sort the books in your library by: Title, Author, Date added, Date published, Size, Rating, Series, etc.
  • In addition, it supports extra searchable metadata:
Calibre will even go out onto the internet to find book metadata based on existing title/author or ISBN information. It can download various types of metadata and covers for your books, automatically.
  • E-book conversion
Calibre can convert from a huge number of formats to a huge number of formats. It supports all the major e-book formats.The input Formats: CBZ, CBR, CBC, CHM, DJVU, EPUB, FB2, HTML, HTMLZ, LIT, LRF, MOBI, ODT, PDF, PRC, PDB, PML, RB, RTF, SNB, TCR, TXT, TXTZand the Output Formats: AZW3, EPUB, FB2, OEB, LIT, LRF, MOBI, HTMLZ, PDB, PML, RB, PDF, RTF, SNB, TCR, TXT, TXTZ
It can rescale all font sizes, ensuring the output e-book is readable no matter what font sizes the input document uses. It can automatically detect/create book structure, like chapters and Table of Contents. It can insert the book metadata into a “Book Jacket” at the start of the book.
  • Syncing to e-book reader devices
  • Downloading news from the web and converting it into e-book form

Calibre can automatically fetch news from websites or RSS feeds, format the news into a ebook and upload to a connected device.

  • Comprehensive e-book viewer
  • Content server for online access to your book collection
Calibre has a built-in web server that allows you to access your ebook collection using a simple browser from any computer anywhere in the world. It can also email your books and downloaded news to you automatically.
Calibre Main Page

Calibre Main Page

Calibre serves the purpose it was made for efficiently so you no longer have to worry about searching your whole file system to find an ebook. I have found it to be one of the most usefull software in the opensource world. Especially the feature to share your books online is an added advantage and setting up the calibre server is an easy task.

Setting Calibre Server

Setting Calibre Server

Calibre is availble for Windows ,Mac and Linux. A portable version of calibre is also available so that you can carry around your library in a pendrive, Installing calibre is a straight forward affair and in ubuntu it is available in the software center. I hope this article serves as an introduction to calibre for those who have not yet heard about it.

Check http://www.calibre-ebook.com for more details.

%d bloggers like this: