Wednesday, April 14, 2010

So I bought a laser cutter...

Something I have always pushed for is to make prototyping and small scale manufacturing easy and cheap for the developing inventor. It's from this strong belief that I've developed quite a fascination in rapid prototyping machines and cnc devices.

I finally decided to purchase a laser cutter, since I already had access to the hackerspace's 3d printer. Unfortunately it's not exactly as easy as jumping on Amazon and reading a few reviews. It took over a week of internet research to come to my decision.

What follows is the what I looked at, and what I eventually decided to buy. Hopefully this will become a multi-post tale of success and glee, and not one of woe. And of course I plan to include a full write-up on setting up, and review of the laser, once I get it.

Monday, March 15, 2010

ATTINY2313 Checksum based serial - March Madness Entry 15

In the last entry, I set up a buffer based ATTINY2313 serial file. In this quick tidbit of code, I implement, using that code, a theoretical implementation of a checksum based serial communication.

Here's the idea - the master gives the slave, our ATTINY2313, a random byte between 0 and 255 (exclusive). It inverts that byte and returns it. It then waits for a SUCCESS or FAIL byte (decided by the implementer). This inversion is a checksum - if the master or the slave are not in sync, the slave would not return the correct checksum, telling both that they need to clear their buffer commands and start over and sync back up.

The modified Serial.c after the jump.

Sunday, March 14, 2010

AVR Serial Buffer - March Madness Entry 14

A little while back, I finally got the USART working on the ATTINY2313. Tonight I managed to adapt buffer code to the device.

The point of the buffer is to allow a host to send a series of commands and let them back up, so that the slave (the ATTINY2313) can deal with the commands as it can. This works best in a one directional setup, where the majority of the information being processed is the master talking to the slave. I will confirm that this works fine for some robotic applications, however. In retrospect I should have used a different system, as that was a robot that mapped an area and returned a heavy amount of data - but it still worked.

In my example, it would wait for 3 bytesCode after the jump.

Saturday, March 13, 2010

March Madness Entry 13

Finally got an Arduino of my own, so I figured while I'm traveling I'll get a simple Arduino program up and running. No video or pictures as I'm in Philly. Simple, short script to get myself up to speed with the Arduino.

The formula I used to calculate the actual distance is linearizing the otherwise cubic return of a typical Sharp IR rangefinder - a popular, easy to use rangefinder that simply returns an analog voltage. This formula can be found in a datasheet provided by Sharp. It may require some minor adjustments for different Sharp sensors.

/*
Sample simple program by Keith Chester

Just print out the distance read from a SHARP IR Rangefinder.
*/

int IR_signal_pin = 1;

void setup(){
  Serial.begin(9600);
}

void loop(){
  int IR_raw_read = analogRead(IR_signal_pin);
  int actual_distance = (6787 / (IR_raw_read - 3)) - 4;
  Serial.println(actual_distance);
}

Friday, March 12, 2010

Second Life - March Madness Entry 12

Some people shudder at the mere thought of it - others salivate at the mere potential of an essentially open world with open scripting and building tools. That's right, I'm talking about Second Life.

I fall somewhere in both camps. I was essentially graded on my immersion of it back in college during my Junior year, where I had to complete an "art project" for a Professor. The project required I write a number of scripts and help generate a lot of interactive content. I got the project done, but was so tired of the public areas of Second Life and the overall depressing reminder of what kind of humanity visits such a place.

It being a lonnnnnnnnnnng time since I've done anything in Second Life, I've managed to forget most of the LSL scripting language. With one of my fellow hackerspace members in charge of virtualizing NJ's state college of Rutgers into the Second Life world, I could hardly not check out the campus and give it a look-see. Heck - the above screen shot is taken in the campus's virtual stadium. Here's a quick hello world that changes a boxes color to red.

Thursday, March 11, 2010

ATTINY2313 Serial - March Madness Entry 11

At the micro controller study group, I decided to dedicate myself to getting a serial library that works on the AVR ATtiny2313 micro controller. I've used the serial ports on ATtiny25/45/85's, Atmega48/88/168/328s, and Atmega644s, etc... But the ATtiny2313 has a weird set of registers for serial port. Since I planned on using it later with a serial application, I realized that I would have to heavily adjust some of my code due to the 2313's odd choice in register names.

This code should work. Please note that the receive interrupt echoes the input - probably a good idea to change that if you're using it for an application.

Qik - MCU Study Group March 11th by Keith Chester

Wednesday, March 10, 2010

March Madness Entry 10

A common theme, to be sure. I'll leave it at that. But when you throw a dying router into the mix with five laptops on it, and suddenly testing your IRC bot becomes a slow, arduous, and sometimes fruitless task. Tonight's code? A rehash of last nights with an added twist.
import twitter
import urllib
from getpass import getpass

def isitgoingtorain():
    answerPage =  urllib.urlopen("http://www.goingtorain.com")

    while answerPage.readline().find("<div id=\"answer\">") is -1:
        pass

    tmpLine = answerPage.readline()

    if tmpLine.find("yes") is not -1:
        return "yes."
    elif tmpLine.find("no") is not -1:
        return "no."
    else:
        return "FAILED"

def createApp(username, password):
    twitterSystem = twitter.Api(username, password)
    return twitterSystem

user = raw_input("Enter your username - ")
pword = getpass("Enter your password - ")

