Monday, March 24, 2014

Reading L3G4200D Gyro sensor via I2C using Stellaris launchPad – PART 1

I got a stellaris LM4F120 launchPad hanging around for sometime. I haven’t done much with that other than trying FreeRTOS on it. Recently I got a cheap L3G4200D from ebay. I read the raw values(XYZ axis angular rate) from it via I2C using the stellaris.

I haven’t yet figured out how to convert it to real angles. In second part I will create a 3D WPF app to display a 3D axis view.

Sensor module i got from ebay have L3G4200D,ADXL345,HMC5883L,BMP085 sensors and its cheap.


Sensor modules I2C SCL & SDA pins are connected to  GPIO pins 6 & 7 ie, PA6 (I2C1SCL), PA7(I2C1SDA) of stellaris 
Value is send to the PC using UART0 which is  connected to the stellaris virtual port which will appear on PC.

Checkout the code in github

Here is the screenshot of raw values received in PC



Links

User manual

Stellaris LM4F120 LaunchPad Evaluation Board Software

Getting Started with the Stellaris EK-LM4F120XL LaunchPad Workshop (Videos & Articles)

Creating a new project 

Blinking LED

Some other tutorials 

Stellaris Launchpad for Beginners http://codeforfree.weebly.com/stellaris.html


Some code I referred



Online Stores to purchase Texas Instruments products

https://estore.ti.com/

http://in.element14.com/texas-instruments

Tuesday, October 9, 2012

AmazonGlacierGUI - A GUI Client for Amazon Glacier


I have created a tool for Amazon glacier ,
checkout

http://amazonglaciergui.codeplex.com/

Its a WPF MVVM application in C#

Amazon glacier pricing information is confusing , a pricing calacultor is available at
https://github.com/brandt/amazon-glacier-calc


Tuesday, November 22, 2011

Google reader notes JSON To Delicious Export Tool

I was heavily using google reader notes for the past 2-3 years , as they stopped note in reader service I moved to delicious, I am happy with it, but i have tons of bookmark in google reader notes, I want them exported to delicious, luckily google reader settings page has an option to export notes to JSON format,

I created a tool to export this JSON to delicious.


Goto http://grnotestodelicious.codeplex.com/ for the tool & source code

Tuesday, May 4, 2010

A generic excel file Importer / Reader - Converting Excel rows into Strongly typed entity

Its my blog post after a long time ,
Its simply a class it can be used to map Excel columns to an entity fields by adding an attribute to the property

Eg: An excel file with two columns Name and Phone Number
Our Entity is

public class ExcelItem
{
[ExcelColumnIndex(Index=0)]
public string Name {get;set;}
[ExcelColumnIndex(Index=1)]
public string Phone {get;set;}
}
To get List <ExcelItem> containg the excel rows, simply
Importer<ExcelItem> _Importer = new Importer<ExcelItem>();
List<ExcelItem> data=_Importer.ParseExcel("FILE PATH", "sheet1");


ExcelImporter.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.OleDb;
namespace ExcelImporter
{
//3-may-2010 Priyan R
public class Importer where T : new()
{
public List ParseExcel(string filePath,string sheetName)
{
string tempFile, connectionString, query;
OleDbConnection con = null;
OleDbDataReader reader = null;
OleDbCommand command = null;
//
connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
filePath + @";Extended Properties=""Excel 8.0;HDR=YES;""";
query = "SELECT * FROM [" + sheetName + "$]";
//
var ret = new List();
try
{
con = new OleDbConnection(connectionString);
con.Open();
command = new OleDbCommand(query, con);
reader = command.ExecuteReader();
while (reader.Read())
{
var entry = new T();
foreach (var property in entry.GetType().GetProperties())
{
var attributes = property.GetCustomAttributes(false);
var attribute = property.GetCustomAttributes(false)
.Where(p => p.GetType() == typeof(ExcelColumnIndex)).FirstOrDefault(); ;
if (attribute != null)
{
property.SetValue(entry, reader[((ExcelColumnIndex)attribute).Index].ToString(), null);
}
}
ret.Add(entry);
}


}
catch
{
throw;
}
finally
{
if (con != null && con.State == System.Data.ConnectionState.Open)
{
con.Close();
}
}
return ret;
}
}
public class ExcelColumnIndex : Attribute
{
public int Index { get; set; }
}
}



Download sample application


Friday, November 27, 2009

ASP.NET Validation Controls - Conditionally validating

