Blog

  • Quaternion Basics

    Motivation

    The orientation of any object can be represented in a number of ways:

    1. Euler Angles – Uses 3 angles around independent axis to express the orientation
    2. Orientation Direction Cosine Matrices – Uses a 3×3 matrix to represent a rotation.
    3. Quaternion – Uses a 4d vector to reperesent the orientation

    Each of the methods have its own merits and demerits. We shall focus here on Quaternions. When using quaternions to describe a rotations, it enjoys the following benifits compared to the other methods:

    1. It is very easy to see the axis around which the rotation takes places.
    2. It is easy to interpolate between the two orientation. It does not suffer from Gimbal Lock which the other representations might.

    The only downside of this representation is that it might lack intuitiveness. In this system the rotation is give as a single rotation around an axis as compared to a sequence of 3 rotations in the case of other two methods

    History

    Quaternions were developed by Willain Rowan Hamilton in 1843. His interests around that time was in complex analysis. The subject had not yet developed as a completly and thus his discovery back then was a major step. His liked the idea that complex number can be rotated in a plane by multiplying with another complex number. He was interested in doing the same things with vectors in space.

    Purely speaking mathematically, his contribution was in Field Extension of the complex field \(\mathbb{C}\) to 4 dimensional space of quaternions represented by \(\mathbb{H}\).” As this field is not Abelian, that is, it does not have the properties of being commutative, Hamilton received a lot of backlash. Studying such mathematical structures was considered not very useful those days. But in the current times it is no longer the case. A lot of non abelian groups like matrices are of very large importance.

    His contributions had a large impact on the mathematical community. As the American mathematician Howard Eves described the significance of Hamilton’s new approach by saying that

    [!quote]
    it opened the floodgates of modern abstract algebra. By weakening or deleting various postulates of common algebra, or by replacing one of more of the postulates by others, which are consistent with the remaining postulates, an enormous variety of systems can be studied. As some of these systems we have groupoids, quasigroups, loops, semi-groups, monoids, groups, rings, integral domains, lattices, division rings, Boolean rings, Boolean algebras, fields, vector spaces, Jordan algebras, and Lie algebras, the last two being examples of non-associative algebras.

    Quaternions also picked up interest in the computer science and graphics community due to its ease of representing rotations. It also has applications in Quantum physics as the spin states can be represented by Quaternions.

    Quaternion Basics

    Quaternions is an extension of the 2D complex numbers to 3d. It was invented by Willain Rowan Hamilton in 1843. He was attempting to come up with a technique for multiplying triplets when he arrived at the quaternions. Just as rotations can easily be represented as multiplications with two complex numbers in 2D, quaternions make rotations in 3D easy to compute.

    Quaternions are represented as a vector of 4 elements in \(R^4\)

    $$
    \begin{bmatrix}
    a \\
    b \\
    c \\
    d \\
    \end{bmatrix} \epsilon R^4
    $$

    This is also broken down into scalar and vector parts

    a = scalar
    (b,c,d) = vector

    This is also represented as $$q =j\alpha_1 + i\alpha_2 + j\alpha_3 + k\alpha_4$$
    The Quaternions are governed by the following rules for multiplication

    [!important]

    $$
    i^2 = j^2 = k^2 = ijk = -1
    $$

    Addition

    Addition in quaternion is same like addition in the case of complex numbers where the numbers are added element wise.

    Two quaternions given by

    $$
    q_1 = a + b\hat{i} + c\hat{j} + d\hat{k}$$ and
    $$ q_2 = e + f\hat{i} + g\hat{j} + h\hat{k}$$

    gives a resultant sum

    [!note]

    $$
    q_1 + q_2 = (a + e) + (b + f)\hat{i} + (c+g)\hat{j} + (d+h)\hat{k}
    $$

    Multiplication

    The multiplication table is given as

     ijk
    i-1k-j
    j-k-1i
    kj-i-1

    Using these rules the two quaternions \(q_1\) and \(q_2\) given by

    $$
    q_1 = a + b\hat{i} + c\hat{j} + d\hat{k}$$ and
    $$ q_2 = e + f\hat{i} + g\hat{j} + h\hat{k}$$

    when mulplied using the distributive rule and applyting the multiplication table gives

    $$
    q_1 q_2 = (ae – bf – cg – dh) + \hat{i}(af + be + ch – dg) + \hat{j}(ag-bh+ce+df) + \hat{k}(ah+bg-cf+de)
    $$

    The other way of looking at this multiplication when viewed as scalar and vector combination is given as

    $$
    q_1 = (s_1, \vec{v_1})$$ and
    $$ q_2 = (s_2, \vec{v_2})$$

    where

    $$
    s1 = a, s2 = e, \vec{v_1} = (b,c,d), \vec{v2} = (f,g,h)
    $$

    hence the product is given as

    [!note]

    $$
    q_1q_2 = (s_1s_2 – \vec{v_1}.\vec{v2}, s_1\vec{v_2} + s_2\vec{v_1}+\vec{v_1}\times\vec{v_2})
    $$

    Conjugation

    Conjugation is the same as conjugation in the case of the complex numbers except that all the components are inverted in sign

    [!note]

    $$
    \overline{q_1} = a – b\hat{i} – c\hat{j} – d\hat{k}
    $$

    Magnitude

    Magnitude of a quaternion is given as the square root of sum of square of each element

    [!note]

    $$
    |{q}| = \sqrt{a^2 + b ^ 2 + c^2 +d^2}
    $$

    Inverse

    Inverse is given as conujugate divided by the square of the magnitude

    [!note]

    $$
    q^{-1}=\frac{\overline{q}}{|q|^2}
    $$

    Rotating a vector

    Theorem

    [!important]
    For any unit quaternion

    $$
    q = q_0 + \vec{q} = cos\frac{\theta}{2} + \vec{u}sin\frac{\theta}{2} \tag{1}
    $$

    and for any vector $\vec{v}\;\epsilon\;\mathbb{R}^3$ the action of the operator

    $$
    L_q(\vec{v}) = q\vec{v}q^*
    $$

    on $\vec{v}$ is equivalent to a rotation of the vector through an angle $\theta$ about $\vec{u}$ as the axis of rotation.

    Why is this theorem important

    If we have a vector $\latex vec{v}$ which we desire to rotate by \(\theta\) around the axis \(\vec{u}\) then it can be accomplished easily by forming the quaternion q and multiplying with \(\vec{v}\).

    Idea of Proof

    Consider a vector \(\vec{v}\). If \(L_q(\vec{v})\) is the rotation operator by the quaternion q on \(\vec{v}\), where the quaternion is given by Equation (1) above. The \(\vec{v}\) can be split into two components.

    1. One along the axis of \(\vec{u}\), called \(\vec{a}\)
    2. Another perpendicular to \(\vec{u}\), called \(\vec{n}\)
      The proof works by proving that the operator \(L_q\) has no effect on \(\vec{a}\) but rotates \(\vec{n}\) in the plane perpendicular to \(\vec{u}\) by an angle \(\theta\).

    Then using the result that the operation \(L_q\) is linear over \(\mathbb{R}^3\) we can say that

    $$
    L_q(\vec{v}) = L_q(\vec{a}) + L_q(\vec{n})
    $$

    Hence, rotates \(\vec{v}\) by an angle \(\theta\).

    Summary of Proof

    1. Prove that \(L_q\) is linear over \(\mathbb{R}^3\).
    2. Prove that \(L_q\) has no effect over \(\vec{a}\)
    3. Prove that \(L_q\) rotates \(\vec{n}\) by an angle \(\theta\) in a plane perpendicular to \(\vec{u}\).

    Proof

    Proof for Prove that \(L_q\) is linear over \(\mathbb{R}^3\).

    Let \(\vec{v_1},\vec{v_2}\; \epsilon\; \mathbb{R}^3\)

    $$
    \begin{aligned}
    L_q(a_1\vec{v_1} + a_2\vec{v_2})&= q(a_1\vec{v_1} + a_2\vec{v_2})q^*\\
    &=(qa_1\vec{v_1} + qa_2\vec{v_2})q^*\\
    &=qa_1\vec{v_1}q^*+ qa_2\vec{v_2}q^*\\
    &=a_1\;q\vec{v_1}q^*+ a_2\;q\vec{v_2}q^*\\
    &= a_1L_q(\vec{v_1}) + a_2L_q(\vec{v_2})
    \end{aligned}
    $$

    Proof for Prove that \(L_q\) has no effect over \(\vec{a}\)

    Since \(\vec{a}\) is in the direction of \(\vec{q}\)

    $$
    \vec{a} = k\vec{q}
    $$

    Thus

    $$
    \begin{aligned}
    q\vec{a}q^* &= q(k\vec{q})q\\
    &= (q_0^2 – ||\vec{q}||^2)k\vec{q} + 2(\vec{q}.k\vec{q})\vec{q}+2q_0(\vec{q}\times\vec{kq})\\
    &=q_0^2k\vec{q} – k||\vec{q}||^2\vec{q} + 2k||\vec{q}||^2\vec{q}\\
    &= k(q_0^2+||\vec{q}||^2)\vec{q}\\
    &=k\vec{q}
    \end{aligned}
    $$

    Here the last reduction happened due to unit quaternion.

    Also,

    $$
    \begin{aligned}
    ||L_q(\vec{v})|| &= ||q\vec{v}q^*||\\
    &=|q|.||\vec{v}||.|q^*|\\
    &= ||\vec{v}||
    \end{aligned}
    $$

    Proof that \(L_q\) rotates \(\vec{n}\) by an angle \(\theta\) in a plane perpendicular to \(\vec{u}\).

    $$
    \begin{aligned}
    ||L_q(\vec{n})|| &= (q_0^2 – ||\vec{q}||^2)\vec{n} + 2(\vec{q}.\vec{n})\vec{q}+2q_0(\vec{q}\times\vec{n})\\
    &= (q_0^2 – ||\vec{q}||^2)\vec{n} +2q_0(\vec{q}\times\vec{n})\\
    &=(q_0^2 – ||\vec{q}||^2)\vec{n} +2q_0||q||(\vec{u}\times\vec{n})\\
    \end{aligned}
    $$

    Let us denote \(\vec{u}\times\vec{n} = \vec{n}_\perp\).

    Thus

    $$
    \begin{aligned}
    ||L_q(\vec{n})|| &=(q_0^2 – ||\vec{q}||^2)\vec{n} +2q_0||q||\vec{n}_\perp\\
    &= (cos^2\frac{\theta}{2} – sin^2\frac{\theta}{2}) \vec{n} + 2cos\frac{\theta}{2}sin\frac{\theta}{2}\vec{n}_\perp\\
    &= cos\theta\vec{n}+sin\theta\vec{n}_\perp
    \end{aligned} \tag{2}
    $$

    Also note

    $$
    ||\vec{n}_\perp|| = ||\vec{u}\times\vec{n}|| = ||\vec{u}||\;||\vec{n}||sin\frac{\pi}{2}=||n||
    $$

    From 2, \(L_q(\vec{n})\) rotates \(\vec{n}\) through \(\theta\).

    Rotating the reference Coordinate frame

    Theorem

    For any unit quaternion

    $$
    q = q_0 + \vec{q} = cos\frac{\theta}{2}+\vec{u}sin\frac{\theta}{2}$$

    and for any vector \(\vec{v}\;\epsilon\;\mathbb{R}^3\) the action of the operator

    $$ L_{q^*}(\vec{v}) = q^*\vec{v}(q^*)^*= q^*\vec{v}q $$

    is a rotation of the coordiante frame about the axis \(\vec{u}\) through an angle \(\theta\) while \(\vec{v}\) is not rotated.

    Composition of Rotation

    If p and q are 2 unit quaternion. If we first apply \(L_p\) to \(\vec{u}\) and obtain \(\vec{v}\). If then apply \(L_q\) to \(\vec{v}\) to get \(\vec{w}\). The we can compose \(L_q \circ L_p\) to get equivalent single operation

    Proof

    $$
    \begin{aligned}
    \vec{w} &= q\vec{v}q*\\
    &= qp\vec{u}p^*q^*\\
    &= (qp)\vec{u}(qp)^*\\
    &= L_{qp}(\vec{u})
    \end{aligned}
    $$

    Composition of Rotation of frame of reference

    If p and q are 2 unit quaternion. If we first apply \(L_{p^*}(\vec{u})\) followed by \(L_{q^*}(\vec{v})\) in order to rotate the reference frame first wrt \(p\) and then wrt to \(q\) without moving \(\vec{u}\) and \(\vec{v}\). Then we can compose to get equiviatent single operation \(L_{(pq)^*}\;\). Notice that in the Vector case it was qp and now it is pq.

    References

    [1] A. Buchmann, “A Brief History of Quaternions and the Theory of Holomorphic Functions of Quaternionic Variables”.
    [2] “Attitude Representations – Understanding Direct Cosine Matrices, Euler Angles and Quaternions – Steven Dumble | PhD.” https://stevendumble.com/attitude-representations-understanding-direct-cosine-matrices-euler-angles-and-quaternions/ (accessed Mar. 12, 2023).
    [3] Computing Euler Angles: Tracking Attitude Using Quaternions, (Apr. 12, 2020). Accessed: Mar. 12, 2023. [Online Video]. Available: https://www.youtube.com/watch?v=98Mfe-Vfgo0
    [4] Euler (gimbal lock) Explained, (Jan. 14, 2009). Accessed: Mar. 12, 2023. [Online Video]. Available: https://www.youtube.com/watch?v=zc8b2Jo7mno
    [5] How quaternions produce 3D rotation, (Jul. 30, 2020). Accessed: Mar. 12, 2023. [Online Video]. Available: https://www.youtube.com/watch?v=jTgdKoQv738
    [6] Quaternions and 3d rotation, explained interactively, (Oct. 26, 2018). Accessed: Mar. 12, 2023. [Online Video]. Available: https://www.youtube.com/watch?v=zjMuIxRvygQ
    [7] Y.-B. Jia, “Quaternions and Rotations”.
    [8] Quaternions EXPLAINED Briefly, (Jun. 19, 2016). Accessed: Mar. 12, 2023. [Online Video]. Available: https://www.youtube.com/watch?v=jlskQDR8-bY
    [9] Rotations and quaternions, (May 06, 2019). Accessed: Mar. 12, 2023. [Online Video]. Available: https://www.youtube.com/watch?v=rJqII1FyrdM

  • Linux Guide to using SDCC compilers for PIC microcontroller

    SDCC or Small device C compiler is an amazing open source compiler. This guide covers the necessary steps needed to setup the SDCC compiler for PIC microcontroller. SDCC has several benefits over the commercial licensed compilers. Firstly, It is free. Secondly, SDCC is retargetable compiler. That is, a wide range of controllers can be compiled using the same compiler. So, once you get comfortable with this compiler it becomes easier to switch between controllers. 

    The only downside of SDCC is that there is a slight learning curve in order to set the compiler. But worry not. This guide will also solve this issue for you. This guide is for PIC controller. Compilers for other controllers like Intel can be setup using similar steps.

    This blog takes you through the steps needed to install the Compiler in a Linux environment. It then explains how to write a program for the controller. Finally, files associated with the compilation steps are described.

    SDCC Compiler setup

    In order to setup, there are two steps. First, we shall install the tools like the assembler, linker and librarian. SDCC compiler uses these tools to compile the C code. Secondly, we have to install the SDCC compiler itself. 

    Installing GPUTILS

    GPUTILS is a group of free software whose main contents include an assembler, linker and a librarian. This shall form the compiler tool chain components for SDCC. SDCC utilizes these utilities to compile the software written in C. Instead of using the GPUTILS, SDCC can be set up to use another assembler and linker from Microchip, such as MPASM and MPLINK.

    GPUTILS installs a set of Linker files for each PIC that it supports. The linker file has information about the memory regions in a device. It is used by the linker to put the code at the proper location in the PIC. It also includes a set of .inc files. These files have the EQU statements for each of the special function registers. These facilitate in programming in assembly language as one does not have to remember the SFR addresses and instead can refer to the locations using names. These are equivalent to #define in C language.

    As this guide is for setting up the free compiler we shall be using GPUTILS instead of MPASM.

    1. Download the latest copy of GPUTILS can be going to this link. Click on the Download Snapshot button on the top right. 
    2. This should download a zip folder by the name gputils-code-<branchname>.zip. 
    3. Uncompress the folder.
    4. Using a terminal navigate to gputils folder in the extracted folder.
    5. Run the following commands in the terminal
    sh ./configure
    make
    make install

    SDCC Installation:

    SDCC or Small Device C Compiler compiles the code. In this section we shall configure SDCC to use the GPUtils installed in the previous steps.

    1. Go to the link here.
    2. Choose the latest version available.
    3. Download the version which does not have -rc- with it.
    4. Extract the folder.
    5. Using a terminal go to the folder

    During one of the steps on installation of SDCC it requires the location of GPUTILS. It uses this location to look for the assembler, linker and other tools. Along with all these tools it also generates include files for the devices. The include files are generated using the .inc files in the GPUTILS. These include files faciliate C programming the same way .inc helps in assembly. Along with the include files it also generates libraries for each device. The libraries have a declaration of symbols of SFRs which are defined in the header file. This libraries will be used during the linking process and helps the programs to find the necessary symbols. These libraries and header files will be saved in a folder at …/share/sdcc/non-free/lib.

    Along with these libraries SDCC installation generates another set of libraries and header files. These are located at …/share/sdcc/lib. These libraries are include the startup codes that the compiler inserts by default with every program or libraries to add functionalities like float handing or multiplication which are not present in the controller by default.

    PIC primer:

    PICs internally have two kinds of memory.

    1. Data memory: Also called the RAM. This part of the memory is used to store data temporarily during computation. These are volatile memory and a part of the RAM address is also called Special Function Register. The SFRs are not used for storing random data like the rest of the RAM but it stores data which alter the functionality of the controller itself. Some of the interesting ones include the registers to control the timers and to control the PORTS of the controller. Program Counter is one very important Register which keeps track of which instruction address the controller is currently executing.
    2. Program memory: Also called as the code memory. This is the flash ROM which resides inside the controller and this is where the program that is executed by the controller resides. These have some important regions itself. It has some addresses called the reset vector and the interrupt vector. These are the locations where the Program Counter (PC) points in the events of Resets or Power on or Interrupt and hence appropriate code should be present there.

    Some other memories

    1. Configuration Registers: These are implemented similar to the flash memory and has functions similar to SFR in controlling the device. The difference between SFR and these being that these can have programmed values during poweron and SFR values need to be set in the program as it resides in the RAM.
    2. EEPROM: A few bytes of data is provided in EEPROM. This can be used to storing data which can be used to remember data across power ons.
    3. Stack: There is a 31 level stack not directly accessible. It is used by PIC for storing Program Counter during function calls.

    Writing Programs:

    This part is fairly simple for most of the part. It involves writing lines of codes using C. Most of the times one would be interested to use SFRs. This can be simplified by including the appropriate header file for the pic. This basically means using #include <pic18f2550.h>. This will bring all the SFR variables into the workspace.

    There are instances when one might need some extra features. There are few of such features which are already available with SDCC. Some of the functions like delay routines and math libraries are provided with SDCC. The header files are present in …/share/sdcc/include/pic16. It has to be linked with the appropriate library otherwise the compiler will complain of missing symbols. Inorder to link one can specify the path to the libraries in IDEs linker path.

    Apart from the basic features there are some additional features.

    1. Storage specifiers: These keywords can be added before the datatypes. The modify the location where the data is storage. They are __near, __far, __code, __sfr
    2. Absolute addressing: This keyword is used to save the data at a particular address location. Keyword __at is used for this.
    3. Volatile: This keyword tells the compiler not to remove the reference to the variable.
    4. __reentrant: This makes the function reentrant. ie. Calling the function again before the function finishes execution still keeps the function execution valid.
    5. #pragma nooverlay: This tells the compiler not to overlay the variables used by this function. This can be used in one of the two cases
      1. If ISR calls a non reentrant function
      2. Inline assembler code calls a C function
    6. __critical: This is added next to a function definition and it tells the compiler to disable all interrupts on entering the function or the section
    7. __naked: This when added to the definition of the function tells the compiler not to add prologue or epilogue. This means that the function will not be responsible to save the Status, WREG and other important registers.

    Linking with libraries:

    During the linking the symbols in the libraries are linked with the main code. It also links with crt0i.o object file. This contains the startup code. The startup code is used by the compiler to create and maintain stacks and other sections.

    Important files created during the compilation process:

    1. .asm: Assembly file created from the c code.
    2. .lst: This is the list file and it shows the linking with the other symbols along with the assembly code.
    3. .map: This file is important and gives a summary of location of the codes in the memory.
    4. .o/.rel: This are the object files. These are linked to create the final hex file.
    5. .hex: This is the final hex file and the product of compilation process.
  • Steps to USBPICPROG firmware loading

    Steps to load the firmware first time:

    1. Load the bootloader using a serial programmer into the PIC and insert the programmed PIC into the hardware.
    2. Insert the first jumper between the first and the second pin as shown in the help of the PC software and connect the USB.
    3. The software should detect the hardware and should show that the bootloader has been connected.
    4. Open the firmware hex file to load and click on program. The hardware will self program.
    5. Connect the second jumper between the 4th and 5th pins and reinsert the USB.
    6. The software will now detect the firmware and the software will check for any update in firmware.
    7. If no update is present then you are good to go.

    To update the firmware:

    1. Select the update option and load the hex file of the new version. The software would have already downloaded the lastest version.
    2. Check to make sure that the ICSP wires are open and not connected to any other PIC.
    3. Click on program and there is no need to removed the second jumper as specified in the website. The programming still works.

    Note: In case something goes wrong with the firmware after the bootloader is properly loaded there is no need to panic!!! You can always remove the jumper between 4th and 5th pins and enter bootloader mode and reload the firmware safely. Have fun 🙂

  • PCB Etching using Peroxide and HCl

    PCB Etching using Peroxide and HCl

    Home PCB etching is a cost-effective approach for creating PCB prototypes in a domestic setting, and it’s a fundamental skill for any hobbyist. One can employ two primary chemical etching methods for PCBs at home. The traditional method employs Ferric chloride, which tends to create stains and can be messy. On the other hand, the alternative method involves using Hydrochloric acid and Peroxide, offering a faster and cleaner approach without leaving any stains.

    This blog explains the toner transfer method of PCB etching using Hydrochloric acid for etching. For the sake of this blog, I assume that the PCB has been already designed. and the layout is available. If you don’t have it yet you can use a CAD software like KiCAD to design it.

    Raw Materials

    1. Hydrogen Peroxide: Available in Medical Shops
    2. Hydro chloric acid : Available as domestic acid for ceramic cleaning or pool cleaning
    3. Toilet Cleaner: I use Harpic but I guess anything will do
    4. Copper Board: PCB board of appropriate size
    5. Photo Paper: Available in stationary stores or studios
    6. Laser Printer

    Process

    Printing

    Print the image of the layer containing the tracks on a good quality photo paper (Paper meant for printing photos) using a Laser Printer. While printing ensure that the image appears mirrored as while transferring the image on board it gets mirrored again.

    Transferring

    1. Wrap the paper around with the printed side down over the coper surface of the board. Stick the paper over the board so as to arrest its movement.
    2. Take a hot iron press set to max heat and then press it evenly over the board. The toner should start appearing on the back side slowly.
    3. Immediately dip the board in a bucket of cold water and wait for the board to cool.
    4. Scrub and remove the top layer of the paper. Do not peel it off.
    5. As you continue scrubbing the tracks will start getting visible. Cautiously every time as you scrub try to notice if the track is breaking.
    6. Repeat steps 2 to 5 until the tracks are completely transferred and paper is removed.

    Pre-Etching:

    1. The board is almost ready for etching but if you wait till the water dries you can see white paper marks between the tracks. If that is present it will act as a mask too and the tracks will get short circuited. To remove it I use few drops of toilet cleaner and gently scrub it with brush. It comes out within no time.

    Etching

    1. Take Hydrogen peroxide 1 parts and 2 parts HCl and mix it. It is better to mix Hydrogen peroxide in the acid. Dip the copper board in the solution and watch the magic happen. The solution will turn green within minutes. Keep stirring till the copper is completely removed.

    Post Etching

    1. Use cotton wool and scrub the black toner off. Otherwise you can’t solder the component over it. Drill the holes using a drill and cut the excess board.
  • 4 Ways to diversify access to your PC

    4 Ways to diversify access to your PC

    You have a good PC. In order to get most out of it you should be able to have an access to it at all times. This blog presents to you the multiple approaches that you can use to diversify the access to your PC. Read along to know what are the different approaches you can use.

    The post goes from the easiest to the more challenging setup that you build. This post will keep your computer on your palm always. This will go a long way in increasing your productivity.

    Diversify By Multi Desktop

    One of the easiest ways to diversify the access to your PC is Multi Desktop. This is a feature which comes in most Linux distributions preinstalled. There are softwares in windows which can do this. The idea here is to have multiple Desktop in the same PC. This helps in organizing the windows for ease of operation. Like I like to have all my programming softwares open on one desktop, while the debug tools in another and music player in another. I can switch between them as I want.

    Pros:

    1. Helps in organizing the windows.
    2. Takes no extra resource than would otherwise would have taken.
    3. Easiest to do.

    Cons:

    1. Only one desktop will be visible at a time.
    2. Only one user can use each desktop at a time.
    3. Can be operated only when sitting near the computer.

    See more simultaneously using Multi Head

    Next up in the bid to diversify access, is to use a Multi Head configuration. Now this is a thing to do if we have more than one display at the disposal. Like I have a TV to which I can connect my laptop through HDMI cable. I can plugin the HDMI and use it as another display. Once this is setup both Linux and Windows support extended display. This can be turned on inorder to see the other display as an extension of the first. So now I can do my programming on the laptop while setting all the debug output to my tv. I can monitor the output as well as code at the same time.

    Pros:

    1. Helps in organizing the windows.
    2. Easy to do as all the modern OS comes with the support for it.
    3. Both the desktops will be visbile together.

    Cons:

    1. Takes more video RAM, as when extending the display the PC internally runs at the resolution of the sum of both screens resolution,
    2. Only one person uses both the display as the display can not be independently worked on.
    3. Still we can’t have remote access.

    Access your PC from anywhere using Remote Desktop

    One of the aims of this post is to enable you to be close to your pc at all times. Remote desktop helps you diversify your options to access your PC over long distances. All the above two needs the user to be near the computer. Remote desktop enables controlling a computer remotely using another computer using a network like LAN or WIFI. This feature works by sending everything on the display from the main computer over LAN to another remote computer. It accepts the input of the other computer like the keystrokes and mouse clicks and the operation is performed on the main compter. During this operation since the control is taken over by the remote computer the host or the main computer can not be operated. As otherwise it will feel like using two mouses connected to the same PC.

    Windows comes with built in support for this called as Remote Desktop. In Linux if it is not already present the host will need a server. The recommended software is VNC server like x11vnc and any client software capable of supporting VNC can be used. I like Reminna.  It supports both VNC and RDP so I can connect to windows remote desktop as well. Team Viewer is also a good software avaialable for free for  home purpose both in linux and windows. VNC and teamviewer are avaialable on android as well.

    Pros:

    1. Remote Access.
    2. Fairly easy to configure and use. On linux the server might look slightly daunting to use at first but there is plenty of support for it.
    3. Multi Head and Multi Desktop can be performed here as well.

    Cons:

    1. When the remote access is being used on a host, the host PC can not be used.
    2. Your whole desktop will be visible. Though the new softwares like Windows live meeting and TeamViewer allows a single window or windows from a single application to be shared.

    All the above ways to diversify only allow to have more eyes and not more hands. That is two people can’t use the same PC together.

    Diversify PC access without adding overhead using MultiSeat

    All above ways to diversify relied on sharing amongst a single user. MultiSeat way of diversifying access is allows people to work on share machine without adding to overheads. Here is where the things get a little tricky and lot interesting. All the methods described above allows more people to see. But Multiseat allows more people to work on the same machine. This is unlike anything described above and the difference is very subtle and needs to be understood. In remote desktop multiple PCs can see and manipulate the host PC. But only one can gain access to it at a time. In MultiSeat all PCs see different instances of the same software on the host. Every PC can then indepently use the software. Here each user does not see what the other user logged on to the same PC is doing.

    To make things clear we can look at it this way. It is like opening say 2 Calculator applications simultaneously. Now assume we have two key boards connected to the same PC. If each Calculator application can get input from a different keyboard then both of them can work together. Now if there are two screens also connected as in MultiHead configuration. If one calculator is displaying in each screen then two users can use the same CPU together without having any extra resource. This needs that the host PC be powerful enough to be able to run double the number of applications together.

    Note: This is not remote desktop or any thing other described above.

    Pros:

    1. A single powerfull PC can be used simultaneously and independently.

    Cons:

    1. Most complicated of all the above methods.

    Multiseat can be done in two ways.

    1) Using a single CPU and connecting multiple display and mouse as described above: –

    The problem with this approach is that most motherboard will limit the number of VGA cards and the keyboards and mouse. So the number of simultaneous users will be limited. Never the less there are articles on the net of people who have expanded the hardware to support mutliseat using softwares like BeTwin, SoftXpand and AsterXP

    Pros:

    1. Needs no extra CPU
    2. Cheap Solution for home use.

    Cons:

    1. There are no free software in windows that can do this.  I did not explore in Linux.
    2. The maximum expansion is limited by the number of VGA cards and hardware that can be connected.

    2) Running separate terminals like the remote desktop.

    Here there will be many independent PCs. Each with its own CPU. Thin Clients will do. They can then log in to the host machine and operate an that. And this was wat I was looking out for the whole day 🙂. I could find just one free software capapble of doing this in Linux and none in Windows. This software is called Xephyr and god bless linux, it comes installed with most distributions :-D. The link here explains how to install and use it.

    Pros:

    1. Any number of PCs can be connected..
    2. Xephyr exists in linux which is free. Probably a combination of cygwin and xephyr can do the trick in windows as well.

    Cons:

    1. The maximum expansion is limited by the memory and processing capability of the host.
    2. As more CPUs are required it is a costlier solution for home.

    My preferred diversification

    This is how I diversify access to my PC. Now I can Program in one display. Connect my TV for debug as second display (Multi Head) and Xephyr (Multi Seat) my music player and open it in a different desktop (as in multi desktop) in the first display. The Xephyr’d terminal can be sent over VNC using x11vnc (Remote Desktop) to my android which is running bVNC client. 😀 Thus all of them available together at fingertips.