This HiTechnic Trike based project uses the HiTechnic IR Seeker V2 together with the IR Ball to make a Hockey Bot. (Or call it a Soccer bot if you prefer, but as I write this we are in the middle of the 2010 Winter Olympics so I have Hockey on my mind). This robot uses the IR Seeker to locate the IR Ball and drive towards it. When the Ultrasonic sensor detects the ball right in front of it, then it gives it a good slap shot (or kick if like soccer).
Building Instructions for the HiTechnic Trike Base
View Instructions for adding sensors and motor to make the HockeyBot
NXT-G HockeyBot Program for LEGO Mindstorms 1.1
NXT-G HockeyBot Program for LEGO Mindstorms 2.0
The IR Seeker V2
The HiTechnic IR Seeker V2 Sensor is designed to determine the approximate direction of an IR source such as the IR Ball or IR Beacon. I have also heard of people using the IR Seeker to locate things like flashlights but that will only work if the flash lights happens to also give out a significant amount of infrared light.
The IR Seeker can operate in two different modes known as AC or DC. If you are using something like the current HiTechnic IR Ball, then you should select AC mode. Also make sure the IR Ball is set to mode D which will modulate at 1200Hz. If you are using an older IR Ball, or something like a flashlight, which does not modulate the IR light, then select DC mode.
If you have the older IR Seeker, known as the IR Seeker V1, then you can still build this robot using that sensor but you will need to change the IR Seeker Sensor block in the program to use the V1 sensor block. If you are uncertain which sensor you have, you can look at the shape of the end-cap.
The IR Seeker V1:
The IR Seeker V2:
The IR Seeker sensor gives a direction value based on this chart:
In addition to a value form 1 to 9 for the direction to the IR source, the direction value can also be zero if no significant IR source is detected.
Note: That in order to use the IR Seeker V2 in the LEGO Mindstorms software, you must first download and install the block from the downloads page. Here is a direct link to download for the block if you need it:
HiTechnic IRSeekerV2 Sensor Block for Mindstorms NXT Software
The HockeyBot Robot
This robot is based on the HiTechnic Trike so the first thing you need to do is build this robot base. Note that this robot base can be built with either the LEGO Mindstorms 1.0 or 2.0 sets. The instructions show this robot with the 2.0 part colors and tires, but you can build this just as well with the 1.0 kits using the part colors and tires from that kit.
Next you need to add the IR Seeker, Ultrasonic sensor and the extra motor. Here are the instructions to add these to the robot base.
Attach the extra motor to port A, the Ultrasonic sensor to port 4, and the IR Seeker to port 3. The left motor should be on Port C and the right motor should be on Port B.
In this model the IR Seeker sensor is mounted high enough to get a good view around the robot to see the IR Ball.
The goal with this robot is to turn and drive towards the IR source. To do that the direction value from the IR Seeker Sensor is used to adjust the motor power so that the robot will turn and drive towards the IR source.
Let’s take a look at the program:
The first thing that happens is that the variable Power is set to 50. This power is used later in the program as the base power used by the drive motors. In the video I demonstrate the robot turning in place to turn towards the IR Ball, I did this by modifying this block and setting the power to 0 instead of 50.
Next the A motor, the Hockey stick motor, is run forwards at low power for half a second. Since the program does not know for sure what the position of the stick is when it starts, this will ensure that the stick is in the retracted position.
Then comes the main control loop of the program. Here you will see that the IR Seeker block reads the sensor and sends the direction value, which will be in the 0 to 9 range, to the first math block, subtract by 5. Then value is then passed on to the multiply block to scale it up. The value range will now be -150 to 120.
Note that this range is asymmetrical since 0 is straight ahead. Remember, if no IR is detected, the direction value is 0, after the math this will turn into -150. What will basically happen is that if no IR is detected the robot will simply spin in place looking for the IR signal.
Once we have the scaled value, it is added to the Power variable to set the motor power on the left side and it is subtracted to set the power on the right side. And if the IR source is straight ahead, both motors will have the same Power value and the robot will go straight towards the IR source.
Note that the Motor block does not respond to negative power values. Internally it takes the absolute value of the power that is passed in and ignores the sign of the value. In order to make the motor reverse if necessary, we have to check the sign of the desired power and then set the direction value separately. In this program this is done by comparing the desired power with 0 and the results is passed to the Direction plug.
Finally at the end of the loop there is a Switch block to check the Ultrasonic sensor. If the sensor detects that there is something less than 10cm in front then it assumes the ball is right in front of the robot. It then stops the robot by using the Move command set to Stop, runs the A motor first one way at high power to hit the ball and then at lower power to reset the stick back again.