I’ve been busy adding in the dead man switch and decided to video tape me taking the skateboard apart.  Everything is taken apart, with get this, 1 Allen wrench.

I’m still noodling on doing some form of a quick disconnect for the wiring on the force sensors for the dead man switch.  I dislike the idea of having to screw and unscrew the wiring every time I want access.

Tags [ Building Skateboard Video ]

I attended a robotic user group called RoboMo in St. Louis and I showed off the skateboard.  I got a better idea for the deadman switch force sensor.  Instead of 2 strips, I’ll be using 4 sensors.  2 will be paired on either side to create a separated “super” sensor.  With the strips, I could technically be on with only 1 foot and still have it register.  I just ordered some 1.5” force sensors along with some rubber pads for grip.

I had two people ride it too!

Tags [ Parts Building Skateboard ]

rockTheEmpireSo yeah, I drank the Kool-Aid (It is blueberry flavored).  Performance reviews are coming up and I have to do my self-evaluation.  It got me thinking about working in general about stuff and how I’ve actually become a bigger fanboy of Microsoft than I was before I started working here.

The culture is shockingly open.  I’ve had the chance to be on Channel 9 multiple times, most recently on This Week on Channel 9 and talk about what has been going on.  Rory Blyth gave me the first taste of it and I have to say I do love it.  While at the time, I was semi-freaked out by back then Rory but I had an awesome time.  I’ve seen some awesome arguments on some email threads.  I honestly would have been afraid to do most of the stuff I do at my old jobs.

As a ADE (Academic Developer Evangelist), I get to go to colleges, talk about why students should learn programming and help out.  Would you go to Fargo, ND during December?  I did and it was AWESOME (cold too).  I give expensive software out to students and universities for free!  More so what I’ve realized is students geek out on stuff I’ve built.  Who doesn’t want to learn about building a Segway?  Plus I get to play with new stuff like Ruby, Excel, Silverlight, LINQ, movie editing, PowerPoint, and Visual Studio for my job.

And yes, this was the perfect way to actively avoid writing my performance review for a while.  I think my skateboard needs a start up protocol written …

Tags [ Ramblings Microsoft ]

Favors one side, think I’ll add in a “dialing” adjustment on the null value for the accelerometers.  The reason why it favors one side is due to more weight on that side.

Tags [ Building Skateboard ]

I’m stupid, I did too many changes in attempts to abstract skateboard logic from the IMU without being able to test it out.  Having bare electronics with LEDs on it that blink while being 2 miles in the air around “normies” isn’t a good idea.

After 2 hours of debugging, I got this:

image

That’s right, 200 cycles a second!  One interesting thing also is how the gyro data is coming back, it appears to be “reversed” with how I’d imagine it would be.

So what did I do?

The IMU logic is now 100% independent of the skateboard which is where you’d want it.  I’ve removed unused / needed members from the ImuData class,

I also reduced the amount of object creation since now I use the ImuData object to process the byte array.  Why did I move this you may ask yourself?  Other than I wanted to make my life hard by refactoring tons of code, the Imu deals with the gyro, why should the Imu class deal with assigning the bytes to the ImuData class?  I can see why someone may disagree with me here, but I think it makes sense so deal with it.  hehe

So now I think I’m officially ready to post the Imu classes for the 6DoF v2 IMU in c#.  I still want to add in a “loader” that will initialize the IMU.  I had something semi working but the new IMU I have has a different style of doing this which instantly broke how I was doing pulling this off.  I also want to create a small project with a similar to the Skateboard UI that gives you all the data back from the IMU.

Also by checking if I have to process something, at the worst case scenario, I’ll only gain a few extra ticks for the if statements. 

public ImuData GetImuData(double maxX, double maxY, double maxZ)
{
    if (!isImuPrimed)
        StartImu();

    //0   1  2  3  4  5  6   7  8  9  10 11 12  13 14 15 16 17 18  19 20  21 22  23 24  25 26  27
    //41 |01 F0 02 03 02 18 |01 C1 02 07 02 18 |02 00 02 03 02 18 |01 4F |01 63 |01 F0 |02 03 |5A
    //A  |240   515   530   |449   263   530   |512   515   530   |335   |355   |496   |515   |Z
    //   |pitch             |roll              |yaw               |X     |Y     |Z     |Bat   |
    com.DiscardInBuffer();

    do
    {
        while (imuDataArray[imuDataArray.Length - 1] != 0x5A)
        {
            imuDataArray[0] = 0;
            while (imuDataArray[0] != 0x41)
                imuDataArray[0] = (byte)com.ReadByte();

            while (com.BytesToRead < imuDataArray.Length)
            {
            }

            com.Read(imuDataArray, 1, imuDataArray.Length - 1);
        }

        data.ProcessData(imuDataArray);
    } while (!checkData());

    // reverting data
    imuDataArray[0] = imuDataArray[imuDataArray.Length - 1] = 0x00;

    now = DateTime.Now;
    data.ChangeInTime = now.Subtract(lastRead);
    lastRead = now;

    applyCorrections(maxX, maxY, maxZ);

    return data;
}
 

Checking in now before my brain dies.

Tags [ Coding Skateboard ]

I tend to like inline statements.  Here is my new favorite.  I even commented!

protected int calculateData(byte[] data)
{
    // why the index++?
    // I want index 1 and 2, since i++ increments it after i been used
    // going int i = 1; Console.Write(i++ + "::" + i++); 
    // will "1::2"
    return ((index + 1) < data.Length) ? 

      calculateData(data[index++], data[index++]) : 0; }

Update: Why I love it and why I did this
It is heavily compacted.  It is an inline if statement along with how I did incremented the index.  It won’t compile if you just ran it since I overloaded calculateData and have a (byte, byte) overload.

if index started at 1, it would leave as 3 from the function.  it calls calculateData like this, calculateData(1,2) and the next cycle would be calculateData(3,4).

So I use this function when I’m creating the ImuData return when I get data from the gyros and accelerometers.  I have a lot of data and the packets need to be parsed.  Since I know the order the items appear in when returning data, I just say, Battery = calculateData(data); in the proper order too.  I know the data will always be 2 bytes per variable too.  This is nice since I don’t have to worry about fixing indexes when I add / remove data from the IMU.

Thanks Alfred for calling me out on not explaining this.  I was in a rush and got side tracked.  Just like a teacher, always marking up my work.

Tags [ Coding Skateboard ]

I’ve been doing some CSS and HTML work and it feels good.  I haven’t done this type of stuff since I started at Microsoft and I love how CSS will constantly make you want to cry to get it to work.

So I’ve been using 2 different types of ways to get rounded corners for appearance since everyone wants their stuff to look Web 2.0’ish.  Images and JavaScript.  I hate using images since you have to render them first so I’ve used javascript.  There are two scripts to do this, the first is Nifty Cube and the second is called Curvy Corners.  Each has pro’s and con’s.

Nifty Corners is very easy and can be applied on anything to use BUT can’t do borders and let the image from a background bleed through while Curvy Corners can do just this but really only gets along with DIV tags.  BTEO right now uses Curvy Corners currently for the background image bleed, this will 99% not be there for the next version.

However I’m developing a site for my brother and liked the Engadget header more or less.  While the color scheme for his site will be different, I’m going to clone it pretty much exactly while he does whatever he does.

image

Curvy Corner could do it but once you started to get a bit deep, and the border issue pretty much screwed it came changing the link background colors when you roll over them with rounded corners.  But you’re asking, Clint, the spec requires a border and you said Nifty couldn’t do borders.

That is why you do something like this:  note the double div

HTML:

<div class="headerBottom">
    <div>
        <ul>
            <li><a href="#">Test 1</a></li>
        </ul>
        <div class="inner">Bob Dole Likes Peanut Butter</div>
    </div>
</div>

With some CSS:

<style type="text/css">        
.headerBottom
{
    top: -3px;
    position: relative;
    background-color: #E7E7E7;
    padding: 3px;
}

.headerBottom div
{    
    height: 50px;
    background-color: #F1F1F1;
}
</style>

JavaScript:

window.onload=function(){
    Nifty("div.headerBottom div","bl small");
    Nifty("div.headerBottom","bl transparent fixed-height");
}

By nesting, I can fake the appearance of a border.  I get something that looks like this and with everything as pure HTML.  Below is a screen grab of the render however.

image

Slight of hand but I do get my corners curved with a border.  Why care?  The client (my brother) can change the colors and I don’t have to render the borders.  Everything can be updated via CSS.  I say this as I’m looking at a render he did that marked a section that is colored gray but has a hex value of pure white (#FFFFFF).

Tags [ Coding ]

captainSlowI got the system up and working and did a trial run last night only to see it act disappointingly slow.  I'm not 100% sure if it is my new laptop (Lenovo x300) or I am missing some bit of code.

One big thing I forgot to do is to tune the Inertial Measurement Unit (IMU) again along with the code.

How can I make a device that runs as a fixed rate faster?  Easy!  By turning off stuff that you don't need to send back, I can get get about a 30%+ jump in data speed.  What don't I need?

The Z gyro, Z gyro voltage, Z gyro temperature, Y gyro, Y gyro voltage, Y gyro temperature, and last but not least, Z accelerometer.  That makes the means I'm reducing my data by exactly 50%.  This almost means I don't have to calculate as much data.  I should make a special "skateboard IMU" and IMU Data class for this.

Plus I question how fast I'm updating my UI.  This may account for some sluggishness.

And I need to redo how I handle data logging again to prevent memory issues.

Note to self: never have bag stole again with source modifications that haven't been checked in.

P.S. If you don't watch Top Gear on the BBC, that is Captain Slow, James May.  Seriously, awesome show.

Tags [ Calculations Coding Skateboard ]

So I fixed this I believe a month ago and ran into a massive issue of “where was that bug I fixed” since it wasn’t backed up / checked in.  I really haven’t found time to play with my skateboard so here I go.

So the bug revolved around the need to have the gyro nulled out.

data.GyroRawData[i] *= data.GyroVoltCorrection[i];

So by correcting for the voltage, I was altering the “raw” value.  This isn’t that big of a deal, however I use that raw value on calibrating the gyro initially.  This is something I want to get away from but until I figure out how to do that, I put the gyro on the ground for 30 seconds and allow it to get enough data to create “null” values.

I actually refactored how I was doing that entire loop.  1 loop instead of 3.  Code still needs a bit of polishing but I’m about 95% sure I can boot up the skateboard with this code base and be able to get on it.

double gyro_temp_differential;
double gyro_temp_differential_squared;
double gyro_null;
double gyro_raw;
double gyro_rates_temp_compensated;
double gyro_scale_factor;

private void applyCorrections(double maxX, double maxY, double maxZ)
{
    for (int i = 0; i < 3; i++)
    {
        data.GyroVoltCorrection[i] = ((2.5 / data.GyroVolt[i]) * 1024) / 5.0;
        gyro_raw = data.GyroRawData[i] * data.GyroVoltCorrection[i];
        data.GyroTemp[i] *= data.GyroVoltCorrection[i];

        data.AccelerationCorrectedRadians[i] = ((data.AccelerationRawData[i] - raw_accels_null[i]) *
                                                analogToVoltage) /
                                               (gOffset);

        //if we convert to rads BEFORE the correction, can the extra precision of
        //the float's mantissa increase the scale precision? probably not, but we'll
        //try it later just to be sure.

        //calculate null temp point (temp out at current vout)
        //current temp - reference temp (25 degrees celsius)
        gyro_temp_differential = (data.GyroTemp[i] - raw_gyro_temperatures_null[i]) * analogToVoltage;

        //previous var square
        gyro_temp_differential_squared = Math.Pow(gyro_temp_differential, 2);

        //current null value (center) from reference null value
        // magic numbers, I know....
        gyro_null = (raw_gyro_rates_null[i] * analogToVoltage) + 0.0086 * (gyro_temp_differential) +
                           0.03597 * (gyro_temp_differential_squared);

        //compensate current output with temp correction
        gyro_rates_temp_compensated = (gyro_raw * analogToVoltage) - gyro_null;

        //convert to degrees by applying the scale factor according to temp
        gyro_scale_factor = 12.744 + 1.26056 * gyro_temp_differential + 0.6728 * (gyro_temp_differential_squared);

        //transform P into corrected degrees per second
        data.GyroCorrectedRadians[i] = gyro_rates_temp_compensated / (gyro_scale_factor / 1000);

        // WE'RE FINISHED EXECUTING OUR CORRECTIONS.
        // WE NOW HAVE EXPORTED CORRECTED VALUES FOR P,Q,R (ROLL,PITCH,YAW) as float corrected_rates in EULER.
        // WE WANT RADS
        data.GyroCorrectedRadians[i] = Angles.DegreesToRadians(data.GyroCorrectedRadians[i]);
    }

    if (data.AccelerationCorrectedRadians_X > maxX)
        data.AccelerationCorrectedRadians_X = maxX;
    else if (data.AccelerationCorrectedRadians_X < -maxX)
        data.AccelerationCorrectedRadians_X = -maxX;


    if (data.AccelerationCorrectedRadians_Y > maxY)
        data.AccelerationCorrectedRadians_Y = maxY;
    else if (data.AccelerationCorrectedRadians_Y < -maxY)
        data.AccelerationCorrectedRadians_Y = -maxY;

    if (data.AccelerationCorrectedRadians_Z > maxZ)
        data.AccelerationCorrectedRadians_Z = maxZ;
    else if (data.AccelerationCorrectedRadians_Z < -maxZ)
        data.AccelerationCorrectedRadians_Z = -maxZ;
}
Tags [ Parts Building Skateboard ]

The gyro works with the TTL to RS232 adapter.  Like I was thinking, the TTL to USB adapter was sending 3.3v to the gyro and not providing enough juice.  Flipping on the battery then provided too much power, oh the irony.

Now that I have a functional IMU unit, I can finish out this code once I finish up my chapter.

Tags [ Building Skateboard ]

image I had the honor of being on This Week on Channel 9 talking about my top 5 (I squeezed 7 technically in) of my favorite tools I must have on my computer.  I co-starred with Scott Hanselman (It is fun to annoy him by mispronounce his last name)

These are from my post earlier on tools but here is what I talked about

1. ReSharper
2. Ultramon
3. Firebug
4. Synergy
5. Windows Live Writer

Tags [ Windows Home Server Maker Faire ]

imageI've been working on an application for an upcoming project that uses Twitter.  I've never seen something that everyone loves fail so regularly.  I'm smashing my head since I can't do proper debugging while people are like "Oh twitter, you're down again." and they slap their knee.

I like twitter, the idea is decent despite what some people may say.  It gives me a place to rant that isn't my blog which has a very targeted outline.  I get to make statements like "Why do people think it is OK for google to have applications for 4+ yrs in beta?"

Now if twitter was produced by any other company, we'd all freak out.  When Friendster was having these issues of uptime, people moved to MySpace.  When MySpace was running into the same issue, people moved to Facebook.  I know most will say MySpace's rise and fall was due to the ability to customize it, but I think it was hugely due to their social site being down. 

Flickr would have lost the war I believe if it acted like Twitter.

Twitter needs to be fixed.  Wether that means it gets neutered and people move on to a different micro-blog site OR they fix their issues.

Maybe people view the Twitter service as pointless amusement and doesn't matter if they have like a 50% uptime rating with developers that constantly produce broken builds on what appears to be a SUPER simple application.

image

I also do love that their error pages have formatting errors.  They make me think everything is alright and twitter has robots fixing everything.

Tags [ Ramblings Twitter ]

image Twitter Vote is pretty much done.  Seeing if I should add in a few features or not.  Time to start typing like I actually know English.

I know the UI could use some TLC but I'm a developer, not a designer.  Yeah, that is my excuse.

Tags [ Coding Twitter Coding4Fun ]

image

Now to make the User Experience look less like poo.  Make it pretty then write the chapter.

The one thing I'm disappointed Twitter could do but doesn't implement properly is the Reply system.  If I reply to a tweet that is 3 down, it will actually log it in their system as the most recent.  BOO-ERNS twitter, boo-erns.  Do some javascript magic there.

Tags [ Coding Twitter Coding4Fun ]