Thursday, December 23, 2010

The Project - Location Recognition

A second part of this project I worked on a few days ago and a bit today. I'm planning to put down a long tape line around parts of the house. The robot will follow that line using one light sensor. Also, I'm planning to put in smaller lines as markers at four points next to the first line. The first point will have one little line, the second two, the third three and the fourth four. The robot will hopefully use its second light sensor to count the small lines and find out where it is.

To do this, I have the robot basically check to see the light value of its second light sensor is near the already saved "on line" variable. When it sees a line, it waits until it does not see the line, adds 1 to a variable called "line_count" and then moves on. It then runs 600 checks for more lines, waiting one thousandth of a second between each line. This leads to 6 seconds all together. If it sees a line, waits until it does not see the line and adds 1 to line_count. If it does not see a line, then it waits a thousandth of a second and tries again. At the end of the loop, it saves sets another variable "location" to the same value as the line_count variable. Here is the code I used:

task get_location ()
{
line_count=0;
while (true)
{
if ((Sensor(S2) < (online + 20)) && (Sensor(S2) > (online - 20)))
{
until (Sensor(S2) > (online + 30))
{
}
PlayTone(600, 200);
line_count=0;
line_count++;
repeat (600)
{
if ((Sensor(S2) < (online + 20)) && (Sensor(S2) > (online - 20)))
{
until (Sensor(S2) > (online + 30))
{
}
PlayTone(600, 200);
line_count++;
Wait(10);
}
else
{
Wait(10);
}
}
}
location=line_count;
}
}

It translates the location variable to readable locations on the NXT screen through this piece of code running in the main task:

// display robot location
TextOut(0, LCD_LINE4, "Location");
if (location == 0)
{
TextOut(0, LCD_LINE5, "Unknown");
}
if (location == 1)
{
TextOut(0, LCD_LINE5, "Kitchen");
}
if (location == 2)
{
TextOut(0, LCD_LINE5, "To Entryway");
}
if (location == 3)
{
TextOut(0, LCD_LINE5, "Entryway");
}
if (location == 4)
{
TextOut(0, LCD_LINE5, "To Kitchen");
}

I'm planning to add a fifth instance so that if it counts more than 4 lines, it puts out a line of text saying "error."

This project may be nearing completion (depending on what else I decide to implement). Stayed tuned.

Sunday, December 19, 2010

The Project - Line Following

Well, I started the building part of this project the day before yesterday, and I finished it yesterday. Now for the programming. I am intending to program it in Not eXactly C, and I've already begun an important part of what this robot will feature - line following.

Line following can be simple or complicated. You can simply put a light sensor on the front of a two power-wheel drive vehicle, and use a simple zig-zag program in that it turns one wheel until it sees the line, then it turns the other wheel until it does not see the line. It is simple and can be quite effective. However, it can be slower than more complicated line-following methods.

The second type of line following comprises not only a "turn until you see the line" state and a "turn until you don't see the line" state, but a "if you see the edge of the line" state, in which the robot does not turn but goes directly forward. Of course, one single light sensor can't really see the edge of the line, but it can use a very neat method used by the NXT 1.0 Car with Game Controller project found on nxtprograms.com (see the "How the Controller Works" section near the bottom of the page) , in that the value of the light sensor when it is on the edge is somewhere between the "on the line" light sensor value and the "off the line" light sensor value. I used a method comprising this idea, having three states, one "on the line," one "off the line" and one "on the edge of the line."

