{"id":1101,"date":"2013-06-11T23:34:24","date_gmt":"2013-06-11T13:34:24","guid":{"rendered":"http:\/\/legoeng.local\/?p=1101"},"modified":"2022-07-18T16:08:21","modified_gmt":"2022-07-18T06:08:21","slug":"motor-vs-move-part-i-the-control-algorithm","status":"publish","type":"post","link":"http:\/\/legoeng.local\/motor-vs-move-part-i-the-control-algorithm\/","title":{"rendered":"Motor vs Move – Part I: The Control Algorithm"},"content":{"rendered":"

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.<\/p>\n

\"Motor<\/a>
Motor block<\/figcaption><\/figure>\n
\"Move<\/a>
Move block<\/figcaption><\/figure>\n

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.<\/p>\n

Intelligence<\/h2>\n

The most important difference between the two programming blocks is the level of intelligence associated with each block.<\/p>\n

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\u2019s target destination.<\/p>\n

The Move block, on the other hand, gives you more control.  With the Move block, the block\u2019s built-in control algorithm programs the NXT to monitor the motor\u2019s 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.<\/p>\n

Sample code in action: Stopping for the pedestrian<\/h2>\n

In this program, the vehicle is programmed to turn left and then stop for the \u201cpedestrian\u201d 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.<\/p>\n

Each program accomplishes the following:<\/p>\n