Page 1 of 2

Lego Mindstorms NXT working on solar energy

Posted: 21 Dec 2010, 13:19
by wildman09
Hello,

I'm a student from The Netherlands. I'm in Gymnasium 6 (VWO 6) and have a assignment. I'm making a Lego Mindstorms NXT which is working on solar energy.

The robot needs to detect the highest light source and drive to it so the robot can "recharge" himself. We have equipped 3 solar panels on the robot and are using 4 Lego Mindstorms Light sensors.

But I have a problem. I don't know exactly how to program this. How can the robot detect the highest light source and drive to it?

I think the program needs to compare the 4 Lego light sensors and go to the direction where the robot measures the highest light intensity. But how?

I hope somebody can help me.

Thanks,
Wildman
([email protected])

Re: Lego Mindstorms NXT working on solar energy

Posted: 21 Dec 2010, 13:44
by dad-and-adam
Hi wildman09,
A good technique is to do programming in small steps.
Step 1 might be: Display the sensor values on the NXT screen.
Step 2 might be: Point the robot (by hand) in various directions and observe the sensor values.
Step 3 might be: Have the robot rotate in place (using the motors) while displaying the sensor values.
Step 4 might be: Have the robot stop rotating when pointing at the highest sensor value.
Step 5 might be: Drive forward (toward the light).
Step 6 might be: Stop occasionally and rotate in place to verify the direction is still toward the highest sensor value.
Step 7 might be: Stop before it runs into the light.

What programming language are you using?

Dave

Re: Lego Mindstorms NXT working on solar energy

Posted: 21 Dec 2010, 13:55
by wildman09
Hi Dave,

Thanks for your comment. That is very useful.

One comment, I don't want the robot to rotate. It needs to measure (continual) during driving and adjust the driving direction. It needs to measure and compare the values and choose the direction with the highest light intensity (using 4 light sensors, Lego).

I'm using the programming language provide with the Lego Mindstorms: Lego mindstorms NXT 2.0 (programming software).

Thanks,
Wildman

Re: Lego Mindstorms NXT working on solar energy

Posted: 21 Dec 2010, 14:47
by dad-and-adam
Now I am starting to understand.
Is it correct that the four sensors are fixed to the vehicle and point in different directions?
If so, what is the angle between the four light sensors?
Is it 90 degrees (so the sensors "look" in all directions)?

Have you been able to determine what small steps are needed to lead to the final solution?

The Lego language is also known as NXT-G. I believe the "G" stands for "graphical".

Dave

Re: Lego Mindstorms NXT working on solar energy

Posted: 21 Dec 2010, 15:08
by wildman09
Yes, that is correct. The angle between the four sensors are 90 degrees (the sensors "look" in all directions).

"Have you been able to determine what small steps are needed to lead to the final solution?"
You mean, how to program it or?

"The Lego language is also known as NXT-G. I believe the "G" stands for "graphical"."
I didn't know that. Thanks.

Thanks,
Wildman

Re: Lego Mindstorms NXT working on solar energy

Posted: 21 Dec 2010, 15:43
by dad-and-adam
"Have you been able to determine what small steps are needed to lead to the final solution?"
You mean, how to program it or?
Before programming, it must be known what is desired. So a list of small steps generally comes first, and then programming is done to accomplish each step. Each step should be tested and refined before moving on to the next step.

So have you been able to determine a list of small steps? Have you been able to program any of them? If you have made some progress, could you share your list and where you get stuck?

Dave

Re: Lego Mindstorms NXT working on solar energy

Posted: 21 Dec 2010, 15:58
by wildman09
Step 1: Start the program, by pressing a button on the Lego Mindstorms (done)
Step 2: The robot needs to measure the light intensity (from the four Lego light sensors, which are in 90 degrees of each other) (trying, but stuck)
Step 3: The robot needs to compare the measured values. (trying, but stuck how to compare all the four sensors. I can't find where you can compare four values.)
Step 4: The robot needs to find the highest sensor value. (trying, but stuck how to find the highest value)
Step 5: Drive toward the light source.
Step 6: Keep measuring and compare the measured sensor values.
Step 7: If the new sensor values are higher then the old (highest) sensor value adjust the direction.
If the new sensor values are lower then the old (highest) sensor value keep driving the same direction.
Step 8: Stop the program, by pressing a button on the Lego Mindstorms (done)

These steps should the robot do.

Wildman

Re: Lego Mindstorms NXT working on solar energy

Posted: 21 Dec 2010, 16:38
by dad-and-adam
Hi,
There is an excellent NXT-G tutorial at http://www.ortop.org/NXT_Tutorial/
It covers a lot a basics like reading sensor values and how to have the program make decisions. That tutorial may help you get further along. Let us know if you are still stuck.

Dave

Re: Lego Mindstorms NXT working on solar energy

Posted: 22 Dec 2010, 15:21
by wildman09
I have had some help and made this program (see print screens).

http://img220.imageshack.us/img220/1993 ... 1from3.jpg
http://img841.imageshack.us/img841/639/ ... 2from3.jpg
http://img211.imageshack.us/img211/2108 ... 3from3.jpg

Tips/Suggestions/Idea's/Comments are welcome :D

Thanks,
Wildman

Re: Lego Mindstorms NXT working on solar energy

Posted: 23 Dec 2010, 00:41
by dad-and-adam
Wow. You have made a lot of progress in one day.
Have you been able to test the program? Does it accomplish the desired task?

Dave