Latest Entries »

Back to writing!

I have not updated this space for years now!

Recently one of my posts on software releases got featured on Electric Cloud’s knowledge hub on software releases.

This has prompted me to come back and start writing again. I remember how excited I used to be while writing a post. Work (and laziness of course) has kept me away all this while.

Well, watch out! A lot of content is in the making!


Hello everyone.

First of all, let me introduce Harshit Jain – my partner in this project. He introduced me to layouts using EAGLE – a big thanks to him!

Following is the schematic of the module that we are planning to develop. (Psst psst…we have already decided where to get the PCBs made from – PowerPCB)

I will upload the layout and the revised schematic once once we get something – even a stream of bytes will verify that the hardware works as desired.

Version 0.1

Version 0.1

There are bound to be some changes to this revision of the schematic – we can’t get it right the very first time, can we?!

The next task is getting a few of these boards assembled and tested for basic I2c functionality – I am not risking assembling a camera without knowing that the configuration commands can actually get to it.

Thanks for reading!

A new post after a long time!

Free time has been very hard to come by over the past few months. But, over the last month or so – I have been obsessed with an idea. Some google-ing around and quick calculations tell me that it is indeed possible to do this. After around an year and a half, I will be working with a camera again – this time, it will be interfacing a CMOS camera with a Cortex-M4 microcontroller.

The camera is Toshiba’s popular TCM82x0 series and the microcontroller is TI’s Tiva TM4C123x/9x series.

A few calculations are in order.

A 128 X 96 pixel image in RGB565 format will consume ~24kB (128*96*2 bytes) of memory and a 320 X 240 pixel image in RGB565 format will consume ~150kB (320*240*2 bytes) of memory.

The TM4C123GH6PM controller used on the Tiva launchpad has 32kB SRAM and the TM4C129XNCZAD controller used on the Tiva Connected Development kit has 256kB SRAM. Seems possible now, huh?

Yes, there will be restrictions on the frame rate that we can work with – but I am not worrying about that now.

Some information about the devices

The camera

The camera that I will be working with is the TCM8230MD. It has a maximum throughput of 640 X 480 pixel images @30 fps. That is indeed remarkable – this is how it looks.

Image - TCM8230MD

Toshiba’s TCM8230MD CMOS camera

As for the development hardware, I found a number of helpful people online who have posted reference schematics and board designs that I can use for my development. I will do exactly that at first. But, if all goes well and I am not yet bored, I wish to make a boosterpack for the Tiva launchpad. What is a boosterpack? Read all about it here!

The camera configuration is done by writing to its registers over a fast I2C bus (400kHz) – its device address is 0x3C (found in the datasheet). I will be using RGB565 output mode at 15 fps with an output resolution of 128 X 96 pixels.

The microcontroller

TI’s Tiva series is a re-branding of the Stellaris Cortex-M3 and Cortex-M4 microcontrollers best remembered for their connectivity options. The TM4C123x series is the lower series and the TM4C129x is the higher series as far as on-board memory are concerned. Following figure highlights the salient features of the Tiva controllers.

TM4C123x family - salient features

TM4C123x family – salient features

One of the best things about using TI’s microcontrollers is the launchpads. The TM4C123GXL is my favorite MCU development kit as of now!

In this space, I shall be posting updates about this project – codes, block diagrams, trials and misses and of course – results!

See you around!

I recently bought TI’s Chronos eZ430 – 433 MHz development kit. Basically, it is a watch with a bunch of sensors and a controller that can be programmed wirelessly over the 433 MHz ISM band.

Yes – I know it is bulky and has a huge ‘Texas Instruments’ logo on it. But, as long as you don’t mind it – or better – are proud of it…you are good to go! You also get an RF access point, a USB debugger and a screwdriver (just in case you want to dismantle your watch and have a look inside).
I was wondering what I can do with it – it has a temperature sensor, a pressure sensor and an accelerometer. I decided to get some accelerometer data out. I would like to share my MATLAB code for the same.
As for the driver installation for the access point, it is a trivial affair and the process can be found online. Please note – this MATLAB script simply takes the accelerometer data out and plots it. Run this script from the command window of MATLAB. It has display messages which will guide you. The main purpose of this code was to be able to take the data out from Chronos using the following process:
Open COM port -> Start Access point -> Start reading accelerometer data -> Wait for, say, 1000 samples to be received -> Stop reading accelerometer data -> Stop Access point -> Close COM port.
clear all
close all
global startAP stopAP getaccAP mydata
startAP = [255 07 03]; % FF 07 03
stopAP = [255 09 03]; % FF 09 03
getaccAP = [255 08 07 00 00 00 00]; % FF 08 07 00 00 00 00
mydata = 'uint8';
s = serial('COM48'); % your COM port might be different - plug it in here
s.BaudRate = 115200; % the AP communicates with this baud - don't change!
if strcmp(s.Status,'open') == 1
 disp1 = 'Starting Access Point.......';
 disp1 = 'You should start the accelerometer transmission from the watch now....';
 disp1 = '...............';
 disp1 = '.......';
 disp1 = '...';
 disp1 = 'Logging starts now!';
 k = 1;
 for i = 1:999

 for f = 1:2000
     for g = 1:1000

 temp = fread(s,7,mydata);
 if temp(4) == 1
 data(:,k) = temp;
 k = k + 1;

 for fg = 1:2000
     for g = 1:1000


 for i=1:1000
     for j= 1:2000

 forplot = 1:size(data,2);