twitterSystem = createApp(user, pword)

tmp = isitgoingtorain()

if tmp is not "FAILED":
    print "Posting..."
    twitterSystem.PostUpdate("APERTURE SCIENCE AUTOMATIC FUTURE RAIN STATUS PREDICTION SCRIPT RESULT: " + tmp)
else:
    print "Failed... could not get rain update."

Tuesday, March 9, 2010

March Madness Entry 9

With an ever shrinking budget of time, a slew of stomach cramps, several sub 5 hour slumber nights, a new project at work, and the ever present long meeting for FUBAR's future tonight, I knew I had to make it short. At least I kept it useful.

Ladies and gentlemen, the daily morning Python script (in function form for future porting to other applications) - Is it going to rain? Powered by Going To Rain?.

Very simple. Use urllib (1, not 2. Yes, there is a difference, it isn't just versioning differences...) to grab a url as a page we can step through, and look until we find a segment of HTML where I know the answer is stored. Once I find that marker, I know the answer is on the very next line, so just check to see if it says "yes".

def isitgoingtorain():
    answerPage =  urllib.urlopen("http://www.goingtorain.com")

    tmpLine = ""

    while answerPage.readline().find("<div id=\"answer\">") is -1:
        pass

    if answerPage.readline().find("yes") is not -1:
        return "yes."
    else:
        return "no."

Monday, March 8, 2010

March Madness Entry 8

As exhaustion sets in from spreading myself a bit thin, I offer up this morsel of python programming to pass yet another day in the challenge. Some of you may notice that yesterday's is missing - the code is done, but the video required for such a project is late coming for various reasons. When I get video and can offer up the code, I will post it.

For now? A touch of getopts.

Saturday, March 6, 2010

March Madness - Entry 6

Couldn't finish the IRC bot (with responses) so I did a Project Euler problem to fill the time. Hmph!


The sum of the squares of the first ten natural numbers is,
12 + 22 + ... + 102 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)2 = 552 = 3025
Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640.
Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.

values = range(1, 100 + 1, 1)

sumSquares = 0
for i in range(0, 100, 1):
    sumSquares += values[i]**2
squareSums = sum(values)**2

print squareSums - sumSquares

Really simple. The result? 25,164,150.

Qik - FUBARlabs Arduino Course by Keith Chester



FUBAR Labs had its first Arduino class today - I had the day off so I popped in and offered help where I could. The class was a huge success! We're looking forward to doing it again and offering other, more advanced classes in the near future.

Friday, March 5, 2010

IRC Bot Template - March Madness Entry 5

For the upcoming Python study group for FUBAR, I decided to focus the group onto a sole project or Python module that we can all learn together, and then work on to expand in different directions with our own creativity. To try out this new model of handling the study group, I decided to have the group create their own respective IRC bot. Together we would figure out how to get them online, parse data, and talk back in the chat. After that, we can have each member implement their own cool bot features - the options really are limitless.

Thursday, March 4, 2010

March Madness Entry 4

A little shy on time today, with a combination of a suddenly changing work schedule due to unforseen circumstances and an unusual bout of exhaustion and nap taking. The result? A project Euler problem to fill the time!
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99.
Find the largest palindrome made from the product of two 3-digit numbers.

Wednesday, March 3, 2010

Hello, Android

Some of you may know that I recently purchased the Nexus One, an incredible phone - of which I have completely fallen in love with - which runs the Android operating system. Despite my Java not being my strongest background, I've long been interested in developing for the Android phone. The idea of being able to develop a personalized program to handle my data on the fly wherever I am is personally very intriguing.

And now, at the start of March Madness, I will walk you through my process of creating the simplest of simple programs - an Android Hello World.

Tuesday, March 2, 2010

March Madness Entry 2

A bit squeezed on time between work and FUBAR Lab's social and administrative meeting, I decided to do something simple tonight - Project Euler! Some of those problems can get ridiculous, so I chose one I happened to know the answer that I've solved in the past, but didn't have the code laying around.

Note - if you want to solve project Euler yourself, don't cheat and peek at the rest of the post. Take this as a warning - the answer is at the end.

Monday, March 1, 2010

March Madness Entry 1

And so I tried something simple to stretch my muscles before taking on the marathon that is March Madness.

The goal? Make a simple twitter client that would share my exercise information - what cardio I did, how long I did it, and the distance I went because of it.

Saturday, February 27, 2010

March Madness Launches Monday

A reminder - March Madness for FUBAR Labs will launch on Monday, March 1st. Sweet! Expect a sudden surge in blog activity.

Friday, February 19, 2010

Qik - Quick browsing of the workshop and projects I'm working on by Keith Chester



Testing out the qik video streaming service, for automatic upload and social sharing. This should make it easier to share what I'm working on at any given time.

March Madness coming soon!

So to try and rally the troops at the hackerspace, I suggested a contest - March Madness. The idea? You have to write one unique program every single day. It doesn't have to be the next Microsoft Office - it just has to be an actual program with a unique goal in mind. You're allowed to use any language and platform you like - I plan on switching between my laptop computer, my new Android phone, and embedded platforms.

I'll be blogging about each program, everyday here - hopefully I'll get back into the swing of things for posting on my work. Especially now I'm starting to catch a bit of the social media frenzy.

Wednesday, February 3, 2010

Relaunch

Yet again, I know. Bare with me.