.comment-link {margin-left:.6em;}

December 29, 2006

 

NXT Tip of the Day #3 - Using the Touch Sensor

Today you decide you want to do different things depending on whether the touch sensor is pressed or not. The touch sensor is a button, and your NXT-G program can make decisions depending on which state it is in.

To do this, you would use a Switch Block. By default, it is set up to make a decision using the touch sensor, but it has many other uses.

When you add a Switch Block, a box shows up in your program with the "switch"part on the left. Inside the box are two sequence beams, instead of the usual one. The blocks (you have to add them, of course) on the top beams are only run if the switch condition is "true". The bottom is run for "false".

The condition is indicated by the choices in the panel at bottom-left. Check that the Port is the one you have wired the sensor to, and change it if necessary. Everything else should be already set correctly for this use.

In the example to the right, you are running a car with motors connected to ports B and C. If the touch sensor is pressed when it gets to this part of the program, it will run forward for 2 seconds. If not, it will go backwards for 2 seconds. If this was the complete program, you would have to press the button as the program is started to have the car go forward.

December 28, 2006

 

NXT Random Number Generator

It's official. The NXT's random number generator is not very good.

The first test was with my Die Rolling Program. I noticed tonight while showing it off that the first ten rolls or so were all even numbers. Then the next five or so were all odd numbers.

So then I saw a comment somewhere about testing randomness but choosing two numbers and plotting a point at the X, Y location on the display. Do that a few thousand times. If you see a pattern, the random number generator is not very random.

Well, it only takes five blocks to write such a test. And the results are not good for the NXT random number generator. The display ends up looking like a grid of squares, instead of filling up randomly and (eventually) completely.

Has anyone found a way to improve the randomness of the Random Number block?

 

Tip of the Day #2 - Multiple Display Blocks

When you want to draw a number of things on the NXT display, you use more than one Display block, as shown at right.

Each one has settings (computer folks often call these "parameters") that determine what is drawn on the display. These are shown at the bottom-left of the NXT programming application. You can draw images (pictures), text, or drawing, such as lines and circles.

So you strings a number of Display blocks together to make something interesting or useful on the NXT display, download it, and run it. Only the last of your Display blocks worked!

What happened? One of the parameters is a check box labeled "Clear". If this is checked, then the display is cleared before that drawing operation is performed. By default (i. e., if you don't change any of the parameters), this check box is checked. So if you have three Display blocks, as shown in the top picture, all three will clear the NXT display, and only the last drawing operation will be visible!

So click on the "Clear" check box if you already have drawings on the NXT display, and only want to add more, not start over.


December 27, 2006

 

Die Rolling Program

I finished my first complex NXT programming project tonight. I wrote it with NXT-G -- the programming environment that comes with the NXT.

It rolls a die randomly, and draws it on the screen, as you can (sort of) see in the picture to the right.

The main program ("Draw Die Test") just chooses a random number from 1 to 6, and then calls a "My Block" called "Draw Die" to (drumroll, please) draw the die. This is the most complex code because there are seven different "spot" position that make up the various die drawings. I actually pretend like there are nine, not seven, so I can do computations assuming a three-by-three grid, numbered from zero to eight. Spots one and seven are never used.

Not quite as complicated, but still using a number of math functions is the "Draw Die Spot" block. It draws just one little circle, in one of the nine positions.

Finally, there is no built-in modulo division function (% to C-language programmers), so I had to steal write a block for that. It's called "Mod".

You can dowload the program here. If you have any questions, please post a comment.

Update: As of 1/8/08, the folder is still not public on BrickShelf.
You can download the four necessary programs here, here, here and here!

 

New NXT Color Sensor from Lego (and HiTechnic)

Lego is selling a color sensor for use with the NXT. It was designed by the HiTechnic company. It will ship in a few weeks. When someone gets one, please leave a comment to let everyone know how it works! The 0-17 color chart looks odd to me, but you do have access to the RGB (red, green, blue) values. Using all of those in NXT-G would be interesting. I'll need to get a bigger monitor for my programs. :)

It is available on the Lego site, and programming and other information is
on the HiTechnic site.

There is also a compass sensor available. More information here.

 

NXT Tip of the Day - Want more of these? Leave comments...

I can see that there are many new readers to this blog, what with
holiday presents, so I will start ...

The NXT Tip of the Day

which may be more like

The NXT Tip of the Week or The NXT Tip of the Month depending on how much time and how many ideas I have. Please leave comments to encourage me, and suggest ideas you are interested in.

So here is Tip #1: In NXT-G (the graphical programming environment that comes with the NXT, save your program often! Don't wait until you've spent three hours getting all your blocks just right and have tested your program ten times. Save your program ever few blocks you add. This is especially true if you use advanced techniques like connecting wires (on the screen wires, not the black wires you use to connect to motors and sensors) or MyBlocks.

In fact, if you have a complicated program, I would suggest saving to two different file names, keeping one as a backup in case something goes wrong. Anyway who hits the "broken wires" bug will thank me.

December 09, 2006

 

Robot Challenge Number 1

If the NXTasy blog can do it, so can I! :)

