Saturday, March 14, 2015

DIY mini-UPS for charging phones or running wifi router or Raspberry Pi

Currently Pakistan is going through an energy crisis. Consequently I am faced with frequent hour long power outages. I have a largish UPS for running an assortment of electrical appliances but I am always vary of using it to power DC electronics.

This is where this DIY mini-UPS comes in handy. It runs off a 12V motorcycle battery and is charged using a standard 12V DC power adapter. It is capable of powering either a standard wireless router (that requires 12V DC), a Raspberry Pi or charging a phone.

The switching from line voltage to battery voltage is fast enough that the wireless router doesn't stutter and the Raspberry Pi keeps running without a hitch.

I followed the instructions from this excellent tutorial which also gives a wonderful explanation for how the circuit works. I did make a few modifications of my own, simplifying the circuit to fit my needs. In particular I connected the DC output directly to the input because the voltage drop across both the 1N4007 diode and the TIP 127 was unacceptable when running off of the battery. The modified circuit is:


(the circuit diagram was drawn using circuitikz package in LaTeX. Here is the how-to)

And here is the end-product, shifted to a perf-board after being tested on a bread-board:
<insert image here>

Friday, March 13, 2015

Drawing Circuit diagrams in LaTeX

Those of you who are familiar with my interests would know that I am both an electronics hobbyist and a huge fan of LaTeX. Therefore I am thrilled with my recent discovery of the ability to draw publication quality circuit diagrams in LaTeX, using the circuitikz package. Take a look at the sample below:


The LaTeX code used to generate this diagram can be found at circuit-ups on GitHub. A simple example of constructing a circuit diagram is
  \begin{figure}
      \begin{circuitikz}

          \draw (0,0)
          to[V,v=$U_q$] (0,2) % The voltage source
          to[short] (2,2)
          to[R=$R_1$] (2,0) % The resistor
          to[short] (0,0);

      \end{circuitikz}

      \caption{My first circuit.}

  \end{figure}
and it creates the following circuit diagram:

Image Source: tutorial

All that is required are the circuitikz and siunitx packages which can be easily downloaded using tlmgr (the Tex-Live manager). On Ubuntu this can be done by running:
    tlmgr install circuitikz
    tlmgr install siunitx

I learned about using circuitikz from the following this tutorial which also contains a link to the circuitikz manual which came in handy.

All of the components in the circuit diagram on top are provided by the circuitikz package with the exception of the 7805 IC which I created by using primitive pgf directives I learned from this second tutorial. This was surprisingly easier than it sounds. And the output is very elegant.

(Note: The LaTeX commands generate pdf which I converted to a png using imagemagick before inserting it in to this blog)

Monday, February 9, 2015

Type-setting Urdu in LaTeX

I gained a considerable amount of experience working with LaTeX while I was completing my PhD. The thought immediately struck me that LaTeX was perfect for type-setting Urdu text because of the high demands for formatting that is required.

Turns out computer enthusiasts were way ahead of me. With the advent of XeTeX which brought unicode support to LaTeX and the bidi Tex-package which allows for bi-directional text (essential since Urdu is written from right to left) it is now possible to create beautiful urdu documents (pdfs), both prose and poetry, using LaTeX.

I have created a tutorial that explains how to do this in Ubuntu.

For samples of this technique:

nasr (prose)

nazm (poetry)

Saturday, January 24, 2015

My book on using LeJOS with EV3 is now out

A little over a year ago when my wife gave me the Lego Mindstorms EV3 as the most awesome of birthday presents I started tinkering with it in an attempt to use Linux to program it. This led me to discover LeJOS. The subsequent joy of discovery moved me to create this blog and post what I learned about it.

These posts brought me to the attention of Packt publishers who commissioned me to write a book on the subject. That book has now been completed and is available on Amazon (amongst other places): Lego Mindstorms EV3 Essentials

The book is in essence a pedagogically rich instruction manual on how to program the EV3 using both the on-brick visual programming language and using Java by installing LeJOS. The primary focus of the book is using LeJOS while programming on a Linux machine. So if you are a robotics enthusiast who is comfortable with Linux (and really one cannot call themselves an enthusiast of any computer related field if one doesn't learn Linux) then you will love the detailed information this book provides on how to program the EV3 on that great OS. The fact that the EV3 runs Linux itself should be reason enough.

To get an idea of how the book presents its material you need go no further than this blog itself, which is the inception of the book, and the detailed information Packt have provided on their website: Packt Publishers - Lego Mindstorms EV3 Essentials.