If you are programming a robot with NXT-G, you may be wondering what’s the difference between the Motor and Move blocks? The answer to this question has a significant impact on how your robot will move.
The LEGO MINDSTORMS Education NXT software (NXT-G) includes these two blocks for motor control. While the Motor and Move blocks may appear very similar, they contain a few subtle but significant differences that can affect your robot’s motion.
Intelligence
The most important difference between the two programming blocks is the level of intelligence associated with each block.
The Motor block is designed simply to turn the motors on and off. You can input the duration of the motion (how many rotations or how many seconds you want the motors to spin), but your robot may overshoot its target. This overshooting can happen because the Motor block does not program the motors to slow down as they near their target duration so momentum can carry a robot past it’s target destination.
The Move block, on the other hand, gives you more control. With the Move block, the block’s built-in control algorithm programs the NXT to monitor the motor’s rotation sensors and to slow the motors as they approach the target duration. This capability is helpful when you want a car to follow a specific track or to arrive exactly at a physical target that is a known distance away.
Sample code in action: Stopping for the pedestrian
In this program, the vehicle is programmed to turn left and then stop for the “pedestrian” LEGO minifig. The vehicle is constructed with the driving base module contained in the LEGO MINDSTORMS education booklet. The LEGO minifig is placed exactly one motor rotation away from the starting position of the vehicle.
Each program accomplishes the following:
- Uses one block that is configured to use the motor at Port B.
- Sets the motor to function in the forward direction.
- Configures the motor to run at 75% power for one rotation.
- Programs the block to wait for completion of the one rotation.
- Sets motor to prepare for braking as “Next Action”.
The above specifications are implemented in each of the programs below.
Motor block program
Move block program
Looking at the above programs, you might think the robots would act identically. The vehicle should travel in a curved path (because only one motor is used) to its target destination, lying one rotation away.
The Motor block program video shows that the car is unable to stop directly at the pedestrian. Instead, the vehicle knocks the figure over and then corrects its motion to the one-rotation point. It ends up at the same final position as the vehicle programmed by the Move block, but only after this correction. As you can see in the “jerky” motion of the car, the motor does not slow near the target distance. The motor returns to the correct target position only after the rotation sensors have measured slightly more than the one-rotation duration.
In the case of the Move block program, the vehicle is able to slow its motor when it senses the nearing of the target distance of one rotation. When the program executes, you can actually hear the slowing of the motor. The vehicle gradually decreases its speed and then and stops directly at the LEGO person. No correction factor is necessary as the Move block programs the NXT to utilize a control algorithm.
Article and models by Ciera Maffei
CEEO
Latest posts by CEEO (see all)
- Chair for Mr Bear - 21 August 2020
- Assistive Technology: Making Lives Easier - 20 August 2020
- Sturdy Tower - 14 June 2020
- Going the Distance - 21 May 2020
- GPS accuracy testing with LEGO bricks - 10 September 2015