Using the server side Page.Validate() and Client Side Page_ClientValidate() , we can validate a group of controls conditionally. For eg. i just need to validate some fields only when a checkbox is checked. Both Page.Validate() and Page_ClientValidate() allows to pass a validation group , So we group a set of controls with a validation group and calls this validation functions in both client & server side only on the required validation condition

Server Side



protected void btnSubmit_Click(object sender, EventArgs e)
{
if(cbValidate.Checked)
{
//validate
Validate("vgSubmit");
}
if (!IsValid) return;
lblMsg.Text = "Passed validation";
}



ClientSide


function CheckValidation() {
var cbValidate = document.getElementById('<%=cbValidate.ClientID %>');
var flag = true;
if (cbValidate.checked) {
if (!Page_ClientValidate("vgSubmit"))
flag = false;
}
else {
Page_ClientValidate("vgDummy")
}
return flag;

}



Download Code

Wednesday, September 23, 2009

URL Rewriting with ASP.NET 3.5 using System.Web.Routing.UrlRoutingModule

In asp.net 2.0 we used Context.RewritePath() or other URL rewrite modules. With asp.net 3.5 its easy to do. I did it for my blog for better SEO.

      • Add reference to system.Web.Routing
        Add System.Web.Routing.UrlRoutingModule http module to web.config
        Implement an IRouteHandler
        Registering routes in global.asax

I am going to rewrite blogs/Posts/{BlogPostID}/{*BlogPostTitle}

I implemented a generic IRouteHandler , it will copy url parameters( eg: BlogPostID,BlogPostTitle ) to http context item collection, so i can URL rewrite any page , without modifying IRouteHandler implementation.



using System;
using System.Web;
using System.Web.Routing;
using System.Web.Compilation;
using System.Web.UI;
public class SiteRouteHandler : IRouteHandler
{
//30 june 2009 Priyan R

public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
Page page;
page = BuildManager.CreateInstanceFromVirtualPath(PageVirtualPath, typeof(Page)) as Page;
foreach (var item in requestContext.RouteData.Values)
{
HttpContext.Current.Items["qparam." + item.Key] = item.Value;
}
return page;
}
public string PageVirtualPath { get; set; }
}

In global.asax added


       

routes.Add(
"BlogPost",
new Route("Blogs/Posts/{BlogPostID}/{*BlogPostTitle}",
new SiteRouteHandler() { PageVirtualPath = "~/Blogs/Details.aspx" })
);


So in Details.aspx I can read the parameters



Context.Items["qparam.BlogPostID"].ToString()
Context.Items["qparam.BlogPostTitle"].ToString()

Check the code.


Download Code

Wednesday, August 26, 2009

My Love Never Dies.......

Almost all people might have loved someone in their life..To say something about my love..
I have experienced it three times..but still I dont know exactly what this love thig is
..it made me laugh and cry at the same time...still i am in search of love..
its such a feeling inside us for someone..makes us feel alive..and we get crazy about it..
how that happens is beyond my thinking..it just happens..
I had felled into love with three..but that was incomplete..does that make any sense??he he
of course yes..its always valuable and such an ever memorable feeling to me..
My love is true..always..

I still remember those school days..I didnt get to know that I was in love with someone..
those four years she was with me..After I left my school I got to know how much I miss
her in my life..I believe she would have felt the same what I did..But dont know what to say..
sense of responsibility to my family or something else pushed me back to concentrate
in my studies more..and that relationship stopped when I left my 10th std and joined
plus2..slowly I started trying to forget her..after few days I met another girl..
This time I couldnt stop myself from not loving that girl..I started thinking a lot
about her..what a crap!!I started dreaming too..but , she was not thinking like I did..
hell it took me into a helpless situation..but I recovered from it very soon..
she was not meant to be mine..

And the third one..this time ,I was more carefull and had a clear idea about my wish..
she was so close..and I was very comfortable with her..she enjoyed my friendship..
but she was not in love with me..I dont know what went wrong this time..
she was mistaken or me??I didnt force her or anyone..
coz I believe ,every one has the right to choose someone whom they want to love..
we should not compromise in case of love..it has to happen inside us..otherwise no use..
now I am not feeling to love anyone..just because it cant be made..
hopefully everything will come out to be fine..
and one day i will get my real love ..yes ..I am waiting for that..:)

( For this post i am really grateful to my friend Praseetha, She edited my story in a poet style :) )