The program was written in Not eXactly C. Here is the code just for following the line.
while (true)
{
lightdisplay = NumToStr(Sensor(S3));
TextOut(40, LCD_LINE8, lightdisplay);
if (Sensor(S3) > online + 6 & Sensor(S3) <> offline - 3)
{
OnRev(OUT_B, 100);
Off(OUT_C);
}
Wait(100);

"online" and "offline" are variables that have light sensor values for when the light sensor is on the line, and when it is off the line. What this program basically does is see that if it is more than the online value but less than the offline value, it will move both motors so that the robot goes forward. However, if it is one the line, it will turn away from it, and if it is off the line, it will turn toward it. I put in all of those numbers that are being subtracted and added in a attempt to make it turn away quicker when it less darkness.

Additionally, I implemented a system that has the user set the online and offline variables before it starts following the line, the idea for which I got from Daniele Benedettelli's project Creating Cool Mindstorms NXT Robots. Here it is.

int online;
int offline;
string lightdisplay;

task main ()
{
while (ButtonPressed(BTNCENTER, false))
{
}
SetSensorLight(S3);
ClearScreen();

//Set on line light value
while (!ButtonPressed(BTNCENTER, false))
{
lightdisplay = NumToStr(Sensor(S3));
TextOut(40, LCD_LINE8, lightdisplay);
TextOut(0, LCD_LINE1, " Please place");
TextOut(0, LCD_LINE2, " center light");
TextOut(0, LCD_LINE3, " sensor on line");
TextOut(0, LCD_LINE4, "and press orange");
TextOut(0, LCD_LINE5, " button");
}
while (ButtonPressed(BTNCENTER, false))
{
}
online = Sensor(S3);
PlayTone(440, 500);
ClearScreen();

//Set off line light value
while (!ButtonPressed(BTNCENTER, false))
{
lightdisplay = NumToStr(Sensor(S3));
TextOut(40, LCD_LINE8, lightdisplay);
TextOut(0, LCD_LINE1, " Please place");
TextOut(0, LCD_LINE2, " center light");
TextOut(0, LCD_LINE3, " sensor off line");
TextOut(0, LCD_LINE4, "and press orange");
TextOut(0, LCD_LINE5, " button");
}
while(ButtonPressed(BTNCENTER, false))
{
}
offline = Sensor(S3);
PlayTone(440, 500);
ClearScreen();

What it basically does is start is variables, then put text on the screen that tells the user to place the center light sensor on the line and press the orange button, and when that is completed, puts text that tells the user to place the center light sensor off the light and press the orange button. Additionally, it displays the current light reflected value from the center light sensor as this is going on, as it does when it is actually following the line.

In total, this line-following method worked out fairly well. In case anyone wants to see it, here's the program in its entirety.

/*
12-18-2010
Line Following program by NatoNX.
Inspiration from a progect on another website and a book. Thanks!
*/

int online;
int offline;
string lightdisplay;

task main ()
{
while (ButtonPressed(BTNCENTER, false))
{
}
SetSensorLight(S3);
ClearScreen();

//Set on line light value
while (!ButtonPressed(BTNCENTER, false))
{
lightdisplay = NumToStr(Sensor(S3));
TextOut(40, LCD_LINE8, lightdisplay);
TextOut(0, LCD_LINE1, " Please place");
TextOut(0, LCD_LINE2, " center light");
TextOut(0, LCD_LINE3, " sensor on line");
TextOut(0, LCD_LINE4, "and press orange");
TextOut(0, LCD_LINE5, " button");
}
while (ButtonPressed(BTNCENTER, false))
{
}
online = Sensor(S3);
PlayTone(440, 500);
ClearScreen();

//Set off line light value
while (!ButtonPressed(BTNCENTER, false))
{
lightdisplay = NumToStr(Sensor(S3));
TextOut(40, LCD_LINE8, lightdisplay);
TextOut(0, LCD_LINE1, " Please place");
TextOut(0, LCD_LINE2, " center light");
TextOut(0, LCD_LINE3, " sensor off line");
TextOut(0, LCD_LINE4, "and press orange");
TextOut(0, LCD_LINE5, " button");
}
while(ButtonPressed(BTNCENTER, false))
{
}
offline = Sensor(S3);
PlayTone(440, 500);
ClearScreen();

//Follow line
TextOut(0, LCD_LINE3, " Following line");
while (true)
{
lightdisplay = NumToStr(Sensor(S3));
TextOut(40, LCD_LINE8, lightdisplay);
if (Sensor(S3) > online + 6 & Sensor(S3) <> offline - 3)
{
OnRev(OUT_B, 100);
Off(OUT_C);
}
Wait(100);
}
}

The Project

Yes...there's a big project in the makings. I hope to put aspects of it here occasionally, and if we're fortunate, I'll get it done before Christmas.

Speaking of Christmas, Happy Birthday, Jesus!

Nato

Four Wheel Drive Car Super Addition V3

Well, I know you are supposed to see it here first, but I put pictures of FWDCSA V3 on NXTLog a long time ago. Sorry. Here's some pictures.
General View














Top View















Bottom View, with Wheels Turned

Monday, November 22, 2010

Four Wheel Drive Car Super Adddition V3

Four Wheel Drive Car Super Addition Version 3 has arrived.
Electrical Components:
- Two NXT Intelligent Bricks
- Five NXT Motors
- One PSP-Nx sensor from mindsensors
- Two NXT Light Sensors
- Two Lamps
- Wires

Physical Makeup Highlights:
- Four Wheel Drive
- Four Wheel Steering
- Four Wheel Independent Suspension
- Two Gear Transmission

That is distributed as follows. Three NXT Motors are connected to one Intelligent Brick, and they all work together to drive the input to the transmission. The transmission is operated by a fourth NXT Motor, driven by the commander NXT Intelligent Brick. That brick also controls the steering motor and the lamps, which are on front and serve as headlights. It is also connected to the PSP-Nx and should be connected to the two light sensors, which should serve as rear lights.

I think that there was slippage in the transmission when just a bit of pressure was applied to the car (it drove onto a rug). However, that was just its chassis without its bodywork, there will be more weight now that the bodywork is added. I was more worried about the eight tooth gear that the transmission-driving motors turn.

Nato

Wednesday, November 10, 2010

I really, really need to make a 4X4X2X2 Jeep V2 soon. I really, really need to make a four wheel drive car super addition V3 soon. There's so much I need to do and so little time. But, anyway,
I want to make an update of this project, 4X4X2X2 Jeep V2. I have a list of goals for aV2:

No Power Functions motors or batter box - two NXT Intelligent Bricks
Three NXT motors for the drive
Two NXT motors for independent from each other front and rear steering
One NXT motor for a two-gear transmission
Weight of the vehicle not resting on the driving axles (I'm sort of thinking turntables)
No lights this time...maybe.
Sensors - I'm thinking one ultrasonic, two touch, one PS2-NX, one Acell and one Compass. Which leaves me two ports left. Power Functions lights, maybe....that's not too bad of an idea.
Greenish-black color scheme
Autonomous or remote controlled modes
Faster and more powerful than its predecessor

I'm thinking bigger than before. 4X4X2X2 Jeep's chassis seems (through the pictures) absolutely tiny in relation to what it did.

Nato

Buggy NXT-Remote and Engine Gear-Up

I ran the buggy off of NXT-Remote in a few of the previous days. NXT-Remote is a great program that allows you to run a vehicle-like robot off of a Bluetooth connection with your computer. It worked pretty well for the buggy. Also, I geared up the fake "engine" so that the pistons turned faster. Just a quick update.

Nato

Thursday, November 4, 2010

"NXTIzed" Buggy

First of all, thanks to this project for the idea for the "NXTIzed" word...I think that it is very neat. I infer that it basically means that the construction you have is a Lego set with some of its moving parts motorized by NXT motors and controlled by a NXT Intelligent Brick. And that is what I did again here.....I tried to build something like the somewhat new Lego Technic set "Buggy," and then changed it to put NXT elements inside of it. I got the instructions for the set on the Lego website, and then tried to build a version of it, which was a challenging because I didn't have all of the right parts, especially parts that operated the front suspension and steering. I had to use an extensive construction of pieces, the inspiration for which I got from this project. However, it turned out all right, you can see it in the first picture. Then, I did with it what I built it for in the first place: I put the NXT inside of it. You can see the result in the second picture. Although the NXT Intelligent Brick may look a bit "raised up," I am rather happy with the result. One motor drives it, the other steers. You can see an overview of the drive and steering mechanisms in the third picture. The motor on the left in the picture turns the differential and the motor on the right in the picture goes into the 90-degree motion change that you can see (I am happy that there is no gear slippage when the front steering is not encountering much resistance, but there is some with resistance), which then ran down a central shaft to where it goes through more gears and eventually, to the rack and pinion steering system. The other side of the differential is connected to a mechanism (in the current buggy, I replaced the two darker gray knob gears to a larger and a smaller gear) which operates the pistons on the fake "engine" quite like in the original set. The original set had no differential, the "engine" was one stud lower and the gearing was different. The construction the rear differential is set up on moves up on down on the two motor's axles and a suspension piece about the same position it was in in the original set gives it a bit of back suspension. It also has independent front suspension as well as front wheel steering through the two front wheel setups.

Nato

Tuesday, October 19, 2010

Slow....

It's been pretty slow round here. I've been working with my FLL team, but besides that I've only built one robot. I was inspired by this robot, and my my school was trying to make money and I wanted to show off, so I built a claw game. It used one motor for backward and forward movement, one for left and right movement, and one to close and raise the claw and lower and open it. I used lollypops as the prize...thanks for buying them, Mom! Again, didn't turn out so well, only made $1:50. Hopefully, I'll make something better next year. I'll see if I can get some pictures up.

Nato

Friday, September 24, 2010

Public and Pinball

I wonder if I should make this blog public.
Anyway, I built a pinball machine a while ago, before my NXT Offroader or my latest dragon. It was inspired by this pinball machine on NXTlog (this links to the secondary project for my inspiration project, for some reason, the main one is gone). It took a long time but turned out really well. Pictures are worth a thousand words, so here's an image of it. Its features included manual flippers, lost ball detector, ball launcher, two scoring methods and lights. I decided to try putting Lego brick elements on their sides to make the playing field. I used many Duplo elements for the board, and the originally liked to break because they didn't connect firmly enough. I put a brace on the bottom of the machine and that worked very well to hold the part of the machine where the ball rolls together. See it in the second picture here. However, the top of the machine, the "walls" nearer to the NXT Intelligent Brick, were very weak and often fell apart. Its first scoring mechanism was the touch sensor and bumper at the top-right of the machine, and the second was the light sensor "box" on the left side of the machine. When one of the sensors that detect scoring was detected, the NXT sent messages to the Power Functions battery box to flash the lights near the corresponding scoring zone. The sensor that detected the ball falling down past the flippers was a RCX light sensor, the idea for which I took from a Robotics Invention System book. I programmed this machine in Not eXactly C...It took hours, but it ended up working pretty well. The program will be at the bottom of this post. Bye!






/* Not eXactly C Code for NXT Ultra Pinball Machine III.

Idea for putting this NXC program in the NXT-G information box from m1n1f1g. Thanks.

Coded by NatoNX. ><> */

#define lights1on HTPFSingleOutputPWM(S4, PF_CHANNEL_1, PF_OUT_A, PF_PWM_FWD7) //define macros
#define lights1off HTPFSingleOutputPWM(S4, PF_CHANNEL_1, PF_OUT_A, PF_PWM_FLOAT)
#define lights2on HTPFSingleOutputPWM(S4, PF_CHANNEL_1, PF_OUT_B, PF_PWM_FWD7)
#define lights2off HTPFSingleOutputPWM(S4, PF_CHANNEL_1, PF_OUT_B, PF_PWM_FLOAT)

int balls; //initiate variables
int score;
int threshold1;
int threshold2;
string display;

task main ()
{
SetSensorTouch(IN_1); //set sensors
SetSensorType(IN_2, IN_TYPE_REFLECTION);
SetSensorLight(IN_3);
SetSensorLowspeed(IN_4);
while (true)
{
OnFwd(OUT_BC, 100); //light up lights powered off of NXT
ClearScreen();
TextOut(20, LCD_LINE2, "NXT Ultra"); //beginning screen
TextOut(5, LCD_LINE3, "Pinball Machine");
TextOut(36, LCD_LINE4, "III");
TextOut(15, LCD_LINE6, "Press Orange");
TextOut(24, LCD_LINE7, "to Start");
while (ButtonPressed(BTNCENTER, true) == TRUE) //wait for orange button to be pressed...
{
}
while (ButtonPressed(BTNCENTER, true) == FALSE) //...and released
{
}
ClearScreen();
TextOut(0, LCD_LINE1, "Use the flippers"); //instructions
TextOut(0, LCD_LINE2, "to get the ball");
TextOut(0, LCD_LINE3, "to hit the black");
TextOut(0, LCD_LINE4, "part at the top");
TextOut(0, LCD_LINE5, "and into the box");
TextOut(0, LCD_LINE6, "on the left. You");
TextOut(0, LCD_LINE7, "have 3 launches.");
TextOut(0, LCD_LINE8, "Press orange.....");
while (ButtonPressed(BTNCENTER, true) == TRUE) //wait for orange button to be pressed...
{
}
while (ButtonPressed(BTNCENTER, true) == FALSE) //...and released
{
}
ClearScreen();
threshold1 = Sensor(IN_3) + 3; //sets thresholds for light sensors
threshold2 = Sensor(IN_2) - 50;
balls = 2;
score = 0;
while (balls > -1)
{
display = "Score: "; //score and ball display
strcat(display, NumToStr(score));
TextOut(0, LCD_LINE2, display);
display = "Balls Left: ";
strcat(display, NumToStr(balls));
TextOut(0, LCD_LINE5, display);
if (Sensor(IN_1)) //if bumper is pressed, add to score...
{
score += 100;
PlayTone(440, 500);
lights1on; //...and flash touch sensor lights
Wait(200);
lights1off;
}
if (Sensor(IN_3) > threshold1) //if score light sensor detects something, add to score...
{
score += 500;
PlayTone(640, 500);
lights2on; //...and flash light sensor lights
Wait(200);
lights2off;
}
if (Sensor(IN_2) < threshold2) //if drain light sensor detects something...
{
balls -= 1; //subtracts from ball count...
PlayFile("! Attention.rso"); //...and plays a sound
Wait(1000);
}
}
ClearScreen(); //if ball count reaches -1, the the game ends. Screen clears
PlayFile("! Startup.rso"); //ending display and sequence
TextOut(17, LCD_LINE2, "Final Score");
TextOut(0, LCD_LINE4, NumToStr(score));
TextOut(23, LCD_LINE6, "Thanks for");
TextOut(0, LCD_LINE7, "playing! Please");
TextOut(12, LCD_LINE8, "press orange.");
while (ButtonPressed(BTNCENTER, true) == FALSE)
{
}
}
}

Monday, September 6, 2010

NXT 4X4 Offroader

First of all, I'm sorry that things have been so slow around here. Literally, one post every few months? Oh, well...

Anyway, a few months ago, I got this one great old Lego set....number 8466, the 4x4 Offroader. You can see it's original box's cover in the first picture (I hope that is is not illigal to take picture of Lego's boxes and put them online). Before I got it, I had already determined that I would try to "NXTize" it - Put NXT Motors and the NXT Intelligent Brick into it to make it mobile. This led me onto three attempts.

When I first built the set, I was disappointed - the drive train was very weak. I tried motorizing it anyway, and I put a Power Functions M motor on a worm and 24 tooth gear gear block. I put the whole thing on the pre-built drive train, and it moved, but with extremely low power and my Lego nemesis, gear slippage. So, I tried modifying the drive train. That didn't work either. Unfortunately, I don't have any picture of that first version, but it was a failure.

The second attempt consisted of me building my own chassis, and putting some 4X4 Offroader parts on top of it. When I built the chassis, I had in mind that I didn't want any gear slippage, so I built it with those four tooth knob gears to transfer power ninety degrees to the front and rear differentials. I also put in a transmission. Then, I put 4X4 Offroader parts on top of it. However, I modified them to make them wider. When I tested it, something went wrong. If I tried to move it forward and steer for too long, it stopped driving - some pressure got too high, and the transmission would slip. If I moved it backwards and then steer after that, it would go just fine - but then the transmission would slip again. Also, the steering arms rubbed against the inside of the wheels when it steered too much. This version was also a failure. You can see it in the second picture.

And now, the third version! This one is really recent, and is still standing now. This time, I simply built the motors almost directly driving the differentials - no drive axle or transmission this time! I wanted to make it so that each differential would be driven by two eight tooth gears for the "slow" original model, the 4x4 Offroader, and one 24 tooth gear for the "fast" alternative model, the 4X4 Race Buggy. I managed to get the steering wheel to turn with the front wheels, and I tried to make the decoration "engine" pistons spin as well, and I rigged up a cool mechanism to do so, but it's gears slipped and it fell off. When I built the third version, I had to lengthen the wheel sets apart to to fit the drive motors, and therefore gives the finished model a kind of "stretched" look, but it's not too bad. After it was basically done, I tried it using the eight-tooth gears, but it slipped, so I replaced them with one 24 tooth gear. After that, it worked well, but I have not tested it fully. See it here in the last picture.

Hopefully I'll get back here before too many months pass.

Nato

Monday, April 19, 2010

MPMA V3


Here is MPMA V3. I think this is the best one yet in the series! It has three pneumatic pistons, a fast pumping mechanism, all LEGO elements and a geared down drive mechanism. The next step could be to implement some "flags" so the position of the switches can be easily viewed.

Nato

Sunday, April 4, 2010

Happy Easter!

Jesus has risen!
He has risen, indeed!

Happy Easter, everyone!

Monday, March 29, 2010

Four Wheel Drive Cars and New Addition


From a long time ago, I have attempted to build four wheel drive cars. But it wasn't until around my third recorded attempt that I got it right....it resulted in Four Wheel Drive Car V3 (FWDC V3), as seen in the first picture here.



Later, I made Four Wheel Drive Car Compact Addition (FWDCCA), which was a compact vehicle that still had four wheel drive. The second time I built it, it had a some gear slippage problems, so I may have left out a piece or built it wrong. It is seen in the second picture.



Quite some time after that, I made Four Wheel Drive Car Super Addition V1 (FWDCSA). I do not think the first version of this vehicle worked well, and is not pictured here. The one pictured here in the third image is still called Four Wheel Drive Car Super Addition V1, although it is not the first version. This one had suspension as well as four wheel drive.



And quite recently, Four Wheel Drive Car Super Addition V2 has arrived. It has four sensors, and can use them to detect its environment, or its heading. However, when resistance is applied to the wheels or differentials, the gears leading to that differential slip. This can happen when it runs into something, or even when it turns!

Nato

Monday, February 15, 2010

Here it is

It works fairly well. It has everything the preceding writing stated, but I remain unpositive about the steering geometry. Grass stops it, but to my knowledge there was no gear slippage.

Nato

Wednesday, February 3, 2010

Idea

I will probably be working on a large truck. It currently has four wheel drive, two wheel steering in the front (I think it may be like Ackermann steering geometry), pendulum suspension in the front and normal suspension in the rear.

Friday, January 29, 2010

The Project

It's not the final version, but here is my result from the plans. Edit 4/4/10 I never "completed" this version. This machine is now long gone, but I can't say it was satisfactory. My "genius" idea displayed in my plans in the previous post was to use the power of two motors to go forward and steer. The steering was achieved by moving only one motor forward. However, this steering scheme was not very maneuverable. Imagine, if the machine got fit into a corner with no room on the sides, getting out would be difficult, if not impossible.

Nato

Tuesday, January 5, 2010

One of my Latest Ideas


One of my latest ideas consisted of a re-design upgrade of this machine. The old one achieved five functions from three motors. My new ideas want to get six functions out of the motors. This will mean the new MPMA can drive, steer, raise and lower its arm, open and close its claw, and turn its wrist left and right. The picture demonstrates my plans.

Monday, January 4, 2010

Welcome to Nato's NXT Project

Welcome to my blog, Nato's NXT Project, showing you some of my NXT related ventures. This blog may not emphasize on my projects. If you want to see some of my "best" projects, click here. If you want a list of many of my constructions, please visit X-1's blog here. Thanks for looking!