Saturday, January 30, 2010

I've been "working" with LEGO Mindstorms for a while now. The biggest struggle is my poor programming skills. The interface hasn't really helped much. Moving from crappy LabVew style block interfaces to variants of c++. I finally made some "progress" when they got leJOS up and running on OS X. Sure, I guess I could have run it's older Unix counterpart on my Mac . . . but I don't know how. So I've been going through a book that is teaching me how to use Java and it's offshoot leJOS. There have been many things that I have learning, but two things stand out the most.

First, version updates suck because they make the examples you have not quite useless but not quite helpful. I've learned the value of sifting through class lists so that I can figure out what has been depreciated and what hasn't. I've learned that finding examples of code online is great . . . until you realize that code requires a class implementation that you didn't include and don't have. All of these things are well known by real programmers and until recently not by me.

Second, after taking a few months off as I was working on other projects I've realized that without formal eduction it is really easy for me to forget things. As a result I need to make sure that I grow from "lesson" to lesson by at least partially reflecting. So that is what I am going to do with this space. I doubt anyone is still reading, and since I have the space to myself I'm going to reflect on what I have learned in hopes of cementing what paltry advances I make.

1/30/10: I've taken to building an oscillator to replace the "wiggler" we had in Cobb Co. It need to be able to oscillate a string at a variable frequency so that students can create standing waves. I built a wiggler out of Mindstorm pieces and now have to figure out how to control it. There is a direct control mechanism that runs from Terminal, but it only works in "Power" settings through a slide bar. I need to be able to figure out what angular speed the motor rotates at for difference power settings. The trick is that it is under an unknown load so I can't just use the standard graphs online. So I have to find a way to track the angular displacement of the motor as it goes through motion at different settings. That means I need to have a way to record the tachometer and write it to a file. TachoCount gets me the reading I need, but writing a file it tougher than I thought. I struggled through some built in DataLogger classes and eventually found a class online that does what I want it to do and I can figure out how to manipulate the code for. It still has a drawback of the number of data points, but I may be able to improve that with time (or not?).

Once that works I realize that the motor speeds indicated on the standard graphs are going to be roughly true, which is bad because they peak out at less than 3 revolutions per second. So I'm going to have to gear the living daylights out of this assembly if I am going to be able to vary the frequency of the oscillator over even the most trivial range (0-50). As it stands now I can gear it up to 1:20, which will accomplish my needs as long as I can control the motor.

Controlling the motor was frustrating. I wrote a bunch of code that was suppose to increase the motor power incrementally (before I collected the data) but it failed because there is an obvious difference between .setPower() and .forward(). Even after I figured that out it seemed like the .setPower() method wasn't doing anything . . . because it wasn't. Apparently the motors have a speed regulator that has to be disabled by setting .regulateSpeed(false). I can now control the motor, and get a graph telling me what power setting equals what RPM. There is a .setSpeed() rating, but not on the direct control.

Which is why the last project because getting direct control from a program other than NXJControl. That would mean having a button response (or something else). I know that you can create button listeners, but the book I have doesn't talk about it much. I spend a lot of time looking for it online and find nothing until I see a small section of code that tells me how to create listeners. So I decide to create a stupid math program where right= +1, left= -1 and enter= +10. I get moving and get an error when I tell it to increment the variable SCORE. I spent a lot of time trying to figure out how to pass and return a variable to a listener before I realize that one option is to make SCORE a static int (which basically makes it global to the whole class so any object/method can alter it). With that done (and on my first upload) I get my math program up and running on the NXT and it works.

I guess the next step is to write a program where you press the buttons to increase the variable put into .setSpeed(). That way one NXT can directly control one motor and get it to move through the whole frequency range. Then I have to find a string that will have a fundamental frequency in the teens to we can get at least 3 standing waves out of it.


Tuesday, January 19, 2010

Welcome back to the future (Nov. 5 1950 style). We have now arrived in a new decade, and plenty of new shit has started happening. Playmotion has gone through turbulent times and seems to currently only have Jeremy as an employee. They are currently restructuring their business model. Jeremy can tell you more about it. Jason's wedding has been called off and he and Maggie are no longer together. On the up side, Jason is around more and is spending time (?) with a nice girl named Vanessa. Mark's been trying to find work, and I think he has a good prospect with Friend of the Fort Dan Campbell. Mike and Amy are due back in the states either in March or April. Perhaps the biggest news (at least on my end) is that Chowning is expecting in the end of May. It is a shocking event (that we had been planning for) that has changed every aspect of our lives. I spent last weekend building a crib and changing table. We as a collective have renewed our trivia goings under Jeremy's watchful eye. I can't make it as much as I like, but I think some brand of our posse has been at trivia every week (that it has happened) for the past few months. Winter is here, so winter conditioning is here and my abs are sore. We celebrated a fun New Year at Matt and Roxanne's and hopefully we will use this new year as an opportunity to post more.

Jeremy and I made a LEGO movie . . . here it is. We will hopefully make more movies as time allows. Carry on.