Latest Entries »

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
clc
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!
fopen(s);
if strcmp(s.Status,'open') == 1
 disp1 = 'Starting Access Point.......';
 disp(disp1);
 pause(1);
 fwrite(s,startAP,mydata)
 fread(s,3,mydata);
 disp1 = 'You should start the accelerometer transmission from the watch now....';
 disp(disp1);
 pause(1);
 disp1 = '...............';
 disp(disp1);
 pause(1);
 disp1 = '.......';
 disp(disp1);
 pause(1);
 disp1 = '...';
 disp(disp1);
 pause(1);
 disp1 = 'Logging starts now!';
 disp(disp1);
 pause(1);
 k = 1;
 for i = 1:999
 fwrite(s,getaccAP,mydata);

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

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

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

 fwrite(s,stopAP,mydata)
 fread(s,3,mydata);

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

 fclose(s);
 forplot = 1:size(data,2);
end

% 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!

Jimbo!

Answer by Graeme Shimmin:

The answer is obvious: Jimmy Wales

Built the world's best website. Answers questions on Quora? Seems like a nice, normal person? People call him Jimbo?

It's all a facade.

'Jimbo'? Really?

First this wikipedia business. He passed up a chance to make billions in order to make the world a better place? Please. That sounds suspiciously like communism to me. It's obviously all part of a diabolical scheme to rule the world, probably involving controlling the internet, holding all the cat pictures to ransom and assassinating the president.

And has anyone ever seen wikipedia? We all use it, but did you ever go to visit, stand outside and see a reassuringly plump receptionist? No. For all we know it could be underground. It could be full of men in jumpsuits carrying clipboards. There might even be a large map on one wall and a countdown to world domination.

Wikipedia's offices. That's Jim in the middle, between the submarines.

I read a answer from Jim the other day where he claimed he was sitting in a library. He didn't mention where the library was.

Jimmy Wales' 'library'.

He has a cat

Jim's cat eyes its next victim.

He has a henchman on Quora, Brandon Harris. Who knows what nefarious plans they are cooking up?

Brandon could bite wikipedia in half, just like that. You know it's true.

[Edit:Brandon has confirmed in the comments that he is made entirely from steel (actually he said steel wool, but he was being too modest) ].

And Jim's wife is beautiful. What more proof do you need? How long before she gets painted gold, huh?

Mrs. Wales, before the paint job.

And, well, there are the rumours of megalomania.

Things were getting out of hand at wikipedia.

But the clincher is: he keeps demanding money. I know, I know, it's all "pretty please", and "we're nice and we do cool stuff" and "think of the children", but imagine, what if we stop meeting his demands? What happens then? What if the mask slips and suddenly it's No More Mr. Nice Guy?

Perhaps we better send one of our agents. You know, just to be on the safe side.

Wikipedia's latest fundraiser ends in disaster.

PS. Jim, Brandon, obviously I don't know you and have no idea what you're like. This is just a bit of fun. You seem like a nice guys and wikipedia is awesome. If you don't like this, I'll edit/delete it.

View Answer on Quora

"there is something that doesn't exist that I think should exist.." – this is like the simplest form of burning desire!

Answer by Jimmy Wales:

I am a good programmer but not a great programmer.

I started in high school.  Languages that I have programmed in for fun or professionally include: Fortran, Pascal, C, C++, Perl, PHP, Javascript, and Ruby.  Languages that I don't know at all include: Python, Lisp, and a bunch more.

Of those, I used to know Perl the best.  In javascript I've never done anything more than little snippets on web pages, and not a lot of that.

I haven't written any code professionally for many years now.  Wikipedia and Wikia have great programmers, so there's no need for me to clunk around. :-)

I just learned Ruby last fall, and I'm currently teaching myself Ruby on Rails.  I'm doing that for the best reason of all: there's something that doesn't exist that I think should exist, and it's fun to build things that should exist.

View Answer on Quora

Answer by Balaji Viswanathan:

Sorry to burst your bubble. But, this conversation involving Mozart will be helpful for you.

In short, if you have to ask how you can become Steve Jobs, you can never become a Steve Jobs. Start with simple apps and device hacks to work your way up. If you are lucky and are really committed, maybe you can really leave a mark.

It took more than 3 decades even for Jobs to be truly recognized as an icon. In the meanwhile he slaved hard, had a temporary rise to the peak, thrown from his perch, ridiculed, worked his way back and prove himself all over again with kick-ass products. Now, you want to jump to the 20th step directly without having any past of crossing even 1 step.

There is a top-secret recipe for success. Keep this secret mantra:

View Answer on Quora

Answer by Hemanth Kumar Mantri:

Data in CDs and DVDs is usually laid out in sectors which go spiral starting from the center. Every sector usually has a checksum at the end, which helps in recovery in the event of bit corruptions within that sector.  One can assume for simplicity that if the number of bits corrupted is beyond the checksum tolerance, that sector is lost.

Scratches that are perpendicular (going from the center outwards) are less disastrous than the scratches that go along along the sectors (spiral).

The following CD has scratches along the sectors which may mean several bits belonging to a sector are corrupted beyond repair using checksum.

This CD, on the other hand, has scratches perpendicular to the sectors indicating only a few bit corruptions in a sector.

Clearly, the first CD is more corrupt than the second one.

View Answer on Quora

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="http://en.wikipedia.org/wiki/TeX" 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

plt.show() # 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.

Procedure:

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?

Reason:

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! :-D ).

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!

Follow

Get every new post delivered to your Inbox.

Join 100 other followers

%d bloggers like this: