My new utility NXT2excel proves to be very useful to examine the NXT closely. Here is an example of the robotC PID speed control in action.

One of the advantages of robotC is that one has very good regulated speed for the NXT motors. Here is a graph I made of the speed control in action . I used NXT2excel  to fetch the data in excel.

The graph shows 2 seconds of action, updated every 0,2 seconds. The dark blue line represents the regulated speed level. It is set to 50 right at the beginning. The dotted line is the actual speed of the motor . The motor runs at about 500 encoder ticks per second when it is stable. The light blue line is the Pulse Width Modulation value. This is a measure of he amount of power sent to the motor. When stable its value  is about 65, meaning that the motor runs at about 65% of its maximum.

One can see that the PID control sends a bit more power to the motor when it is still gaining speed. Just before the intended speed is reached the PID control starts to power down the motor. This is to minimise overshoot. The motor speed is stable after 0,8 seconds and stays very stable. The power send to the motor changes a bit over time to keep the speed stable. At the moment the motor has to stop the PID control applies negative power to break the motor (I set the motor rest state to halt instead of coast). The  motor halts within 0,4 seconds.

I love regulated speed!

(Battery level was about 7,1 Volt at the time. The motor was driving a NXT wheel with 20:12 gear ratio.)

Here is another graph, this one based on readings every 50 ms.