I'm just starting to work on a project for a science fair demonstration (adults make them at the school in question), and thought I'd make it into a challenge.

Make a robot that can write one or more letters on paper. The letter or letters should be chosen somehow by the user, and not be fixed in the program or entered via a PC keyboard. That is, you should be able to take the robot somewhere without a computer and use it.

The official rules are as follows, but it's not an easy task, so you modify the goal for yourself to fit your experience level. Please enter even if you don't finish your robot - let all see what you tried to do!

1) To enter, you must post a movie of your robot performing the goal (or trying!) somewhere by midnight (local time) on January 9, 2007. In the movie, you should say "Robot Challenge Number 1" and your name (or a fake name if you prefer). You must post a comment to this blog entry with a description of your robot, and a link to your movie.

2) You can use one RCX or one NXT.

3) All parts must be official Lego, except you can use a pen or pencil, and some paper.

4) Once the program starts, it must not communicate with a PC, and cannot be controlled by a remote.

5) The program should not know what letter or letters it is to write until the user instructs the robot after the program has started.

6) There is no prize except for the glory of winning and having fun.

Go!

 

Old Mindstorms (RIS) Software on Win XP - USB Tower Lockup - Patch

Last night I started working on a project for the old Mindstorms kit with the RCX. I got a new PC a couple months ago, and this is the first time I've installed the old RIS software on it and tried to use the USB IR tower. When I connected the tower, it locked up my PC.

After some searching, I found there is a driver patch to fix this. Lego has information on this here. If you want to jump straight to getting the patch for English, click here. Other languages are available - see the first link I have above for those.

Yippee... No lockup!

December 07, 2006

 

NXT Tutorial

Just found these tutorials tonight. I'm only now
watching the very first one now, but it looks promising.

Post a comment if you find them helpful (or not)...

December 04, 2006

 

Tricycle - My first homemade robot

After a couple months with the new NXT kit, I finally made a robot of my own design tonight.

It's not much. Just a simple tricycle, not too different from the Tribot.

The motors are quite large, so it takes some experimenting to attach them. After using L-liftarms to connect to the NXT, it was quite unstable. So I secured the motors to each other at front and back. It's not perfect, but now it's pretty stable.

At the front is a caster made with a pulley. It needs a little improvement, but I threw the whole thing together pretty quickly.

One annoyance is the new wires. The NXT only comes with one of the shortest lengths, which is more than long enough for this robot.

I wrote a simple test program. It has a loop that executes three times. In it are six motor control blocks. The sequence makes it go straight for a bit, then a little turn, etc. Fun to watch, though I was hoping it would annoy the cats a little more. Must download a barking sound to it.

Here's a picture from the bottom.

All in all fairly successful as a platform to add things too, I think, and simple to build. If enough people beg nicely, I'll think about generating building instructions for it, though it probably doesn't add much over the TriBot design.

This page is powered by Blogger. Isn't yours?