% The data variable is a 7 by 1000 array - in every column the last three entries are accelerations in X, Y and Z directions

Happy hacking with your Chronos!

Plotting with Matplotlib

So, I was looking for a good plotting library in Python. There are a number of choices – that’s the best part. So many options!

There is Chaco!

There is MathGL!

There is PyQwt!

There is PyX!

And then, there is Matplotlib. And, then I stopped looking. Before settling onto MPL, I read stuff on each of the libraries mentioned above. Chaco is a very good library but documentation is not its strongest point. MathGL suffers from the same. PyQwt does not have the biggest following and development going on. PyX was less recommended.

And Matplotlib – well – lets just say it was the overwhelming winner. Simply because, it has a voluminous documentation, lots of sample codes, lots of forums discussing it…and Scipy and Numpy tutorials use it for their plotting purposes! I even read somewhere that Scipy + Numpy + Matplotlib + Mayavi (a 3d plotting library) is a MATLAB-killer. Now, that is a huge thing to say, considering MATLAB is the leader as far as scientific computation is concerned.

I have an experiment in mind. It is not the most innovative one. But, it is relevant to what I propose to accomplish with Python. I will hook up a potentiometer to my Arduino, convert the analog signal to digital and transmit the data serially to my Python script which will (hopefully) plot the voltage at that instant. But, for that, I first need to know how to use Matplotlib. So, I did some studying and learnt how to generate data, plot data, manipulate a few properties, add text to the plots – and last, but definitely not the least – update the plots at run-time.

Here’s a simple code that will plot the quadratic equation “x^2 – 4*x + 1”, marks the critical points i.e. the minimum and the x-axis cutting points, annotates them, the title of the plot uses the super-scripted form of x^2 and some other small features.

The code is well-commented. So, I don’t think it should be a problem picking it up.

import numpy as np # standard library imports - nothing special here
import matplotlib.pyplot as plt # same as above

a = np.arange(-6,10,0.1) # create an array having the numbers -6,-5.9,-5.8,...,-0.1,0,0.1,...,.9.8,9.9,10

def evalf(arg): # define function evalf to evaluate f(x) at x=x
 return arg**2 - 4*arg + 1

b = evalf(a)

fig = plt.figure() # hold the matplotlib in a  variable
sp = fig.add_subplot(111) # add a subplot to the figure - 111 means 1 row, 1 column, 1st subplot 1 is current
sp.grid('True') # enable the grid
plt.xlabel('value of x -->') # labeling the x-axis
plt.ylabel('value of f(x) -->') # labeling the y-axis
plt.title(r'$f(x) = x^2 - 4x + 1$') # giving the title - accepts <a title="TeX wiki" href="" target="_blank">TeX</a> also

myplot = sp.plot(a,b,'b') # hold the plot in a variable
myplot2 = sp.plot(2,evalf(2),'ro',3.732,evalf(3.732),'yo',0.268,evalf(0.268),'yo') # plotting critical points
sp.annotate('Minimum',(2,evalf(2)),xytext=(1.05,10),arrowprops=dict(facecolor='black', shrink=0.05))
sp.annotate('X-crossing 1',(0.268,evalf(0.268)),xytext=(-5,0),arrowprops=dict(facecolor='green', shrink=0.05))
sp.annotate('X-crossing 2',(3.732,evalf(3.732)),xytext=(6.5,0),arrowprops=dict(facecolor='green', shrink=0.05))

# annotation of all three points was achieved using the above three functions - text, point to be annotated, point for# text to be written and properties of the arrow mark used # after everything - just show the plot!

This is the result of this code-snippet.

Plot using Matplotlib
Please note the title and the annotations

The plot is not yet a real-time plot. It is a static plot with fixed X and Y data. To make it real-time, we have to constantly change its X and Y data in a loop and re-plot. I shall post about this after I am done with my activity.

A Useful Arduino Tip

Arduino does not cease to amaze.

Recently, I was chalking out plans for my first project with my new GSM-GPRS module (my birthday gift actually 🙂 ). My friends very intelligently chose a board with a four-wire serial interface rather than the conventional 9-pin RS-232 connector interface. This choice is intelligent because it is better to interface the board with a microcontroller for a more appealing project.

But, to get started with it and to practice AT commands, I need to interface this board with a computer. What do I do? I don’t have a USB to RS232 converter at hand. Moreover, even if I get one, taking out wires from the connector to the module will involve tedious soldering.

This is where Arduino is a life-saver. Arduino already has a USB-to-Serial conversion circuit on-board which it uses to interface with the PC. In case of Duemilanove and few lower versions, it is the FT232 chip and in case of Uno and its revisions, it is the ATmega8 controller. You can directly use these without writing a single line of code or downloading any kind of sketch onto Arduino.


1) Connect the RESET pin on your Arduino to GND. You are basically keeping the controller in the reset mode at all times. All controller pins are tri-stated.

2) Connect the RX and TX pins of your Arduino to the TX and RX pins of your device (a GSM-GPRS module, a Zigbee module, an I/O card, an LCD, a controller – anything with an RS232 serial interface)

3) Start the Serial Monitor and watch the data ring in and out!

But, why did it work?


Arduino uses the RX and TX pins to program the microcontroller. As a result there is a short between the RX-TX pins and the TX-RX pins of the converter in between (FT232 or ATmega8). With the controller pins tri-stated, any activity on these pins is mimicked at the other end.

A simple solution, isn’t it?

BeagleBoard on Quora

So there is a topic named BeagleBoard on Quora!

I expect to see more and more questions, interactions and discussions coming up!

Processing with Processing

Those of you who haven’t heard about Processing will not appreciate the effort I put into coming up with the title of this post. Anyhow, in this post, I will tell you about my very brief entry to the world of processing with Processing.This is the logo of Processing

Processing is an open-source project by Casey Reas and Benjamin Fry. Yes, the same guys who are mentioned in the Based on Processing by…. line in the welcome box of Arduino IDE. Processing is the name of the language as well as the IDE in which the programming is done. The IDE is very clean and not at all overwhelming for the new user. This is in line with the aim of this project – to get the non-programmers to program. Another goal that Processing was supposed to complete was to be the foundation of electronic sketchbooks. And, as I found out soon enough – it is definitely a good place to start.

Visualization is very convenient with Processing. A few lines of code can accomplish what bunches of code do in the more-popular graphical platforms like the DOT NET platform (for instance). This makes it a very good choice for a programming beginner. I do not intend to compare the two (partly because I am not capable of that). The basic principle of Processing is to make programming a fun experience by showing the user what he/she has done – in the form of graphics, animations, figures and drawings.

Export Away!

Another heart-warming feature of Processing is the Export to Application and Export to Applet facility.

Export to Application creates double-click-and-run applications for you. You no more need to integrate multiple libraries for this. I remember my time with wxPython – always looking for a library for this, a library for that. As a beginner, my time was spent more in researching and less in developing. Processing is not as feature-rich as wxPython or Tkinter or DOT NET. But hey! I don’t want to make a chat client – I just want to see how the for-loop does what it does or how the football goes when I kick it at an x-degree angle!

Export to Applet makes it possible to generate applets without the tedious coding involved. Processing does it for you – with the applet’s java code at your disposal (so that an applet designer can tweak your work later if needed). Try it out yourself!

So what can I do?

I may not be the best person to answer this. In fact, no one can tell you what you can do with Processing. It is one of those things. Processing has done and is doing to programming what Arduino did and is doing to hobby electronics. A small time with Google will tell you the myriad applications people have created with Processing. There are funny animations, physics and chemistry simulations, mathematical models, robot emulators and lots more.

You can not only animate or simulate or create figures – there is a host of libraries that exponentially increases the potential applications that can be designed.

There is the Serial I/O library that lets you interact with data coming into and going out of your computer – there is no more the need to learn about using a new plotting library. Grab the data coming in and throw it on your screen for the world to see!

There is a Network library that lets you throw data between computers by allowing configuration of servers and client (see – maybe I was wrong about the chat client thing – maybe Processing can do THAT too! 😀 ).

