## Motor Speed vs. Motor Power

•February 9, 2011 • 10 Comments

Polled at a Motor Power Output (%) every 5% increase, over a motor rotation of 720 degrees each. Motor Rotation Speed vs Motor Power Output (%) for NBC/NXC Firmware 1.28. As you can see, it's a pretty linear.

I was interested in how fast the motors would spin (in the air for the first tests, to not let gravity/load/friction/etc affect the results) depending on what I set pwr in the NXC function OnFwd(outputs, pwr).

I wrote a program (download here) which logged the time it took to spin the motor at 720 degrees (in one experiment), and with a starting pwr value of 5, increasing by 5, until it reached 100. It was tested on the NBC/NXC Firmware 1.28.

It seemed to be linear, and I did a little “analysis” (if you can call it that), and came up with the graph on the right, which represents the ratio between Speed and Power. This ratio is about 7:1.

Next, I tried it with the robot on the ground. The results were pretty much the same (linear), as you can see in the image to the bottom left. Of course, it slowed down a bit, as can be expected.

I still haven’t figured out how this is useful, but if you can suggest reasons for why I haven’t wasted my time (which I actually like doing, believe it or not), please tell me in the comments. Now I’m adding meaningless text just to fill this line, so my blog post looks good. 🙂

## Set Firefox [4] Default Search Engine in URL Box

•January 25, 2011 • 9 Comments

This post will show how to make the Firefox [4 Beta 8] URL box (which is the left one, by default; and it’s different from the search box) default to Google when something other than an URL is entered. (Just like Chrome’s omnibox.) It currently goes to Yahoo! For example, if you type, “hello world“, you want it to search for “hello world” (in Google). But it searches this in Yahoo! instead! Fortunately, there’s a way to change it to Google. (URLs like muntoo.wordpress.com will not be affected.)

1. First, type in “about:config” into the url box, and click on “I’ll be careful, I promise!“:

2. Under Filter, type in “http://search.yahoo.com/search?p=“:

3. Edit the value of keyword.URL by double clicking it (or right click->Modify) and change it to “http://www.google.com/search?q=“:

4. Do the same with browser.bdtoolbar.orig_keyword_url:

5. And you’re done! Test by typing “the answer to life the universe and everything” into the url box.

## Bezier Curves On The NXT

•January 13, 2011 • 5 Comments

Bezier Curve Speed Test for a 4th Degree Bezier Curve. At a resolution of 50, each new render takes 286.5 ms, or about a third of a second.

As some of you from NXTasy may remember, I was working on a Bezier Curve implementation for the NXT in NXC. (I was also competing with Spiller for rendering speed; his code is in BezierCurve.zip\BezierComparison\Bezier_curves2\Bézier_curves2.nxc) I’ve managed to render the curve in the picture above in 286.5 ms. And that’s a 4th degree curve (3 control points and 2 end points) with 52 different points along the curve calculated and interpolated to give a “high resolution” output.

To do this, I added a bunch of my own optimizations and tried to avoid floating-point operations where possible. Then, using Spiller’s idea that:

$\mathbf{B}(t) = \displaystyle\sum_{i=0}^n {n\choose i}(1-t)^{n-i}t^i\mathbf{P}_i$

Can be converted to:

$\displaystyle \mathbf{C}_i = {n\choose i} \mathbf{P}_i \\ \mathbf{B}(t) = \displaystyle\sum_{i=0}^n (1-t)^{n-i}t^i \mathbf{C}_i$

I was able to speed up my drawing routines by up to 200%! (On the GeneralBezierCurve2DOut() drawing routine.)

NOTE: $n$ is the degree of the curve. $\mathbf{B}(t)$ is the Bezier Curve parametric function. $\mathbf{P}$ represent the control points. $\mathbf{C}$ and $i$ are temporary variables.
NOTE 2: Math geeks, sorry about the “while” notation. If you have any ideas in which I can use pure mathematical notation without resorting to C, please notify me by leaving a comment.

As well as the demos, I’ve included an entire library (BezierCurve.zip\BezierCurve\v0_3\BezierCurve_v0_3.h.nxc). It can:

• Draw curves on the screen using BezierCurve2DOut().
• Draw different shapes using the ShapeType parameter! For example, you can interpolate the points using Lines, make the curve thicker by using [Filled/Clear/etc] Circles/Ellipses, or make “calligraphy” effects using [Filled/Clear/etc] Rectangles.
• Determine the length of the Bezier curve using GeneralBezierCurve2D_Length_LocationType().
• Draw/connect points in an array onto the screen using LocationType_PointsOut(). (And specify the shape too, of course.)
• Pre-calculate Bezier curves and store their values in an array to increase program performance using BezierCurve2D_GetPoints_LocationType().
• And more!

It is possible that it requires the Enhanced NBC/NXC firmware. That is available here. [LINK]

Here’s a video of the demo/speed test programs in action:

Radar Image on the NXT's Screen.

Once made a long, long time ago, in a galaxy far, far away was my Radar program. Not very advanced, mind you. If you wish, you can take a look at Lumpiluk’s Version, which is a lot more awesome. (I’m very good at marketing. 😉 )

## NXT File Manager (v1.4)

•December 19, 2010 • 3 Comments

The NXTFileManager (v1.4) - This screenshot shows a list of files on the NXT displayed in the NXTFileManager program.

I have created a File Managing program for the NXT. You can view/open/delete all file types. You can even play “.rmd” and “.rso” sound files, and quickly display a “.ric” picture file, and even specify the parameters! A larger list of features is below.

Some Features Include:

• Lists ALL files on the NXT
• Total file count at top-right of File List Screen
• File Options:
1. Open:
• Picture files (“.ric” – you can even specify one parameter; support for multiple parameters can be added if there is a demand for it)
• Sound files (“.rso”, and “.rmd”)
2. Hex Viewer: Can view in:
• Hexadecimal (“47 4F 4F 47 4C 45 4B 4F”)
• Decimal (“71 79 79 71 76 69 75 79”)
• Binary (“01000111 01001111 01001111 01000111 01001100 01000101 01001011 01001111”)
3. Delete: Deletes selected file
4. File Properties: Shows file size and other properties of the file

It is possible that it requires the Enhanced NBC/NXC firmware. That is available here. [LINK]

Here’s a video of the program in action (be sure to view it with captions enabled):

## NXT SnakeWorm Game (v1.0)

The SnakeWorm Game (v1.0)

I have created a SnakeWorm Game for the NXT. It’s based on that old snake game, but has different mini-games (called “game modes”), so you never get bored! [Well, maybe you’ll get bored if you compare this to Call Of Duty, but otherwise…]
My game has more features, though. It is written in NXC, so it has a much smaller compiled program file size, in proportion to a program written in NXT-G.

Some features include:

• Highscore
• Game Mode
• Relax Mode (Do whatever you want! Change the speed of your snake, and just cruise along capturing as many objects as you can before you get bored.)
• Collision Mode (Try and catch as many objects as possible without colliding with the walls or yourself! The game gets faster and faster as you catch more objects.)
• Time Mode (Choose your speed, and race against the clock! Every level the time allowed to complete it gets shorter and shorter until your fingers are a blur!)
• Level Mode (Select how many levels you want [between 1 and 10]. Each level, you must catch an object. The faster you catch an object, the more points you earn! The game gets faster each level.)
• Enable/Disable Grid
• Change look of snake:
• Rectangular
• Circular
• (Coming soon: Smooth Mode)

It is possible that it requires the Enhanced NBC/NXC firmware. That is available here. [LINK]

Here’s a video of the game in action:

## NXT Helicopter Game (v2.3)

The Helicopter Game

I have created a Helicopter Game for the NXT. I got the idea from Frenchie16 on NXTLOG – helicopter 2.0 (video game).
My game has more features, though. Dispite all those features, it has a frame rate of 10 fps (which is pretty fast for such a big game). It is written in NXC, so it has a much smaller compiled program file size, in proportion to a program written in NXT-G.

Some features include:

• Highscore
• Cheat Mode
• Lives
• Choose Number of Walls
• Objects (Extra points, lives, and invincibility mode)
• Wall and Roof

Here are some screenshots:

The Title Screen

In Game

Game Over

Here’s a video of the game in action: