View unanswered posts | View active topics It is currently Sat Jan 19, 2019 4:31 pm






Reply to topic  [ 2 posts ] 
Bluetooth motor stutter 
Author Message
Rookie

Joined: Wed Jan 28, 2015 12:26 pm
Posts: 1
Post 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 133 times
File comment: Code for the brick on the robot.
Bluetoothreceiver.c [1.27 KiB]
Downloaded 100 times
Wed Jan 28, 2015 12:32 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 722
Post 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();

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.


Wed Jan 28, 2015 12:44 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.