Motor Power Meter NXT-G Block
software/
NXT Repository/Programming/NXT-G/

This block is a “sensor” which allows you to monitor the actual power sent to the NXT servo motor. In a single motor mode (Motor block) with “Motor Power” enabled the firmware automatically increases the power to keep constant speed. Monitoring the ”Actual Power” allows detecting stall conditions as well as slip conditions (e.g. when your robot hits the wall, its motors might still be able to slip in place but the robot does not move). The former condition can be detected using encoders (as previously shown by Brian Davis and Dick Swan), but slipping can’t. Nevertheless, the actual power during slipping will be larger then the set power. The same goes for 2 motor “Move” command.
Usage: look for the typical min/max value of Actual Power during regular operation. Use the previously published MinMax Block to do this. Then set the threshold to a value larger then the maximal value rechieved during operation (I found 10-15% extra power is sufficiently discriminating and gives little false positive readouts). You can also monitor the difference (i.e. Actual Power - Set Power). Complete stall conditions for a single motor (with Motor block) are detected as “Actual Power” > 99.
NOTE: The NXT internal Power values are signed, where the sign defines the direction of motion. This block ignores the sign and allways returns positive values.
Download the block here.