NXC question
Posted: 20 Jan 2011, 13:34
I have two problems at the moment and would be grateful for some assistance.
In NXT-G I could use a 'reset motor' block to zero the motor rotation counters.This cancelled out any movements the motors had made prior to that command and stopped the motors from trying to correct for these movements. Otherwise when I issued a command the motors went back to the place they were when I first switched the brick on before carrying out the new command.
In NXC I tried both the statements below and am not sure which one is most effective so at the moment am using both!
OffEx (OUT_A, RESET_ALL); // Reset the motor counters
Wait (250);
ResetSensor (SENSOR_1); // Clear the sensor on port 0
Wait (100);
I also found that they did not seem to work properly unless I put a wait statement after them. Any comments or guidance would be appreciated.
I am also having a slight problem with the 'sleep' function. Is there a command similar to the 'stay alive' block in NXT-G or do I have to make sure I specify a long enough time using the sleep command? I want to put something in the program in case I forget to set the brick to 'always on' before running the programs.
In NXT-G I could use a 'reset motor' block to zero the motor rotation counters.This cancelled out any movements the motors had made prior to that command and stopped the motors from trying to correct for these movements. Otherwise when I issued a command the motors went back to the place they were when I first switched the brick on before carrying out the new command.
In NXC I tried both the statements below and am not sure which one is most effective so at the moment am using both!
OffEx (OUT_A, RESET_ALL); // Reset the motor counters
Wait (250);
ResetSensor (SENSOR_1); // Clear the sensor on port 0
Wait (100);
I also found that they did not seem to work properly unless I put a wait statement after them. Any comments or guidance would be appreciated.
I am also having a slight problem with the 'sleep' function. Is there a command similar to the 'stay alive' block in NXT-G or do I have to make sure I specify a long enough time using the sleep command? I want to put something in the program in case I forget to set the brick to 'always on' before running the programs.