You knew it was coming, didn’t you? With all this talk about animations and simulation, there indeed is a Video library that lets you generate and play movies and also interface with a camera! There you go – lots of windows open right there!

There is a facility of exporting your sketches as PDFs using the PDF Export facility – isn’t that wonderful?

The icing on the cake – there is a library for interfacing with your Arduino – no need to swap between IDEs while making your next great project using Arduino – you can program it from Processing as well using the Arduino library!

You can visit this page for more info about the library support.

Help me do stuff!

This is the link to the book I used to get started with Processing – it is a fantastic beginner book authored by the creators of Processing.

As is the case with open-source stuff, there is oodles of support available. This is the official forum – and a bit of googling will direct you to even more forums where people discuss their experiences with Processing.

Also, check out OpenProcessing. It is a community of Processing users where they share their work, exchange info and extend help to fellow users.

Did this post encourage you to go ahead and try out processing with Processing? Have something else to tell me and/or others?
Comment away! 🙂

We have almost come to the end of our project – An Indoor Navigation System using OpenCV on BeagleBoard-xM. It has been a wonderful five months over which we have seen many ups and downs.

Following are the videos of the practical trials of our system – the first has the camera stationary and the marker mounted on a moving vehicle. The second video has the camera mounted on the vehicle and the marker stationary. Please note, the second video shows the implementation of our code on a laptop instead of a BeagleBoard-xM because we did not have a power source on-board (and we were too lazy to arrange for a long power extension cord). But. the code is the same – I promise!

You can also see these videos on Youtube to comment, like and go through the descriptions.

Also, I have a video of our very first pre-practical trial coming up. I like to call it Practical Trial Zero 🙂.

Watch out!

Powering the Beagle!

First things first – this might seem to be a very trivial thing. Powering is simply plugging in that AC-to-DC converter into that barrel, right? Well, that is partly correct. But, how else can you power up your Beagle? And what operation modes are available and what power considerations do we have to keep in mind while operating in a particular mode? In this post, I try to throw light upon this topic and try to integrate information from different sources on the internet.

There are two ways in which you can power-up your Beagle – the USB OTG port and using a AC-to-DC supply (barrel connector). I was surprised when I found out that it is not possible to power up the Beagle using the USB host ports. For an explanation (rather vague), you can visit the ‘USB-related’ section of this page.

Powering up using the USB OTG port

If you plan to power up your BeagleBoard-xM using the USB OTG port, there are two things you have to keep in mind:

1) Please use an externally powered USB hub
2) You can use the USB OTG port in as a client only – not as a master.

But, in case, you don’t have an externally-powered hub and only want to use a pen-drive (or something similar – for a short while), you can use a Y-cable. It is a cable that can connect to the Beagle’s OTG port and the other two ends draw power from your laptop/PC. But, please keep in mind – don’t load all your USB ports in this condition because the manual clearly says that each USB port will draw 500 mA of current.

Please do not try using any of the USB hosts when powering up using the OTG port using a normal cable – the power delivered by the OTG to the on-board USB-hub is simply not enough. Check this out! And if you are still doubtful, check out the info in the ‘Powering the BeagleBoard-xM’ floating box on this page.

Powering up using the 2.1 mm barrel

This is the best way to power up your Beagle. The reason for this is that it does not require any current-limiting from your side. But, one thing you have to consider is that the power supply you use should be of a good quality. The excursions should not take the supply to >5.2 V else, you may end up damaging the board. The BB-xM does have a safety LED which glows (RED in color) whenever the power supply is improper (exceedingly low or high) and cuts off all supply to the circuitry. But, at the end of the day, it is a circuit!

The absolute maximum rating of the power supply should be 5V/3A with 2A being perfect for most of your applications.

Powering up using the barrel allows you to use our OTG port in the host mode which opens up more possibilities for you.

You don’t need an externally-powered USB hub when using a DC supply. I have worked with a keyboard, a mouse, a Logitech C905 webcam and an HP v165w pen-drive plugged in and there was absolutely no problem faced. (My power supply’s rating is 5v/3A max.)

One more thing – suppose you are using the OTG port to power up your Beagle and suddenly turn on the DC power supply using the barrel, the ‘hand-over’ of the powering-up business will be seamless because the circuitry is such that the power-path from  the OTG to the various parts of the board is automatically removed.

Have you experienced a problem in powering up your Beagle? Do you have any suggestions or changes that I can add to this post? Anything that you want to tell me? If yes, please comment away! 🙂

%d bloggers like this: