ROBOTC.net forums
http://robotc.net/forums/

Bluetooth motor stutter
http://robotc.net/forums/viewtopic.php?f=1&t=10387
Page 1 of 1

Author:  Etparty [ Wed Jan 28, 2015 12:32 pm ]
Post subject:  Bluetooth motor stutter

In RobotC 3.0, ive been building a remote out of one brick that sends instructions to another brick via bluetooth. The problem ive been having is that the motors movement is choppy/stuttering. This shows with all directions of movement except for the movement right before the "Else" statement. I cant seem to find any way to stop the stuttering. Any help would be appreciated.

Attachments:
File comment: Code for the remote.
Bluetoothsender.c [825 Bytes]
Downloaded 271 times
File comment: Code for the brick on the robot.
Bluetoothreceiver.c [1.27 KiB]
Downloaded 231 times

Author:  JohnWatson [ Wed Jan 28, 2015 12:44 pm ]
Post subject:  Re: Bluetooth motor stutter

Looking at the receiver code specifically:

Code:
      
      if(forward == 12)
      {
         motor(mtr_S1_C1_1) = 100;
         motor(mtr_S1_C1_2) = 100;
         wait1Msec(100);
      }

if(forward == 13)
      {
         motor(mtr_S1_C1_1) = 100;
         motor(mtr_S1_C1_2) = -100;
         wait1Msec(100);
      }
      else
      {
         motor(mtr_S1_C1_1) = 0;      motor(mtr_S1_C1_2) = 0;
         wait1Msec(100);
         ClearMessage();
      }
      ClearMessage();


Let's assume the variable 'forward' receives a value of 12. The if statement will return true, and the motors will turn on for 100 ms (0.1 second). Next, the program checks to see if the variable forward contains a value of 13. It doesn't, so the 'else' statement runs and turn the motors off.

This happens for every iteration of the value in forward *except* 13. To resolve this, try putting everything in one if/else if/else block:

Code:
      if(forward == 10)
      {
         motor(mtr_S1_C1_1) = -100;
         motor(mtr_S1_C1_2) = 100;
         wait1Msec(100);
      }

      else if(forward == 11)
      {
         motor(mtr_S1_C1_1) = -100;
         motor(mtr_S1_C1_2) = -100;
         wait1Msec(100);
      }

      else if(forward == 12)
      {
         motor(mtr_S1_C1_1) = 100;
         motor(mtr_S1_C1_2) = 100;
         wait1Msec(100);
      }

      else if(forward == 13)
      {
         motor(mtr_S1_C1_1) = 100;
         motor(mtr_S1_C1_2) = -100;
         wait1Msec(100);
      }
      
      else
      {
         motor(mtr_S1_C1_1) = 0;      motor(mtr_S1_C1_2) = 0;
         wait1Msec(100);
      }
      
      ClearMessage();

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/